@stripe/stripe-react-native 0.19.0 → 0.21.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.
Files changed (115) hide show
  1. package/CHANGELOG.md +46 -5
  2. package/README.md +2 -2
  3. package/android/build.gradle +1 -2
  4. package/android/gradle.properties +1 -1
  5. package/android/src/main/java/com/reactnativestripesdk/CardFieldView.kt +6 -3
  6. package/android/src/main/java/com/reactnativestripesdk/CardFormView.kt +22 -7
  7. package/android/src/main/java/com/reactnativestripesdk/CollectBankAccountLauncherFragment.kt +1 -1
  8. package/android/src/main/java/com/reactnativestripesdk/FinancialConnectionsSheetFragment.kt +5 -1
  9. package/android/src/main/java/com/reactnativestripesdk/GooglePayFragment.kt +1 -1
  10. package/android/src/main/java/com/reactnativestripesdk/PaymentLauncherFragment.kt +2 -1
  11. package/android/src/main/java/com/reactnativestripesdk/PaymentSheetAppearance.kt +10 -9
  12. package/android/src/main/java/com/reactnativestripesdk/PaymentSheetFragment.kt +11 -4
  13. package/android/src/main/java/com/reactnativestripesdk/StripeSdkModule.kt +27 -14
  14. package/android/src/main/java/com/reactnativestripesdk/StripeSdkPackage.kt +3 -1
  15. package/android/src/main/java/com/reactnativestripesdk/addresssheet/AddressLauncherFragment.kt +111 -0
  16. package/android/src/main/java/com/reactnativestripesdk/addresssheet/AddressSheetEvent.kt +28 -0
  17. package/android/src/main/java/com/reactnativestripesdk/addresssheet/AddressSheetView.kt +178 -0
  18. package/android/src/main/java/com/reactnativestripesdk/addresssheet/AddressSheetViewManager.kt +67 -0
  19. package/android/src/main/java/com/reactnativestripesdk/utils/Mappers.kt +3 -1
  20. package/ios/AddressSheet/AddressSheetUtils.swift +98 -0
  21. package/ios/AddressSheet/AddressSheetView.swift +131 -0
  22. package/ios/AddressSheet/AddressSheetViewManager.m +25 -0
  23. package/ios/AddressSheet/AddressSheetViewManager.swift +19 -0
  24. package/ios/ApplePayUtils.swift +1 -1
  25. package/ios/CardFieldView.swift +3 -3
  26. package/ios/FinancialConnections.swift +23 -22
  27. package/ios/Mappers.swift +10 -2
  28. package/ios/PaymentMethodFactory.swift +6 -7
  29. package/ios/PaymentSheetAppearance.swift +27 -26
  30. package/ios/{pushprovisioning → PushProvisioning}/AddToWalletButtonManager.m +0 -0
  31. package/ios/{pushprovisioning → PushProvisioning}/AddToWalletButtonManager.swift +0 -0
  32. package/ios/{pushprovisioning → PushProvisioning}/AddToWalletButtonView.swift +0 -0
  33. package/ios/{pushprovisioning → PushProvisioning}/PushProvisioningUtils.swift +0 -0
  34. package/ios/StripeSdk.m +5 -0
  35. package/ios/StripeSdk.swift +75 -27
  36. package/ios/Tests/AddressSheetUtilsTests.swift +279 -0
  37. package/jest/mock.js +2 -0
  38. package/lib/commonjs/NativeStripeSdk.js.map +1 -1
  39. package/lib/commonjs/components/AddressSheet.js +2 -0
  40. package/lib/commonjs/components/AddressSheet.js.map +1 -0
  41. package/lib/commonjs/functions.js +1 -1
  42. package/lib/commonjs/functions.js.map +1 -1
  43. package/lib/commonjs/hooks/usePaymentSheet.js +1 -1
  44. package/lib/commonjs/hooks/usePaymentSheet.js.map +1 -1
  45. package/lib/commonjs/hooks/useStripe.js +1 -1
  46. package/lib/commonjs/hooks/useStripe.js.map +1 -1
  47. package/lib/commonjs/index.js +1 -1
  48. package/lib/commonjs/index.js.map +1 -1
  49. package/lib/commonjs/types/Errors.js +1 -1
  50. package/lib/commonjs/types/Errors.js.map +1 -1
  51. package/lib/commonjs/types/FinancialConnections.js.map +1 -1
  52. package/lib/commonjs/types/index.js +1 -1
  53. package/lib/commonjs/types/index.js.map +1 -1
  54. package/lib/module/NativeStripeSdk.js.map +1 -1
  55. package/lib/module/components/AddressSheet.js +2 -0
  56. package/lib/module/components/AddressSheet.js.map +1 -0
  57. package/lib/module/functions.js +1 -1
  58. package/lib/module/functions.js.map +1 -1
  59. package/lib/module/hooks/usePaymentSheet.js +1 -1
  60. package/lib/module/hooks/usePaymentSheet.js.map +1 -1
  61. package/lib/module/hooks/useStripe.js +1 -1
  62. package/lib/module/hooks/useStripe.js.map +1 -1
  63. package/lib/module/index.js +1 -1
  64. package/lib/module/index.js.map +1 -1
  65. package/lib/module/types/Errors.js +1 -1
  66. package/lib/module/types/Errors.js.map +1 -1
  67. package/lib/module/types/FinancialConnections.js.map +1 -1
  68. package/lib/module/types/index.js +1 -1
  69. package/lib/module/types/index.js.map +1 -1
  70. package/lib/typescript/src/NativeStripeSdk.d.ts +1 -0
  71. package/lib/typescript/src/components/AddressSheet.d.ts +53 -0
  72. package/lib/typescript/src/functions.d.ts +6 -0
  73. package/lib/typescript/src/hooks/usePaymentSheet.d.ts +6 -0
  74. package/lib/typescript/src/hooks/useStripe.d.ts +6 -0
  75. package/lib/typescript/src/index.d.ts +1 -0
  76. package/lib/typescript/src/types/Common.d.ts +12 -0
  77. package/lib/typescript/src/types/Errors.d.ts +4 -0
  78. package/lib/typescript/src/types/FinancialConnections.d.ts +2 -2
  79. package/lib/typescript/src/types/PaymentMethod.d.ts +2 -0
  80. package/lib/typescript/src/types/PaymentSheet.d.ts +24 -1
  81. package/lib/typescript/src/types/index.d.ts +3 -6
  82. package/package.json +1 -1
  83. package/src/NativeStripeSdk.tsx +1 -0
  84. package/src/components/AddressSheet.tsx +82 -0
  85. package/src/functions.ts +9 -0
  86. package/src/hooks/usePaymentSheet.tsx +14 -0
  87. package/src/hooks/useStripe.tsx +11 -0
  88. package/src/index.tsx +4 -1
  89. package/src/types/Common.ts +13 -0
  90. package/src/types/Errors.ts +5 -0
  91. package/src/types/FinancialConnections.ts +4 -4
  92. package/src/types/PaymentMethod.ts +2 -0
  93. package/src/types/PaymentSheet.ts +26 -1
  94. package/src/types/index.ts +5 -10
  95. package/stripe-react-native.podspec +6 -2
  96. package/android/.gradle/7.1/dependencies-accessors/dependencies-accessors.lock +0 -0
  97. package/android/.gradle/7.1/dependencies-accessors/gc.properties +0 -0
  98. package/android/.gradle/7.1/fileChanges/last-build.bin +0 -0
  99. package/android/.gradle/7.1/fileHashes/fileHashes.lock +0 -0
  100. package/android/.gradle/7.1/gc.properties +0 -0
  101. package/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock +0 -0
  102. package/android/.gradle/buildOutputCleanup/cache.properties +0 -2
  103. package/android/.gradle/checksums/checksums.lock +0 -0
  104. package/android/.gradle/vcs-1/gc.properties +0 -0
  105. package/android/.idea/gradle.xml +0 -13
  106. package/android/.idea/misc.xml +0 -9
  107. package/android/.idea/modules/android.iml +0 -18
  108. package/android/.idea/modules.xml +0 -8
  109. package/android/.idea/vcs.xml +0 -6
  110. package/android/local.properties +0 -8
  111. package/ios/StripeSdk.xcodeproj/project.xcworkspace/contents.xcworkspacedata +0 -7
  112. package/ios/StripeSdk.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +0 -8
  113. package/ios/StripeSdk.xcodeproj/project.xcworkspace/xcuserdata/charliecruzan.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
  114. package/ios/StripeSdk.xcodeproj/xcuserdata/charliecruzan.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist +0 -22
  115. package/ios/StripeSdk.xcodeproj/xcuserdata/charliecruzan.xcuserdatad/xcschemes/xcschememanagement.plist +0 -27
package/CHANGELOG.md CHANGED
@@ -2,6 +2,42 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ ## 0.21.0 - 2022-11-15
6
+
7
+ ### Breaking changes
8
+
9
+ ### New features
10
+
11
+ - Added the `<AddressSheet />` component, which enables you to collect local and international shipping or billing addresses from your customers _with_ address autocomplete. [#1169](https://github.com/stripe/stripe-react-native/pull/1169)
12
+ - Added the `defaultShippingDetails` field to the `params` argument in `initPaymentSheet(params)`. This will allow you to collect shipping details (either in your own UI or using the new `<AddressSheet />` component) for payments in the Payment Sheet. [#1169](https://github.com/stripe/stripe-react-native/pull/1169)
13
+
14
+ ## Fixes
15
+
16
+ - Fixed a build error on Android when using Kotlin version 1.7.10. [#1195](https://github.com/stripe/stripe-react-native/pull/1195)
17
+
18
+ ## 0.20.0 - 2022-11-03
19
+
20
+ ### Breaking changes
21
+
22
+ - 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)
23
+
24
+ ### New features
25
+
26
+ - Added [Link](https://stripe.com/docs/payments/link) support in Payment Sheet. [#1176](https://github.com/stripe/stripe-react-native/pull/1176)
27
+ - Added the `resetPaymentSheetCustomer` method to clear persisted authentication state in the PaymentSheet. [#1176](https://github.com/stripe/stripe-react-native/pull/1176)
28
+ - Added `preferredNetwork` and `availableNetworks` fields to the `CardResult` payment method. [#1176](https://github.com/stripe/stripe-react-native/pull/1176)
29
+ - Added support for custom fonts to `CardForm` and `CardView` on Android. [#1150](https://github.com/stripe/stripe-react-native/pull/1150)
30
+ - 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)
31
+
32
+ ## Fixes
33
+
34
+ - 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)
35
+ - Upgraded `stripe-android` to 20.15.+. [#1176](https://github.com/stripe/stripe-react-native/pull/1176)
36
+ - Upgraded `stripe-ios` to 23.1.+. [#1190](https://github.com/stripe/stripe-react-native/pull/1190)
37
+ - 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)
38
+ - 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)
39
+ - Fixed `borderWidth` and `borderRadius` for `<CardField />` and `CardForm />` was inconsistent across iOS and Android. [#1182](https://github.com/stripe/stripe-react-native/pull/1182)
40
+
5
41
  ## 0.19.0 - 2022-09-16
6
42
 
7
43
  ### Breaking changes
@@ -116,7 +152,7 @@
116
152
  - 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
153
  - 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
154
 
119
- ## 0.13.1 - 2022-06-16
155
+ ## 0.13.1 - 2022-06-16 (📌 Expo SDK 46)
120
156
 
121
157
  ### Breaking changes
122
158
 
@@ -257,6 +293,11 @@
257
293
  - (Typescript) `GooglePay.IsGooglePaySupportedParams` is now `GooglePay.IsSupportedParams`
258
294
  - (Typescript) Removed `GooglePay.SetupIntentParams`
259
295
 
296
+ ## 0.6.1 - 2022-04-01 (📌 Expo SDK 45)
297
+
298
+ - Fix: correctly overwrite `package.json` import via babel. [#924](https://github.com/stripe/stripe-react-native/pull/924)
299
+ - Fix: upgrade expo config plugins. [#936](https://github.com/stripe/stripe-react-native/pull/936)
300
+
260
301
  ## 0.6.0 - 2022-04-01
261
302
 
262
303
  - [#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 +347,7 @@
306
347
  - [#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
348
  - [#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
349
 
309
- ## 0.2.3 - 2021-10-18
350
+ ## 0.2.3 - 2021-10-18 (📌 Expo SDK 44)
310
351
 
311
352
  - [#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
353
  - [#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 +355,7 @@
314
355
  - [#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
356
  - [#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
357
 
317
- ## 0.2.2 - 2021-09-15
358
+ ## 0.2.2 - 2021-09-15 (📌 Expo SDK 43)
318
359
 
319
360
  - [#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
361
 
@@ -350,7 +391,7 @@
350
391
  - [#337](https://github.com/stripe/stripe-react-native/pull/337) feat: expose CardField methods (focus, blur, clear)
351
392
  - [#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
393
 
353
- ## 0.1.4 - 2021-06-04 - Expo SDK 42.0.0
394
+ ## 0.1.4 - 2021-06-04 (📌 Expo SDK 42)
354
395
 
355
396
  ## 0.1.3 - 2021-06-04
356
397
 
@@ -374,7 +415,7 @@
374
415
  - [#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
416
  - [#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
417
 
377
- ## 0.1.1 - 2021-05-14 - Expo SDK 41.0.0
418
+ ## 0.1.1 - 2021-05-14 (📌 Expo SDK 41)
378
419
 
379
420
  - [#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
421
  - [#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 12 or above. For iOS 11 support, please use [`@stripe/stripe-react-native@0.5.0`](https://github.com/stripe/stripe-react-native/releases/tag/v0.5.0).
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
 
@@ -4,7 +4,7 @@ buildscript {
4
4
 
5
5
  repositories {
6
6
  google()
7
- jcenter()
7
+ mavenCentral()
8
8
  }
9
9
 
10
10
  dependencies {
@@ -57,7 +57,6 @@ android {
57
57
 
58
58
  repositories {
59
59
  mavenCentral()
60
- jcenter()
61
60
  google()
62
61
 
63
62
  def found = false
@@ -1,2 +1,2 @@
1
1
  StripeSdk_kotlinVersion=1.6.21
2
- StripeSdk_stripeVersion=20.12.+
2
+ StripeSdk_stripeVersion=20.16.+
@@ -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
- editTextBinding.typeface = Typeface.create(it, Typeface.NORMAL)
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 * 2).toFloat())
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 * 2).toFloat()
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
- multilineWidgetBinding.tlExpiry.defaultHintTextColor = ColorStateList.valueOf(Color.parseColor(it))
152
- multilineWidgetBinding.tlCardNumber.defaultHintTextColor = ColorStateList.valueOf(Color.parseColor(it))
153
- multilineWidgetBinding.tlCvc.defaultHintTextColor = ColorStateList.valueOf(Color.parseColor(it))
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 = Typeface.create(it, Typeface.NORMAL)
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 * 2).toFloat())
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 * 2).toFloat()
205
+ shape.strokeWidth = PixelUtil.toPixelFromDIP(it.toDouble())
191
206
  }
192
207
  borderColor?.let {
193
208
  shape.strokeColor = ColorStateList.valueOf(Color.parseColor(it))
@@ -91,6 +91,6 @@ class CollectBankAccountLauncherFragment(
91
91
  }
92
92
 
93
93
  companion object {
94
- const val TAG = "collect_bank_account_launcher_fragment"
94
+ internal const val TAG = "collect_bank_account_launcher_fragment"
95
95
  }
96
96
  }
@@ -125,7 +125,7 @@ class FinancialConnectionsSheetFragment : Fragment() {
125
125
  private fun commitFragmentAndStartFlow(currentActivity: AppCompatActivity) {
126
126
  try {
127
127
  currentActivity.supportFragmentManager.beginTransaction()
128
- .add(this, "financial_connections_sheet_launch_fragment")
128
+ .add(this, TAG)
129
129
  .commit()
130
130
  } catch (error: IllegalStateException) {
131
131
  promise.resolve(createError(ErrorType.Failed.toString(), error.message))
@@ -133,6 +133,8 @@ class FinancialConnectionsSheetFragment : Fragment() {
133
133
  }
134
134
 
135
135
  companion object {
136
+ internal const val TAG = "financial_connections_sheet_launch_fragment"
137
+
136
138
  private fun createTokenResult(result: FinancialConnectionsSheetForTokenResult.Completed): WritableMap {
137
139
  return WritableNativeMap().also {
138
140
  it.putMap("session", mapFromSession(result.financialConnectionsSession))
@@ -237,7 +239,9 @@ class FinancialConnectionsSheetFragment : Fragment() {
237
239
  FinancialConnectionsAccount.Permissions.BALANCES -> "balances"
238
240
  FinancialConnectionsAccount.Permissions.OWNERSHIP -> "ownership"
239
241
  FinancialConnectionsAccount.Permissions.TRANSACTIONS -> "transactions"
242
+ FinancialConnectionsAccount.Permissions.ACCOUNT_NUMBERS -> "accountNumbers"
240
243
  FinancialConnectionsAccount.Permissions.UNKNOWN -> "unparsable"
244
+ FinancialConnectionsAccount.Permissions.ACCOUNT_NUMBERS -> "accountNumbers"
241
245
  }
242
246
  }
243
247
 
@@ -206,6 +206,6 @@ class GooglePayFragment(private val initPromise: Promise) : Fragment() {
206
206
  }
207
207
 
208
208
  companion object {
209
- const val TAG = "google_pay_launch_fragment"
209
+ internal const val TAG = "google_pay_launch_fragment"
210
210
  }
211
211
  }
@@ -120,7 +120,7 @@ class PaymentLauncherFragment(
120
120
  }
121
121
  }
122
122
 
123
- const val TAG = "payment_launcher_fragment"
123
+ internal const val TAG = "payment_launcher_fragment"
124
124
  }
125
125
 
126
126
  override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?,
@@ -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
  }
@@ -2,27 +2,28 @@ package com.reactnativestripesdk
2
2
 
3
3
  import android.graphics.Color
4
4
  import android.os.Bundle
5
+ import com.facebook.react.bridge.ReactContext
5
6
  import com.reactnativestripesdk.utils.PaymentSheetAppearanceException
6
7
  import com.stripe.android.paymentsheet.PaymentSheet
7
8
 
8
- fun PaymentSheetFragment.buildPaymentSheetAppearance(userParams: Bundle?): PaymentSheet.Appearance {
9
+ fun buildPaymentSheetAppearance(userParams: Bundle?, context: ReactContext): PaymentSheet.Appearance {
9
10
  val colorParams = userParams?.getBundle(PaymentSheetAppearanceKeys.COLORS)
10
11
  val lightColorParams = colorParams?.getBundle(PaymentSheetAppearanceKeys.LIGHT) ?: colorParams
11
12
  val darkColorParams = colorParams?.getBundle(PaymentSheetAppearanceKeys.DARK) ?: colorParams
12
13
 
13
14
  return PaymentSheet.Appearance(
14
- typography = buildTypography(userParams?.getBundle(PaymentSheetAppearanceKeys.FONT)),
15
+ typography = buildTypography(userParams?.getBundle(PaymentSheetAppearanceKeys.FONT), context),
15
16
  colorsLight = buildColors(lightColorParams, PaymentSheet.Colors.defaultLight),
16
17
  colorsDark = buildColors(darkColorParams, PaymentSheet.Colors.defaultDark),
17
18
  shapes = buildShapes(userParams?.getBundle(PaymentSheetAppearanceKeys.SHAPES)),
18
- primaryButton = buildPrimaryButton(userParams?.getBundle(PaymentSheetAppearanceKeys.PRIMARY_BUTTON))
19
+ primaryButton = buildPrimaryButton(userParams?.getBundle(PaymentSheetAppearanceKeys.PRIMARY_BUTTON), context)
19
20
  )
20
21
  }
21
22
 
22
- private fun PaymentSheetFragment.buildTypography(fontParams: Bundle?): PaymentSheet.Typography {
23
+ private fun buildTypography(fontParams: Bundle?, context: ReactContext): PaymentSheet.Typography {
23
24
  return PaymentSheet.Typography.default.copy(
24
25
  sizeScaleFactor = getFloatOr(fontParams, PaymentSheetAppearanceKeys.SCALE, PaymentSheet.Typography.default.sizeScaleFactor),
25
- fontResId = getFontResId(fontParams, PaymentSheetAppearanceKeys.FAMILY, PaymentSheet.Typography.default.fontResId)
26
+ fontResId = getFontResId(fontParams, PaymentSheetAppearanceKeys.FAMILY, PaymentSheet.Typography.default.fontResId, context)
26
27
  )
27
28
  }
28
29
 
@@ -64,7 +65,7 @@ private fun buildShapes(shapeParams: Bundle?): PaymentSheet.Shapes {
64
65
  )
65
66
  }
66
67
 
67
- private fun PaymentSheetFragment.buildPrimaryButton(params: Bundle?): PaymentSheet.PrimaryButton {
68
+ private fun buildPrimaryButton(params: Bundle?, context: ReactContext): PaymentSheet.PrimaryButton {
68
69
  if (params == null) {
69
70
  return PaymentSheet.PrimaryButton()
70
71
  }
@@ -83,7 +84,7 @@ private fun PaymentSheetFragment.buildPrimaryButton(params: Bundle?): PaymentShe
83
84
  borderStrokeWidthDp = getFloatOrNull(shapeParams, PaymentSheetAppearanceKeys.BORDER_WIDTH),
84
85
  ),
85
86
  typography = PaymentSheet.PrimaryButtonTypography(
86
- fontResId = getFontResId(fontParams, PaymentSheetAppearanceKeys.FAMILY, null)
87
+ fontResId = getFontResId(fontParams, PaymentSheetAppearanceKeys.FAMILY, null, context)
87
88
  )
88
89
  )
89
90
  }
@@ -120,7 +121,7 @@ private fun getFloatOrNull(bundle: Bundle?, key: String): Float? {
120
121
  }
121
122
 
122
123
  @Throws(PaymentSheetAppearanceException::class)
123
- private fun PaymentSheetFragment.getFontResId(bundle: Bundle?, key: String, defaultValue: Int?): Int? {
124
+ private fun getFontResId(bundle: Bundle?, key: String, defaultValue: Int?, context: ReactContext): Int? {
124
125
  val fontErrorPrefix = "Encountered an error when setting a custom font:"
125
126
  if (bundle?.containsKey(key) != true) {
126
127
  return defaultValue
@@ -134,7 +135,7 @@ private fun PaymentSheetFragment.getFontResId(bundle: Bundle?, key: String, defa
134
135
  )
135
136
  }
136
137
 
137
- val id = resources.getIdentifier(fontFileName, "font", context?.packageName)
138
+ val id = context.resources.getIdentifier(fontFileName, "font", context.packageName)
138
139
  if (id == 0) {
139
140
  throw PaymentSheetAppearanceException("$fontErrorPrefix Failed to find font: $fontFileName")
140
141
  } else {
@@ -10,7 +10,6 @@ import android.view.LayoutInflater
10
10
  import android.view.View
11
11
  import android.view.ViewGroup
12
12
  import android.widget.FrameLayout
13
- import androidx.appcompat.app.AppCompatActivity
14
13
  import androidx.appcompat.content.res.AppCompatResources
15
14
  import androidx.core.graphics.drawable.DrawableCompat
16
15
  import androidx.fragment.app.Fragment
@@ -18,6 +17,7 @@ import com.facebook.react.bridge.Promise
18
17
  import com.facebook.react.bridge.ReactApplicationContext
19
18
  import com.facebook.react.bridge.WritableMap
20
19
  import com.facebook.react.bridge.WritableNativeMap
20
+ import com.reactnativestripesdk.addresssheet.AddressSheetView
21
21
  import com.reactnativestripesdk.utils.*
22
22
  import com.reactnativestripesdk.utils.createError
23
23
  import com.reactnativestripesdk.utils.createResult
@@ -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"))
@@ -64,12 +65,16 @@ class PaymentSheetFragment(
64
65
  paymentIntentClientSecret = arguments?.getString("paymentIntentClientSecret").orEmpty()
65
66
  setupIntentClientSecret = arguments?.getString("setupIntentClientSecret").orEmpty()
66
67
  val appearance = try {
67
- buildPaymentSheetAppearance(arguments?.getBundle("appearance"))
68
+ buildPaymentSheetAppearance(arguments?.getBundle("appearance"), context)
68
69
  } catch (error: PaymentSheetAppearanceException) {
69
70
  initPromise.resolve(createError(ErrorType.Failed.toString(), error))
70
71
  return
71
72
  }
72
73
 
74
+ val shippingDetails = arguments?.getBundle("defaultShippingDetails")?.let {
75
+ AddressSheetView.buildAddressDetails(it)
76
+ }
77
+
73
78
  val paymentOptionCallback = PaymentOptionCallback { paymentOption ->
74
79
  val result = paymentOption?.let {
75
80
  val bitmap = getBitmapFromVectorDrawable(context, it.drawableResourceId)
@@ -126,7 +131,9 @@ class PaymentSheetFragment(
126
131
  ephemeralKeySecret = customerEphemeralKeySecret
127
132
  ) else null,
128
133
  googlePay = googlePayConfig,
129
- appearance = appearance
134
+ appearance = appearance,
135
+ shippingDetails = shippingDetails,
136
+ primaryButtonLabel = primaryButtonLabel
130
137
  )
131
138
 
132
139
  if (arguments?.getBoolean("customFlow") == true) {
@@ -196,7 +203,7 @@ class PaymentSheetFragment(
196
203
  }
197
204
 
198
205
  companion object {
199
- const val TAG = "payment_sheet_launch_fragment"
206
+ internal const val TAG = "payment_sheet_launch_fragment"
200
207
 
201
208
  internal fun buildGooglePayConfig(params: Bundle?): PaymentSheet.GooglePayConfiguration? {
202
209
  if (params == null) {
@@ -5,18 +5,17 @@ import android.content.Intent
5
5
  import android.os.Parcelable
6
6
  import android.util.Log
7
7
  import androidx.appcompat.app.AppCompatActivity
8
- import androidx.fragment.app.Fragment
9
8
  import com.facebook.react.bridge.*
10
9
  import com.facebook.react.module.annotations.ReactModule
10
+ import com.reactnativestripesdk.addresssheet.AddressLauncherFragment
11
11
  import com.reactnativestripesdk.pushprovisioning.PushProvisioningProxy
12
12
  import com.reactnativestripesdk.utils.*
13
- import com.reactnativestripesdk.utils.createError
14
- import com.reactnativestripesdk.utils.createMissingActivityError
15
13
  import com.stripe.android.*
16
14
  import com.stripe.android.core.ApiVersion
17
15
  import com.stripe.android.core.AppInfo
18
16
  import com.stripe.android.model.*
19
17
  import com.stripe.android.payments.bankaccount.CollectBankAccountConfiguration
18
+ import com.stripe.android.paymentsheet.PaymentSheet
20
19
  import com.stripe.android.view.AddPaymentMethodActivityStarter
21
20
  import kotlinx.coroutines.CoroutineScope
22
21
  import kotlinx.coroutines.Dispatchers
@@ -44,14 +43,17 @@ class StripeSdkModule(reactContext: ReactApplicationContext) : ReactContextBaseJ
44
43
  private var googlePayFragment: GooglePayFragment? = null
45
44
  private var paymentLauncherFragment: PaymentLauncherFragment? = null
46
45
  private var collectBankAccountLauncherFragment: CollectBankAccountLauncherFragment? = null
47
- private var financialConnectionsSheetFragment: FinancialConnectionsSheetFragment? = null
48
- private val allFragments: List<Fragment?>
46
+
47
+ // If you create a new Fragment, you must put the tag here, otherwise result callbacks for that
48
+ // Fragment will not work on RN < 0.65
49
+ private val allStripeFragmentTags: List<String>
49
50
  get() = listOf(
50
- paymentSheetFragment,
51
- googlePayFragment,
52
- paymentLauncherFragment,
53
- collectBankAccountLauncherFragment,
54
- financialConnectionsSheetFragment
51
+ PaymentSheetFragment.TAG,
52
+ GooglePayFragment.TAG,
53
+ PaymentLauncherFragment.TAG,
54
+ CollectBankAccountLauncherFragment.TAG,
55
+ FinancialConnectionsSheetFragment.TAG,
56
+ AddressLauncherFragment.TAG
55
57
  )
56
58
 
57
59
  private val mActivityEventListener = object : BaseActivityEventListener() {
@@ -76,8 +78,12 @@ class StripeSdkModule(reactContext: ReactApplicationContext) : ReactContextBaseJ
76
78
 
77
79
  // Necessary on older versions of React Native (~0.65 and below)
78
80
  private fun dispatchActivityResultsToFragments(requestCode: Int, resultCode: Int, data: Intent?) {
79
- for (fragment in allFragments) {
80
- fragment?.activity?.activityResultRegistry?.dispatchResult(requestCode, resultCode, data)
81
+ getCurrentActivityOrResolveWithError(null)?.supportFragmentManager?.let { fragmentManager ->
82
+ for (tag in allStripeFragmentTags) {
83
+ fragmentManager.findFragmentByTag(tag)?.let {
84
+ it.activity?.activityResultRegistry?.dispatchResult(requestCode, resultCode, data)
85
+ }
86
+ }
81
87
  }
82
88
  }
83
89
 
@@ -119,6 +125,7 @@ class StripeSdkModule(reactContext: ReactApplicationContext) : ReactContextBaseJ
119
125
  }
120
126
 
121
127
  this.publishableKey = publishableKey
128
+ AddressLauncherFragment.publishableKey = publishableKey
122
129
 
123
130
  val name = getValOr(appInfo, "name", "") as String
124
131
  val partnerId = getValOr(appInfo, "partnerId", "")
@@ -160,6 +167,12 @@ class StripeSdkModule(reactContext: ReactApplicationContext) : ReactContextBaseJ
160
167
  paymentSheetFragment?.confirmPayment(promise)
161
168
  }
162
169
 
170
+ @ReactMethod
171
+ fun resetPaymentSheetCustomer(promise: Promise) {
172
+ PaymentSheet.resetCustomer(context = reactApplicationContext)
173
+ promise.resolve(null)
174
+ }
175
+
163
176
  private fun payWithFpx() {
164
177
  getCurrentActivityOrResolveWithError(confirmPromise)?.let {
165
178
  AddPaymentMethodActivityStarter(it)
@@ -711,7 +724,7 @@ class StripeSdkModule(reactContext: ReactApplicationContext) : ReactContextBaseJ
711
724
  promise.resolve(createMissingInitError())
712
725
  return
713
726
  }
714
- financialConnectionsSheetFragment = FinancialConnectionsSheetFragment().also {
727
+ FinancialConnectionsSheetFragment().also {
715
728
  it.presentFinancialConnectionsSheet(clientSecret, FinancialConnectionsSheetFragment.Mode.ForToken, publishableKey, stripeAccountId, promise, reactApplicationContext)
716
729
  }
717
730
  }
@@ -722,7 +735,7 @@ class StripeSdkModule(reactContext: ReactApplicationContext) : ReactContextBaseJ
722
735
  promise.resolve(createMissingInitError())
723
736
  return
724
737
  }
725
- financialConnectionsSheetFragment = FinancialConnectionsSheetFragment().also {
738
+ FinancialConnectionsSheetFragment().also {
726
739
  it.presentFinancialConnectionsSheet(clientSecret, FinancialConnectionsSheetFragment.Mode.ForSession, publishableKey, stripeAccountId, promise, reactApplicationContext)
727
740
  }
728
741
  }
@@ -4,6 +4,7 @@ import com.facebook.react.ReactPackage
4
4
  import com.facebook.react.bridge.NativeModule
5
5
  import com.facebook.react.bridge.ReactApplicationContext
6
6
  import com.facebook.react.uimanager.ViewManager
7
+ import com.reactnativestripesdk.addresssheet.AddressSheetViewManager
7
8
  import com.reactnativestripesdk.pushprovisioning.AddToWalletButtonManager
8
9
 
9
10
  class StripeSdkPackage : ReactPackage {
@@ -18,7 +19,8 @@ class StripeSdkPackage : ReactPackage {
18
19
  StripeContainerManager(),
19
20
  CardFormViewManager(),
20
21
  GooglePayButtonManager(),
21
- AddToWalletButtonManager(reactContext)
22
+ AddToWalletButtonManager(reactContext),
23
+ AddressSheetViewManager()
22
24
  )
23
25
  }
24
26
  }