@stripe/stripe-react-native 0.42.0 → 0.44.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/.husky/pre-commit +0 -3
- package/CHANGELOG.md +26 -0
- package/android/.gradle/8.11.1/checksums/checksums.lock +0 -0
- package/android/.gradle/8.11.1/checksums/md5-checksums.bin +0 -0
- package/android/.gradle/8.11.1/checksums/sha1-checksums.bin +0 -0
- package/android/.gradle/8.11.1/executionHistory/executionHistory.lock +0 -0
- package/android/.gradle/8.11.1/fileHashes/fileHashes.lock +0 -0
- package/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock +0 -0
- package/android/.gradle/buildOutputCleanup/cache.properties +2 -2
- package/android/.project +0 -11
- package/android/.settings/org.eclipse.buildship.core.prefs +3 -3
- package/android/build.gradle +8 -1
- package/android/gradle/wrapper/gradle-wrapper.jar +0 -0
- package/android/gradle/wrapper/gradle-wrapper.properties +7 -0
- package/android/gradle.properties +4 -1
- package/android/gradlew +249 -0
- package/android/gradlew.bat +92 -0
- package/android/spotless.gradle +19 -0
- package/android/src/main/java/com/reactnativestripesdk/AuBECSDebitFormView.kt +30 -34
- package/android/src/main/java/com/reactnativestripesdk/AuBECSDebitFormViewManager.kt +20 -10
- package/android/src/main/java/com/reactnativestripesdk/CardChangedEvent.kt +12 -13
- package/android/src/main/java/com/reactnativestripesdk/CardFieldView.kt +242 -105
- package/android/src/main/java/com/reactnativestripesdk/CardFieldViewManager.kt +58 -20
- package/android/src/main/java/com/reactnativestripesdk/CardFocusEvent.kt +8 -11
- package/android/src/main/java/com/reactnativestripesdk/CardFormCompleteEvent.kt +10 -12
- package/android/src/main/java/com/reactnativestripesdk/CardFormView.kt +135 -87
- package/android/src/main/java/com/reactnativestripesdk/CardFormViewManager.kt +57 -22
- package/android/src/main/java/com/reactnativestripesdk/CollectBankAccountLauncherFragment.kt +33 -24
- package/android/src/main/java/com/reactnativestripesdk/FinancialConnectionsSheetFragment.kt +107 -85
- package/android/src/main/java/com/reactnativestripesdk/FormCompleteEvent.kt +9 -11
- package/android/src/main/java/com/reactnativestripesdk/GooglePayButtonManager.kt +16 -9
- package/android/src/main/java/com/reactnativestripesdk/GooglePayButtonView.kt +36 -28
- package/android/src/main/java/com/reactnativestripesdk/GooglePayLauncherFragment.kt +67 -43
- package/android/src/main/java/com/reactnativestripesdk/GooglePayPaymentMethodLauncherFragment.kt +21 -16
- package/android/src/main/java/com/reactnativestripesdk/GooglePayRequestHelper.kt +101 -56
- package/android/src/main/java/com/reactnativestripesdk/PaymentLauncherFragment.kt +244 -166
- package/android/src/main/java/com/reactnativestripesdk/PaymentMethodCreateParamsFactory.kt +137 -156
- package/android/src/main/java/com/reactnativestripesdk/PaymentSheetAppearance.kt +181 -57
- package/android/src/main/java/com/reactnativestripesdk/PaymentSheetFragment.kt +422 -258
- package/android/src/main/java/com/reactnativestripesdk/StripeContainerManager.kt +11 -4
- package/android/src/main/java/com/reactnativestripesdk/StripeContainerView.kt +5 -1
- package/android/src/main/java/com/reactnativestripesdk/StripeSdkModule.kt +656 -299
- package/android/src/main/java/com/reactnativestripesdk/StripeSdkPackage.kt +12 -14
- package/android/src/main/java/com/reactnativestripesdk/addresssheet/AddressLauncherFragment.kt +42 -37
- package/android/src/main/java/com/reactnativestripesdk/addresssheet/AddressSheetEvent.kt +12 -11
- package/android/src/main/java/com/reactnativestripesdk/addresssheet/AddressSheetView.kt +29 -29
- package/android/src/main/java/com/reactnativestripesdk/addresssheet/AddressSheetViewManager.kt +50 -18
- package/android/src/main/java/com/reactnativestripesdk/customersheet/CustomerSheetFragment.kt +227 -147
- package/android/src/main/java/com/reactnativestripesdk/customersheet/ReactNativeCustomerAdapter.kt +15 -18
- package/android/src/main/java/com/reactnativestripesdk/pushprovisioning/AddToWalletButtonManager.kt +33 -15
- package/android/src/main/java/com/reactnativestripesdk/pushprovisioning/AddToWalletButtonView.kt +63 -37
- package/android/src/main/java/com/reactnativestripesdk/pushprovisioning/AddToWalletCompleteEvent.kt +9 -13
- package/android/src/main/java/com/reactnativestripesdk/pushprovisioning/EphemeralKeyProvider.kt +15 -17
- package/android/src/main/java/com/reactnativestripesdk/pushprovisioning/PushProvisioningProxy.kt +76 -60
- package/android/src/main/java/com/reactnativestripesdk/pushprovisioning/TapAndPayProxy.kt +71 -47
- package/android/src/main/java/com/reactnativestripesdk/utils/Errors.kt +117 -51
- package/android/src/main/java/com/reactnativestripesdk/utils/Extensions.kt +4 -3
- package/android/src/main/java/com/reactnativestripesdk/utils/KeepJsAwakeTask.kt +39 -0
- package/android/src/main/java/com/reactnativestripesdk/utils/Mappers.kt +295 -258
- package/android/src/main/java/com/reactnativestripesdk/utils/PostalCodeUtilities.kt +2 -11
- package/ios/CustomerSheet/CustomerSheetUtils.swift +13 -7
- package/ios/FinancialConnections.swift +6 -2
- package/ios/StripeSdk+CustomerSheet.swift +3 -1
- package/ios/StripeSdk+PaymentSheet.swift +86 -21
- package/ios/StripeSdk.m +2 -0
- package/ios/StripeSdk.swift +72 -11
- package/lib/commonjs/NativeStripeSdk.js +1 -1
- package/lib/commonjs/NativeStripeSdk.js.map +1 -1
- 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/ApplePayButtonNative.js +1 -1
- package/lib/commonjs/components/ApplePayButtonNative.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/CustomerSheet.js +1 -1
- package/lib/commonjs/components/CustomerSheet.js.map +1 -1
- package/lib/commonjs/components/GooglePayButtonNative.js +1 -1
- package/lib/commonjs/components/GooglePayButtonNative.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/functions.js +1 -1
- package/lib/commonjs/functions.js.map +1 -1
- package/lib/commonjs/helpers.js +1 -1
- package/lib/commonjs/helpers.js.map +1 -1
- package/lib/commonjs/hooks/useConfirmPayment.js.map +1 -1
- package/lib/commonjs/hooks/useConfirmSetupIntent.js.map +1 -1
- package/lib/commonjs/hooks/useFinancialConnectionsSheet.js.map +1 -1
- package/lib/commonjs/hooks/usePaymentSheet.js.map +1 -1
- package/lib/commonjs/hooks/usePlatformPay.js.map +1 -1
- package/lib/commonjs/hooks/useStripe.js.map +1 -1
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/package.json +1 -0
- package/lib/commonjs/plugin/withStripe.js +1 -1
- package/lib/commonjs/plugin/withStripe.js.map +1 -1
- package/lib/commonjs/types/ApplePay.js.map +1 -1
- package/lib/commonjs/types/Common.js +1 -1
- package/lib/commonjs/types/Common.js.map +1 -1
- package/lib/commonjs/types/CustomerSheet.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/FinancialConnections.js +1 -1
- package/lib/commonjs/types/FinancialConnections.js.map +1 -1
- package/lib/commonjs/types/NextAction.js.map +1 -1
- package/lib/commonjs/types/PaymentIntent.js +1 -1
- package/lib/commonjs/types/PaymentIntent.js.map +1 -1
- package/lib/commonjs/types/PaymentMethod.js.map +1 -1
- package/lib/commonjs/types/PaymentSheet.js +1 -1
- package/lib/commonjs/types/PaymentSheet.js.map +1 -1
- package/lib/commonjs/types/PlatformPay.js +1 -1
- package/lib/commonjs/types/PlatformPay.js.map +1 -1
- package/lib/commonjs/types/PushProvisioning.js +1 -1
- package/lib/commonjs/types/PushProvisioning.js.map +1 -1
- package/lib/commonjs/types/SetupIntent.js +1 -1
- package/lib/commonjs/types/SetupIntent.js.map +1 -1
- package/lib/commonjs/types/ThreeDSecure.js +1 -1
- package/lib/commonjs/types/ThreeDSecure.js.map +1 -1
- package/lib/commonjs/types/Token.js.map +1 -1
- package/lib/commonjs/types/components/ApplePayButtonComponent.js.map +1 -1
- package/lib/commonjs/types/components/AuBECSDebitFormComponent.js.map +1 -1
- package/lib/commonjs/types/components/CardFieldInput.js +1 -1
- package/lib/commonjs/types/components/CardFieldInput.js.map +1 -1
- package/lib/commonjs/types/components/CardFormView.js.map +1 -1
- package/lib/commonjs/types/components/GooglePayButtonComponent.js.map +1 -1
- package/lib/commonjs/types/index.js +1 -1
- package/lib/commonjs/types/index.js.map +1 -1
- package/lib/module/NativeStripeSdk.js +1 -1
- package/lib/module/NativeStripeSdk.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/ApplePayButtonNative.js +1 -1
- package/lib/module/components/ApplePayButtonNative.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/CustomerSheet.js +1 -1
- package/lib/module/components/CustomerSheet.js.map +1 -1
- package/lib/module/components/GooglePayButtonNative.js +1 -1
- package/lib/module/components/GooglePayButtonNative.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/functions.js +1 -1
- package/lib/module/functions.js.map +1 -1
- package/lib/module/helpers.js +1 -1
- package/lib/module/helpers.js.map +1 -1
- package/lib/module/hooks/useConfirmPayment.js.map +1 -1
- package/lib/module/hooks/useConfirmSetupIntent.js.map +1 -1
- package/lib/module/hooks/useFinancialConnectionsSheet.js.map +1 -1
- package/lib/module/hooks/usePaymentSheet.js.map +1 -1
- package/lib/module/hooks/usePlatformPay.js.map +1 -1
- package/lib/module/hooks/useStripe.js.map +1 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/package.json +1 -0
- package/lib/module/plugin/withStripe.js +1 -1
- package/lib/module/plugin/withStripe.js.map +1 -1
- package/lib/module/types/ApplePay.js.map +1 -1
- package/lib/module/types/Common.js +1 -1
- package/lib/module/types/Common.js.map +1 -1
- package/lib/module/types/CustomerSheet.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/FinancialConnections.js +1 -1
- package/lib/module/types/FinancialConnections.js.map +1 -1
- package/lib/module/types/NextAction.js.map +1 -1
- package/lib/module/types/PaymentIntent.js +1 -1
- package/lib/module/types/PaymentIntent.js.map +1 -1
- package/lib/module/types/PaymentMethod.js.map +1 -1
- package/lib/module/types/PaymentSheet.js +1 -1
- package/lib/module/types/PaymentSheet.js.map +1 -1
- package/lib/module/types/PlatformPay.js +1 -1
- package/lib/module/types/PlatformPay.js.map +1 -1
- package/lib/module/types/PushProvisioning.js +1 -1
- package/lib/module/types/PushProvisioning.js.map +1 -1
- package/lib/module/types/SetupIntent.js +1 -1
- package/lib/module/types/SetupIntent.js.map +1 -1
- package/lib/module/types/ThreeDSecure.js +1 -1
- package/lib/module/types/ThreeDSecure.js.map +1 -1
- package/lib/module/types/Token.js.map +1 -1
- package/lib/module/types/components/ApplePayButtonComponent.js.map +1 -1
- package/lib/module/types/components/AuBECSDebitFormComponent.js.map +1 -1
- package/lib/module/types/components/CardFieldInput.js +1 -1
- package/lib/module/types/components/CardFieldInput.js.map +1 -1
- package/lib/module/types/components/CardFormView.js.map +1 -1
- package/lib/module/types/components/GooglePayButtonComponent.js.map +1 -1
- package/lib/module/types/index.js +1 -1
- package/lib/module/types/index.js.map +1 -1
- package/lib/typescript/src/NativeStripeSdk.d.ts +4 -3
- package/lib/typescript/src/NativeStripeSdk.d.ts.map +1 -0
- package/lib/typescript/src/components/AddToWalletButton.d.ts +3 -1
- package/lib/typescript/src/components/AddToWalletButton.d.ts.map +1 -0
- package/lib/typescript/src/components/AddressSheet.d.ts +4 -2
- package/lib/typescript/src/components/AddressSheet.d.ts.map +1 -0
- package/lib/typescript/src/components/ApplePayButtonNative.d.ts +1 -0
- package/lib/typescript/src/components/ApplePayButtonNative.d.ts.map +1 -0
- package/lib/typescript/src/components/AuBECSDebitForm.d.ts +3 -1
- package/lib/typescript/src/components/AuBECSDebitForm.d.ts.map +1 -0
- package/lib/typescript/src/components/CardField.d.ts +1 -0
- package/lib/typescript/src/components/CardField.d.ts.map +1 -0
- package/lib/typescript/src/components/CardForm.d.ts +1 -0
- package/lib/typescript/src/components/CardForm.d.ts.map +1 -0
- package/lib/typescript/src/components/CustomerSheet.d.ts +2 -1
- package/lib/typescript/src/components/CustomerSheet.d.ts.map +1 -0
- package/lib/typescript/src/components/GooglePayButtonNative.d.ts +1 -0
- package/lib/typescript/src/components/GooglePayButtonNative.d.ts.map +1 -0
- package/lib/typescript/src/components/PlatformPayButton.d.ts +3 -1
- package/lib/typescript/src/components/PlatformPayButton.d.ts.map +1 -0
- package/lib/typescript/src/components/StripeContainer.d.ts +2 -1
- package/lib/typescript/src/components/StripeContainer.d.ts.map +1 -0
- package/lib/typescript/src/components/StripeProvider.d.ts +3 -2
- package/lib/typescript/src/components/StripeProvider.d.ts.map +1 -0
- package/lib/typescript/src/functions.d.ts +6 -5
- package/lib/typescript/src/functions.d.ts.map +1 -0
- package/lib/typescript/src/helpers.d.ts +1 -0
- package/lib/typescript/src/helpers.d.ts.map +1 -0
- package/lib/typescript/src/hooks/useConfirmPayment.d.ts +2 -1
- package/lib/typescript/src/hooks/useConfirmPayment.d.ts.map +1 -0
- package/lib/typescript/src/hooks/useConfirmSetupIntent.d.ts +1 -0
- package/lib/typescript/src/hooks/useConfirmSetupIntent.d.ts.map +1 -0
- package/lib/typescript/src/hooks/useFinancialConnectionsSheet.d.ts +3 -2
- package/lib/typescript/src/hooks/useFinancialConnectionsSheet.d.ts.map +1 -0
- package/lib/typescript/src/hooks/usePaymentSheet.d.ts +2 -1
- package/lib/typescript/src/hooks/usePaymentSheet.d.ts.map +1 -0
- package/lib/typescript/src/hooks/usePlatformPay.d.ts +4 -3
- package/lib/typescript/src/hooks/usePlatformPay.d.ts.map +1 -0
- package/lib/typescript/src/hooks/useStripe.d.ts +11 -8
- package/lib/typescript/src/hooks/useStripe.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +1 -0
- package/lib/typescript/src/index.d.ts.map +1 -0
- package/lib/typescript/src/plugin/withStripe.d.ts +2 -1
- package/lib/typescript/src/plugin/withStripe.d.ts.map +1 -0
- package/lib/typescript/src/types/ApplePay.d.ts +6 -5
- package/lib/typescript/src/types/ApplePay.d.ts.map +1 -0
- package/lib/typescript/src/types/Common.d.ts +4 -1
- package/lib/typescript/src/types/Common.d.ts.map +1 -0
- package/lib/typescript/src/types/CustomerSheet.d.ts +16 -4
- package/lib/typescript/src/types/CustomerSheet.d.ts.map +1 -0
- package/lib/typescript/src/types/Errors.d.ts +2 -1
- package/lib/typescript/src/types/Errors.d.ts.map +1 -0
- package/lib/typescript/src/types/FinancialConnections.d.ts +21 -17
- package/lib/typescript/src/types/FinancialConnections.d.ts.map +1 -0
- package/lib/typescript/src/types/NextAction.d.ts +9 -8
- package/lib/typescript/src/types/NextAction.d.ts.map +1 -0
- package/lib/typescript/src/types/PaymentIntent.d.ts +16 -15
- package/lib/typescript/src/types/PaymentIntent.d.ts.map +1 -0
- package/lib/typescript/src/types/PaymentMethod.d.ts +21 -16
- package/lib/typescript/src/types/PaymentMethod.d.ts.map +1 -0
- package/lib/typescript/src/types/PaymentSheet.d.ts +91 -22
- package/lib/typescript/src/types/PaymentSheet.d.ts.map +1 -0
- package/lib/typescript/src/types/PlatformPay.d.ts +22 -21
- package/lib/typescript/src/types/PlatformPay.d.ts.map +1 -0
- package/lib/typescript/src/types/PushProvisioning.d.ts +5 -4
- package/lib/typescript/src/types/PushProvisioning.d.ts.map +1 -0
- package/lib/typescript/src/types/SetupIntent.d.ts +4 -3
- package/lib/typescript/src/types/SetupIntent.d.ts.map +1 -0
- package/lib/typescript/src/types/ThreeDSecure.d.ts +1 -0
- package/lib/typescript/src/types/ThreeDSecure.d.ts.map +1 -0
- package/lib/typescript/src/types/Token.d.ts +10 -9
- package/lib/typescript/src/types/Token.d.ts.map +1 -0
- package/lib/typescript/src/types/components/ApplePayButtonComponent.d.ts +3 -2
- package/lib/typescript/src/types/components/ApplePayButtonComponent.d.ts.map +1 -0
- package/lib/typescript/src/types/components/AuBECSDebitFormComponent.d.ts +1 -0
- package/lib/typescript/src/types/components/AuBECSDebitFormComponent.d.ts.map +1 -0
- package/lib/typescript/src/types/components/CardFieldInput.d.ts +8 -5
- package/lib/typescript/src/types/components/CardFieldInput.d.ts.map +1 -0
- package/lib/typescript/src/types/components/CardFormView.d.ts +9 -6
- package/lib/typescript/src/types/components/CardFormView.d.ts.map +1 -0
- package/lib/typescript/src/types/components/GooglePayButtonComponent.d.ts +1 -0
- package/lib/typescript/src/types/components/GooglePayButtonComponent.d.ts.map +1 -0
- package/lib/typescript/src/types/index.d.ts +24 -23
- package/lib/typescript/src/types/index.d.ts.map +1 -0
- package/package.json +32 -40
- package/src/NativeStripeSdk.tsx +4 -2
- package/src/components/CardField.tsx +1 -1
- package/src/components/CardForm.tsx +12 -9
- package/src/components/CustomerSheet.tsx +4 -6
- package/src/components/StripeProvider.tsx +17 -0
- package/src/functions.ts +13 -14
- package/src/helpers.ts +2 -1
- package/src/types/Common.ts +3 -0
- package/src/types/CustomerSheet.ts +11 -0
- package/src/types/FinancialConnections.ts +3 -0
- package/src/types/PaymentMethod.ts +5 -1
- package/src/types/PaymentSheet.ts +85 -4
- package/src/types/components/CardFieldInput.ts +8 -4
- package/src/types/components/CardFormView.ts +8 -4
- package/stripe-react-native.podspec +2 -1
- package/android/.gradle/8.9/checksums/checksums.lock +0 -0
- package/android/.gradle/8.9/fileHashes/fileHashes.lock +0 -0
- package/android/.gradle/8.9/gc.properties +0 -0
- /package/android/.gradle/{8.9 → 8.11.1}/fileChanges/last-build.bin +0 -0
- /package/android/.gradle/{8.9/dependencies-accessors → 8.11.1}/gc.properties +0 -0
|
@@ -9,18 +9,26 @@ import androidx.fragment.app.Fragment
|
|
|
9
9
|
import androidx.fragment.app.FragmentActivity
|
|
10
10
|
import com.facebook.react.bridge.Promise
|
|
11
11
|
import com.facebook.react.bridge.ReactApplicationContext
|
|
12
|
-
import com.reactnativestripesdk.utils
|
|
12
|
+
import com.reactnativestripesdk.utils.ConfirmPaymentErrorType
|
|
13
|
+
import com.reactnativestripesdk.utils.ConfirmSetupIntentErrorType
|
|
14
|
+
import com.reactnativestripesdk.utils.ErrorType
|
|
13
15
|
import com.reactnativestripesdk.utils.createError
|
|
14
16
|
import com.reactnativestripesdk.utils.createMissingActivityError
|
|
17
|
+
import com.reactnativestripesdk.utils.createResult
|
|
18
|
+
import com.reactnativestripesdk.utils.mapFromPaymentIntentResult
|
|
19
|
+
import com.reactnativestripesdk.utils.mapFromSetupIntentResult
|
|
20
|
+
import com.reactnativestripesdk.utils.removeFragment
|
|
15
21
|
import com.stripe.android.ApiResultCallback
|
|
16
22
|
import com.stripe.android.Stripe
|
|
17
|
-
import com.stripe.android.model
|
|
23
|
+
import com.stripe.android.model.ConfirmPaymentIntentParams
|
|
24
|
+
import com.stripe.android.model.ConfirmSetupIntentParams
|
|
25
|
+
import com.stripe.android.model.PaymentIntent
|
|
26
|
+
import com.stripe.android.model.SetupIntent
|
|
27
|
+
import com.stripe.android.model.StripeIntent
|
|
18
28
|
import com.stripe.android.payments.paymentlauncher.PaymentLauncher
|
|
19
29
|
import com.stripe.android.payments.paymentlauncher.PaymentResult
|
|
20
30
|
|
|
21
|
-
/**
|
|
22
|
-
* Instances of this class should only be initialized with the companion's helper methods.
|
|
23
|
-
*/
|
|
31
|
+
/** Instances of this class should only be initialized with the companion's helper methods. */
|
|
24
32
|
class PaymentLauncherFragment(
|
|
25
33
|
private val context: ReactApplicationContext,
|
|
26
34
|
private val stripe: Stripe,
|
|
@@ -41,113 +49,123 @@ class PaymentLauncherFragment(
|
|
|
41
49
|
private lateinit var paymentLauncher: PaymentLauncher
|
|
42
50
|
|
|
43
51
|
companion object {
|
|
44
|
-
/**
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
val paymentLauncherFragment =
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
52
|
+
/** Helper-constructor used for confirming payment intents */
|
|
53
|
+
fun forPayment(
|
|
54
|
+
context: ReactApplicationContext,
|
|
55
|
+
stripe: Stripe,
|
|
56
|
+
publishableKey: String,
|
|
57
|
+
stripeAccountId: String?,
|
|
58
|
+
promise: Promise,
|
|
59
|
+
paymentIntentClientSecret: String,
|
|
60
|
+
confirmPaymentParams: ConfirmPaymentIntentParams,
|
|
61
|
+
): PaymentLauncherFragment {
|
|
62
|
+
val paymentLauncherFragment =
|
|
63
|
+
PaymentLauncherFragment(
|
|
64
|
+
context,
|
|
65
|
+
stripe,
|
|
66
|
+
publishableKey,
|
|
67
|
+
stripeAccountId,
|
|
68
|
+
promise,
|
|
69
|
+
paymentIntentClientSecret = paymentIntentClientSecret,
|
|
70
|
+
confirmPaymentParams = confirmPaymentParams,
|
|
71
|
+
)
|
|
63
72
|
addFragment(paymentLauncherFragment, context, promise)
|
|
64
73
|
return paymentLauncherFragment
|
|
65
74
|
}
|
|
66
75
|
|
|
67
|
-
/**
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
val paymentLauncherFragment =
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
76
|
+
/** Helper-constructor used for confirming setup intents */
|
|
77
|
+
fun forSetup(
|
|
78
|
+
context: ReactApplicationContext,
|
|
79
|
+
stripe: Stripe,
|
|
80
|
+
publishableKey: String,
|
|
81
|
+
stripeAccountId: String?,
|
|
82
|
+
promise: Promise,
|
|
83
|
+
setupIntentClientSecret: String,
|
|
84
|
+
confirmSetupParams: ConfirmSetupIntentParams,
|
|
85
|
+
): PaymentLauncherFragment {
|
|
86
|
+
val paymentLauncherFragment =
|
|
87
|
+
PaymentLauncherFragment(
|
|
88
|
+
context,
|
|
89
|
+
stripe,
|
|
90
|
+
publishableKey,
|
|
91
|
+
stripeAccountId,
|
|
92
|
+
promise,
|
|
93
|
+
setupIntentClientSecret = setupIntentClientSecret,
|
|
94
|
+
confirmSetupParams = confirmSetupParams,
|
|
95
|
+
)
|
|
86
96
|
addFragment(paymentLauncherFragment, context, promise)
|
|
87
97
|
return paymentLauncherFragment
|
|
88
98
|
}
|
|
89
99
|
|
|
90
|
-
/**
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
val paymentLauncherFragment =
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
100
|
+
/** Helper-constructor used for handling the next action on a payment intent */
|
|
101
|
+
fun forNextActionPayment(
|
|
102
|
+
context: ReactApplicationContext,
|
|
103
|
+
stripe: Stripe,
|
|
104
|
+
publishableKey: String,
|
|
105
|
+
stripeAccountId: String?,
|
|
106
|
+
promise: Promise,
|
|
107
|
+
handleNextActionPaymentIntentClientSecret: String,
|
|
108
|
+
): PaymentLauncherFragment {
|
|
109
|
+
val paymentLauncherFragment =
|
|
110
|
+
PaymentLauncherFragment(
|
|
111
|
+
context,
|
|
112
|
+
stripe,
|
|
113
|
+
publishableKey,
|
|
114
|
+
stripeAccountId,
|
|
115
|
+
promise,
|
|
116
|
+
handleNextActionPaymentIntentClientSecret = handleNextActionPaymentIntentClientSecret,
|
|
117
|
+
)
|
|
107
118
|
addFragment(paymentLauncherFragment, context, promise)
|
|
108
119
|
return paymentLauncherFragment
|
|
109
120
|
}
|
|
110
121
|
|
|
111
|
-
/**
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
val paymentLauncherFragment =
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
122
|
+
/** Helper-constructor used for handling the next action on a setup intent */
|
|
123
|
+
fun forNextActionSetup(
|
|
124
|
+
context: ReactApplicationContext,
|
|
125
|
+
stripe: Stripe,
|
|
126
|
+
publishableKey: String,
|
|
127
|
+
stripeAccountId: String?,
|
|
128
|
+
promise: Promise,
|
|
129
|
+
handleNextActionSetupIntentClientSecret: String,
|
|
130
|
+
): PaymentLauncherFragment {
|
|
131
|
+
val paymentLauncherFragment =
|
|
132
|
+
PaymentLauncherFragment(
|
|
133
|
+
context,
|
|
134
|
+
stripe,
|
|
135
|
+
publishableKey,
|
|
136
|
+
stripeAccountId,
|
|
137
|
+
promise,
|
|
138
|
+
handleNextActionSetupIntentClientSecret = handleNextActionSetupIntentClientSecret,
|
|
139
|
+
)
|
|
128
140
|
addFragment(paymentLauncherFragment, context, promise)
|
|
129
141
|
return paymentLauncherFragment
|
|
130
142
|
}
|
|
131
143
|
|
|
132
|
-
private fun addFragment(
|
|
144
|
+
private fun addFragment(
|
|
145
|
+
fragment: PaymentLauncherFragment,
|
|
146
|
+
context: ReactApplicationContext,
|
|
147
|
+
promise: Promise,
|
|
148
|
+
) {
|
|
133
149
|
(context.currentActivity as? FragmentActivity)?.let {
|
|
134
150
|
try {
|
|
135
|
-
it.supportFragmentManager
|
|
151
|
+
it.supportFragmentManager
|
|
152
|
+
.beginTransaction()
|
|
136
153
|
.add(fragment, TAG)
|
|
137
154
|
.commit()
|
|
138
155
|
} catch (error: IllegalStateException) {
|
|
139
156
|
promise.resolve(createError(ErrorType.Failed.toString(), error.message))
|
|
140
157
|
}
|
|
141
|
-
} ?: run {
|
|
142
|
-
promise.resolve(createMissingActivityError())
|
|
143
|
-
}
|
|
158
|
+
} ?: run { promise.resolve(createMissingActivityError()) }
|
|
144
159
|
}
|
|
145
160
|
|
|
146
161
|
internal const val TAG = "payment_launcher_fragment"
|
|
147
162
|
}
|
|
148
163
|
|
|
149
|
-
override fun onCreateView(
|
|
150
|
-
|
|
164
|
+
override fun onCreateView(
|
|
165
|
+
inflater: LayoutInflater,
|
|
166
|
+
container: ViewGroup?,
|
|
167
|
+
savedInstanceState: Bundle?,
|
|
168
|
+
): View {
|
|
151
169
|
paymentLauncher = createPaymentLauncher()
|
|
152
170
|
if (paymentIntentClientSecret != null && confirmPaymentParams != null) {
|
|
153
171
|
paymentLauncher.confirm(confirmPaymentParams)
|
|
@@ -158,15 +176,15 @@ class PaymentLauncherFragment(
|
|
|
158
176
|
} else if (handleNextActionSetupIntentClientSecret != null) {
|
|
159
177
|
paymentLauncher.handleNextActionForSetupIntent(handleNextActionSetupIntentClientSecret)
|
|
160
178
|
} else {
|
|
161
|
-
throw Exception(
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
it.visibility = View.GONE
|
|
179
|
+
throw Exception(
|
|
180
|
+
"Invalid parameters provided to PaymentLauncher. Ensure that you are providing the correct client secret and setup params (if necessary).",
|
|
181
|
+
)
|
|
165
182
|
}
|
|
183
|
+
return FrameLayout(requireActivity()).also { it.visibility = View.GONE }
|
|
166
184
|
}
|
|
167
185
|
|
|
168
|
-
private fun createPaymentLauncher(): PaymentLauncher
|
|
169
|
-
|
|
186
|
+
private fun createPaymentLauncher(): PaymentLauncher =
|
|
187
|
+
PaymentLauncher.create(this, publishableKey, stripeAccountId) { paymentResult ->
|
|
170
188
|
when (paymentResult) {
|
|
171
189
|
is PaymentResult.Completed -> {
|
|
172
190
|
if (paymentIntentClientSecret != null) {
|
|
@@ -186,106 +204,167 @@ class PaymentLauncherFragment(
|
|
|
186
204
|
removeFragment(context)
|
|
187
205
|
}
|
|
188
206
|
is PaymentResult.Failed -> {
|
|
189
|
-
promise.resolve(
|
|
207
|
+
promise.resolve(
|
|
208
|
+
createError(ConfirmPaymentErrorType.Failed.toString(), paymentResult.throwable),
|
|
209
|
+
)
|
|
190
210
|
removeFragment(context)
|
|
191
211
|
}
|
|
192
212
|
}
|
|
193
213
|
}
|
|
194
|
-
}
|
|
195
214
|
|
|
196
|
-
private fun retrieveSetupIntent(
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
215
|
+
private fun retrieveSetupIntent(
|
|
216
|
+
clientSecret: String,
|
|
217
|
+
stripeAccountId: String?,
|
|
218
|
+
) {
|
|
219
|
+
stripe.retrieveSetupIntent(
|
|
220
|
+
clientSecret,
|
|
221
|
+
stripeAccountId,
|
|
222
|
+
expand = listOf("payment_method"),
|
|
223
|
+
object : ApiResultCallback<SetupIntent> {
|
|
224
|
+
override fun onError(e: Exception) {
|
|
225
|
+
promise.resolve(createError(ConfirmSetupIntentErrorType.Failed.toString(), e))
|
|
226
|
+
removeFragment(context)
|
|
227
|
+
}
|
|
202
228
|
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
}
|
|
211
|
-
StripeIntent.Status.RequiresAction -> {
|
|
212
|
-
if (isNextActionSuccessState(result.nextActionType)) {
|
|
229
|
+
override fun onSuccess(result: SetupIntent) {
|
|
230
|
+
when (result.status) {
|
|
231
|
+
StripeIntent.Status.Succeeded,
|
|
232
|
+
StripeIntent.Status.Processing,
|
|
233
|
+
StripeIntent.Status.RequiresConfirmation,
|
|
234
|
+
StripeIntent.Status.RequiresCapture,
|
|
235
|
+
-> {
|
|
213
236
|
promise.resolve(createResult("setupIntent", mapFromSetupIntentResult(result)))
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
237
|
+
}
|
|
238
|
+
StripeIntent.Status.RequiresAction -> {
|
|
239
|
+
if (isNextActionSuccessState(result.nextActionType)) {
|
|
240
|
+
promise.resolve(createResult("setupIntent", mapFromSetupIntentResult(result)))
|
|
241
|
+
} else {
|
|
242
|
+
(result.lastSetupError)?.let {
|
|
243
|
+
promise.resolve(
|
|
244
|
+
createError(ConfirmSetupIntentErrorType.Canceled.toString(), it),
|
|
245
|
+
)
|
|
246
|
+
}
|
|
247
|
+
?: run {
|
|
248
|
+
promise.resolve(
|
|
249
|
+
createError(
|
|
250
|
+
ConfirmSetupIntentErrorType.Canceled.toString(),
|
|
251
|
+
"Setup has been canceled",
|
|
252
|
+
),
|
|
253
|
+
)
|
|
254
|
+
}
|
|
219
255
|
}
|
|
220
256
|
}
|
|
257
|
+
StripeIntent.Status.RequiresPaymentMethod -> {
|
|
258
|
+
promise.resolve(
|
|
259
|
+
createError(
|
|
260
|
+
ConfirmSetupIntentErrorType.Failed.toString(),
|
|
261
|
+
result.lastSetupError,
|
|
262
|
+
),
|
|
263
|
+
)
|
|
264
|
+
}
|
|
265
|
+
StripeIntent.Status.Canceled -> {
|
|
266
|
+
promise.resolve(
|
|
267
|
+
createError(
|
|
268
|
+
ConfirmSetupIntentErrorType.Canceled.toString(),
|
|
269
|
+
result.lastSetupError,
|
|
270
|
+
),
|
|
271
|
+
)
|
|
272
|
+
}
|
|
273
|
+
else -> {
|
|
274
|
+
promise.resolve(
|
|
275
|
+
createError(
|
|
276
|
+
ConfirmSetupIntentErrorType.Unknown.toString(),
|
|
277
|
+
"unhandled error: ${result.status}",
|
|
278
|
+
),
|
|
279
|
+
)
|
|
280
|
+
}
|
|
221
281
|
}
|
|
222
|
-
|
|
223
|
-
promise.resolve(createError(ConfirmSetupIntentErrorType.Failed.toString(), result.lastSetupError))
|
|
224
|
-
}
|
|
225
|
-
StripeIntent.Status.Canceled -> {
|
|
226
|
-
promise.resolve(createError(ConfirmSetupIntentErrorType.Canceled.toString(), result.lastSetupError))
|
|
227
|
-
}
|
|
228
|
-
else -> {
|
|
229
|
-
promise.resolve(createError(ConfirmSetupIntentErrorType.Unknown.toString(), "unhandled error: ${result.status}"))
|
|
230
|
-
}
|
|
282
|
+
removeFragment(context)
|
|
231
283
|
}
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
})
|
|
284
|
+
},
|
|
285
|
+
)
|
|
235
286
|
}
|
|
236
287
|
|
|
237
|
-
private fun retrievePaymentIntent(
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
288
|
+
private fun retrievePaymentIntent(
|
|
289
|
+
clientSecret: String,
|
|
290
|
+
stripeAccountId: String?,
|
|
291
|
+
) {
|
|
292
|
+
stripe.retrievePaymentIntent(
|
|
293
|
+
clientSecret,
|
|
294
|
+
stripeAccountId,
|
|
295
|
+
expand = listOf("payment_method"),
|
|
296
|
+
object : ApiResultCallback<PaymentIntent> {
|
|
297
|
+
override fun onError(e: Exception) {
|
|
298
|
+
promise.resolve(createError(ConfirmPaymentErrorType.Failed.toString(), e))
|
|
299
|
+
removeFragment(context)
|
|
300
|
+
}
|
|
243
301
|
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
}
|
|
252
|
-
StripeIntent.Status.RequiresAction -> {
|
|
253
|
-
if (isNextActionSuccessState(result.nextActionType)) {
|
|
302
|
+
override fun onSuccess(result: PaymentIntent) {
|
|
303
|
+
when (result.status) {
|
|
304
|
+
StripeIntent.Status.Succeeded,
|
|
305
|
+
StripeIntent.Status.Processing,
|
|
306
|
+
StripeIntent.Status.RequiresConfirmation,
|
|
307
|
+
StripeIntent.Status.RequiresCapture,
|
|
308
|
+
-> {
|
|
254
309
|
promise.resolve(createResult("paymentIntent", mapFromPaymentIntentResult(result)))
|
|
255
|
-
}
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
310
|
+
}
|
|
311
|
+
StripeIntent.Status.RequiresAction -> {
|
|
312
|
+
if (isNextActionSuccessState(result.nextActionType)) {
|
|
313
|
+
promise.resolve(createResult("paymentIntent", mapFromPaymentIntentResult(result)))
|
|
314
|
+
} else {
|
|
315
|
+
(result.lastPaymentError)?.let {
|
|
316
|
+
promise.resolve(createError(ConfirmPaymentErrorType.Canceled.toString(), it))
|
|
317
|
+
}
|
|
318
|
+
?: run {
|
|
319
|
+
promise.resolve(
|
|
320
|
+
createError(
|
|
321
|
+
ConfirmPaymentErrorType.Canceled.toString(),
|
|
322
|
+
"The payment has been canceled",
|
|
323
|
+
),
|
|
324
|
+
)
|
|
325
|
+
}
|
|
260
326
|
}
|
|
261
327
|
}
|
|
328
|
+
StripeIntent.Status.RequiresPaymentMethod -> {
|
|
329
|
+
promise.resolve(
|
|
330
|
+
createError(ConfirmPaymentErrorType.Failed.toString(), result.lastPaymentError),
|
|
331
|
+
)
|
|
332
|
+
}
|
|
333
|
+
StripeIntent.Status.Canceled -> {
|
|
334
|
+
promise.resolve(
|
|
335
|
+
createError(
|
|
336
|
+
ConfirmPaymentErrorType.Canceled.toString(),
|
|
337
|
+
result.lastPaymentError,
|
|
338
|
+
),
|
|
339
|
+
)
|
|
340
|
+
}
|
|
341
|
+
else -> {
|
|
342
|
+
promise.resolve(
|
|
343
|
+
createError(
|
|
344
|
+
ConfirmPaymentErrorType.Unknown.toString(),
|
|
345
|
+
"unhandled error: ${result.status}",
|
|
346
|
+
),
|
|
347
|
+
)
|
|
348
|
+
}
|
|
262
349
|
}
|
|
263
|
-
|
|
264
|
-
promise.resolve(createError(ConfirmPaymentErrorType.Failed.toString(), result.lastPaymentError))
|
|
265
|
-
}
|
|
266
|
-
StripeIntent.Status.Canceled -> {
|
|
267
|
-
promise.resolve(createError(ConfirmPaymentErrorType.Canceled.toString(), result.lastPaymentError))
|
|
268
|
-
}
|
|
269
|
-
else -> {
|
|
270
|
-
promise.resolve(createError(ConfirmPaymentErrorType.Unknown.toString(), "unhandled error: ${result.status}"))
|
|
271
|
-
}
|
|
350
|
+
removeFragment(context)
|
|
272
351
|
}
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
})
|
|
352
|
+
},
|
|
353
|
+
)
|
|
276
354
|
}
|
|
277
355
|
|
|
278
356
|
/**
|
|
279
|
-
* Check if paymentIntent.nextAction is out-of-band, such as voucher-based or waiting
|
|
280
|
-
*
|
|
357
|
+
* Check if paymentIntent.nextAction is out-of-band, such as voucher-based or waiting on customer
|
|
358
|
+
* verification. If it is, then being in this state is considered "successful".
|
|
281
359
|
*/
|
|
282
|
-
private fun isNextActionSuccessState(nextAction: StripeIntent.NextActionType?): Boolean
|
|
283
|
-
|
|
360
|
+
private fun isNextActionSuccessState(nextAction: StripeIntent.NextActionType?): Boolean =
|
|
361
|
+
when (nextAction) {
|
|
284
362
|
StripeIntent.NextActionType.DisplayOxxoDetails,
|
|
285
363
|
StripeIntent.NextActionType.DisplayBoletoDetails,
|
|
286
364
|
StripeIntent.NextActionType.DisplayKonbiniDetails,
|
|
287
365
|
StripeIntent.NextActionType.VerifyWithMicrodeposits,
|
|
288
|
-
StripeIntent.NextActionType.DisplayMultibancoDetails
|
|
366
|
+
StripeIntent.NextActionType.DisplayMultibancoDetails,
|
|
367
|
+
-> true
|
|
289
368
|
StripeIntent.NextActionType.RedirectToUrl,
|
|
290
369
|
StripeIntent.NextActionType.UseStripeSdk,
|
|
291
370
|
StripeIntent.NextActionType.AlipayRedirect,
|
|
@@ -294,8 +373,7 @@ class PaymentLauncherFragment(
|
|
|
294
373
|
StripeIntent.NextActionType.UpiAwaitNotification,
|
|
295
374
|
StripeIntent.NextActionType.CashAppRedirect,
|
|
296
375
|
StripeIntent.NextActionType.SwishRedirect,
|
|
297
|
-
null,
|
|
376
|
+
null,
|
|
377
|
+
-> false
|
|
298
378
|
}
|
|
299
|
-
}
|
|
300
379
|
}
|
|
301
|
-
|