@stripe/stripe-react-native 0.19.0 → 0.20.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +33 -5
- package/README.md +2 -2
- package/android/build.gradle +1 -2
- package/android/gradle.properties +1 -1
- package/android/src/main/java/com/reactnativestripesdk/CardFieldView.kt +6 -3
- package/android/src/main/java/com/reactnativestripesdk/CardFormView.kt +22 -7
- package/android/src/main/java/com/reactnativestripesdk/FinancialConnectionsSheetFragment.kt +1 -0
- package/android/src/main/java/com/reactnativestripesdk/PaymentLauncherFragment.kt +1 -0
- package/android/src/main/java/com/reactnativestripesdk/PaymentSheetFragment.kt +3 -1
- package/android/src/main/java/com/reactnativestripesdk/StripeSdkModule.kt +7 -0
- package/android/src/main/java/com/reactnativestripesdk/utils/Mappers.kt +2 -0
- package/ios/ApplePayUtils.swift +1 -1
- package/ios/CardFieldView.swift +3 -3
- package/ios/FinancialConnections.swift +23 -22
- package/ios/Mappers.swift +10 -2
- package/ios/PaymentMethodFactory.swift +6 -7
- package/ios/PaymentSheetAppearance.swift +5 -5
- package/ios/StripeSdk.m +5 -0
- package/ios/StripeSdk.swift +68 -26
- package/jest/mock.js +2 -0
- package/lib/commonjs/NativeStripeSdk.js.map +1 -1
- package/lib/commonjs/functions.js +1 -1
- package/lib/commonjs/functions.js.map +1 -1
- package/lib/commonjs/hooks/usePaymentSheet.js +1 -1
- package/lib/commonjs/hooks/usePaymentSheet.js.map +1 -1
- package/lib/commonjs/hooks/useStripe.js +1 -1
- package/lib/commonjs/hooks/useStripe.js.map +1 -1
- package/lib/commonjs/types/FinancialConnections.js.map +1 -1
- package/lib/module/NativeStripeSdk.js.map +1 -1
- package/lib/module/functions.js +1 -1
- package/lib/module/functions.js.map +1 -1
- package/lib/module/hooks/usePaymentSheet.js +1 -1
- package/lib/module/hooks/usePaymentSheet.js.map +1 -1
- package/lib/module/hooks/useStripe.js +1 -1
- package/lib/module/hooks/useStripe.js.map +1 -1
- package/lib/module/types/FinancialConnections.js.map +1 -1
- package/lib/typescript/src/NativeStripeSdk.d.ts +1 -0
- package/lib/typescript/src/functions.d.ts +6 -0
- package/lib/typescript/src/hooks/usePaymentSheet.d.ts +6 -0
- package/lib/typescript/src/hooks/useStripe.d.ts +6 -0
- package/lib/typescript/src/types/FinancialConnections.d.ts +2 -2
- package/lib/typescript/src/types/PaymentMethod.d.ts +2 -0
- package/lib/typescript/src/types/PaymentSheet.d.ts +17 -0
- package/package.json +1 -1
- package/src/NativeStripeSdk.tsx +1 -0
- package/src/functions.ts +9 -0
- package/src/hooks/usePaymentSheet.tsx +14 -0
- package/src/hooks/useStripe.tsx +11 -0
- package/src/types/FinancialConnections.ts +4 -4
- package/src/types/PaymentMethod.ts +2 -0
- package/src/types/PaymentSheet.ts +19 -0
- package/stripe-react-native.podspec +6 -2
- package/android/.gradle/7.1/dependencies-accessors/dependencies-accessors.lock +0 -0
- package/android/.gradle/7.1/dependencies-accessors/gc.properties +0 -0
- package/android/.gradle/7.1/fileChanges/last-build.bin +0 -0
- package/android/.gradle/7.1/fileHashes/fileHashes.lock +0 -0
- package/android/.gradle/7.1/gc.properties +0 -0
- package/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock +0 -0
- package/android/.gradle/buildOutputCleanup/cache.properties +0 -2
- package/android/.gradle/checksums/checksums.lock +0 -0
- package/android/.gradle/vcs-1/gc.properties +0 -0
- package/android/.idea/gradle.xml +0 -13
- package/android/.idea/misc.xml +0 -9
- package/android/.idea/modules/android.iml +0 -18
- package/android/.idea/modules.xml +0 -8
- package/android/.idea/vcs.xml +0 -6
- package/android/local.properties +0 -8
- package/ios/StripeSdk.xcodeproj/project.xcworkspace/contents.xcworkspacedata +0 -7
- package/ios/StripeSdk.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +0 -8
- package/ios/StripeSdk.xcodeproj/project.xcworkspace/xcuserdata/charliecruzan.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
- package/ios/StripeSdk.xcodeproj/xcuserdata/charliecruzan.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist +0 -22
- package/ios/StripeSdk.xcodeproj/xcuserdata/charliecruzan.xcuserdatad/xcschemes/xcschememanagement.plist +0 -27
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,29 @@
|
|
|
2
2
|
|
|
3
3
|
## Unreleased
|
|
4
4
|
|
|
5
|
+
## 0.20.0 - 2022-11-03
|
|
6
|
+
|
|
7
|
+
### Breaking changes
|
|
8
|
+
|
|
9
|
+
- This library now supports iOS 13 and up, due to `stripe-ios` increasing the deployment target. If you would like to build for iOS 12, please continue to use `@stripe/stripe-react-native@0.19.0`. [#1190](https://github.com/stripe/stripe-react-native/pull/1190)
|
|
10
|
+
|
|
11
|
+
### New features
|
|
12
|
+
|
|
13
|
+
- Added [Link](https://stripe.com/docs/payments/link) support in Payment Sheet. [#1176](https://github.com/stripe/stripe-react-native/pull/1176)
|
|
14
|
+
- Added the `resetPaymentSheetCustomer` method to clear persisted authentication state in the PaymentSheet. [#1176](https://github.com/stripe/stripe-react-native/pull/1176)
|
|
15
|
+
- Added `preferredNetwork` and `availableNetworks` fields to the `CardResult` payment method. [#1176](https://github.com/stripe/stripe-react-native/pull/1176)
|
|
16
|
+
- Added support for custom fonts to `CardForm` and `CardView` on Android. [#1150](https://github.com/stripe/stripe-react-native/pull/1150)
|
|
17
|
+
- Added support for customizing the call to action button label in Payment Sheet by providing the `primaryButtonLabel` property to `initPaymentSheet()`. [#1190](https://github.com/stripe/stripe-react-native/pull/1190)
|
|
18
|
+
|
|
19
|
+
## Fixes
|
|
20
|
+
|
|
21
|
+
- Fixed an issue on iOS where `confirmSetupIntent` would throw an error if the `Card` payment method was provided with the `paymentMethodId` parameter. [#1151](https://github.com/stripe/stripe-react-native/pull/1151)
|
|
22
|
+
- Upgraded `stripe-android` to 20.15.+. [#1176](https://github.com/stripe/stripe-react-native/pull/1176)
|
|
23
|
+
- Upgraded `stripe-ios` to 23.1.+. [#1190](https://github.com/stripe/stripe-react-native/pull/1190)
|
|
24
|
+
- Fixed `FinancialConnections.Subcategory` and `FinancialConnections.Permission` types to be camel-case instead of snake case. [#1176](https://github.com/stripe/stripe-react-native/pull/1176)
|
|
25
|
+
- Fixed an issue with Financial Connections on iOS where the app wouldn't properly redirect back after authentication. [#1178](https://github.com/stripe/stripe-react-native/pull/1178)
|
|
26
|
+
- Fixed `borderWidth` and `borderRadius` for `<CardField />` and `CardForm />` was inconsistent across iOS and Android. [#1182](https://github.com/stripe/stripe-react-native/pull/1182)
|
|
27
|
+
|
|
5
28
|
## 0.19.0 - 2022-09-16
|
|
6
29
|
|
|
7
30
|
### Breaking changes
|
|
@@ -116,7 +139,7 @@
|
|
|
116
139
|
- Fixed a bug on Android where a crash could occur if the PaymentSheet was canceled and opened again. [#1014](https://github.com/stripe/stripe-react-native/pull/1014)
|
|
117
140
|
- Fixed an instance on iOS where `CardField`'s expiry date would remain marked as valid, even when it's invalid. [#1018](https://github.com/stripe/stripe-react-native/issues/1018)
|
|
118
141
|
|
|
119
|
-
## 0.13.1 - 2022-06-16
|
|
142
|
+
## 0.13.1 - 2022-06-16 (📌 Expo SDK 46)
|
|
120
143
|
|
|
121
144
|
### Breaking changes
|
|
122
145
|
|
|
@@ -257,6 +280,11 @@
|
|
|
257
280
|
- (Typescript) `GooglePay.IsGooglePaySupportedParams` is now `GooglePay.IsSupportedParams`
|
|
258
281
|
- (Typescript) Removed `GooglePay.SetupIntentParams`
|
|
259
282
|
|
|
283
|
+
## 0.6.1 - 2022-04-01 (📌 Expo SDK 45)
|
|
284
|
+
|
|
285
|
+
- Fix: correctly overwrite `package.json` import via babel. [#924](https://github.com/stripe/stripe-react-native/pull/924)
|
|
286
|
+
- Fix: upgrade expo config plugins. [#936](https://github.com/stripe/stripe-react-native/pull/936)
|
|
287
|
+
|
|
260
288
|
## 0.6.0 - 2022-04-01
|
|
261
289
|
|
|
262
290
|
- [#861](https://github.com/stripe/stripe-react-native/pull/861) BREAKING: This library now supports iOS 12 and up, due to `stripe-ios` increasing the deployment target. If you would like to build for iOS 11, please continue to use `@stripe/stripe-react-native@0.5.0`.
|
|
@@ -306,7 +334,7 @@
|
|
|
306
334
|
- [#658](https://github.com/stripe/stripe-react-native/pull/658) fix: TS issue with 0.2.3 StripeProvider cannot be used as a JSX component ([#658](https://github.com/stripe/stripe-react-native/issues/658))
|
|
307
335
|
- [#635](https://github.com/stripe/stripe-react-native/pull/635) fix: billing address postal code ([#635](https://github.com/stripe/stripe-react-native/issues/635))
|
|
308
336
|
|
|
309
|
-
## 0.2.3 - 2021-10-18
|
|
337
|
+
## 0.2.3 - 2021-10-18 (📌 Expo SDK 44)
|
|
310
338
|
|
|
311
339
|
- [#565](https://github.com/stripe/stripe-react-native/pull/565) chore: Add jest mock file ([#565](https://github.com/stripe/stripe-react-native/issues/565))
|
|
312
340
|
- [#587](https://github.com/stripe/stripe-react-native/pull/587) chore: Update Podfile.lock stripe-react-native version ([#587](https://github.com/stripe/stripe-react-native/issues/587))
|
|
@@ -314,7 +342,7 @@
|
|
|
314
342
|
- [#631](https://github.com/stripe/stripe-react-native/pull/631) chore: Update tips migration guide ([#631](https://github.com/stripe/stripe-react-native/issues/631))
|
|
315
343
|
- [#601](https://github.com/stripe/stripe-react-native/pull/601) feat: Add button color, return URL, allowsDelayedPaymentMethods, and billing details to PaymentSheet ([#601](https://github.com/stripe/stripe-react-native/issues/601))
|
|
316
344
|
|
|
317
|
-
## 0.2.2 - 2021-09-15
|
|
345
|
+
## 0.2.2 - 2021-09-15 (📌 Expo SDK 43)
|
|
318
346
|
|
|
319
347
|
- [#588](https://github.com/stripe/stripe-react-native/pull/588) fix: use the LocalBroadcastManager ([#588](https://github.com/stripe/stripe-react-native/issues/588))
|
|
320
348
|
|
|
@@ -350,7 +378,7 @@
|
|
|
350
378
|
- [#337](https://github.com/stripe/stripe-react-native/pull/337) feat: expose CardField methods (focus, blur, clear)
|
|
351
379
|
- [#366](https://github.com/stripe/stripe-react-native/pull/366) fix: open payment sheet from modal ([#315](https://github.com/stripe/stripe-react-native/issues/315); [#290](https://github.com/stripe/stripe-react-native/issues/290))
|
|
352
380
|
|
|
353
|
-
## 0.1.4 - 2021-06-04
|
|
381
|
+
## 0.1.4 - 2021-06-04 (📌 Expo SDK 42)
|
|
354
382
|
|
|
355
383
|
## 0.1.3 - 2021-06-04
|
|
356
384
|
|
|
@@ -374,7 +402,7 @@
|
|
|
374
402
|
- [#234](https://github.com/stripe/stripe-react-native/pull/234) fix: add missing 3D Secure button props ([#201](https://github.com/stripe/stripe-react-native/issues/201))
|
|
375
403
|
- [#226](https://github.com/stripe/stripe-react-native/pull/226) feat: add `autofocus` prop to `CardField` component ([#199](https://github.com/stripe/stripe-react-native/issues/199))
|
|
376
404
|
|
|
377
|
-
## 0.1.1 - 2021-05-14
|
|
405
|
+
## 0.1.1 - 2021-05-14 (📌 Expo SDK 41)
|
|
378
406
|
|
|
379
407
|
- [#224](https://github.com/stripe/stripe-react-native/pull/224) chore: upgrade to [`stripe-android` version `16.8.2`](https://github.com/stripe/stripe-android/blob/master/CHANGELOG.md#1682---2021-05-14) ([#212](https://github.com/stripe/stripe-react-native/issues/212))
|
|
380
408
|
- [#213](https://github.com/stripe/stripe-react-native/pull/213) fix: expose config-plugin and add blank swift file
|
package/README.md
CHANGED
|
@@ -96,7 +96,7 @@ implementation 'com.google.android.material:material:<version>'
|
|
|
96
96
|
|
|
97
97
|
#### iOS
|
|
98
98
|
|
|
99
|
-
The Stripe React Native SDK requires Xcode 13.2.1 or later and is compatible with apps targeting iOS
|
|
99
|
+
The Stripe React Native SDK requires Xcode 13.2.1 or later and is compatible with apps targeting iOS 13 or above. For iOS 12 support, please use [`@stripe/stripe-react-native@0.19.0`](https://github.com/stripe/stripe-react-native/releases/tag/v0.19.0).
|
|
100
100
|
|
|
101
101
|
The SDK uses TypeScript features available in Babel version `7.9.0` and above.
|
|
102
102
|
Alternatively use the `plugin-transform-typescript` plugin in your project.
|
|
@@ -258,7 +258,7 @@ Follow these steps to resolve this:
|
|
|
258
258
|
|
|
259
259
|
- Open your project via Xcode, go to `project -> build settings`, find `library search paths` and remove all swift related entries such as:
|
|
260
260
|
`$(TOOLCHAIN_DIR)/usr/lib/swift/$(PLATFORM_NAME)` and `$(TOOLCHAIN_DIR)/usr/lib/swift-5.0/$(PLATFORM_NAME)`.
|
|
261
|
-
- Create a new Swift file to the project (File > New > File > Swift), give it any name (e.g. `Fix.swift`) and create a bridging header when prompted by Xcode.
|
|
261
|
+
- Create a new Swift file to the project (File > New > File > Swift), give it any name (e.g. `Fix.swift`), check the appropriate Targets and create a bridging header when prompted by Xcode.
|
|
262
262
|
|
|
263
263
|
### `TypeError: null is not an object (evaluating '_NativeStripeSdk.default.initialise')` on Android
|
|
264
264
|
|
package/android/build.gradle
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
StripeSdk_kotlinVersion=1.6.21
|
|
2
|
-
StripeSdk_stripeVersion=20.
|
|
2
|
+
StripeSdk_stripeVersion=20.15.+
|
|
@@ -11,9 +11,11 @@ import android.util.Log
|
|
|
11
11
|
import android.widget.FrameLayout
|
|
12
12
|
import androidx.core.os.LocaleListCompat
|
|
13
13
|
import com.facebook.react.bridge.ReadableMap
|
|
14
|
+
import com.facebook.react.uimanager.PixelUtil
|
|
14
15
|
import com.facebook.react.uimanager.ThemedReactContext
|
|
15
16
|
import com.facebook.react.uimanager.UIManagerModule
|
|
16
17
|
import com.facebook.react.uimanager.events.EventDispatcher
|
|
18
|
+
import com.facebook.react.views.text.ReactTypefaceUtils
|
|
17
19
|
import com.google.android.material.shape.CornerFamily
|
|
18
20
|
import com.google.android.material.shape.MaterialShapeDrawable
|
|
19
21
|
import com.google.android.material.shape.ShapeAppearanceModel
|
|
@@ -124,7 +126,8 @@ class CardFieldView(context: ThemedReactContext) : FrameLayout(context) {
|
|
|
124
126
|
}
|
|
125
127
|
fontFamily?.let {
|
|
126
128
|
for (editTextBinding in bindings) {
|
|
127
|
-
|
|
129
|
+
// Load custom font from assets, and fallback to default system font
|
|
130
|
+
editTextBinding.typeface = ReactTypefaceUtils.applyStyles(null, -1, -1, it.takeIf { it.isNotEmpty() }, context.assets)
|
|
128
131
|
}
|
|
129
132
|
}
|
|
130
133
|
cursorColor?.let {
|
|
@@ -144,14 +147,14 @@ class CardFieldView(context: ThemedReactContext) : FrameLayout(context) {
|
|
|
144
147
|
mCardWidget.background = MaterialShapeDrawable(
|
|
145
148
|
ShapeAppearanceModel()
|
|
146
149
|
.toBuilder()
|
|
147
|
-
.setAllCorners(CornerFamily.ROUNDED, (borderRadius
|
|
150
|
+
.setAllCorners(CornerFamily.ROUNDED, PixelUtil.toPixelFromDIP(borderRadius.toDouble()))
|
|
148
151
|
.build()
|
|
149
152
|
).also { shape ->
|
|
150
153
|
shape.strokeWidth = 0.0f
|
|
151
154
|
shape.strokeColor = ColorStateList.valueOf(Color.parseColor("#000000"))
|
|
152
155
|
shape.fillColor = ColorStateList.valueOf(Color.parseColor("#FFFFFF"))
|
|
153
156
|
borderWidth?.let {
|
|
154
|
-
shape.strokeWidth = (it
|
|
157
|
+
shape.strokeWidth = PixelUtil.toPixelFromDIP(it.toDouble())
|
|
155
158
|
}
|
|
156
159
|
borderColor?.let {
|
|
157
160
|
shape.strokeColor = ColorStateList.valueOf(Color.parseColor(it))
|
|
@@ -9,9 +9,11 @@ import android.view.View
|
|
|
9
9
|
import android.view.View.OnFocusChangeListener
|
|
10
10
|
import android.widget.FrameLayout
|
|
11
11
|
import com.facebook.react.bridge.ReadableMap
|
|
12
|
+
import com.facebook.react.uimanager.PixelUtil
|
|
12
13
|
import com.facebook.react.uimanager.ThemedReactContext
|
|
13
14
|
import com.facebook.react.uimanager.UIManagerModule
|
|
14
15
|
import com.facebook.react.uimanager.events.EventDispatcher
|
|
16
|
+
import com.facebook.react.views.text.ReactTypefaceUtils
|
|
15
17
|
import com.google.android.material.shape.CornerFamily
|
|
16
18
|
import com.google.android.material.shape.MaterialShapeDrawable
|
|
17
19
|
import com.google.android.material.shape.ShapeAppearanceModel
|
|
@@ -134,6 +136,12 @@ class CardFormView(context: ThemedReactContext) : FrameLayout(context) {
|
|
|
134
136
|
cardFormViewBinding.cardMultilineWidget.expiryDateEditText,
|
|
135
137
|
cardFormViewBinding.postalCode
|
|
136
138
|
)
|
|
139
|
+
val placeholderTextBindings = setOf(
|
|
140
|
+
multilineWidgetBinding.tlExpiry,
|
|
141
|
+
multilineWidgetBinding.tlCardNumber,
|
|
142
|
+
multilineWidgetBinding.tlCvc,
|
|
143
|
+
cardFormViewBinding.postalCodeContainer,
|
|
144
|
+
)
|
|
137
145
|
|
|
138
146
|
textColor?.let {
|
|
139
147
|
for (binding in editTextBindings) {
|
|
@@ -148,10 +156,9 @@ class CardFormView(context: ThemedReactContext) : FrameLayout(context) {
|
|
|
148
156
|
}
|
|
149
157
|
}
|
|
150
158
|
placeholderColor?.let {
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
cardFormViewBinding.postalCodeContainer.defaultHintTextColor = ColorStateList.valueOf(Color.parseColor(it))
|
|
159
|
+
for (binding in placeholderTextBindings) {
|
|
160
|
+
binding.defaultHintTextColor = ColorStateList.valueOf(Color.parseColor(it))
|
|
161
|
+
}
|
|
155
162
|
}
|
|
156
163
|
fontSize?.let {
|
|
157
164
|
for (binding in editTextBindings) {
|
|
@@ -159,9 +166,17 @@ class CardFormView(context: ThemedReactContext) : FrameLayout(context) {
|
|
|
159
166
|
}
|
|
160
167
|
}
|
|
161
168
|
fontFamily?.let {
|
|
169
|
+
// Load custom font from assets, and fallback to default system font
|
|
170
|
+
val typeface = ReactTypefaceUtils.applyStyles(null, -1, -1, it.takeIf { it.isNotEmpty() }, context.assets)
|
|
162
171
|
for (binding in editTextBindings) {
|
|
163
|
-
binding.typeface =
|
|
172
|
+
binding.typeface = typeface
|
|
173
|
+
}
|
|
174
|
+
for (binding in placeholderTextBindings) {
|
|
175
|
+
binding.typeface = typeface
|
|
164
176
|
}
|
|
177
|
+
cardFormViewBinding.countryLayout.typeface = typeface
|
|
178
|
+
cardFormViewBinding.countryLayout.countryAutocomplete.typeface = typeface
|
|
179
|
+
cardFormViewBinding.errors.typeface = typeface
|
|
165
180
|
}
|
|
166
181
|
cursorColor?.let {
|
|
167
182
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
|
|
@@ -180,14 +195,14 @@ class CardFormView(context: ThemedReactContext) : FrameLayout(context) {
|
|
|
180
195
|
cardFormViewBinding.cardMultilineWidgetContainer.background = MaterialShapeDrawable(
|
|
181
196
|
ShapeAppearanceModel()
|
|
182
197
|
.toBuilder()
|
|
183
|
-
.setAllCorners(CornerFamily.ROUNDED, (borderRadius
|
|
198
|
+
.setAllCorners(CornerFamily.ROUNDED, PixelUtil.toPixelFromDIP(borderRadius.toDouble()))
|
|
184
199
|
.build()
|
|
185
200
|
).also { shape ->
|
|
186
201
|
shape.strokeWidth = 0.0f
|
|
187
202
|
shape.strokeColor = ColorStateList.valueOf(Color.parseColor("#000000"))
|
|
188
203
|
shape.fillColor = ColorStateList.valueOf(Color.parseColor("#FFFFFF"))
|
|
189
204
|
borderWidth?.let {
|
|
190
|
-
shape.strokeWidth = (it
|
|
205
|
+
shape.strokeWidth = PixelUtil.toPixelFromDIP(it.toDouble())
|
|
191
206
|
}
|
|
192
207
|
borderColor?.let {
|
|
193
208
|
shape.strokeColor = ColorStateList.valueOf(Color.parseColor(it))
|
|
@@ -237,6 +237,7 @@ class FinancialConnectionsSheetFragment : Fragment() {
|
|
|
237
237
|
FinancialConnectionsAccount.Permissions.BALANCES -> "balances"
|
|
238
238
|
FinancialConnectionsAccount.Permissions.OWNERSHIP -> "ownership"
|
|
239
239
|
FinancialConnectionsAccount.Permissions.TRANSACTIONS -> "transactions"
|
|
240
|
+
FinancialConnectionsAccount.Permissions.ACCOUNT_NUMBERS -> "accountNumbers"
|
|
240
241
|
FinancialConnectionsAccount.Permissions.UNKNOWN -> "unparsable"
|
|
241
242
|
}
|
|
242
243
|
}
|
|
@@ -261,6 +261,7 @@ class PaymentLauncherFragment(
|
|
|
261
261
|
StripeIntent.NextActionType.AlipayRedirect,
|
|
262
262
|
StripeIntent.NextActionType.BlikAuthorize,
|
|
263
263
|
StripeIntent.NextActionType.WeChatPayRedirect,
|
|
264
|
+
StripeIntent.NextActionType.UpiAwaitNotification,
|
|
264
265
|
null -> false
|
|
265
266
|
}
|
|
266
267
|
}
|
|
@@ -56,6 +56,7 @@ class PaymentSheetFragment(
|
|
|
56
56
|
initPromise.resolve(createError(ErrorType.Failed.toString(), "merchantDisplayName cannot be empty or null."))
|
|
57
57
|
return
|
|
58
58
|
}
|
|
59
|
+
val primaryButtonLabel = arguments?.getString("primaryButtonLabel")
|
|
59
60
|
val customerId = arguments?.getString("customerId").orEmpty()
|
|
60
61
|
val customerEphemeralKeySecret = arguments?.getString("customerEphemeralKeySecret").orEmpty()
|
|
61
62
|
val googlePayConfig = buildGooglePayConfig(arguments?.getBundle("googlePay"))
|
|
@@ -126,7 +127,8 @@ class PaymentSheetFragment(
|
|
|
126
127
|
ephemeralKeySecret = customerEphemeralKeySecret
|
|
127
128
|
) else null,
|
|
128
129
|
googlePay = googlePayConfig,
|
|
129
|
-
appearance = appearance
|
|
130
|
+
appearance = appearance,
|
|
131
|
+
primaryButtonLabel = primaryButtonLabel
|
|
130
132
|
)
|
|
131
133
|
|
|
132
134
|
if (arguments?.getBoolean("customFlow") == true) {
|
|
@@ -17,6 +17,7 @@ import com.stripe.android.core.ApiVersion
|
|
|
17
17
|
import com.stripe.android.core.AppInfo
|
|
18
18
|
import com.stripe.android.model.*
|
|
19
19
|
import com.stripe.android.payments.bankaccount.CollectBankAccountConfiguration
|
|
20
|
+
import com.stripe.android.paymentsheet.PaymentSheet
|
|
20
21
|
import com.stripe.android.view.AddPaymentMethodActivityStarter
|
|
21
22
|
import kotlinx.coroutines.CoroutineScope
|
|
22
23
|
import kotlinx.coroutines.Dispatchers
|
|
@@ -160,6 +161,12 @@ class StripeSdkModule(reactContext: ReactApplicationContext) : ReactContextBaseJ
|
|
|
160
161
|
paymentSheetFragment?.confirmPayment(promise)
|
|
161
162
|
}
|
|
162
163
|
|
|
164
|
+
@ReactMethod
|
|
165
|
+
fun resetPaymentSheetCustomer(promise: Promise) {
|
|
166
|
+
PaymentSheet.resetCustomer(context = reactApplicationContext)
|
|
167
|
+
promise.resolve(null)
|
|
168
|
+
}
|
|
169
|
+
|
|
163
170
|
private fun payWithFpx() {
|
|
164
171
|
getCurrentActivityOrResolveWithError(confirmPromise)?.let {
|
|
165
172
|
AddPaymentMethodActivityStarter(it)
|
|
@@ -347,6 +347,8 @@ internal fun mapFromPaymentMethod(paymentMethod: PaymentMethod): WritableMap {
|
|
|
347
347
|
card.putString("funding", paymentMethod.card?.funding)
|
|
348
348
|
card.putString("last4", paymentMethod.card?.last4)
|
|
349
349
|
card.putString("fingerprint", paymentMethod.card?.fingerprint)
|
|
350
|
+
card.putString("preferredNetwork", paymentMethod.card?.networks?.preferred)
|
|
351
|
+
card.putArray("availableNetworks", paymentMethod.card?.networks?.available?.toList() as? ReadableArray)
|
|
350
352
|
|
|
351
353
|
sepaDebit.putString("bankCode", paymentMethod.sepaDebit?.bankCode)
|
|
352
354
|
sepaDebit.putString("country", paymentMethod.sepaDebit?.country)
|
package/ios/ApplePayUtils.swift
CHANGED
package/ios/CardFieldView.swift
CHANGED
|
@@ -9,7 +9,7 @@ class CardFieldView: UIView, STPPaymentCardTextFieldDelegate {
|
|
|
9
9
|
|
|
10
10
|
private var cardField = STPPaymentCardTextField()
|
|
11
11
|
|
|
12
|
-
public var cardParams:
|
|
12
|
+
public var cardParams: STPPaymentMethodParams? = nil
|
|
13
13
|
public var cardPostalCode: String? = nil
|
|
14
14
|
|
|
15
15
|
@objc var postalCodeEnabled: Bool = true {
|
|
@@ -144,7 +144,7 @@ class CardFieldView: UIView, STPPaymentCardTextFieldDelegate {
|
|
|
144
144
|
"expiryYear": textField.expirationYear,
|
|
145
145
|
"complete": textField.isValid,
|
|
146
146
|
"brand": Mappers.mapFromCardBrand(brand) ?? NSNull(),
|
|
147
|
-
"last4": textField.
|
|
147
|
+
"last4": textField.paymentMethodParams.card!.last4 ?? "",
|
|
148
148
|
"validExpiryDate": Mappers.mapFromCardValidationState(state: validExpiryDate),
|
|
149
149
|
"validCVC": Mappers.mapFromCardValidationState(state: validCVC),
|
|
150
150
|
"validNumber": Mappers.mapFromCardValidationState(state: validNumber)
|
|
@@ -159,7 +159,7 @@ class CardFieldView: UIView, STPPaymentCardTextFieldDelegate {
|
|
|
159
159
|
onCardChange!(cardData as [AnyHashable : Any])
|
|
160
160
|
}
|
|
161
161
|
if (textField.isValid) {
|
|
162
|
-
self.cardParams = textField.
|
|
162
|
+
self.cardParams = textField.paymentMethodParams
|
|
163
163
|
self.cardPostalCode = textField.postalCode
|
|
164
164
|
} else {
|
|
165
165
|
self.cardParams = nil
|
|
@@ -10,13 +10,14 @@ import StripeFinancialConnections
|
|
|
10
10
|
import Stripe
|
|
11
11
|
|
|
12
12
|
class FinancialConnections {
|
|
13
|
-
|
|
13
|
+
|
|
14
14
|
internal static func present(
|
|
15
15
|
withClientSecret: String,
|
|
16
|
+
returnURL: String? = nil,
|
|
16
17
|
resolve: @escaping RCTPromiseResolveBlock
|
|
17
18
|
) -> Void {
|
|
18
19
|
DispatchQueue.main.async {
|
|
19
|
-
FinancialConnectionsSheet(financialConnectionsSessionClientSecret: withClientSecret).present(
|
|
20
|
+
FinancialConnectionsSheet(financialConnectionsSessionClientSecret: withClientSecret, returnURL: returnURL).present(
|
|
20
21
|
from: findViewControllerPresenter(from: UIApplication.shared.delegate?.window??.rootViewController ?? UIViewController()),
|
|
21
22
|
completion: { result in
|
|
22
23
|
switch result {
|
|
@@ -30,13 +31,14 @@ class FinancialConnections {
|
|
|
30
31
|
})
|
|
31
32
|
}
|
|
32
33
|
}
|
|
33
|
-
|
|
34
|
+
|
|
34
35
|
internal static func presentForToken(
|
|
35
36
|
withClientSecret: String,
|
|
37
|
+
returnURL: String? = nil,
|
|
36
38
|
resolve: @escaping RCTPromiseResolveBlock
|
|
37
39
|
) -> Void {
|
|
38
40
|
DispatchQueue.main.async {
|
|
39
|
-
FinancialConnectionsSheet(financialConnectionsSessionClientSecret: withClientSecret).presentForToken(
|
|
41
|
+
FinancialConnectionsSheet(financialConnectionsSessionClientSecret: withClientSecret, returnURL: returnURL).presentForToken(
|
|
40
42
|
from: findViewControllerPresenter(from: UIApplication.shared.delegate?.window??.rootViewController ?? UIViewController()),
|
|
41
43
|
completion: { result in
|
|
42
44
|
switch result {
|
|
@@ -55,7 +57,7 @@ class FinancialConnections {
|
|
|
55
57
|
})
|
|
56
58
|
}
|
|
57
59
|
}
|
|
58
|
-
|
|
60
|
+
|
|
59
61
|
internal static func mapFromSessionResult(
|
|
60
62
|
_ session: StripeAPI.FinancialConnectionsSession
|
|
61
63
|
) -> NSDictionary {
|
|
@@ -66,7 +68,7 @@ class FinancialConnections {
|
|
|
66
68
|
"accounts": mapFromAccountsList(accounts: session.accounts)
|
|
67
69
|
]
|
|
68
70
|
}
|
|
69
|
-
|
|
71
|
+
|
|
70
72
|
internal static func mapFromTokenResult(
|
|
71
73
|
_ token: StripeAPI.BankAccountToken?
|
|
72
74
|
) -> NSDictionary {
|
|
@@ -79,7 +81,7 @@ class FinancialConnections {
|
|
|
79
81
|
"created": NSNull(), // Doesn't exist on StripeAPI.BankAccountToken
|
|
80
82
|
]
|
|
81
83
|
}
|
|
82
|
-
|
|
84
|
+
|
|
83
85
|
internal static func mapFromBankAccount(
|
|
84
86
|
bankAccount: StripeAPI.BankAccountToken.BankAccount?
|
|
85
87
|
) -> NSDictionary? {
|
|
@@ -100,12 +102,12 @@ class FinancialConnections {
|
|
|
100
102
|
"status": bankAccount.status.prefix(1).uppercased() + bankAccount.status.lowercased().dropFirst(), // stripe-ios returns a string, not STPBankAccountStatus
|
|
101
103
|
]
|
|
102
104
|
}
|
|
103
|
-
|
|
105
|
+
|
|
104
106
|
internal static func mapFromAccountsList(
|
|
105
107
|
accounts: StripeAPI.FinancialConnectionsSession.AccountList
|
|
106
108
|
) -> [[String: Any]] {
|
|
107
109
|
var result = [[String: Any]]()
|
|
108
|
-
|
|
110
|
+
|
|
109
111
|
for account in accounts.data {
|
|
110
112
|
result.append([
|
|
111
113
|
"id": account.id,
|
|
@@ -123,7 +125,7 @@ class FinancialConnections {
|
|
|
123
125
|
"supportedPaymentMethodTypes": account.supportedPaymentMethodTypes.map { mapFromSupportedPaymentMethodTypes($0) },
|
|
124
126
|
])
|
|
125
127
|
}
|
|
126
|
-
|
|
128
|
+
|
|
127
129
|
return result
|
|
128
130
|
}
|
|
129
131
|
|
|
@@ -133,13 +135,12 @@ class FinancialConnections {
|
|
|
133
135
|
guard let balance = balance else {
|
|
134
136
|
return nil
|
|
135
137
|
}
|
|
136
|
-
|
|
138
|
+
|
|
137
139
|
return [
|
|
138
140
|
"asOf": balance.asOf * 1000,
|
|
139
141
|
"type": mapFromBalanceType(balance.type),
|
|
140
|
-
|
|
141
|
-
"
|
|
142
|
-
"credit": ["used": NSNull()], // balance.credit?.used
|
|
142
|
+
"cash": ["available": balance.cash?.available],
|
|
143
|
+
"credit": ["used": balance.credit?.used],
|
|
143
144
|
"current": balance.current,
|
|
144
145
|
]
|
|
145
146
|
}
|
|
@@ -150,13 +151,13 @@ class FinancialConnections {
|
|
|
150
151
|
guard let balanceRefresh = balanceRefresh else {
|
|
151
152
|
return nil
|
|
152
153
|
}
|
|
153
|
-
|
|
154
|
+
|
|
154
155
|
return [
|
|
155
156
|
"status": mapFromBalanceRefreshStatus(balanceRefresh.status),
|
|
156
157
|
"lastAttemptedAt": balanceRefresh.lastAttemptedAt * 1000,
|
|
157
158
|
]
|
|
158
159
|
}
|
|
159
|
-
|
|
160
|
+
|
|
160
161
|
internal static func mapFromStatus( _ status: StripeAPI.FinancialConnectionsAccount.Status) -> String {
|
|
161
162
|
switch status {
|
|
162
163
|
case .active:
|
|
@@ -169,7 +170,7 @@ class FinancialConnections {
|
|
|
169
170
|
return "unparsable"
|
|
170
171
|
}
|
|
171
172
|
}
|
|
172
|
-
|
|
173
|
+
|
|
173
174
|
internal static func mapFromCategory( _ category: StripeAPI.FinancialConnectionsAccount.Category) -> String {
|
|
174
175
|
switch category {
|
|
175
176
|
case .cash:
|
|
@@ -184,7 +185,7 @@ class FinancialConnections {
|
|
|
184
185
|
return "unparsable"
|
|
185
186
|
}
|
|
186
187
|
}
|
|
187
|
-
|
|
188
|
+
|
|
188
189
|
internal static func mapFromSubcategory( _ subcategory: StripeAPI.FinancialConnectionsAccount.Subcategory) -> String {
|
|
189
190
|
switch subcategory {
|
|
190
191
|
case .savings:
|
|
@@ -203,7 +204,7 @@ class FinancialConnections {
|
|
|
203
204
|
return "unparsable"
|
|
204
205
|
}
|
|
205
206
|
}
|
|
206
|
-
|
|
207
|
+
|
|
207
208
|
internal static func mapFromPermission( _ permission: StripeAPI.FinancialConnectionsAccount.Permissions) -> String {
|
|
208
209
|
switch permission {
|
|
209
210
|
case .transactions:
|
|
@@ -220,7 +221,7 @@ class FinancialConnections {
|
|
|
220
221
|
return "unparsable"
|
|
221
222
|
}
|
|
222
223
|
}
|
|
223
|
-
|
|
224
|
+
|
|
224
225
|
internal static func mapFromSupportedPaymentMethodTypes( _ type: StripeAPI.FinancialConnectionsAccount.SupportedPaymentMethodTypes) -> String {
|
|
225
226
|
switch type {
|
|
226
227
|
case .usBankAccount:
|
|
@@ -231,7 +232,7 @@ class FinancialConnections {
|
|
|
231
232
|
return "unparsable"
|
|
232
233
|
}
|
|
233
234
|
}
|
|
234
|
-
|
|
235
|
+
|
|
235
236
|
internal static func mapFromBalanceType( _ type: StripeAPI.FinancialConnectionsAccount.Balance.ModelType) -> String {
|
|
236
237
|
switch type {
|
|
237
238
|
case .cash:
|
|
@@ -242,7 +243,7 @@ class FinancialConnections {
|
|
|
242
243
|
return "unparsable"
|
|
243
244
|
}
|
|
244
245
|
}
|
|
245
|
-
|
|
246
|
+
|
|
246
247
|
internal static func mapFromBalanceRefreshStatus( _ status: StripeAPI.FinancialConnectionsAccount.BalanceRefresh.Status) -> String {
|
|
247
248
|
switch status {
|
|
248
249
|
case .succeeded:
|
package/ios/Mappers.swift
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import Stripe
|
|
2
|
+
import StripePaymentSheet
|
|
2
3
|
|
|
3
4
|
class Mappers {
|
|
4
5
|
class func createResult(_ key: String, _ value: NSDictionary?) -> NSDictionary {
|
|
@@ -53,7 +54,7 @@ class Mappers {
|
|
|
53
54
|
guard let bankAccount = bankAccount else {
|
|
54
55
|
return nil
|
|
55
56
|
}
|
|
56
|
-
|
|
57
|
+
|
|
57
58
|
let result: NSDictionary = [
|
|
58
59
|
"id": bankAccount.stripeID,
|
|
59
60
|
"bankName": bankAccount.bankName ?? NSNull(),
|
|
@@ -594,8 +595,11 @@ class Mappers {
|
|
|
594
595
|
"expMonth": paymentMethod.card?.expMonth ?? NSNull(),
|
|
595
596
|
"fingerprint": paymentMethod.card?.fingerprint ?? NSNull(),
|
|
596
597
|
"funding": paymentMethod.card?.funding ?? NSNull(),
|
|
597
|
-
"last4": paymentMethod.card?.last4 ?? NSNull()
|
|
598
|
+
"last4": paymentMethod.card?.last4 ?? NSNull(),
|
|
599
|
+
"preferredNetwork": paymentMethod.card?.networks?.preferred ?? NSNull(),
|
|
600
|
+
"availableNetworks": paymentMethod.card?.networks?.available ?? NSNull(),
|
|
598
601
|
]
|
|
602
|
+
|
|
599
603
|
let sepaDebit: NSDictionary = [
|
|
600
604
|
"bankCode": paymentMethod.sepaDebit?.bankCode ?? NSNull(),
|
|
601
605
|
"country": paymentMethod.sepaDebit?.country ?? NSNull(),
|
|
@@ -743,6 +747,10 @@ class Mappers {
|
|
|
743
747
|
return urlScheme + "://safepay"
|
|
744
748
|
}
|
|
745
749
|
|
|
750
|
+
class func mapToFinancialConnectionsReturnURL(urlScheme: String) -> String {
|
|
751
|
+
return urlScheme + "://financial_connections_redirect"
|
|
752
|
+
}
|
|
753
|
+
|
|
746
754
|
class func mapUICustomization(_ params: NSDictionary) -> STPThreeDSUICustomization {
|
|
747
755
|
let uiCustomization = STPThreeDSUICustomization()
|
|
748
756
|
if let labelSettings = params["label"] as? Dictionary<String, Any?> {
|
|
@@ -162,11 +162,7 @@ class PaymentMethodFactory {
|
|
|
162
162
|
return STPPaymentMethodParams(card: methodParams, billingDetails: billingDetailsParams, metadata: nil)
|
|
163
163
|
}
|
|
164
164
|
|
|
165
|
-
|
|
166
|
-
throw PaymentMethodError.cardPaymentMissingParams
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
if cardFieldView?.cardParams != nil {
|
|
165
|
+
if let params = cardFieldView?.cardParams as? STPPaymentMethodParams {
|
|
170
166
|
if let postalCode = cardFieldView?.cardPostalCode{
|
|
171
167
|
if (billingDetailsParams == nil) {
|
|
172
168
|
let bd = STPPaymentMethodBillingDetails()
|
|
@@ -177,8 +173,10 @@ class PaymentMethodFactory {
|
|
|
177
173
|
billingDetailsParams?.address?.postalCode = postalCode
|
|
178
174
|
}
|
|
179
175
|
}
|
|
176
|
+
params.billingDetails = billingDetailsParams
|
|
177
|
+
return params
|
|
180
178
|
}
|
|
181
|
-
if cardFormView?.cardParams
|
|
179
|
+
if let params = cardFormView?.cardParams as? STPPaymentMethodCardParams {
|
|
182
180
|
if let address = cardFormView?.cardForm?.cardParams?.billingDetails?.address {
|
|
183
181
|
if (billingDetailsParams == nil) {
|
|
184
182
|
let bd = STPPaymentMethodBillingDetails()
|
|
@@ -191,9 +189,10 @@ class PaymentMethodFactory {
|
|
|
191
189
|
billingDetailsParams?.address?.country = address.country
|
|
192
190
|
}
|
|
193
191
|
}
|
|
192
|
+
return STPPaymentMethodParams(card: params, billingDetails: billingDetailsParams, metadata: nil)
|
|
194
193
|
}
|
|
195
194
|
|
|
196
|
-
|
|
195
|
+
throw PaymentMethodError.cardPaymentMissingParams
|
|
197
196
|
}
|
|
198
197
|
|
|
199
198
|
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
//
|
|
5
5
|
// Created by Charles Cruzan on 5/11/22.
|
|
6
6
|
//
|
|
7
|
-
import
|
|
7
|
+
import StripePaymentSheet
|
|
8
8
|
|
|
9
9
|
extension StripeSdk {
|
|
10
10
|
func buildPaymentSheetAppearance(userParams: NSDictionary) throws -> PaymentSheet.Appearance {
|
|
@@ -30,8 +30,8 @@ extension StripeSdk {
|
|
|
30
30
|
return appearance
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
-
private func buildFont(params: NSDictionary) throws ->
|
|
34
|
-
var font =
|
|
33
|
+
private func buildFont(params: NSDictionary) throws -> PaymentSheet.Appearance.Font {
|
|
34
|
+
var font = PaymentSheet.Appearance.Font()
|
|
35
35
|
if let fontName = params[PaymentSheetAppearanceKeys.FAMILY] as? String {
|
|
36
36
|
guard let customFont = UIFont(name: fontName, size: UIFont.systemFontSize) else {
|
|
37
37
|
throw PaymentSheetAppearanceError.missingFont(fontName)
|
|
@@ -42,8 +42,8 @@ extension StripeSdk {
|
|
|
42
42
|
return font
|
|
43
43
|
}
|
|
44
44
|
|
|
45
|
-
private func buildColors(params: NSDictionary) throws ->
|
|
46
|
-
var colors =
|
|
45
|
+
private func buildColors(params: NSDictionary) throws -> PaymentSheet.Appearance.Colors {
|
|
46
|
+
var colors = PaymentSheet.Appearance.Colors()
|
|
47
47
|
|
|
48
48
|
if (params.object(forKey: PaymentSheetAppearanceKeys.LIGHT) != nil && params.object(forKey: PaymentSheetAppearanceKeys.DARK) == nil ||
|
|
49
49
|
params.object(forKey: PaymentSheetAppearanceKeys.DARK) != nil && params.object(forKey: PaymentSheetAppearanceKeys.LIGHT) == nil) {
|
package/ios/StripeSdk.m
CHANGED
|
@@ -92,6 +92,11 @@ RCT_EXTERN_METHOD(
|
|
|
92
92
|
rejecter: (RCTPromiseRejectBlock)reject
|
|
93
93
|
)
|
|
94
94
|
|
|
95
|
+
RCT_EXTERN_METHOD(
|
|
96
|
+
resetPaymentSheetCustomer:(RCTPromiseResolveBlock)resolve
|
|
97
|
+
rejecter: (RCTPromiseRejectBlock)reject
|
|
98
|
+
)
|
|
99
|
+
|
|
95
100
|
RCT_EXTERN_METHOD(
|
|
96
101
|
confirmPayment:(NSString *)paymentIntentClientSecret
|
|
97
102
|
data:(NSDictionary *)data
|