@stripe/stripe-react-native 0.62.0 → 0.64.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/android/gradle.properties +1 -1
- package/android/src/main/java/com/reactnativestripesdk/EventEmitterCompat.kt +4 -0
- package/android/src/main/java/com/reactnativestripesdk/PaymentMethodCreateParamsFactory.kt +22 -0
- package/android/src/main/java/com/reactnativestripesdk/StripeSdkModule.kt +6 -0
- package/android/src/main/java/com/reactnativestripesdk/StripeSdkPackage.kt +5 -5
- package/android/src/main/java/com/reactnativestripesdk/utils/Mappers.kt +2 -0
- package/android/src/oldarch/java/com/reactnativestripesdk/NativeOnrampSdkModuleSpec.java +8 -11
- package/android/src/onramp/java/com/reactnativestripesdk/OnrampMappers.kt +47 -0
- package/android/src/onramp/java/com/reactnativestripesdk/OnrampSdkModule.kt +21 -2
- package/android/src/test/java/com/reactnativestripesdk/mappers/MappersTest.kt +33 -0
- package/android/src/test/java/com/reactnativestripesdk/mappers/OnrampMappersTest.kt +301 -0
- package/ios/AddressSheet/AddressSheetUtils.swift +23 -0
- package/ios/AddressSheet/AddressSheetView.swift +9 -14
- package/ios/Mappers.swift +74 -0
- package/ios/PaymentMethodFactory.swift +19 -0
- package/ios/StripeOnrampSdk.h +3 -4
- package/ios/StripeSdk-Bridging-Header.h +1 -0
- package/ios/StripeSdk.mm +1 -1
- package/ios/StripeSdkImpl.swift +38 -10
- package/ios/StripeSwiftInterop.h +1 -0
- package/jest/mock.js +2 -0
- package/lib/commonjs/components/AddToWalletButton.js +1 -1
- package/lib/commonjs/components/AddToWalletButton.js.map +1 -1
- package/lib/commonjs/components/AddressSheet.js +1 -1
- package/lib/commonjs/components/AddressSheet.js.map +1 -1
- package/lib/commonjs/components/AuBECSDebitForm.js +1 -1
- package/lib/commonjs/components/AuBECSDebitForm.js.map +1 -1
- package/lib/commonjs/components/CardField.js +1 -1
- package/lib/commonjs/components/CardField.js.map +1 -1
- package/lib/commonjs/components/CardForm.js +1 -1
- package/lib/commonjs/components/CardForm.js.map +1 -1
- package/lib/commonjs/components/PlatformPayButton.js +1 -1
- package/lib/commonjs/components/PlatformPayButton.js.map +1 -1
- package/lib/commonjs/components/StripeContainer.js +1 -1
- package/lib/commonjs/components/StripeContainer.js.map +1 -1
- package/lib/commonjs/components/StripeProvider.js +1 -1
- package/lib/commonjs/components/StripeProvider.js.map +1 -1
- package/lib/commonjs/connect/Components.js +1 -1
- package/lib/commonjs/connect/Components.js.map +1 -1
- package/lib/commonjs/connect/ConnectComponentsProvider.js +1 -1
- package/lib/commonjs/connect/ConnectComponentsProvider.js.map +1 -1
- package/lib/commonjs/connect/EmbeddedComponent.js +1 -1
- package/lib/commonjs/connect/EmbeddedComponent.js.map +1 -1
- package/lib/commonjs/connect/ModalCloseButton.js +1 -1
- package/lib/commonjs/connect/ModalCloseButton.js.map +1 -1
- package/lib/commonjs/connect/NavigationBar.js +1 -1
- package/lib/commonjs/connect/NavigationBar.js.map +1 -1
- package/lib/commonjs/connect/testUtils.js +1 -1
- package/lib/commonjs/connect/testUtils.js.map +1 -1
- package/lib/commonjs/events.js +1 -1
- package/lib/commonjs/events.js.map +1 -1
- package/lib/commonjs/functions.js +1 -1
- package/lib/commonjs/functions.js.map +1 -1
- package/lib/commonjs/helpers.js +1 -1
- package/lib/commonjs/hooks/useOnramp.js +1 -1
- package/lib/commonjs/hooks/useOnramp.js.map +1 -1
- package/lib/commonjs/specs/NativeAddToWalletButton.js +1 -1
- package/lib/commonjs/specs/NativeAddressSheet.js +1 -1
- package/lib/commonjs/specs/NativeApplePayButton.js +1 -1
- package/lib/commonjs/specs/NativeAuBECSDebitForm.js +1 -1
- package/lib/commonjs/specs/NativeCardField.js +1 -1
- package/lib/commonjs/specs/NativeCardField.js.map +1 -1
- package/lib/commonjs/specs/NativeCardForm.js +1 -1
- package/lib/commonjs/specs/NativeCardForm.js.map +1 -1
- package/lib/commonjs/specs/NativeConnectAccountOnboardingView.js +1 -1
- package/lib/commonjs/specs/NativeEmbeddedPaymentElement.js +1 -1
- package/lib/commonjs/specs/NativeEmbeddedPaymentElement.js.map +1 -1
- package/lib/commonjs/specs/NativeGooglePayButton.js +1 -1
- package/lib/commonjs/specs/NativeNavigationBar.js +1 -1
- package/lib/commonjs/specs/NativeOnrampSdkModule.js +1 -1
- package/lib/commonjs/specs/NativeOnrampSdkModule.js.map +1 -1
- package/lib/commonjs/specs/NativePaymentMethodMessagingElement.js +1 -1
- package/lib/commonjs/specs/NativeStripeContainer.js +1 -1
- package/lib/commonjs/specs/NativeStripeSdkModule.js.map +1 -1
- package/lib/commonjs/types/EmbeddedPaymentElement.js +1 -1
- package/lib/commonjs/types/EmbeddedPaymentElement.js.map +1 -1
- package/lib/commonjs/types/Onramp.js.map +1 -1
- package/lib/commonjs/types/PaymentIntent.js.map +1 -1
- package/lib/module/components/AddToWalletButton.js +1 -1
- package/lib/module/components/AddToWalletButton.js.map +1 -1
- package/lib/module/components/AddressSheet.js +1 -1
- package/lib/module/components/AddressSheet.js.map +1 -1
- package/lib/module/components/AuBECSDebitForm.js +1 -1
- package/lib/module/components/AuBECSDebitForm.js.map +1 -1
- package/lib/module/components/CardField.js +1 -1
- package/lib/module/components/CardField.js.map +1 -1
- package/lib/module/components/CardForm.js +1 -1
- package/lib/module/components/CardForm.js.map +1 -1
- package/lib/module/components/PlatformPayButton.js +1 -1
- package/lib/module/components/PlatformPayButton.js.map +1 -1
- package/lib/module/components/StripeContainer.js +1 -1
- package/lib/module/components/StripeContainer.js.map +1 -1
- package/lib/module/components/StripeProvider.js +1 -1
- package/lib/module/components/StripeProvider.js.map +1 -1
- package/lib/module/connect/Components.js +1 -1
- package/lib/module/connect/Components.js.map +1 -1
- package/lib/module/connect/ConnectComponentsProvider.js +1 -1
- package/lib/module/connect/ConnectComponentsProvider.js.map +1 -1
- package/lib/module/connect/EmbeddedComponent.js +1 -1
- package/lib/module/connect/EmbeddedComponent.js.map +1 -1
- package/lib/module/connect/ModalCloseButton.js +1 -1
- package/lib/module/connect/ModalCloseButton.js.map +1 -1
- package/lib/module/connect/NavigationBar.js +1 -1
- package/lib/module/connect/NavigationBar.js.map +1 -1
- package/lib/module/connect/testUtils.js +1 -1
- package/lib/module/connect/testUtils.js.map +1 -1
- package/lib/module/events.js +1 -1
- package/lib/module/events.js.map +1 -1
- package/lib/module/functions.js +1 -1
- package/lib/module/functions.js.map +1 -1
- package/lib/module/helpers.js +1 -1
- package/lib/module/hooks/useOnramp.js +1 -1
- package/lib/module/hooks/useOnramp.js.map +1 -1
- package/lib/module/specs/NativeAddToWalletButton.js +1 -1
- package/lib/module/specs/NativeAddressSheet.js +1 -1
- package/lib/module/specs/NativeApplePayButton.js +1 -1
- package/lib/module/specs/NativeAuBECSDebitForm.js +1 -1
- package/lib/module/specs/NativeCardField.js +1 -1
- package/lib/module/specs/NativeCardField.js.map +1 -1
- package/lib/module/specs/NativeCardForm.js +1 -1
- package/lib/module/specs/NativeCardForm.js.map +1 -1
- package/lib/module/specs/NativeConnectAccountOnboardingView.js +1 -1
- package/lib/module/specs/NativeEmbeddedPaymentElement.js +1 -1
- package/lib/module/specs/NativeEmbeddedPaymentElement.js.map +1 -1
- package/lib/module/specs/NativeGooglePayButton.js +1 -1
- package/lib/module/specs/NativeNavigationBar.js +1 -1
- package/lib/module/specs/NativeOnrampSdkModule.js +1 -1
- package/lib/module/specs/NativeOnrampSdkModule.js.map +1 -1
- package/lib/module/specs/NativePaymentMethodMessagingElement.js +1 -1
- package/lib/module/specs/NativeStripeContainer.js +1 -1
- package/lib/module/specs/NativeStripeSdkModule.js.map +1 -1
- package/lib/module/types/EmbeddedPaymentElement.js +1 -1
- package/lib/module/types/EmbeddedPaymentElement.js.map +1 -1
- package/lib/module/types/Onramp.js.map +1 -1
- package/lib/module/types/PaymentIntent.js.map +1 -1
- package/lib/typescript/src/connect/connectTypes.d.ts +76 -0
- package/lib/typescript/src/connect/connectTypes.d.ts.map +1 -1
- package/lib/typescript/src/connect/testUtils.d.ts +4 -0
- package/lib/typescript/src/connect/testUtils.d.ts.map +1 -1
- package/lib/typescript/src/events.d.ts +5 -3
- package/lib/typescript/src/events.d.ts.map +1 -1
- package/lib/typescript/src/functions.d.ts +2 -0
- package/lib/typescript/src/functions.d.ts.map +1 -1
- package/lib/typescript/src/hooks/useOnramp.d.ts +8 -3
- package/lib/typescript/src/hooks/useOnramp.d.ts.map +1 -1
- package/lib/typescript/src/specs/NativeOnrampSdkModule.d.ts +3 -3
- package/lib/typescript/src/specs/NativeOnrampSdkModule.d.ts.map +1 -1
- package/lib/typescript/src/specs/NativeStripeSdkModule.d.ts +3 -1
- package/lib/typescript/src/specs/NativeStripeSdkModule.d.ts.map +1 -1
- package/lib/typescript/src/types/NextAction.d.ts +8 -1
- package/lib/typescript/src/types/NextAction.d.ts.map +1 -1
- package/lib/typescript/src/types/Onramp.d.ts +40 -1
- package/lib/typescript/src/types/Onramp.d.ts.map +1 -1
- package/lib/typescript/src/types/PaymentIntent.d.ts +11 -1
- package/lib/typescript/src/types/PaymentIntent.d.ts.map +1 -1
- package/lib/typescript/src/types/PaymentMethod.d.ts +10 -2
- package/lib/typescript/src/types/PaymentMethod.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/components/StripeProvider.tsx +1 -1
- package/src/connect/connectTypes.ts +88 -0
- package/src/connect/testUtils.ts +2 -0
- package/src/events.ts +14 -11
- package/src/functions.ts +1 -1
- package/src/hooks/useOnramp.tsx +38 -23
- package/src/specs/NativeOnrampSdkModule.ts +3 -3
- package/src/specs/NativeStripeSdkModule.ts +3 -1
- package/src/types/NextAction.ts +9 -0
- package/src/types/Onramp.ts +45 -1
- package/src/types/PaymentIntent.ts +10 -0
- package/src/types/PaymentMethod.ts +9 -0
- package/stripe-react-native.podspec +1 -1
- package/android/.idea/.name +0 -1
- package/android/.idea/AndroidProjectSystem.xml +0 -6
- package/android/.idea/android.iml +0 -9
- package/android/.idea/caches/deviceStreaming.xml +0 -1550
- package/android/.idea/compiler.xml +0 -6
- package/android/.idea/gradle.xml +0 -19
- package/android/.idea/kotlinc.xml +0 -7
- package/android/.idea/migrations.xml +0 -10
- package/android/.idea/misc.xml +0 -10
- package/android/.idea/runConfigurations.xml +0 -17
- package/android/.idea/vcs.xml +0 -6
- package/android/local.properties +0 -8
- package/android/src/main/java/com/reactnativestripesdk/FakeOnrampSdkModule.kt +0 -149
|
@@ -1,14 +1,26 @@
|
|
|
1
|
+
@file:OptIn(ExperimentalCryptoOnramp::class)
|
|
2
|
+
|
|
1
3
|
package com.reactnativestripesdk.mappers
|
|
2
4
|
|
|
3
5
|
import android.annotation.SuppressLint
|
|
4
6
|
import androidx.compose.ui.graphics.toArgb
|
|
5
7
|
import com.reactnativestripesdk.mapAppearance
|
|
6
8
|
import com.reactnativestripesdk.mapConfig
|
|
9
|
+
import com.reactnativestripesdk.mapFromKycInfo
|
|
10
|
+
import com.reactnativestripesdk.mapGooglePayConfig
|
|
7
11
|
import com.reactnativestripesdk.utils.readableMapOf
|
|
12
|
+
import com.stripe.android.crypto.onramp.ExperimentalCryptoOnramp
|
|
13
|
+
import com.stripe.android.crypto.onramp.model.KycInfo
|
|
14
|
+
import com.stripe.android.googlepaylauncher.GooglePayEnvironment
|
|
15
|
+
import com.stripe.android.googlepaylauncher.GooglePayPaymentMethodLauncher
|
|
8
16
|
import com.stripe.android.link.LinkAppearance.Style
|
|
17
|
+
import com.stripe.android.model.DateOfBirth
|
|
18
|
+
import com.stripe.android.paymentsheet.PaymentSheet
|
|
9
19
|
import org.junit.Assert.assertEquals
|
|
20
|
+
import org.junit.Assert.assertFalse
|
|
10
21
|
import org.junit.Assert.assertNotNull
|
|
11
22
|
import org.junit.Assert.assertNull
|
|
23
|
+
import org.junit.Assert.assertTrue
|
|
12
24
|
import org.junit.Test
|
|
13
25
|
import org.junit.runner.RunWith
|
|
14
26
|
import org.robolectric.RobolectricTestRunner
|
|
@@ -16,6 +28,182 @@ import org.robolectric.RobolectricTestRunner
|
|
|
16
28
|
@SuppressLint("RestrictedApi")
|
|
17
29
|
@RunWith(RobolectricTestRunner::class)
|
|
18
30
|
class OnrampMappersTest {
|
|
31
|
+
@Test
|
|
32
|
+
fun mapGooglePayConfig_NullMap_ReturnsNull() {
|
|
33
|
+
val result = mapGooglePayConfig(null)
|
|
34
|
+
assertNull(result)
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
@Test
|
|
38
|
+
fun mapGooglePayConfig_MissingMerchantCountryCode_ReturnsNull() {
|
|
39
|
+
val params =
|
|
40
|
+
readableMapOf(
|
|
41
|
+
"merchantName" to "Test Merchant",
|
|
42
|
+
)
|
|
43
|
+
val result = mapGooglePayConfig(params)
|
|
44
|
+
assertNull(result)
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
@Test
|
|
48
|
+
fun mapGooglePayConfig_Defaults() {
|
|
49
|
+
val params =
|
|
50
|
+
readableMapOf(
|
|
51
|
+
"merchantCountryCode" to "US",
|
|
52
|
+
"merchantName" to "Test Merchant",
|
|
53
|
+
)
|
|
54
|
+
val result = mapGooglePayConfig(params)
|
|
55
|
+
|
|
56
|
+
assertNotNull(result)
|
|
57
|
+
assertEquals(GooglePayEnvironment.Production, result!!.environment)
|
|
58
|
+
assertFalse(result.isEmailRequired)
|
|
59
|
+
assertTrue(result.allowCreditCards)
|
|
60
|
+
assertFalse(result.existingPaymentMethodRequired)
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
@Test
|
|
64
|
+
fun mapGooglePayConfig_TestEnv() {
|
|
65
|
+
val params =
|
|
66
|
+
readableMapOf(
|
|
67
|
+
"merchantCountryCode" to "US",
|
|
68
|
+
"merchantName" to "Test Merchant",
|
|
69
|
+
"testEnv" to true,
|
|
70
|
+
)
|
|
71
|
+
val result = mapGooglePayConfig(params)
|
|
72
|
+
|
|
73
|
+
assertNotNull(result)
|
|
74
|
+
assertEquals(GooglePayEnvironment.Test, result!!.environment)
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
@Test
|
|
78
|
+
fun mapGooglePayConfig_IsEmailRequired_True() {
|
|
79
|
+
val params =
|
|
80
|
+
readableMapOf(
|
|
81
|
+
"merchantCountryCode" to "US",
|
|
82
|
+
"merchantName" to "Test Merchant",
|
|
83
|
+
"isEmailRequired" to true,
|
|
84
|
+
)
|
|
85
|
+
val result = mapGooglePayConfig(params)
|
|
86
|
+
|
|
87
|
+
assertNotNull(result)
|
|
88
|
+
assertTrue(result!!.isEmailRequired)
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
@Test
|
|
92
|
+
fun mapGooglePayConfig_AllowCreditCards_False() {
|
|
93
|
+
val params =
|
|
94
|
+
readableMapOf(
|
|
95
|
+
"merchantCountryCode" to "US",
|
|
96
|
+
"merchantName" to "Test Merchant",
|
|
97
|
+
"allowCreditCards" to false,
|
|
98
|
+
)
|
|
99
|
+
val result = mapGooglePayConfig(params)
|
|
100
|
+
|
|
101
|
+
assertNotNull(result)
|
|
102
|
+
assertFalse(result!!.allowCreditCards)
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
@Test
|
|
106
|
+
fun mapGooglePayConfig_MissingMerchantName_ReturnsNull() {
|
|
107
|
+
val params =
|
|
108
|
+
readableMapOf(
|
|
109
|
+
"merchantCountryCode" to "US",
|
|
110
|
+
)
|
|
111
|
+
val result = mapGooglePayConfig(params)
|
|
112
|
+
assertNull(result)
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
@Test
|
|
116
|
+
fun mapGooglePayConfig_ExistingPaymentMethodRequired_False() {
|
|
117
|
+
val params =
|
|
118
|
+
readableMapOf(
|
|
119
|
+
"merchantCountryCode" to "US",
|
|
120
|
+
"merchantName" to "Test Merchant",
|
|
121
|
+
"existingPaymentMethodRequired" to false,
|
|
122
|
+
)
|
|
123
|
+
val result = mapGooglePayConfig(params)
|
|
124
|
+
|
|
125
|
+
assertNotNull(result)
|
|
126
|
+
assertFalse(result!!.existingPaymentMethodRequired)
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
@Test
|
|
130
|
+
fun mapGooglePayConfig_WithBillingAddressConfig_IsRequired() {
|
|
131
|
+
val billingAddressConfig =
|
|
132
|
+
readableMapOf(
|
|
133
|
+
"isRequired" to true,
|
|
134
|
+
)
|
|
135
|
+
val params =
|
|
136
|
+
readableMapOf(
|
|
137
|
+
"merchantCountryCode" to "US",
|
|
138
|
+
"merchantName" to "Test Merchant",
|
|
139
|
+
"billingAddressConfig" to billingAddressConfig,
|
|
140
|
+
)
|
|
141
|
+
val result = mapGooglePayConfig(params)
|
|
142
|
+
|
|
143
|
+
assertNotNull(result)
|
|
144
|
+
assertTrue(result!!.billingAddressConfig.isRequired)
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
@Test
|
|
148
|
+
fun mapGooglePayConfig_WithBillingAddressConfig_FullFormat() {
|
|
149
|
+
val billingAddressConfig =
|
|
150
|
+
readableMapOf(
|
|
151
|
+
"format" to "Full",
|
|
152
|
+
)
|
|
153
|
+
val params =
|
|
154
|
+
readableMapOf(
|
|
155
|
+
"merchantCountryCode" to "US",
|
|
156
|
+
"merchantName" to "Test Merchant",
|
|
157
|
+
"billingAddressConfig" to billingAddressConfig,
|
|
158
|
+
)
|
|
159
|
+
val result = mapGooglePayConfig(params)
|
|
160
|
+
|
|
161
|
+
assertNotNull(result)
|
|
162
|
+
assertEquals(
|
|
163
|
+
GooglePayPaymentMethodLauncher.BillingAddressConfig.Format.Full,
|
|
164
|
+
result!!.billingAddressConfig.format,
|
|
165
|
+
)
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
@Test
|
|
169
|
+
fun mapGooglePayConfig_WithBillingAddressConfig_UnknownFormat_DefaultsToMin() {
|
|
170
|
+
val billingAddressConfig =
|
|
171
|
+
readableMapOf(
|
|
172
|
+
"format" to "Unknown",
|
|
173
|
+
)
|
|
174
|
+
val params =
|
|
175
|
+
readableMapOf(
|
|
176
|
+
"merchantCountryCode" to "US",
|
|
177
|
+
"merchantName" to "Test Merchant",
|
|
178
|
+
"billingAddressConfig" to billingAddressConfig,
|
|
179
|
+
)
|
|
180
|
+
val result = mapGooglePayConfig(params)
|
|
181
|
+
|
|
182
|
+
assertNotNull(result)
|
|
183
|
+
assertEquals(
|
|
184
|
+
GooglePayPaymentMethodLauncher.BillingAddressConfig.Format.Min,
|
|
185
|
+
result!!.billingAddressConfig.format,
|
|
186
|
+
)
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
@Test
|
|
190
|
+
fun mapGooglePayConfig_WithBillingAddressConfig_IsPhoneNumberRequired() {
|
|
191
|
+
val billingAddressConfig =
|
|
192
|
+
readableMapOf(
|
|
193
|
+
"isPhoneNumberRequired" to true,
|
|
194
|
+
)
|
|
195
|
+
val params =
|
|
196
|
+
readableMapOf(
|
|
197
|
+
"merchantCountryCode" to "US",
|
|
198
|
+
"merchantName" to "Test Merchant",
|
|
199
|
+
"billingAddressConfig" to billingAddressConfig,
|
|
200
|
+
)
|
|
201
|
+
val result = mapGooglePayConfig(params)
|
|
202
|
+
|
|
203
|
+
assertNotNull(result)
|
|
204
|
+
assertTrue(result!!.billingAddressConfig.isPhoneNumberRequired)
|
|
205
|
+
}
|
|
206
|
+
|
|
19
207
|
@Test
|
|
20
208
|
fun mapConfig_WithAppearance() {
|
|
21
209
|
val appearance =
|
|
@@ -216,4 +404,117 @@ class OnrampMappersTest {
|
|
|
216
404
|
assertEquals(8f, state.primaryButton.cornerRadiusDp)
|
|
217
405
|
assertEquals(48f, state.primaryButton.heightDp)
|
|
218
406
|
}
|
|
407
|
+
|
|
408
|
+
@Test
|
|
409
|
+
fun mapFromKycInfo_AllFields() {
|
|
410
|
+
val kycInfo =
|
|
411
|
+
KycInfo(
|
|
412
|
+
firstName = "Jane",
|
|
413
|
+
lastName = "Doe",
|
|
414
|
+
idNumber = "123456789",
|
|
415
|
+
address =
|
|
416
|
+
PaymentSheet.Address(
|
|
417
|
+
city = "San Francisco",
|
|
418
|
+
country = "US",
|
|
419
|
+
line1 = "123 Main St",
|
|
420
|
+
line2 = "Apt 4",
|
|
421
|
+
postalCode = "94105",
|
|
422
|
+
state = "CA",
|
|
423
|
+
),
|
|
424
|
+
dateOfBirth = DateOfBirth(day = 15, month = 6, year = 1990),
|
|
425
|
+
)
|
|
426
|
+
val result = mapFromKycInfo(kycInfo)
|
|
427
|
+
|
|
428
|
+
assertEquals("Jane", result.getString("firstName"))
|
|
429
|
+
assertEquals("Doe", result.getString("lastName"))
|
|
430
|
+
assertEquals("123456789", result.getString("idNumber"))
|
|
431
|
+
|
|
432
|
+
val address = result.getMap("address")
|
|
433
|
+
assertNotNull(address)
|
|
434
|
+
assertEquals("San Francisco", address!!.getString("city"))
|
|
435
|
+
assertEquals("US", address.getString("country"))
|
|
436
|
+
assertEquals("123 Main St", address.getString("line1"))
|
|
437
|
+
assertEquals("Apt 4", address.getString("line2"))
|
|
438
|
+
assertEquals("94105", address.getString("postalCode"))
|
|
439
|
+
assertEquals("CA", address.getString("state"))
|
|
440
|
+
|
|
441
|
+
val dob = result.getMap("dateOfBirth")
|
|
442
|
+
assertNotNull(dob)
|
|
443
|
+
assertEquals(15, dob!!.getInt("day"))
|
|
444
|
+
assertEquals(6, dob.getInt("month"))
|
|
445
|
+
assertEquals(1990, dob.getInt("year"))
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
@Test
|
|
449
|
+
fun mapFromKycInfo_AllNullFields() {
|
|
450
|
+
val kycInfo =
|
|
451
|
+
KycInfo(
|
|
452
|
+
firstName = null,
|
|
453
|
+
lastName = null,
|
|
454
|
+
idNumber = null,
|
|
455
|
+
address = null,
|
|
456
|
+
dateOfBirth = null,
|
|
457
|
+
)
|
|
458
|
+
val result = mapFromKycInfo(kycInfo)
|
|
459
|
+
|
|
460
|
+
assertFalse(result.hasKey("firstName"))
|
|
461
|
+
assertFalse(result.hasKey("lastName"))
|
|
462
|
+
assertFalse(result.hasKey("idNumber"))
|
|
463
|
+
assertFalse(result.hasKey("address"))
|
|
464
|
+
assertFalse(result.hasKey("dateOfBirth"))
|
|
465
|
+
}
|
|
466
|
+
|
|
467
|
+
@Test
|
|
468
|
+
fun mapFromKycInfo_PartialFields() {
|
|
469
|
+
val kycInfo =
|
|
470
|
+
KycInfo(
|
|
471
|
+
firstName = "Jane",
|
|
472
|
+
lastName = null,
|
|
473
|
+
idNumber = null,
|
|
474
|
+
address = null,
|
|
475
|
+
dateOfBirth = DateOfBirth(day = 1, month = 1, year = 2000),
|
|
476
|
+
)
|
|
477
|
+
val result = mapFromKycInfo(kycInfo)
|
|
478
|
+
|
|
479
|
+
assertEquals("Jane", result.getString("firstName"))
|
|
480
|
+
assertFalse(result.hasKey("lastName"))
|
|
481
|
+
assertFalse(result.hasKey("idNumber"))
|
|
482
|
+
assertFalse(result.hasKey("address"))
|
|
483
|
+
|
|
484
|
+
val dob = result.getMap("dateOfBirth")
|
|
485
|
+
assertNotNull(dob)
|
|
486
|
+
assertEquals(1, dob!!.getInt("day"))
|
|
487
|
+
assertEquals(1, dob.getInt("month"))
|
|
488
|
+
assertEquals(2000, dob.getInt("year"))
|
|
489
|
+
}
|
|
490
|
+
|
|
491
|
+
@Test
|
|
492
|
+
fun mapFromKycInfo_AddressWithPartialFields() {
|
|
493
|
+
val kycInfo =
|
|
494
|
+
KycInfo(
|
|
495
|
+
firstName = null,
|
|
496
|
+
lastName = null,
|
|
497
|
+
idNumber = null,
|
|
498
|
+
address =
|
|
499
|
+
PaymentSheet.Address(
|
|
500
|
+
city = "New York",
|
|
501
|
+
country = "US",
|
|
502
|
+
line1 = null,
|
|
503
|
+
line2 = null,
|
|
504
|
+
postalCode = null,
|
|
505
|
+
state = null,
|
|
506
|
+
),
|
|
507
|
+
dateOfBirth = null,
|
|
508
|
+
)
|
|
509
|
+
val result = mapFromKycInfo(kycInfo)
|
|
510
|
+
|
|
511
|
+
val address = result.getMap("address")
|
|
512
|
+
assertNotNull(address)
|
|
513
|
+
assertEquals("New York", address!!.getString("city"))
|
|
514
|
+
assertEquals("US", address.getString("country"))
|
|
515
|
+
assertFalse(address.hasKey("line1"))
|
|
516
|
+
assertFalse(address.hasKey("line2"))
|
|
517
|
+
assertFalse(address.hasKey("postalCode"))
|
|
518
|
+
assertFalse(address.hasKey("state"))
|
|
519
|
+
}
|
|
219
520
|
}
|
|
@@ -79,6 +79,29 @@ class AddressSheetUtils {
|
|
|
79
79
|
}
|
|
80
80
|
}
|
|
81
81
|
|
|
82
|
+
internal class func buildConfiguration(
|
|
83
|
+
appearance: NSDictionary?,
|
|
84
|
+
defaultValues: NSDictionary?,
|
|
85
|
+
additionalFields: NSDictionary?,
|
|
86
|
+
allowedCountries: [String],
|
|
87
|
+
autocompleteCountries: [String],
|
|
88
|
+
buttonTitle: String?,
|
|
89
|
+
sheetTitle: String?
|
|
90
|
+
) throws -> AddressViewController.Configuration {
|
|
91
|
+
let appearanceConfiguration = try PaymentSheetAppearance.buildAppearanceFromParams(userParams: appearance)
|
|
92
|
+
|
|
93
|
+
var config = AddressViewController.Configuration(
|
|
94
|
+
defaultValues: buildDefaultValues(params: defaultValues),
|
|
95
|
+
additionalFields: buildAdditionalFieldsConfiguration(params: additionalFields),
|
|
96
|
+
allowedCountries: allowedCountries,
|
|
97
|
+
appearance: appearanceConfiguration,
|
|
98
|
+
buttonTitle: buttonTitle,
|
|
99
|
+
title: sheetTitle
|
|
100
|
+
)
|
|
101
|
+
config.autocompleteCountries = autocompleteCountries
|
|
102
|
+
return config
|
|
103
|
+
}
|
|
104
|
+
|
|
82
105
|
internal class func buildResult(address: AddressViewController.AddressDetails) -> [AnyHashable: Any] {
|
|
83
106
|
return [
|
|
84
107
|
"result": [
|
|
@@ -60,7 +60,15 @@ public class AddressSheetView: UIView {
|
|
|
60
60
|
}
|
|
61
61
|
var config: AddressViewController.Configuration
|
|
62
62
|
do {
|
|
63
|
-
config = try
|
|
63
|
+
config = try AddressSheetUtils.buildConfiguration(
|
|
64
|
+
appearance: appearance,
|
|
65
|
+
defaultValues: defaultValues,
|
|
66
|
+
additionalFields: additionalFields,
|
|
67
|
+
allowedCountries: allowedCountries,
|
|
68
|
+
autocompleteCountries: autocompleteCountries,
|
|
69
|
+
buttonTitle: primaryButtonTitle,
|
|
70
|
+
sheetTitle: sheetTitle
|
|
71
|
+
)
|
|
64
72
|
} catch {
|
|
65
73
|
onErrorAction!(
|
|
66
74
|
Errors.createError(ErrorType.Failed, error.localizedDescription) as? [AnyHashable: Any]
|
|
@@ -80,19 +88,6 @@ public class AddressSheetView: UIView {
|
|
|
80
88
|
vc.present(navigationController, animated: true)
|
|
81
89
|
}
|
|
82
90
|
|
|
83
|
-
private func buildAddressSheetConfiguration() throws -> AddressViewController.Configuration {
|
|
84
|
-
let appearanceConfiguration = try PaymentSheetAppearance.buildAppearanceFromParams(userParams: appearance)
|
|
85
|
-
|
|
86
|
-
return AddressViewController.Configuration(
|
|
87
|
-
defaultValues: AddressSheetUtils.buildDefaultValues(params: defaultValues),
|
|
88
|
-
additionalFields: AddressSheetUtils.buildAdditionalFieldsConfiguration(params: additionalFields),
|
|
89
|
-
allowedCountries: allowedCountries,
|
|
90
|
-
appearance: appearanceConfiguration,
|
|
91
|
-
buttonTitle: primaryButtonTitle,
|
|
92
|
-
title: sheetTitle
|
|
93
|
-
)
|
|
94
|
-
}
|
|
95
|
-
|
|
96
91
|
private func getModalPresentationStyle() -> UIModalPresentationStyle {
|
|
97
92
|
switch presentationStyle {
|
|
98
93
|
case "fullscreen":
|
package/ios/Mappers.swift
CHANGED
|
@@ -295,6 +295,7 @@ class Mappers {
|
|
|
295
295
|
case STPPaymentMethodType.EPS: return "Eps"
|
|
296
296
|
case STPPaymentMethodType.bancontact: return "Bancontact"
|
|
297
297
|
case STPPaymentMethodType.billie: return "Billie"
|
|
298
|
+
case STPPaymentMethodType.multibanco: return "Multibanco"
|
|
298
299
|
case STPPaymentMethodType.OXXO: return "Oxxo"
|
|
299
300
|
case STPPaymentMethodType.UPI: return "Upi"
|
|
300
301
|
case STPPaymentMethodType.afterpayClearpay: return "AfterpayClearpay"
|
|
@@ -327,6 +328,7 @@ class Mappers {
|
|
|
327
328
|
case "Eps": return STPPaymentMethodType.EPS
|
|
328
329
|
case "Bancontact": return STPPaymentMethodType.bancontact
|
|
329
330
|
case "Billie": return STPPaymentMethodType.billie
|
|
331
|
+
case "Multibanco": return STPPaymentMethodType.multibanco
|
|
330
332
|
case "Oxxo": return STPPaymentMethodType.OXXO
|
|
331
333
|
case "Upi": return STPPaymentMethodType.UPI
|
|
332
334
|
case "AfterpayClearpay": return STPPaymentMethodType.afterpayClearpay
|
|
@@ -475,6 +477,14 @@ class Mappers {
|
|
|
475
477
|
"type": "konbiniVoucher",
|
|
476
478
|
"voucherURL": it.konbiniDisplayDetails?.hostedVoucherURL.absoluteString ?? NSNull(),
|
|
477
479
|
]
|
|
480
|
+
case .multibancoDisplayDetails:
|
|
481
|
+
return [
|
|
482
|
+
"type": "multibanco",
|
|
483
|
+
"entity": it.multibancoDisplayDetails?.entity ?? NSNull(),
|
|
484
|
+
"reference": it.multibancoDisplayDetails?.reference ?? NSNull(),
|
|
485
|
+
"expiresAt": it.multibancoDisplayDetails?.expiresAt.timeIntervalSince1970 ?? NSNull(),
|
|
486
|
+
"voucherURL": it.multibancoDisplayDetails?.hostedVoucherURL.absoluteString ?? NSNull(),
|
|
487
|
+
]
|
|
478
488
|
default: // .useStripeSDK, .BLIKAuthorize, .unknown
|
|
479
489
|
return nil
|
|
480
490
|
}
|
|
@@ -1267,6 +1277,70 @@ class Mappers {
|
|
|
1267
1277
|
)
|
|
1268
1278
|
}
|
|
1269
1279
|
|
|
1280
|
+
class func mapFromKycInfo(_ kycInfo: KycInfo) -> [String: Any] {
|
|
1281
|
+
var result: [String: Any] = [:]
|
|
1282
|
+
|
|
1283
|
+
if let firstName = kycInfo.firstName {
|
|
1284
|
+
result["firstName"] = firstName
|
|
1285
|
+
}
|
|
1286
|
+
|
|
1287
|
+
if let lastName = kycInfo.lastName {
|
|
1288
|
+
result["lastName"] = lastName
|
|
1289
|
+
}
|
|
1290
|
+
|
|
1291
|
+
if let idNumber = kycInfo.idNumber {
|
|
1292
|
+
result["idNumber"] = idNumber
|
|
1293
|
+
}
|
|
1294
|
+
|
|
1295
|
+
if let address = kycInfo.address {
|
|
1296
|
+
result["address"] = mapFromKycAddress(address)
|
|
1297
|
+
}
|
|
1298
|
+
|
|
1299
|
+
if let dateOfBirth = kycInfo.dateOfBirth {
|
|
1300
|
+
result["dateOfBirth"] = mapFromDateOfBirth(dateOfBirth)
|
|
1301
|
+
}
|
|
1302
|
+
|
|
1303
|
+
return result
|
|
1304
|
+
}
|
|
1305
|
+
|
|
1306
|
+
class func mapFromKycAddress(_ address: Address) -> [String: Any] {
|
|
1307
|
+
var result: [String: Any] = [:]
|
|
1308
|
+
|
|
1309
|
+
if let city = address.city {
|
|
1310
|
+
result["city"] = city
|
|
1311
|
+
}
|
|
1312
|
+
|
|
1313
|
+
if let country = address.country {
|
|
1314
|
+
result["country"] = country
|
|
1315
|
+
}
|
|
1316
|
+
|
|
1317
|
+
if let line1 = address.line1 {
|
|
1318
|
+
result["line1"] = line1
|
|
1319
|
+
}
|
|
1320
|
+
|
|
1321
|
+
if let line2 = address.line2 {
|
|
1322
|
+
result["line2"] = line2
|
|
1323
|
+
}
|
|
1324
|
+
|
|
1325
|
+
if let postalCode = address.postalCode {
|
|
1326
|
+
result["postalCode"] = postalCode
|
|
1327
|
+
}
|
|
1328
|
+
|
|
1329
|
+
if let state = address.state {
|
|
1330
|
+
result["state"] = state
|
|
1331
|
+
}
|
|
1332
|
+
|
|
1333
|
+
return result
|
|
1334
|
+
}
|
|
1335
|
+
|
|
1336
|
+
class func mapFromDateOfBirth(_ dateOfBirth: KycInfo.DateOfBirth) -> [String: Int] {
|
|
1337
|
+
[
|
|
1338
|
+
"day": dateOfBirth.day,
|
|
1339
|
+
"month": dateOfBirth.month,
|
|
1340
|
+
"year": dateOfBirth.year,
|
|
1341
|
+
]
|
|
1342
|
+
}
|
|
1343
|
+
|
|
1270
1344
|
private class func mapOptionalKycAddress(_ value: Any?) throws -> Address? {
|
|
1271
1345
|
guard let value else {
|
|
1272
1346
|
return nil
|
|
@@ -37,6 +37,8 @@ class PaymentMethodFactory {
|
|
|
37
37
|
return try createBancontactPaymentMethodParams()
|
|
38
38
|
case STPPaymentMethodType.billie:
|
|
39
39
|
return try createBilliePaymentMethodParams()
|
|
40
|
+
case STPPaymentMethodType.multibanco:
|
|
41
|
+
return try createMultibancoPaymentMethodParams()
|
|
40
42
|
case STPPaymentMethodType.SEPADebit:
|
|
41
43
|
return try createSepaPaymentMethodParams()
|
|
42
44
|
case STPPaymentMethodType.EPS:
|
|
@@ -90,6 +92,8 @@ class PaymentMethodFactory {
|
|
|
90
92
|
return nil
|
|
91
93
|
case STPPaymentMethodType.billie:
|
|
92
94
|
return nil
|
|
95
|
+
case STPPaymentMethodType.multibanco:
|
|
96
|
+
return nil
|
|
93
97
|
case STPPaymentMethodType.SEPADebit:
|
|
94
98
|
return nil
|
|
95
99
|
case STPPaymentMethodType.OXXO:
|
|
@@ -297,6 +301,18 @@ class PaymentMethodFactory {
|
|
|
297
301
|
return STPPaymentMethodParams(oxxo: params, billingDetails: billingDetails, metadata: metadata)
|
|
298
302
|
}
|
|
299
303
|
|
|
304
|
+
private func createMultibancoPaymentMethodParams() throws -> STPPaymentMethodParams {
|
|
305
|
+
let params = STPPaymentMethodMultibancoParams()
|
|
306
|
+
|
|
307
|
+
guard let billingDetails = billingDetailsParams,
|
|
308
|
+
let email = billingDetails.email,
|
|
309
|
+
!email.isEmpty else {
|
|
310
|
+
throw PaymentMethodError.multibancoPaymentMissingParams
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
return STPPaymentMethodParams(multibanco: params, billingDetails: billingDetails, metadata: metadata)
|
|
314
|
+
}
|
|
315
|
+
|
|
300
316
|
private func createEPSPaymentMethodParams() throws -> STPPaymentMethodParams {
|
|
301
317
|
let params = STPPaymentMethodEPSParams()
|
|
302
318
|
|
|
@@ -406,6 +422,7 @@ enum PaymentMethodError: Error {
|
|
|
406
422
|
case billiePaymentMissingParams
|
|
407
423
|
case sepaPaymentMissingParams
|
|
408
424
|
case p24PaymentMissingParams
|
|
425
|
+
case multibancoPaymentMissingParams
|
|
409
426
|
case afterpayClearpayPaymentMissingParams
|
|
410
427
|
// Klarna no longer requires email and country in billing details
|
|
411
428
|
case weChatPayPaymentMissingParams
|
|
@@ -429,6 +446,8 @@ extension PaymentMethodError: LocalizedError {
|
|
|
429
446
|
return NSLocalizedString("Billie requires that you provide the following billing details: email, country", comment: "Create payment error")
|
|
430
447
|
case .sepaPaymentMissingParams:
|
|
431
448
|
return NSLocalizedString("You must provide billing details and IBAN", comment: "Create payment error")
|
|
449
|
+
case .multibancoPaymentMissingParams:
|
|
450
|
+
return NSLocalizedString("Multibanco requires that you provide the following billing details: email", comment: "Create payment error")
|
|
432
451
|
case .epsPaymentMissingParams:
|
|
433
452
|
return NSLocalizedString("You must provide billing details", comment: "Create payment error")
|
|
434
453
|
case .afterpayClearpayPaymentMissingParams:
|
package/ios/StripeOnrampSdk.h
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
#ifdef RCT_NEW_ARCH_ENABLED
|
|
2
2
|
#import <rnstripe/rnstripe.h>
|
|
3
|
-
#else
|
|
4
|
-
#import <React/RCTBridgeModule.h>
|
|
5
|
-
#import "StripeSdkEventEmitterCompat.h"
|
|
6
3
|
#endif
|
|
7
4
|
|
|
5
|
+
#import "StripeSdkEventEmitterCompat.h"
|
|
6
|
+
|
|
8
7
|
NS_ASSUME_NONNULL_BEGIN
|
|
9
8
|
|
|
10
9
|
#ifdef RCT_NEW_ARCH_ENABLED
|
|
11
|
-
@interface StripeOnrampSdk :
|
|
10
|
+
@interface StripeOnrampSdk : StripeSdkEventEmitterCompat <NativeOnrampSdkModuleSpec>
|
|
12
11
|
#else
|
|
13
12
|
@interface StripeOnrampSdk : StripeSdkEventEmitterCompat <RCTBridgeModule>
|
|
14
13
|
#endif
|
package/ios/StripeSdk.mm
CHANGED
|
@@ -92,7 +92,7 @@ RCT_EXPORT_METHOD(configureOrderTracking:(nonnull NSString *)orderTypeIdentifier
|
|
|
92
92
|
}
|
|
93
93
|
|
|
94
94
|
RCT_EXPORT_METHOD(confirmPayment:(nonnull NSString *)paymentIntentClientSecret
|
|
95
|
-
params:(
|
|
95
|
+
params:(nullable NSDictionary *)params
|
|
96
96
|
options:(nonnull NSDictionary *)options
|
|
97
97
|
resolve:(nonnull RCTPromiseResolveBlock)resolve
|
|
98
98
|
reject:(nonnull RCTPromiseRejectBlock)reject)
|
package/ios/StripeSdkImpl.swift
CHANGED
|
@@ -2,7 +2,7 @@ import AuthenticationServices
|
|
|
2
2
|
import Foundation
|
|
3
3
|
import PassKit
|
|
4
4
|
@_spi(DashboardOnly) @_spi(STP) import Stripe
|
|
5
|
-
@_spi(STP) import StripeCore
|
|
5
|
+
@_spi(STP) @_spi(ReactNativeSDK) import StripeCore
|
|
6
6
|
import StripeFinancialConnections
|
|
7
7
|
@_spi(STP) @_spi(ConfirmationTokensPublicPreview) import StripePayments
|
|
8
8
|
import StripePaymentsUI
|
|
@@ -42,6 +42,22 @@ private func getDeviceType() -> String {
|
|
|
42
42
|
public class StripeSdkImpl: NSObject, UIAdaptivePresentationControllerDelegate {
|
|
43
43
|
@objc public static let shared = StripeSdkImpl()
|
|
44
44
|
|
|
45
|
+
static var isNewArchitecture: Bool {
|
|
46
|
+
#if RCT_NEW_ARCH_ENABLED
|
|
47
|
+
return true
|
|
48
|
+
#else
|
|
49
|
+
return false
|
|
50
|
+
#endif
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
static var reactNativeVersion: String {
|
|
54
|
+
let version = RCTGetReactNativeVersion()
|
|
55
|
+
let major = version?["major"] ?? 0
|
|
56
|
+
let minor = version?["minor"] ?? 0
|
|
57
|
+
let patch = version?["patch"] ?? 0
|
|
58
|
+
return "\(major).\(minor).\(patch)"
|
|
59
|
+
}
|
|
60
|
+
|
|
45
61
|
@objc public weak var emitter: StripeSdkEmitter?
|
|
46
62
|
@objc public weak var onrampEmitter: StripeOnrampSdkEmitter?
|
|
47
63
|
weak var cardFieldView: CardFieldView?
|
|
@@ -125,6 +141,8 @@ public class StripeSdkImpl: NSObject, UIAdaptivePresentationControllerDelegate {
|
|
|
125
141
|
"deviceType": getDeviceType(),
|
|
126
142
|
"appName": Bundle.stp_applicationName() ?? "",
|
|
127
143
|
"appVersion": Bundle.stp_applicationVersion() ?? "",
|
|
144
|
+
"isNewArchitecture": Self.isNewArchitecture,
|
|
145
|
+
"reactNativeVersion": Self.reactNativeVersion,
|
|
128
146
|
],
|
|
129
147
|
]
|
|
130
148
|
}
|
|
@@ -158,6 +176,8 @@ public class StripeSdkImpl: NSObject, UIAdaptivePresentationControllerDelegate {
|
|
|
158
176
|
let url = appInfo["url"] as? String ?? ""
|
|
159
177
|
|
|
160
178
|
STPAPIClient.shared.appInfo = STPAppInfo(name: name, partnerId: partnerId, version: version, url: url)
|
|
179
|
+
ReactNativeAnalytics.isNewArchitecture = Self.isNewArchitecture
|
|
180
|
+
ReactNativeAnalytics.reactNativeVersion = Self.reactNativeVersion
|
|
161
181
|
self.merchantIdentifier = merchantIdentifier
|
|
162
182
|
resolve(NSNull())
|
|
163
183
|
}
|
|
@@ -880,7 +900,7 @@ public class StripeSdkImpl: NSObject, UIAdaptivePresentationControllerDelegate {
|
|
|
880
900
|
@objc(confirmPayment:data:options:resolver:rejecter:)
|
|
881
901
|
public func confirmPayment(
|
|
882
902
|
paymentIntentClientSecret: String,
|
|
883
|
-
params: NSDictionary
|
|
903
|
+
params: NSDictionary?,
|
|
884
904
|
options: NSDictionary,
|
|
885
905
|
resolver resolve: @escaping RCTPromiseResolveBlock,
|
|
886
906
|
rejecter reject: @escaping RCTPromiseRejectBlock
|
|
@@ -888,10 +908,8 @@ public class StripeSdkImpl: NSObject, UIAdaptivePresentationControllerDelegate {
|
|
|
888
908
|
self.confirmPaymentResolver = resolve
|
|
889
909
|
self.confirmPaymentClientSecret = paymentIntentClientSecret
|
|
890
910
|
|
|
891
|
-
|
|
892
|
-
let
|
|
893
|
-
let paymentMethodData = actualParams?["paymentMethodData"] as? NSDictionary
|
|
894
|
-
let (missingPaymentMethodError, paymentMethodType) = getPaymentMethodType(params: actualParams)
|
|
911
|
+
let paymentMethodData = params?["paymentMethodData"] as? NSDictionary
|
|
912
|
+
let (missingPaymentMethodError, paymentMethodType) = getPaymentMethodType(params: params)
|
|
895
913
|
if missingPaymentMethodError != nil {
|
|
896
914
|
resolve(missingPaymentMethodError)
|
|
897
915
|
return
|
|
@@ -1582,12 +1600,22 @@ public class StripeSdkImpl: NSObject, UIAdaptivePresentationControllerDelegate {
|
|
|
1582
1600
|
let presentingViewController = await MainActor.run {
|
|
1583
1601
|
findViewControllerPresenter(from: RCTKeyWindow()?.rootViewController ?? UIViewController())
|
|
1584
1602
|
}
|
|
1585
|
-
|
|
1586
|
-
|
|
1587
|
-
|
|
1588
|
-
} else {
|
|
1603
|
+
let result = try await coordinator.collectPaymentMethod(type: paymentMethodType, from: presentingViewController)
|
|
1604
|
+
switch result {
|
|
1605
|
+
case .canceled:
|
|
1589
1606
|
let errorResult = Errors.createError(ErrorType.Canceled, "Payment collection was cancelled")
|
|
1590
1607
|
resolve(["error": errorResult["error"]!])
|
|
1608
|
+
case .completed(let displayData, let kycInfo):
|
|
1609
|
+
var response: [String: Any] = ["displayData": Mappers.paymentMethodDisplayDataToMap(displayData)]
|
|
1610
|
+
|
|
1611
|
+
if let kycInfo {
|
|
1612
|
+
response["kycInfo"] = Mappers.mapFromKycInfo(kycInfo)
|
|
1613
|
+
}
|
|
1614
|
+
|
|
1615
|
+
resolve(response)
|
|
1616
|
+
@unknown default:
|
|
1617
|
+
let errorResult = Errors.createError(ErrorType.Failed, "Received an unexpected payment collection result")
|
|
1618
|
+
resolve(["error": errorResult["error"]!])
|
|
1591
1619
|
}
|
|
1592
1620
|
} catch {
|
|
1593
1621
|
let errorResult = Errors.createError(ErrorType.Failed, error)
|
package/ios/StripeSwiftInterop.h
CHANGED
|
@@ -15,6 +15,7 @@ typedef NS_ENUM(NSInteger, STPPaymentStatus);
|
|
|
15
15
|
|
|
16
16
|
// stripe_react_native-Swift.h also depends on these headers.
|
|
17
17
|
#import <React/RCTBridgeModule.h>
|
|
18
|
+
#import <React/RCTVersion.h>
|
|
18
19
|
#import <React/RCTViewManager.h>
|
|
19
20
|
|
|
20
21
|
// When using frameworks the import is different.
|