@stripe/stripe-react-native 0.66.0 → 0.67.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/StripeSdkModule.kt +0 -11
- package/android/src/main/java/com/reactnativestripesdk/utils/Errors.kt +11 -6
- package/android/src/oldarch/java/com/reactnativestripesdk/NativeOnrampSdkModuleSpec.java +1 -1
- package/android/src/oldarch/java/com/reactnativestripesdk/NativeStripeSdkModuleSpec.java +0 -4
- package/android/src/onramp/java/com/reactnativestripesdk/OnrampErrors.kt +145 -0
- package/android/src/onramp/java/com/reactnativestripesdk/OnrampMappers.kt +10 -1
- package/android/src/onramp/java/com/reactnativestripesdk/OnrampSdkModule.kt +45 -31
- package/android/src/test/java/com/reactnativestripesdk/OnrampErrorsTest.kt +168 -0
- package/ios/Mappers.swift +8 -6
- package/ios/OnrampErrors.swift +132 -0
- package/ios/StripeOnrampSdk.mm +3 -3
- package/ios/StripeSdk.mm +0 -13
- package/ios/StripeSdkImpl+Checkout.swift +0 -17
- package/ios/StripeSdkImpl.swift +34 -22
- package/lib/commonjs/components/StripeProvider.js +1 -1
- package/lib/commonjs/components/StripeProvider.js.map +1 -1
- package/lib/commonjs/hooks/useCheckout.js +1 -1
- package/lib/commonjs/hooks/useCheckout.js.map +1 -1
- package/lib/commonjs/hooks/useOnramp.js +1 -1
- package/lib/commonjs/hooks/useOnramp.js.map +1 -1
- package/lib/commonjs/internal/stripeConfig.js +2 -0
- package/lib/commonjs/internal/stripeConfig.js.map +1 -0
- package/lib/commonjs/specs/NativeStripeSdkModule.js.map +1 -1
- package/lib/commonjs/types/Errors.js +1 -1
- package/lib/commonjs/types/Errors.js.map +1 -1
- package/lib/commonjs/types/Onramp.js +1 -1
- package/lib/commonjs/types/Onramp.js.map +1 -1
- package/lib/module/components/StripeProvider.js +1 -1
- package/lib/module/components/StripeProvider.js.map +1 -1
- package/lib/module/hooks/useCheckout.js +1 -1
- package/lib/module/hooks/useCheckout.js.map +1 -1
- package/lib/module/hooks/useOnramp.js +1 -1
- package/lib/module/hooks/useOnramp.js.map +1 -1
- package/lib/module/internal/stripeConfig.js +2 -0
- package/lib/module/internal/stripeConfig.js.map +1 -0
- package/lib/module/specs/NativeStripeSdkModule.js.map +1 -1
- package/lib/module/types/Errors.js +1 -1
- package/lib/module/types/Errors.js.map +1 -1
- package/lib/module/types/Onramp.js +1 -1
- package/lib/module/types/Onramp.js.map +1 -1
- package/lib/typescript/src/components/StripeProvider.d.ts.map +1 -1
- package/lib/typescript/src/hooks/useCheckout.d.ts.map +1 -1
- package/lib/typescript/src/hooks/useOnramp.d.ts +13 -13
- package/lib/typescript/src/hooks/useOnramp.d.ts.map +1 -1
- package/lib/typescript/src/internal/stripeConfig.d.ts +3 -0
- package/lib/typescript/src/internal/stripeConfig.d.ts.map +1 -0
- package/lib/typescript/src/specs/NativeOnrampSdkModule.d.ts +1 -1
- package/lib/typescript/src/specs/NativeOnrampSdkModule.d.ts.map +1 -1
- package/lib/typescript/src/specs/NativeStripeSdkModule.d.ts +0 -1
- package/lib/typescript/src/specs/NativeStripeSdkModule.d.ts.map +1 -1
- package/lib/typescript/src/types/Checkout.d.ts +0 -8
- package/lib/typescript/src/types/Checkout.d.ts.map +1 -1
- package/lib/typescript/src/types/Errors.d.ts +0 -5
- package/lib/typescript/src/types/Errors.d.ts.map +1 -1
- package/lib/typescript/src/types/Onramp.d.ts +84 -19
- package/lib/typescript/src/types/Onramp.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/components/StripeProvider.tsx +2 -0
- package/src/hooks/useCheckout.tsx +0 -9
- package/src/hooks/useOnramp.tsx +101 -18
- package/src/internal/stripeConfig.ts +9 -0
- package/src/specs/NativeOnrampSdkModule.ts +1 -1
- package/src/specs/NativeStripeSdkModule.ts +0 -6
- package/src/types/Checkout.ts +0 -9
- package/src/types/Errors.ts +0 -6
- package/src/types/Onramp.ts +93 -19
- package/stripe-react-native.podspec +3 -3
|
@@ -3,4 +3,4 @@ StripeSdk_compileSdkVersion=36
|
|
|
3
3
|
StripeSdk_targetSdkVersion=36
|
|
4
4
|
StripeSdk_minSdkVersion=23
|
|
5
5
|
# Keep StripeSdk_stripeVersion in sync with https://github.com/stripe/stripe-identity-react-native/blob/main/android/gradle.properties
|
|
6
|
-
StripeSdk_stripeVersion=23.
|
|
6
|
+
StripeSdk_stripeVersion=23.10.+
|
|
@@ -1869,17 +1869,6 @@ class StripeSdkModule(
|
|
|
1869
1869
|
}
|
|
1870
1870
|
}
|
|
1871
1871
|
|
|
1872
|
-
override fun checkoutUpdateTaxId(
|
|
1873
|
-
sessionKey: String,
|
|
1874
|
-
type: String,
|
|
1875
|
-
value: String,
|
|
1876
|
-
promise: Promise,
|
|
1877
|
-
) {
|
|
1878
|
-
performCheckoutMutation(sessionKey, promise) { checkout ->
|
|
1879
|
-
checkout.updateTaxId(type = type, value = value)
|
|
1880
|
-
}
|
|
1881
|
-
}
|
|
1882
|
-
|
|
1883
1872
|
override fun checkoutRunServerUpdateStart(
|
|
1884
1873
|
sessionKey: String,
|
|
1885
1874
|
promise: Promise,
|
|
@@ -5,6 +5,7 @@ import com.facebook.react.bridge.WritableMap
|
|
|
5
5
|
import com.stripe.android.core.exception.APIException
|
|
6
6
|
import com.stripe.android.core.exception.AuthenticationException
|
|
7
7
|
import com.stripe.android.core.exception.InvalidRequestException
|
|
8
|
+
import com.stripe.android.core.exception.StripeException
|
|
8
9
|
import com.stripe.android.exception.CardException
|
|
9
10
|
import com.stripe.android.model.PaymentIntent
|
|
10
11
|
import com.stripe.android.model.SetupIntent
|
|
@@ -173,6 +174,16 @@ internal fun createError(
|
|
|
173
174
|
error.stripeError?.code,
|
|
174
175
|
)
|
|
175
176
|
}
|
|
177
|
+
is StripeException -> {
|
|
178
|
+
mapError(
|
|
179
|
+
code,
|
|
180
|
+
error.message,
|
|
181
|
+
error.localizedMessage,
|
|
182
|
+
error.stripeError?.declineCode,
|
|
183
|
+
error.stripeError?.type,
|
|
184
|
+
error.stripeError?.code
|
|
185
|
+
)
|
|
186
|
+
}
|
|
176
187
|
else -> mapError(code, error.message, error.localizedMessage.orEmpty(), null, null, null)
|
|
177
188
|
}
|
|
178
189
|
|
|
@@ -197,9 +208,3 @@ internal fun createMissingInitError(): WritableMap =
|
|
|
197
208
|
"Stripe has not been initialized. Initialize Stripe in your app with the StripeProvider component " +
|
|
198
209
|
"or the initStripe method.",
|
|
199
210
|
)
|
|
200
|
-
|
|
201
|
-
internal fun createOnrampNotConfiguredError(): WritableMap =
|
|
202
|
-
createError(
|
|
203
|
-
ErrorType.Failed.toString(),
|
|
204
|
-
"Onramp is not configured.",
|
|
205
|
-
)
|
|
@@ -69,7 +69,7 @@ public abstract class NativeOnrampSdkModuleSpec extends ReactContextBaseJavaModu
|
|
|
69
69
|
|
|
70
70
|
@ReactMethod
|
|
71
71
|
@DoNotStrip
|
|
72
|
-
public abstract void
|
|
72
|
+
public abstract void presentUserAttestation(Promise promise);
|
|
73
73
|
|
|
74
74
|
@ReactMethod
|
|
75
75
|
@DoNotStrip
|
|
@@ -329,10 +329,6 @@ public abstract class NativeStripeSdkModuleSpec extends ReactContextBaseJavaModu
|
|
|
329
329
|
@DoNotStrip
|
|
330
330
|
public abstract void checkoutSelectShippingOption(String sessionKey, String id, Promise promise);
|
|
331
331
|
|
|
332
|
-
@ReactMethod
|
|
333
|
-
@DoNotStrip
|
|
334
|
-
public abstract void checkoutUpdateTaxId(String sessionKey, String type, String value, Promise promise);
|
|
335
|
-
|
|
336
332
|
@ReactMethod
|
|
337
333
|
@DoNotStrip
|
|
338
334
|
public abstract void checkoutRunServerUpdateStart(String sessionKey, Promise promise);
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
@file:OptIn(ExperimentalCryptoOnramp::class)
|
|
2
|
+
|
|
3
|
+
package com.reactnativestripesdk
|
|
4
|
+
|
|
5
|
+
import com.facebook.react.bridge.Arguments
|
|
6
|
+
import com.facebook.react.bridge.WritableArray
|
|
7
|
+
import com.facebook.react.bridge.WritableMap
|
|
8
|
+
import com.reactnativestripesdk.utils.ErrorType
|
|
9
|
+
import com.stripe.android.core.exception.StripeException
|
|
10
|
+
import com.stripe.android.crypto.onramp.ExperimentalCryptoOnramp
|
|
11
|
+
import com.stripe.android.crypto.onramp.exception.AppAttestationException
|
|
12
|
+
import com.stripe.android.crypto.onramp.exception.CryptoOnrampApiException
|
|
13
|
+
import com.stripe.android.crypto.onramp.exception.SDKVersion
|
|
14
|
+
import com.stripe.android.crypto.onramp.exception.StripeCryptoOnrampError
|
|
15
|
+
|
|
16
|
+
internal fun createOnrampFailedError(error: Throwable): WritableMap =
|
|
17
|
+
createOnrampError(ErrorType.Failed.toString(), error)
|
|
18
|
+
|
|
19
|
+
internal fun createOnrampNotConfiguredError(): WritableMap =
|
|
20
|
+
createOnrampMessageError(
|
|
21
|
+
ErrorType.Failed.toString(),
|
|
22
|
+
"Onramp is not configured.",
|
|
23
|
+
)
|
|
24
|
+
|
|
25
|
+
private fun createOnrampError(
|
|
26
|
+
code: String,
|
|
27
|
+
error: Throwable,
|
|
28
|
+
): WritableMap {
|
|
29
|
+
val apiException =
|
|
30
|
+
error as? CryptoOnrampApiException
|
|
31
|
+
?: return createNonApiOnrampError(code, error)
|
|
32
|
+
|
|
33
|
+
val stripeError = apiException.stripeError
|
|
34
|
+
val onrampErrorType = apiException.toOnrampErrorType()
|
|
35
|
+
|
|
36
|
+
return createOnrampErrorMap(
|
|
37
|
+
code = code,
|
|
38
|
+
message = apiException.userMessage,
|
|
39
|
+
localizedMessage = apiException.localizedMessage,
|
|
40
|
+
declineCode = stripeError?.declineCode,
|
|
41
|
+
type = apiException.context.apiErrorType ?: stripeError?.type,
|
|
42
|
+
stripeErrorCode = apiException.code,
|
|
43
|
+
) {
|
|
44
|
+
putString("onrampErrorType", onrampErrorType)
|
|
45
|
+
putString("developerMessage", apiException.developerMessage)
|
|
46
|
+
putString("userMessage", apiException.userMessage)
|
|
47
|
+
putString("reason", apiException.context.reason)
|
|
48
|
+
putString("operation", apiException.context.operation)
|
|
49
|
+
putString("appPackageName", apiException.context.appPackageName)
|
|
50
|
+
putString("mode", apiException.context.mode)
|
|
51
|
+
putArray("sdkVersions", mapFromSdkVersions(apiException.sdkVersions))
|
|
52
|
+
putString("requestId", apiException.context.requestId)
|
|
53
|
+
putString("apiErrorCode", apiException.context.apiErrorCode)
|
|
54
|
+
putString("apiErrorType", apiException.context.apiErrorType)
|
|
55
|
+
putString("apiErrorMessage", apiException.context.apiErrorMessage)
|
|
56
|
+
putString("apiUserMessage", apiException.context.apiUserMessage)
|
|
57
|
+
putString("docUrl", apiException.context.docUrl)
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
private fun createNonApiOnrampError(
|
|
62
|
+
code: String,
|
|
63
|
+
error: Throwable,
|
|
64
|
+
): WritableMap {
|
|
65
|
+
val onrampError =
|
|
66
|
+
error as? StripeCryptoOnrampError
|
|
67
|
+
?: return createGenericError(code, error)
|
|
68
|
+
|
|
69
|
+
return createOnrampErrorMap(
|
|
70
|
+
code = code,
|
|
71
|
+
message = onrampError.userMessage,
|
|
72
|
+
localizedMessage = error.localizedMessage,
|
|
73
|
+
stripeErrorCode = onrampError.code,
|
|
74
|
+
) {
|
|
75
|
+
putString("developerMessage", onrampError.developerMessage)
|
|
76
|
+
putString("userMessage", onrampError.userMessage)
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
private fun createOnrampMessageError(
|
|
81
|
+
code: String,
|
|
82
|
+
message: String?,
|
|
83
|
+
): WritableMap =
|
|
84
|
+
createOnrampErrorMap(code = code, message = message)
|
|
85
|
+
|
|
86
|
+
private fun CryptoOnrampApiException.toOnrampErrorType(): String =
|
|
87
|
+
if (this is AppAttestationException) {
|
|
88
|
+
"AppAttestationError"
|
|
89
|
+
} else {
|
|
90
|
+
"UncategorizedApiError"
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
private fun createGenericError(
|
|
94
|
+
code: String,
|
|
95
|
+
error: Throwable,
|
|
96
|
+
): WritableMap {
|
|
97
|
+
val stripeError = (error as? StripeException)?.stripeError
|
|
98
|
+
|
|
99
|
+
return createOnrampErrorMap(
|
|
100
|
+
code = code,
|
|
101
|
+
message = error.message,
|
|
102
|
+
localizedMessage = error.localizedMessage,
|
|
103
|
+
declineCode = stripeError?.declineCode,
|
|
104
|
+
type = stripeError?.type,
|
|
105
|
+
stripeErrorCode = stripeError?.code,
|
|
106
|
+
)
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
private fun createOnrampErrorMap(
|
|
110
|
+
code: String,
|
|
111
|
+
message: String?,
|
|
112
|
+
localizedMessage: String? = message,
|
|
113
|
+
declineCode: String? = null,
|
|
114
|
+
type: String? = null,
|
|
115
|
+
stripeErrorCode: String? = null,
|
|
116
|
+
configure: (WritableMap.() -> Unit)? = null,
|
|
117
|
+
): WritableMap {
|
|
118
|
+
val map: WritableMap = Arguments.createMap()
|
|
119
|
+
val details: WritableMap = Arguments.createMap()
|
|
120
|
+
|
|
121
|
+
details.putString("code", code)
|
|
122
|
+
details.putString("message", message)
|
|
123
|
+
details.putString("localizedMessage", localizedMessage)
|
|
124
|
+
details.putString("declineCode", declineCode)
|
|
125
|
+
details.putString("type", type)
|
|
126
|
+
details.putString("stripeErrorCode", stripeErrorCode)
|
|
127
|
+
configure?.invoke(details)
|
|
128
|
+
|
|
129
|
+
map.putMap("error", details)
|
|
130
|
+
return map
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
private fun mapFromSdkVersions(
|
|
134
|
+
sdkVersions: List<SDKVersion>,
|
|
135
|
+
): WritableArray =
|
|
136
|
+
Arguments.createArray().apply {
|
|
137
|
+
sdkVersions.forEach { sdkVersion ->
|
|
138
|
+
pushMap(
|
|
139
|
+
Arguments.createMap().apply {
|
|
140
|
+
putString("name", sdkVersion.name)
|
|
141
|
+
putString("version", sdkVersion.version)
|
|
142
|
+
},
|
|
143
|
+
)
|
|
144
|
+
}
|
|
145
|
+
}
|
|
@@ -10,6 +10,7 @@ import com.facebook.react.bridge.ReadableMap
|
|
|
10
10
|
import com.facebook.react.bridge.WritableArray
|
|
11
11
|
import com.stripe.android.core.model.CountryCode
|
|
12
12
|
import com.stripe.android.crypto.onramp.ExperimentalCryptoOnramp
|
|
13
|
+
import com.stripe.android.crypto.onramp.exception.SDKVersion
|
|
13
14
|
import com.stripe.android.crypto.onramp.model.KycInfo
|
|
14
15
|
import com.stripe.android.crypto.onramp.model.OnrampConfiguration
|
|
15
16
|
import com.stripe.android.crypto.onramp.model.PaymentMethodDisplayData
|
|
@@ -32,6 +33,7 @@ import com.stripe.android.paymentsheet.PaymentSheet
|
|
|
32
33
|
internal fun mapConfig(
|
|
33
34
|
configMap: ReadableMap,
|
|
34
35
|
publishableKey: String,
|
|
36
|
+
additionalSdkVersions: List<SDKVersion> = emptyList(),
|
|
35
37
|
): OnrampConfiguration {
|
|
36
38
|
val appearanceMap = configMap.getMap("appearance")
|
|
37
39
|
val appearance =
|
|
@@ -52,6 +54,11 @@ internal fun mapConfig(
|
|
|
52
54
|
.appearance(appearance)
|
|
53
55
|
.cryptoCustomerId(cryptoCustomerId)
|
|
54
56
|
.apply { googlePayConfig?.let { googlePayConfig(it) } }
|
|
57
|
+
.apply {
|
|
58
|
+
if (additionalSdkVersions.isNotEmpty()) {
|
|
59
|
+
this.additionalSdkVersions(additionalSdkVersions)
|
|
60
|
+
}
|
|
61
|
+
}
|
|
55
62
|
}
|
|
56
63
|
|
|
57
64
|
@SuppressLint("RestrictedApi")
|
|
@@ -222,14 +229,16 @@ internal fun mapFromComplianceIdentifierRequirements(
|
|
|
222
229
|
) = Arguments.createMap().apply {
|
|
223
230
|
putArray("identifiers", mapFromComplianceIdentifierRequirementsList(requirements.identifiers))
|
|
224
231
|
putArray("alternatives", mapFromComplianceIdentifierAlternativeGroups(requirements.alternatives))
|
|
232
|
+
putBoolean("carfTinRequired", requirements.carfTinRequired)
|
|
225
233
|
}
|
|
226
234
|
|
|
227
235
|
internal fun mapFromSubmitIdentifiersResult(
|
|
228
236
|
result: SubmitIdentifiersResult,
|
|
229
237
|
) = Arguments.createMap().apply {
|
|
230
|
-
putBoolean("
|
|
238
|
+
putBoolean("completed", result.completed)
|
|
231
239
|
putArray("identifiers", mapFromComplianceIdentifierRequirementsList(result.identifiers))
|
|
232
240
|
putArray("alternatives", mapFromComplianceIdentifierAlternativeGroups(result.alternatives))
|
|
241
|
+
putBoolean("carfTinRequired", result.carfTinRequired)
|
|
233
242
|
putArray("invalidIdentifiers", mapFromComplianceIdentifierTypes(result.invalidIdentifiers))
|
|
234
243
|
}
|
|
235
244
|
|
|
@@ -20,16 +20,15 @@ import com.reactnativestripesdk.utils.ErrorType
|
|
|
20
20
|
import com.reactnativestripesdk.utils.createCanceledError
|
|
21
21
|
import com.reactnativestripesdk.utils.createEmptyResult
|
|
22
22
|
import com.reactnativestripesdk.utils.createError
|
|
23
|
-
import com.reactnativestripesdk.utils.createFailedError
|
|
24
23
|
import com.reactnativestripesdk.utils.createMissingActivityError
|
|
25
24
|
import com.reactnativestripesdk.utils.createMissingInitError
|
|
26
|
-
import com.reactnativestripesdk.utils.createOnrampNotConfiguredError
|
|
27
25
|
import com.reactnativestripesdk.utils.createResult
|
|
28
26
|
import com.reactnativestripesdk.utils.getStringList
|
|
29
27
|
import com.reactnativestripesdk.utils.getValOr
|
|
30
28
|
import com.reactnativestripesdk.utils.mapToPaymentSheetAddress
|
|
31
29
|
import com.stripe.android.crypto.onramp.ExperimentalCryptoOnramp
|
|
32
30
|
import com.stripe.android.crypto.onramp.OnrampCoordinator
|
|
31
|
+
import com.stripe.android.crypto.onramp.exception.SDKVersion
|
|
33
32
|
import com.stripe.android.crypto.onramp.model.CryptoNetwork
|
|
34
33
|
import com.stripe.android.crypto.onramp.model.KycInfo
|
|
35
34
|
import com.stripe.android.crypto.onramp.model.LinkUserInfo
|
|
@@ -72,6 +71,7 @@ class OnrampSdkModule(
|
|
|
72
71
|
reactContext: ReactApplicationContext,
|
|
73
72
|
) : NativeOnrampSdkModuleSpec(reactContext) {
|
|
74
73
|
private val eventEmitterCompat = EventEmitterCompat(reactContext)
|
|
74
|
+
private var reactNativeSdkVersion: String? = null
|
|
75
75
|
private lateinit var publishableKey: String
|
|
76
76
|
private var stripeAccountId: String? = null
|
|
77
77
|
|
|
@@ -84,7 +84,7 @@ class OnrampSdkModule(
|
|
|
84
84
|
private var authorizePromise: Promise? = null
|
|
85
85
|
private var checkoutPromise: Promise? = null
|
|
86
86
|
private var verifyKycPromise: Promise? = null
|
|
87
|
-
private var
|
|
87
|
+
private var userAttestationPromise: Promise? = null
|
|
88
88
|
|
|
89
89
|
private var checkoutClientSecretDeferred: CompletableDeferred<String>? = null
|
|
90
90
|
private val rnScope = CoroutineScope(SupervisorJob() + Dispatchers.Main.immediate)
|
|
@@ -96,6 +96,10 @@ class OnrampSdkModule(
|
|
|
96
96
|
) {
|
|
97
97
|
// Note: This method depends on `StripeSdkModule#initialise()` being called as well.
|
|
98
98
|
val publishableKey = getValOr(params, "publishableKey", null) as String
|
|
99
|
+
reactNativeSdkVersion =
|
|
100
|
+
params.getMap("appInfo")
|
|
101
|
+
?.getString("version")
|
|
102
|
+
?.takeIf { it.isNotBlank() }
|
|
99
103
|
this.stripeAccountId = getValOr(params, "stripeAccountId", null)
|
|
100
104
|
this.publishableKey = publishableKey
|
|
101
105
|
|
|
@@ -149,8 +153,8 @@ class OnrampSdkModule(
|
|
|
149
153
|
}.verifyKycCallback { result ->
|
|
150
154
|
handleOnrampKycVerificationResult(result, verifyKycPromise!!)
|
|
151
155
|
}.crsCarfDeclarationCallback { result ->
|
|
152
|
-
|
|
153
|
-
|
|
156
|
+
userAttestationPromise?.let {
|
|
157
|
+
handleUserAttestationResult(result, it)
|
|
154
158
|
}
|
|
155
159
|
}.onrampSessionClientSecretProvider { sessionId ->
|
|
156
160
|
checkoutClientSecretDeferred = CompletableDeferred()
|
|
@@ -170,7 +174,7 @@ class OnrampSdkModule(
|
|
|
170
174
|
.also { this.onrampCoordinator = it }
|
|
171
175
|
|
|
172
176
|
CoroutineScope(Dispatchers.IO).launch {
|
|
173
|
-
val configuration = mapConfig(config, publishableKey)
|
|
177
|
+
val configuration = mapConfig(config, publishableKey, onrampAdditionalSdkVersions())
|
|
174
178
|
val configureResult = coordinator.configure(configuration)
|
|
175
179
|
|
|
176
180
|
CoroutineScope(Dispatchers.Main).launch {
|
|
@@ -179,7 +183,7 @@ class OnrampSdkModule(
|
|
|
179
183
|
createOnrampPresenter(promise)
|
|
180
184
|
}
|
|
181
185
|
is OnrampConfigurationResult.Failed -> {
|
|
182
|
-
promise.resolve(
|
|
186
|
+
promise.resolve(createOnrampFailedError(configureResult.error))
|
|
183
187
|
}
|
|
184
188
|
}
|
|
185
189
|
}
|
|
@@ -206,7 +210,7 @@ class OnrampSdkModule(
|
|
|
206
210
|
onrampPresenter = onrampCoordinator!!.createPresenter(activity)
|
|
207
211
|
promise.resolveVoid()
|
|
208
212
|
} catch (e: Exception) {
|
|
209
|
-
promise.resolve(
|
|
213
|
+
promise.resolve(createOnrampFailedError(e))
|
|
210
214
|
}
|
|
211
215
|
}
|
|
212
216
|
|
|
@@ -226,7 +230,7 @@ class OnrampSdkModule(
|
|
|
226
230
|
promise.resolveBoolean("hasLinkAccount", result.hasLinkAccount)
|
|
227
231
|
}
|
|
228
232
|
is OnrampHasLinkAccountResult.Failed -> {
|
|
229
|
-
promise.resolve(
|
|
233
|
+
promise.resolve(createOnrampFailedError(result.error))
|
|
230
234
|
}
|
|
231
235
|
}
|
|
232
236
|
}
|
|
@@ -257,7 +261,7 @@ class OnrampSdkModule(
|
|
|
257
261
|
promise.resolveString("customerId", result.customerId)
|
|
258
262
|
}
|
|
259
263
|
is OnrampRegisterLinkUserResult.Failed -> {
|
|
260
|
-
promise.resolve(
|
|
264
|
+
promise.resolve(createOnrampFailedError(result.error))
|
|
261
265
|
}
|
|
262
266
|
}
|
|
263
267
|
}
|
|
@@ -286,7 +290,7 @@ class OnrampSdkModule(
|
|
|
286
290
|
promise.resolveVoid()
|
|
287
291
|
}
|
|
288
292
|
is OnrampRegisterWalletAddressResult.Failed -> {
|
|
289
|
-
promise.resolve(
|
|
293
|
+
promise.resolve(createOnrampFailedError(result.error))
|
|
290
294
|
}
|
|
291
295
|
}
|
|
292
296
|
}
|
|
@@ -350,7 +354,7 @@ class OnrampSdkModule(
|
|
|
350
354
|
promise.resolveVoid()
|
|
351
355
|
}
|
|
352
356
|
is OnrampAttachKycInfoResult.Failed -> {
|
|
353
|
-
promise.resolve(
|
|
357
|
+
promise.resolve(createOnrampFailedError(result.error))
|
|
354
358
|
}
|
|
355
359
|
}
|
|
356
360
|
}
|
|
@@ -370,7 +374,7 @@ class OnrampSdkModule(
|
|
|
370
374
|
promise.resolve(mapFromComplianceIdentifierRequirements(result.requirements))
|
|
371
375
|
}
|
|
372
376
|
is OnrampRetrieveMissingIdentifiersResult.Failed -> {
|
|
373
|
-
promise.resolve(
|
|
377
|
+
promise.resolve(createOnrampFailedError(result.error))
|
|
374
378
|
}
|
|
375
379
|
}
|
|
376
380
|
}
|
|
@@ -407,21 +411,21 @@ class OnrampSdkModule(
|
|
|
407
411
|
promise.resolve(mapFromSubmitIdentifiersResult(result.result))
|
|
408
412
|
}
|
|
409
413
|
is OnrampSubmitIdentifiersResult.Failed -> {
|
|
410
|
-
promise.resolve(
|
|
414
|
+
promise.resolve(createOnrampFailedError(result.error))
|
|
411
415
|
}
|
|
412
416
|
}
|
|
413
417
|
}
|
|
414
418
|
}
|
|
415
419
|
|
|
416
420
|
@ReactMethod
|
|
417
|
-
override fun
|
|
421
|
+
override fun presentUserAttestation(promise: Promise) {
|
|
418
422
|
val presenter =
|
|
419
423
|
onrampPresenter ?: run {
|
|
420
424
|
promise.resolve(createOnrampNotConfiguredError())
|
|
421
425
|
return
|
|
422
426
|
}
|
|
423
427
|
|
|
424
|
-
|
|
428
|
+
userAttestationPromise = promise
|
|
425
429
|
presenter.presentCrsCarfDeclaration()
|
|
426
430
|
}
|
|
427
431
|
|
|
@@ -441,7 +445,7 @@ class OnrampSdkModule(
|
|
|
441
445
|
promise.resolveVoid()
|
|
442
446
|
}
|
|
443
447
|
is OnrampUpdatePhoneNumberResult.Failed -> {
|
|
444
|
-
promise.resolve(
|
|
448
|
+
promise.resolve(createOnrampFailedError(result.error))
|
|
445
449
|
}
|
|
446
450
|
}
|
|
447
451
|
}
|
|
@@ -499,7 +503,7 @@ class OnrampSdkModule(
|
|
|
499
503
|
platformPayParams.getMap("googlePay")
|
|
500
504
|
?: run {
|
|
501
505
|
promise.resolve(
|
|
502
|
-
|
|
506
|
+
createOnrampFailedError(
|
|
503
507
|
IllegalArgumentException("Missing googlePay params in platformPayParams"),
|
|
504
508
|
),
|
|
505
509
|
)
|
|
@@ -520,7 +524,7 @@ class OnrampSdkModule(
|
|
|
520
524
|
}
|
|
521
525
|
else -> {
|
|
522
526
|
promise.resolve(
|
|
523
|
-
|
|
527
|
+
createOnrampFailedError(
|
|
524
528
|
IllegalArgumentException("Unsupported payment method: $paymentMethod"),
|
|
525
529
|
),
|
|
526
530
|
)
|
|
@@ -648,7 +652,7 @@ class OnrampSdkModule(
|
|
|
648
652
|
|
|
649
653
|
if (paymentDetails == null) {
|
|
650
654
|
promise.resolve(
|
|
651
|
-
|
|
655
|
+
createOnrampFailedError(
|
|
652
656
|
IllegalArgumentException("Unsupported payment method"),
|
|
653
657
|
),
|
|
654
658
|
)
|
|
@@ -749,7 +753,7 @@ class OnrampSdkModule(
|
|
|
749
753
|
promise.resolve(createCanceledError("Identity verification was cancelled"))
|
|
750
754
|
}
|
|
751
755
|
is OnrampVerifyIdentityResult.Failed -> {
|
|
752
|
-
promise.resolve(
|
|
756
|
+
promise.resolve(createOnrampFailedError(result.error))
|
|
753
757
|
}
|
|
754
758
|
}
|
|
755
759
|
}
|
|
@@ -773,12 +777,12 @@ class OnrampSdkModule(
|
|
|
773
777
|
promise.resolve(createCanceledError("KYC verification was cancelled"))
|
|
774
778
|
}
|
|
775
779
|
is OnrampVerifyKycInfoResult.Failed -> {
|
|
776
|
-
promise.resolve(
|
|
780
|
+
promise.resolve(createOnrampFailedError(result.error))
|
|
777
781
|
}
|
|
778
782
|
}
|
|
779
783
|
}
|
|
780
784
|
|
|
781
|
-
private fun
|
|
785
|
+
private fun handleUserAttestationResult(
|
|
782
786
|
result: OnrampCrsCarfDeclarationResult,
|
|
783
787
|
promise: Promise,
|
|
784
788
|
) {
|
|
@@ -789,10 +793,10 @@ class OnrampSdkModule(
|
|
|
789
793
|
)
|
|
790
794
|
}
|
|
791
795
|
is OnrampCrsCarfDeclarationResult.Cancelled -> {
|
|
792
|
-
promise.resolve(createCanceledError("
|
|
796
|
+
promise.resolve(createCanceledError("User attestation was canceled"))
|
|
793
797
|
}
|
|
794
798
|
is OnrampCrsCarfDeclarationResult.Failed -> {
|
|
795
|
-
promise.resolve(
|
|
799
|
+
promise.resolve(createOnrampFailedError(result.error))
|
|
796
800
|
}
|
|
797
801
|
}
|
|
798
802
|
}
|
|
@@ -843,7 +847,7 @@ class OnrampSdkModule(
|
|
|
843
847
|
}
|
|
844
848
|
|
|
845
849
|
is OnrampCollectPaymentMethodResult.Failed -> {
|
|
846
|
-
promise.resolve(
|
|
850
|
+
promise.resolve(createOnrampFailedError(result.error))
|
|
847
851
|
}
|
|
848
852
|
}
|
|
849
853
|
}
|
|
@@ -872,7 +876,7 @@ class OnrampSdkModule(
|
|
|
872
876
|
promise.resolve(createCanceledError("Authorization was cancelled"))
|
|
873
877
|
}
|
|
874
878
|
is OnrampAuthorizeResult.Failed -> {
|
|
875
|
-
promise.resolve(
|
|
879
|
+
promise.resolve(createOnrampFailedError(result.error))
|
|
876
880
|
}
|
|
877
881
|
}
|
|
878
882
|
}
|
|
@@ -889,7 +893,7 @@ class OnrampSdkModule(
|
|
|
889
893
|
promise.resolve(createCanceledError("Checkout was cancelled"))
|
|
890
894
|
}
|
|
891
895
|
is OnrampCheckoutResult.Failed -> {
|
|
892
|
-
promise.resolve(
|
|
896
|
+
promise.resolve(createOnrampFailedError(result.error))
|
|
893
897
|
}
|
|
894
898
|
}
|
|
895
899
|
}
|
|
@@ -903,7 +907,7 @@ class OnrampSdkModule(
|
|
|
903
907
|
promise.resolveString("cryptoPaymentToken", result.cryptoPaymentToken)
|
|
904
908
|
}
|
|
905
909
|
is OnrampCreateCryptoPaymentTokenResult.Failed -> {
|
|
906
|
-
promise.resolve(
|
|
910
|
+
promise.resolve(createOnrampFailedError(result.error))
|
|
907
911
|
}
|
|
908
912
|
}
|
|
909
913
|
}
|
|
@@ -917,7 +921,7 @@ class OnrampSdkModule(
|
|
|
917
921
|
promise.resolveVoid()
|
|
918
922
|
}
|
|
919
923
|
is OnrampLogOutResult.Failed -> {
|
|
920
|
-
promise.resolve(
|
|
924
|
+
promise.resolve(createOnrampFailedError(result.error))
|
|
921
925
|
}
|
|
922
926
|
}
|
|
923
927
|
}
|
|
@@ -931,7 +935,7 @@ class OnrampSdkModule(
|
|
|
931
935
|
promise.resolveVoid()
|
|
932
936
|
}
|
|
933
937
|
is OnrampTokenAuthenticationResult.Failed -> {
|
|
934
|
-
promise.resolve(
|
|
938
|
+
promise.resolve(createOnrampFailedError(result.error))
|
|
935
939
|
}
|
|
936
940
|
}
|
|
937
941
|
}
|
|
@@ -953,4 +957,14 @@ class OnrampSdkModule(
|
|
|
953
957
|
) {
|
|
954
958
|
resolve(WritableNativeMap().apply { putBoolean(key, value) })
|
|
955
959
|
}
|
|
960
|
+
|
|
961
|
+
private fun onrampAdditionalSdkVersions(): List<SDKVersion> =
|
|
962
|
+
reactNativeSdkVersion?.let {
|
|
963
|
+
listOf(
|
|
964
|
+
SDKVersion(
|
|
965
|
+
name = "stripe-react-native",
|
|
966
|
+
version = it,
|
|
967
|
+
),
|
|
968
|
+
)
|
|
969
|
+
} ?: emptyList()
|
|
956
970
|
}
|