@stripe/stripe-react-native 0.56.0 → 0.57.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/AuBECSDebitFormView.kt +4 -3
- package/android/src/main/java/com/reactnativestripesdk/CardFieldView.kt +7 -6
- package/android/src/main/java/com/reactnativestripesdk/CardFormView.kt +11 -11
- package/android/src/main/java/com/reactnativestripesdk/{CollectBankAccountLauncherFragment.kt → CollectBankAccountLauncherManager.kt} +21 -44
- package/android/src/main/java/com/reactnativestripesdk/EmbeddedPaymentElementViewManager.kt +17 -24
- package/android/src/main/java/com/reactnativestripesdk/{FinancialConnectionsSheetFragment.kt → FinancialConnectionsSheetManager.kt} +30 -77
- package/android/src/main/java/com/reactnativestripesdk/GooglePayLauncherManager.kt +107 -0
- package/android/src/main/java/com/reactnativestripesdk/GooglePayPaymentMethodLauncherManager.kt +37 -0
- package/android/src/main/java/com/reactnativestripesdk/{PaymentLauncherFragment.kt → PaymentLauncherManager.kt} +39 -77
- package/android/src/main/java/com/reactnativestripesdk/PaymentMethodCreateParamsFactory.kt +8 -20
- package/android/src/main/java/com/reactnativestripesdk/PaymentSheetAppearance.kt +366 -483
- package/android/src/main/java/com/reactnativestripesdk/{PaymentSheetFragment.kt → PaymentSheetManager.kt} +79 -88
- package/android/src/main/java/com/reactnativestripesdk/StripeSdkModule.kt +176 -219
- package/android/src/main/java/com/reactnativestripesdk/addresssheet/AddressLauncherManager.kt +78 -0
- package/android/src/main/java/com/reactnativestripesdk/addresssheet/AddressSheetView.kt +48 -35
- package/android/src/main/java/com/reactnativestripesdk/customersheet/{CustomerSheetFragment.kt → CustomerSheetManager.kt} +70 -85
- package/android/src/main/java/com/reactnativestripesdk/customersheet/ReactNativeCustomerSessionProvider.kt +0 -2
- package/android/src/main/java/com/reactnativestripesdk/utils/Extensions.kt +47 -12
- package/android/src/main/java/com/reactnativestripesdk/utils/Mappers.kt +87 -142
- package/android/src/main/java/com/reactnativestripesdk/utils/StripeUIManager.kt +62 -0
- package/ios/AddressSheet/AddressSheetView.swift +1 -1
- package/ios/FinancialConnections.swift +2 -2
- package/ios/Mappers.swift +2 -4
- package/ios/PaymentMethodFactory.swift +0 -17
- package/ios/PushProvisioning/AddToWalletButtonView.swift +1 -1
- package/ios/StripeSdkImpl+CustomerSheet.swift +1 -1
- package/ios/StripeSdkImpl+PaymentSheet.swift +15 -8
- package/ios/StripeSdkImpl.swift +6 -6
- 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/types/EmbeddedPaymentElement.js +1 -1
- package/lib/commonjs/types/EmbeddedPaymentElement.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/types/EmbeddedPaymentElement.js +1 -1
- package/lib/module/types/EmbeddedPaymentElement.js.map +1 -1
- package/lib/module/types/PaymentIntent.js.map +1 -1
- package/lib/typescript/src/types/PaymentIntent.d.ts +1 -9
- package/lib/typescript/src/types/PaymentIntent.d.ts.map +1 -1
- package/lib/typescript/src/types/PaymentMethod.d.ts +2 -8
- package/lib/typescript/src/types/PaymentMethod.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/types/PaymentIntent.ts +0 -10
- package/src/types/PaymentMethod.ts +0 -9
- package/stripe-react-native.podspec +1 -1
- package/android/.idea/AndroidProjectSystem.xml +0 -6
- package/android/.idea/caches/deviceStreaming.xml +0 -703
- package/android/.idea/compiler.xml +0 -6
- package/android/.idea/gradle.xml +0 -18
- 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/GooglePayLauncherFragment.kt +0 -146
- package/android/src/main/java/com/reactnativestripesdk/GooglePayPaymentMethodLauncherFragment.kt +0 -68
- package/android/src/main/java/com/reactnativestripesdk/addresssheet/AddressLauncherFragment.kt +0 -102
- package/android/src/main/java/com/reactnativestripesdk/utils/StripeFragment.kt +0 -52
package/android/src/main/java/com/reactnativestripesdk/GooglePayPaymentMethodLauncherManager.kt
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
package com.reactnativestripesdk
|
|
2
|
+
|
|
3
|
+
import android.annotation.SuppressLint
|
|
4
|
+
import com.facebook.react.bridge.ReactApplicationContext
|
|
5
|
+
import com.reactnativestripesdk.utils.StripeUIManager
|
|
6
|
+
import com.stripe.android.core.reactnative.ReactNativeSdkInternal
|
|
7
|
+
import com.stripe.android.googlepaylauncher.GooglePayEnvironment
|
|
8
|
+
import com.stripe.android.googlepaylauncher.GooglePayPaymentMethodLauncher
|
|
9
|
+
|
|
10
|
+
@ReactNativeSdkInternal
|
|
11
|
+
class GooglePayPaymentMethodLauncherManager(
|
|
12
|
+
context: ReactApplicationContext,
|
|
13
|
+
private val isTestEnv: Boolean,
|
|
14
|
+
private val paymentMethodRequired: Boolean,
|
|
15
|
+
) : StripeUIManager(context) {
|
|
16
|
+
override fun onPresent() {
|
|
17
|
+
val activity = getCurrentActivityOrResolveWithError(promise) ?: return
|
|
18
|
+
@SuppressLint("RestrictedApi")
|
|
19
|
+
GooglePayPaymentMethodLauncher(
|
|
20
|
+
activity = activity,
|
|
21
|
+
signal = signal,
|
|
22
|
+
config =
|
|
23
|
+
GooglePayPaymentMethodLauncher.Config(
|
|
24
|
+
environment =
|
|
25
|
+
if (isTestEnv) GooglePayEnvironment.Test else GooglePayEnvironment.Production,
|
|
26
|
+
existingPaymentMethodRequired = paymentMethodRequired,
|
|
27
|
+
merchantCountryCode =
|
|
28
|
+
"", // Unnecessary since all we are checking for is Google Pay availability
|
|
29
|
+
merchantName = "", // Same as above
|
|
30
|
+
),
|
|
31
|
+
readyCallback = {
|
|
32
|
+
promise?.resolve(it)
|
|
33
|
+
},
|
|
34
|
+
resultCallback = {},
|
|
35
|
+
)
|
|
36
|
+
}
|
|
37
|
+
}
|
|
@@ -1,20 +1,18 @@
|
|
|
1
1
|
package com.reactnativestripesdk
|
|
2
2
|
|
|
3
|
-
import
|
|
4
|
-
import
|
|
3
|
+
import android.annotation.SuppressLint
|
|
4
|
+
import androidx.activity.ComponentActivity
|
|
5
5
|
import com.facebook.react.bridge.ReactApplicationContext
|
|
6
6
|
import com.reactnativestripesdk.utils.ConfirmPaymentErrorType
|
|
7
7
|
import com.reactnativestripesdk.utils.ConfirmSetupIntentErrorType
|
|
8
|
-
import com.reactnativestripesdk.utils.
|
|
9
|
-
import com.reactnativestripesdk.utils.StripeFragment
|
|
8
|
+
import com.reactnativestripesdk.utils.StripeUIManager
|
|
10
9
|
import com.reactnativestripesdk.utils.createError
|
|
11
|
-
import com.reactnativestripesdk.utils.createMissingActivityError
|
|
12
10
|
import com.reactnativestripesdk.utils.createResult
|
|
13
11
|
import com.reactnativestripesdk.utils.mapFromPaymentIntentResult
|
|
14
12
|
import com.reactnativestripesdk.utils.mapFromSetupIntentResult
|
|
15
|
-
import com.reactnativestripesdk.utils.removeFragment
|
|
16
13
|
import com.stripe.android.ApiResultCallback
|
|
17
14
|
import com.stripe.android.Stripe
|
|
15
|
+
import com.stripe.android.core.reactnative.ReactNativeSdkInternal
|
|
18
16
|
import com.stripe.android.model.ConfirmPaymentIntentParams
|
|
19
17
|
import com.stripe.android.model.ConfirmSetupIntentParams
|
|
20
18
|
import com.stripe.android.model.PaymentIntent
|
|
@@ -24,12 +22,13 @@ import com.stripe.android.payments.paymentlauncher.PaymentLauncher
|
|
|
24
22
|
import com.stripe.android.payments.paymentlauncher.PaymentResult
|
|
25
23
|
|
|
26
24
|
/** Instances of this class should only be initialized with the companion's helper methods. */
|
|
27
|
-
class
|
|
28
|
-
|
|
25
|
+
@OptIn(ReactNativeSdkInternal::class)
|
|
26
|
+
class PaymentLauncherManager(
|
|
27
|
+
context: ReactApplicationContext,
|
|
28
|
+
) : StripeUIManager(context) {
|
|
29
29
|
private lateinit var stripe: Stripe
|
|
30
30
|
private lateinit var publishableKey: String
|
|
31
31
|
private var stripeAccountId: String? = null
|
|
32
|
-
private lateinit var promise: Promise
|
|
33
32
|
|
|
34
33
|
// Used when confirming a payment intent
|
|
35
34
|
private var paymentIntentClientSecret: String? = null
|
|
@@ -52,20 +51,17 @@ class PaymentLauncherFragment : StripeFragment() {
|
|
|
52
51
|
stripe: Stripe,
|
|
53
52
|
publishableKey: String,
|
|
54
53
|
stripeAccountId: String?,
|
|
55
|
-
promise: Promise,
|
|
56
54
|
paymentIntentClientSecret: String? = null,
|
|
57
55
|
confirmPaymentParams: ConfirmPaymentIntentParams? = null,
|
|
58
56
|
setupIntentClientSecret: String? = null,
|
|
59
57
|
confirmSetupParams: ConfirmSetupIntentParams? = null,
|
|
60
58
|
handleNextActionPaymentIntentClientSecret: String? = null,
|
|
61
59
|
handleNextActionSetupIntentClientSecret: String? = null,
|
|
62
|
-
):
|
|
63
|
-
val instance =
|
|
64
|
-
instance.context = context
|
|
60
|
+
): PaymentLauncherManager {
|
|
61
|
+
val instance = PaymentLauncherManager(context)
|
|
65
62
|
instance.stripe = stripe
|
|
66
63
|
instance.publishableKey = publishableKey
|
|
67
64
|
instance.stripeAccountId = stripeAccountId
|
|
68
|
-
instance.promise = promise
|
|
69
65
|
instance.paymentIntentClientSecret = paymentIntentClientSecret
|
|
70
66
|
instance.confirmPaymentParams = confirmPaymentParams
|
|
71
67
|
instance.setupIntentClientSecret = setupIntentClientSecret
|
|
@@ -81,21 +77,18 @@ class PaymentLauncherFragment : StripeFragment() {
|
|
|
81
77
|
stripe: Stripe,
|
|
82
78
|
publishableKey: String,
|
|
83
79
|
stripeAccountId: String?,
|
|
84
|
-
promise: Promise,
|
|
85
80
|
paymentIntentClientSecret: String,
|
|
86
81
|
confirmPaymentParams: ConfirmPaymentIntentParams,
|
|
87
|
-
):
|
|
82
|
+
): PaymentLauncherManager {
|
|
88
83
|
val paymentLauncherFragment =
|
|
89
84
|
create(
|
|
90
85
|
context,
|
|
91
86
|
stripe,
|
|
92
87
|
publishableKey,
|
|
93
88
|
stripeAccountId,
|
|
94
|
-
promise,
|
|
95
89
|
paymentIntentClientSecret = paymentIntentClientSecret,
|
|
96
90
|
confirmPaymentParams = confirmPaymentParams,
|
|
97
91
|
)
|
|
98
|
-
addFragment(paymentLauncherFragment, context, promise)
|
|
99
92
|
return paymentLauncherFragment
|
|
100
93
|
}
|
|
101
94
|
|
|
@@ -105,21 +98,18 @@ class PaymentLauncherFragment : StripeFragment() {
|
|
|
105
98
|
stripe: Stripe,
|
|
106
99
|
publishableKey: String,
|
|
107
100
|
stripeAccountId: String?,
|
|
108
|
-
promise: Promise,
|
|
109
101
|
setupIntentClientSecret: String,
|
|
110
102
|
confirmSetupParams: ConfirmSetupIntentParams,
|
|
111
|
-
):
|
|
103
|
+
): PaymentLauncherManager {
|
|
112
104
|
val paymentLauncherFragment =
|
|
113
105
|
create(
|
|
114
106
|
context,
|
|
115
107
|
stripe,
|
|
116
108
|
publishableKey,
|
|
117
109
|
stripeAccountId,
|
|
118
|
-
promise,
|
|
119
110
|
setupIntentClientSecret = setupIntentClientSecret,
|
|
120
111
|
confirmSetupParams = confirmSetupParams,
|
|
121
112
|
)
|
|
122
|
-
addFragment(paymentLauncherFragment, context, promise)
|
|
123
113
|
return paymentLauncherFragment
|
|
124
114
|
}
|
|
125
115
|
|
|
@@ -129,19 +119,16 @@ class PaymentLauncherFragment : StripeFragment() {
|
|
|
129
119
|
stripe: Stripe,
|
|
130
120
|
publishableKey: String,
|
|
131
121
|
stripeAccountId: String?,
|
|
132
|
-
promise: Promise,
|
|
133
122
|
handleNextActionPaymentIntentClientSecret: String,
|
|
134
|
-
):
|
|
123
|
+
): PaymentLauncherManager {
|
|
135
124
|
val paymentLauncherFragment =
|
|
136
125
|
create(
|
|
137
126
|
context,
|
|
138
127
|
stripe,
|
|
139
128
|
publishableKey,
|
|
140
129
|
stripeAccountId,
|
|
141
|
-
promise,
|
|
142
130
|
handleNextActionPaymentIntentClientSecret = handleNextActionPaymentIntentClientSecret,
|
|
143
131
|
)
|
|
144
|
-
addFragment(paymentLauncherFragment, context, promise)
|
|
145
132
|
return paymentLauncherFragment
|
|
146
133
|
}
|
|
147
134
|
|
|
@@ -151,44 +138,23 @@ class PaymentLauncherFragment : StripeFragment() {
|
|
|
151
138
|
stripe: Stripe,
|
|
152
139
|
publishableKey: String,
|
|
153
140
|
stripeAccountId: String?,
|
|
154
|
-
promise: Promise,
|
|
155
141
|
handleNextActionSetupIntentClientSecret: String,
|
|
156
|
-
):
|
|
142
|
+
): PaymentLauncherManager {
|
|
157
143
|
val paymentLauncherFragment =
|
|
158
144
|
create(
|
|
159
145
|
context,
|
|
160
146
|
stripe,
|
|
161
147
|
publishableKey,
|
|
162
148
|
stripeAccountId,
|
|
163
|
-
promise,
|
|
164
149
|
handleNextActionSetupIntentClientSecret = handleNextActionSetupIntentClientSecret,
|
|
165
150
|
)
|
|
166
|
-
addFragment(paymentLauncherFragment, context, promise)
|
|
167
151
|
return paymentLauncherFragment
|
|
168
152
|
}
|
|
169
|
-
|
|
170
|
-
private fun addFragment(
|
|
171
|
-
fragment: PaymentLauncherFragment,
|
|
172
|
-
context: ReactApplicationContext,
|
|
173
|
-
promise: Promise,
|
|
174
|
-
) {
|
|
175
|
-
(context.currentActivity as? FragmentActivity)?.let {
|
|
176
|
-
try {
|
|
177
|
-
it.supportFragmentManager
|
|
178
|
-
.beginTransaction()
|
|
179
|
-
.add(fragment, TAG)
|
|
180
|
-
.commit()
|
|
181
|
-
} catch (error: IllegalStateException) {
|
|
182
|
-
promise.resolve(createError(ErrorType.Failed.toString(), error.message))
|
|
183
|
-
}
|
|
184
|
-
} ?: run { promise.resolve(createMissingActivityError()) }
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
internal const val TAG = "payment_launcher_fragment"
|
|
188
153
|
}
|
|
189
154
|
|
|
190
|
-
override fun
|
|
191
|
-
|
|
155
|
+
override fun onPresent() {
|
|
156
|
+
val activity = getCurrentActivityOrResolveWithError(promise) ?: return
|
|
157
|
+
paymentLauncher = createPaymentLauncher(activity)
|
|
192
158
|
if (paymentIntentClientSecret != null && confirmPaymentParams != null) {
|
|
193
159
|
paymentLauncher.confirm(confirmPaymentParams!!)
|
|
194
160
|
} else if (setupIntentClientSecret != null && confirmSetupParams != null) {
|
|
@@ -204,8 +170,9 @@ class PaymentLauncherFragment : StripeFragment() {
|
|
|
204
170
|
}
|
|
205
171
|
}
|
|
206
172
|
|
|
207
|
-
private fun createPaymentLauncher(): PaymentLauncher =
|
|
208
|
-
|
|
173
|
+
private fun createPaymentLauncher(activity: ComponentActivity): PaymentLauncher =
|
|
174
|
+
@SuppressLint("RestrictedApi")
|
|
175
|
+
PaymentLauncher.create(activity, signal, publishableKey, stripeAccountId) { paymentResult ->
|
|
209
176
|
when (paymentResult) {
|
|
210
177
|
is PaymentResult.Completed -> {
|
|
211
178
|
paymentIntentClientSecret?.let {
|
|
@@ -219,14 +186,12 @@ class PaymentLauncherFragment : StripeFragment() {
|
|
|
219
186
|
} ?: throw Exception("Failed to create Payment Launcher. No client secret provided.")
|
|
220
187
|
}
|
|
221
188
|
is PaymentResult.Canceled -> {
|
|
222
|
-
promise
|
|
223
|
-
removeFragment(context)
|
|
189
|
+
promise?.resolve(createError(ConfirmPaymentErrorType.Canceled.toString(), message = null))
|
|
224
190
|
}
|
|
225
191
|
is PaymentResult.Failed -> {
|
|
226
|
-
promise
|
|
192
|
+
promise?.resolve(
|
|
227
193
|
createError(ConfirmPaymentErrorType.Failed.toString(), paymentResult.throwable),
|
|
228
194
|
)
|
|
229
|
-
removeFragment(context)
|
|
230
195
|
}
|
|
231
196
|
}
|
|
232
197
|
}
|
|
@@ -241,8 +206,7 @@ class PaymentLauncherFragment : StripeFragment() {
|
|
|
241
206
|
expand = listOf("payment_method"),
|
|
242
207
|
object : ApiResultCallback<SetupIntent> {
|
|
243
208
|
override fun onError(e: Exception) {
|
|
244
|
-
promise
|
|
245
|
-
removeFragment(context)
|
|
209
|
+
promise?.resolve(createError(ConfirmSetupIntentErrorType.Failed.toString(), e))
|
|
246
210
|
}
|
|
247
211
|
|
|
248
212
|
override fun onSuccess(result: SetupIntent) {
|
|
@@ -252,19 +216,19 @@ class PaymentLauncherFragment : StripeFragment() {
|
|
|
252
216
|
StripeIntent.Status.RequiresConfirmation,
|
|
253
217
|
StripeIntent.Status.RequiresCapture,
|
|
254
218
|
-> {
|
|
255
|
-
promise
|
|
219
|
+
promise?.resolve(createResult("setupIntent", mapFromSetupIntentResult(result)))
|
|
256
220
|
}
|
|
257
221
|
StripeIntent.Status.RequiresAction -> {
|
|
258
222
|
if (isNextActionSuccessState(result.nextActionType)) {
|
|
259
|
-
promise
|
|
223
|
+
promise?.resolve(createResult("setupIntent", mapFromSetupIntentResult(result)))
|
|
260
224
|
} else {
|
|
261
225
|
(result.lastSetupError)?.let {
|
|
262
|
-
promise
|
|
226
|
+
promise?.resolve(
|
|
263
227
|
createError(ConfirmSetupIntentErrorType.Canceled.toString(), it),
|
|
264
228
|
)
|
|
265
229
|
}
|
|
266
230
|
?: run {
|
|
267
|
-
promise
|
|
231
|
+
promise?.resolve(
|
|
268
232
|
createError(
|
|
269
233
|
ConfirmSetupIntentErrorType.Canceled.toString(),
|
|
270
234
|
"Setup has been canceled",
|
|
@@ -274,7 +238,7 @@ class PaymentLauncherFragment : StripeFragment() {
|
|
|
274
238
|
}
|
|
275
239
|
}
|
|
276
240
|
StripeIntent.Status.RequiresPaymentMethod -> {
|
|
277
|
-
promise
|
|
241
|
+
promise?.resolve(
|
|
278
242
|
createError(
|
|
279
243
|
ConfirmSetupIntentErrorType.Failed.toString(),
|
|
280
244
|
result.lastSetupError,
|
|
@@ -282,7 +246,7 @@ class PaymentLauncherFragment : StripeFragment() {
|
|
|
282
246
|
)
|
|
283
247
|
}
|
|
284
248
|
StripeIntent.Status.Canceled -> {
|
|
285
|
-
promise
|
|
249
|
+
promise?.resolve(
|
|
286
250
|
createError(
|
|
287
251
|
ConfirmSetupIntentErrorType.Canceled.toString(),
|
|
288
252
|
result.lastSetupError,
|
|
@@ -290,7 +254,7 @@ class PaymentLauncherFragment : StripeFragment() {
|
|
|
290
254
|
)
|
|
291
255
|
}
|
|
292
256
|
else -> {
|
|
293
|
-
promise
|
|
257
|
+
promise?.resolve(
|
|
294
258
|
createError(
|
|
295
259
|
ConfirmSetupIntentErrorType.Unknown.toString(),
|
|
296
260
|
"unhandled error: ${result.status}",
|
|
@@ -298,7 +262,6 @@ class PaymentLauncherFragment : StripeFragment() {
|
|
|
298
262
|
)
|
|
299
263
|
}
|
|
300
264
|
}
|
|
301
|
-
removeFragment(context)
|
|
302
265
|
}
|
|
303
266
|
},
|
|
304
267
|
)
|
|
@@ -314,8 +277,7 @@ class PaymentLauncherFragment : StripeFragment() {
|
|
|
314
277
|
expand = listOf("payment_method"),
|
|
315
278
|
object : ApiResultCallback<PaymentIntent> {
|
|
316
279
|
override fun onError(e: Exception) {
|
|
317
|
-
promise
|
|
318
|
-
removeFragment(context)
|
|
280
|
+
promise?.resolve(createError(ConfirmPaymentErrorType.Failed.toString(), e))
|
|
319
281
|
}
|
|
320
282
|
|
|
321
283
|
override fun onSuccess(result: PaymentIntent) {
|
|
@@ -325,17 +287,17 @@ class PaymentLauncherFragment : StripeFragment() {
|
|
|
325
287
|
StripeIntent.Status.RequiresConfirmation,
|
|
326
288
|
StripeIntent.Status.RequiresCapture,
|
|
327
289
|
-> {
|
|
328
|
-
promise
|
|
290
|
+
promise?.resolve(createResult("paymentIntent", mapFromPaymentIntentResult(result)))
|
|
329
291
|
}
|
|
330
292
|
StripeIntent.Status.RequiresAction -> {
|
|
331
293
|
if (isNextActionSuccessState(result.nextActionType)) {
|
|
332
|
-
promise
|
|
294
|
+
promise?.resolve(createResult("paymentIntent", mapFromPaymentIntentResult(result)))
|
|
333
295
|
} else {
|
|
334
296
|
(result.lastPaymentError)?.let {
|
|
335
|
-
promise
|
|
297
|
+
promise?.resolve(createError(ConfirmPaymentErrorType.Canceled.toString(), it))
|
|
336
298
|
}
|
|
337
299
|
?: run {
|
|
338
|
-
promise
|
|
300
|
+
promise?.resolve(
|
|
339
301
|
createError(
|
|
340
302
|
ConfirmPaymentErrorType.Canceled.toString(),
|
|
341
303
|
"The payment has been canceled",
|
|
@@ -345,12 +307,12 @@ class PaymentLauncherFragment : StripeFragment() {
|
|
|
345
307
|
}
|
|
346
308
|
}
|
|
347
309
|
StripeIntent.Status.RequiresPaymentMethod -> {
|
|
348
|
-
promise
|
|
310
|
+
promise?.resolve(
|
|
349
311
|
createError(ConfirmPaymentErrorType.Failed.toString(), result.lastPaymentError),
|
|
350
312
|
)
|
|
351
313
|
}
|
|
352
314
|
StripeIntent.Status.Canceled -> {
|
|
353
|
-
promise
|
|
315
|
+
promise?.resolve(
|
|
354
316
|
createError(
|
|
355
317
|
ConfirmPaymentErrorType.Canceled.toString(),
|
|
356
318
|
result.lastPaymentError,
|
|
@@ -358,7 +320,7 @@ class PaymentLauncherFragment : StripeFragment() {
|
|
|
358
320
|
)
|
|
359
321
|
}
|
|
360
322
|
else -> {
|
|
361
|
-
promise
|
|
323
|
+
promise?.resolve(
|
|
362
324
|
createError(
|
|
363
325
|
ConfirmPaymentErrorType.Unknown.toString(),
|
|
364
326
|
"unhandled error: ${result.status}",
|
|
@@ -366,7 +328,6 @@ class PaymentLauncherFragment : StripeFragment() {
|
|
|
366
328
|
)
|
|
367
329
|
}
|
|
368
330
|
}
|
|
369
|
-
removeFragment(context)
|
|
370
331
|
}
|
|
371
332
|
},
|
|
372
333
|
)
|
|
@@ -394,6 +355,7 @@ class PaymentLauncherFragment : StripeFragment() {
|
|
|
394
355
|
StripeIntent.NextActionType.UpiAwaitNotification,
|
|
395
356
|
StripeIntent.NextActionType.CashAppRedirect,
|
|
396
357
|
StripeIntent.NextActionType.SwishRedirect,
|
|
358
|
+
StripeIntent.NextActionType.DisplayPromptPayDetails,
|
|
397
359
|
null,
|
|
398
360
|
-> false
|
|
399
361
|
}
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
package com.reactnativestripesdk
|
|
2
2
|
|
|
3
3
|
import com.facebook.react.bridge.ReadableMap
|
|
4
|
-
import com.reactnativestripesdk.utils.
|
|
5
|
-
import com.reactnativestripesdk.utils.getMapOrNull
|
|
4
|
+
import com.reactnativestripesdk.utils.getBooleanOr
|
|
6
5
|
import com.reactnativestripesdk.utils.getValOr
|
|
7
6
|
import com.reactnativestripesdk.utils.mapToBillingDetails
|
|
8
7
|
import com.reactnativestripesdk.utils.mapToMetadata
|
|
@@ -25,11 +24,11 @@ class PaymentMethodCreateParamsFactory(
|
|
|
25
24
|
) {
|
|
26
25
|
private val billingDetailsParams =
|
|
27
26
|
mapToBillingDetails(
|
|
28
|
-
|
|
27
|
+
paymentMethodData?.getMap("billingDetails"),
|
|
29
28
|
cardFieldView?.cardAddress ?: cardFormView?.cardAddress,
|
|
30
29
|
)
|
|
31
30
|
private val metadataParams: Map<String, String>? =
|
|
32
|
-
mapToMetadata(
|
|
31
|
+
mapToMetadata(paymentMethodData?.getMap("metadata"))
|
|
33
32
|
|
|
34
33
|
@Throws(PaymentMethodCreateParamsException::class)
|
|
35
34
|
fun createPaymentMethodParams(paymentMethodType: PaymentMethod.Type): PaymentMethodCreateParams {
|
|
@@ -43,7 +42,6 @@ class PaymentMethodCreateParamsFactory(
|
|
|
43
42
|
PaymentMethod.Type.Billie -> createBillieParams()
|
|
44
43
|
PaymentMethod.Type.SepaDebit -> createSepaParams()
|
|
45
44
|
PaymentMethod.Type.Oxxo -> createOXXOParams()
|
|
46
|
-
PaymentMethod.Type.Giropay -> createGiropayParams()
|
|
47
45
|
PaymentMethod.Type.Eps -> createEPSParams()
|
|
48
46
|
PaymentMethod.Type.GrabPay -> createGrabPayParams()
|
|
49
47
|
PaymentMethod.Type.P24 -> createP24Params()
|
|
@@ -132,15 +130,6 @@ class PaymentMethodCreateParamsFactory(
|
|
|
132
130
|
throw PaymentMethodCreateParamsException("You must provide billing details")
|
|
133
131
|
}
|
|
134
132
|
|
|
135
|
-
@Throws(PaymentMethodCreateParamsException::class)
|
|
136
|
-
private fun createGiropayParams(): PaymentMethodCreateParams {
|
|
137
|
-
billingDetailsParams?.let {
|
|
138
|
-
return PaymentMethodCreateParams.createGiropay(billingDetails = it, metadata = metadataParams)
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
throw PaymentMethodCreateParamsException("You must provide billing details")
|
|
142
|
-
}
|
|
143
|
-
|
|
144
133
|
@Throws(PaymentMethodCreateParamsException::class)
|
|
145
134
|
private fun createEPSParams(): PaymentMethodCreateParams {
|
|
146
135
|
billingDetailsParams?.let {
|
|
@@ -167,7 +156,7 @@ class PaymentMethodCreateParamsFactory(
|
|
|
167
156
|
|
|
168
157
|
@Throws(PaymentMethodCreateParamsException::class)
|
|
169
158
|
private fun createFpxParams(): PaymentMethodCreateParams {
|
|
170
|
-
val bank =
|
|
159
|
+
val bank = paymentMethodData.getBooleanOr("testOfflineBank", false).let { "test_offline_bank" }
|
|
171
160
|
return PaymentMethodCreateParams.create(
|
|
172
161
|
PaymentMethodCreateParams.Fpx(bank),
|
|
173
162
|
metadata = metadataParams,
|
|
@@ -189,7 +178,7 @@ class PaymentMethodCreateParamsFactory(
|
|
|
189
178
|
@Throws(PaymentMethodCreateParamsException::class)
|
|
190
179
|
private fun createAuBecsDebitParams(): PaymentMethodCreateParams {
|
|
191
180
|
val formDetails =
|
|
192
|
-
|
|
181
|
+
paymentMethodData?.getMap("formDetails")
|
|
193
182
|
?: run { throw PaymentMethodCreateParamsException("You must provide form details") }
|
|
194
183
|
|
|
195
184
|
val bsbNumber = getValOr(formDetails, "bsbNumber") as String
|
|
@@ -266,7 +255,6 @@ class PaymentMethodCreateParamsFactory(
|
|
|
266
255
|
PaymentMethod.Type.Billie,
|
|
267
256
|
PaymentMethod.Type.SepaDebit,
|
|
268
257
|
PaymentMethod.Type.Oxxo,
|
|
269
|
-
PaymentMethod.Type.Giropay,
|
|
270
258
|
PaymentMethod.Type.Eps,
|
|
271
259
|
PaymentMethod.Type.GrabPay,
|
|
272
260
|
PaymentMethod.Type.P24,
|
|
@@ -455,9 +443,9 @@ class PaymentMethodCreateParamsFactory(
|
|
|
455
443
|
}
|
|
456
444
|
|
|
457
445
|
private fun buildMandateDataParams(): MandateDataParams? {
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
446
|
+
paymentMethodData?.getMap("mandateData")?.let { mandateData ->
|
|
447
|
+
mandateData.getMap("customerAcceptance")?.let { customerAcceptance ->
|
|
448
|
+
customerAcceptance.getMap("online")?.let { onlineParams ->
|
|
461
449
|
return MandateDataParams(
|
|
462
450
|
MandateDataParams.Type.Online(
|
|
463
451
|
ipAddress = getValOr(onlineParams, "ipAddress", "") ?: "",
|