@stripe/stripe-react-native 0.41.0 → 0.43.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 +27 -0
- package/README.md +3 -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/fileChanges/last-build.bin +0 -0
- package/android/.gradle/8.11.1/fileHashes/fileHashes.lock +0 -0
- package/android/.gradle/8.11.1/gc.properties +0 -0
- package/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock +0 -0
- package/android/.gradle/buildOutputCleanup/cache.properties +2 -0
- package/android/.gradle/vcs-1/gc.properties +0 -0
- package/android/build.gradle +7 -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 +53 -23
- package/android/src/main/java/com/reactnativestripesdk/FinancialConnectionsSheetFragment.kt +125 -83
- 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 +183 -123
- package/android/src/main/java/com/reactnativestripesdk/PaymentSheetAppearance.kt +181 -57
- package/android/src/main/java/com/reactnativestripesdk/PaymentSheetFragment.kt +402 -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 +654 -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 +337 -250
- package/android/src/main/java/com/reactnativestripesdk/utils/PostalCodeUtilities.kt +2 -11
- package/ios/CustomerSheet/CustomerSheetUtils.swift +3 -1
- package/ios/FinancialConnections.swift +18 -2
- package/ios/Mappers.swift +23 -0
- package/ios/PaymentMethodFactory.swift +31 -29
- package/ios/StripeSdk+CustomerSheet.swift +2 -1
- package/ios/StripeSdk+PaymentSheet.swift +42 -0
- package/ios/StripeSdk.m +2 -0
- package/ios/StripeSdk.swift +116 -24
- 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 +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 +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 +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 +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 +5 -4
- 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 +12 -7
- 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 +5 -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 +12 -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 +82 -14
- 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 +41 -14
- package/lib/typescript/src/types/PaymentIntent.d.ts.map +1 -0
- package/lib/typescript/src/types/PaymentMethod.d.ts +27 -15
- package/lib/typescript/src/types/PaymentMethod.d.ts.map +1 -0
- package/lib/typescript/src/types/PaymentSheet.d.ts +72 -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 +33 -42
- package/src/NativeStripeSdk.tsx +5 -3
- 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 +70 -16
- package/src/hooks/useFinancialConnectionsSheet.tsx +12 -4
- package/src/hooks/useStripe.tsx +10 -4
- package/src/types/Common.ts +3 -0
- package/src/types/CustomerSheet.ts +7 -0
- package/src/types/FinancialConnections.ts +72 -0
- package/src/types/PaymentIntent.ts +30 -1
- package/src/types/PaymentMethod.ts +13 -1
- package/src/types/PaymentSheet.ts +65 -5
- package/src/types/components/CardFieldInput.ts +8 -4
- package/src/types/components/CardFormView.ts +8 -4
- package/stripe-react-native.podspec +2 -1
|
@@ -5,22 +5,21 @@ import android.util.Log
|
|
|
5
5
|
import com.facebook.react.bridge.ReadableMap
|
|
6
6
|
import com.facebook.react.bridge.WritableMap
|
|
7
7
|
import com.facebook.react.bridge.WritableNativeMap
|
|
8
|
-
import com.reactnativestripesdk.utils.createError
|
|
9
8
|
import com.google.android.gms.tasks.Task
|
|
9
|
+
import com.reactnativestripesdk.utils.createError
|
|
10
10
|
|
|
11
|
-
typealias TokenCheckHandler =
|
|
11
|
+
typealias TokenCheckHandler =
|
|
12
|
+
(isCardInWallet: Boolean, token: WritableMap?, error: WritableMap?) -> Unit
|
|
12
13
|
|
|
13
14
|
object TapAndPayProxy {
|
|
14
15
|
private const val TAG = "StripeTapAndPay"
|
|
15
16
|
private var tapAndPayClient: Any? = null
|
|
16
17
|
const val REQUEST_CODE_TOKENIZE = 90909
|
|
17
18
|
|
|
18
|
-
private fun getTapandPayTokens(activity: Activity): Task<List<Any>>?
|
|
19
|
-
|
|
19
|
+
private fun getTapandPayTokens(activity: Activity): Task<List<Any>>? =
|
|
20
|
+
try {
|
|
20
21
|
val tapAndPayClass = Class.forName("com.google.android.gms.tapandpay.TapAndPay")
|
|
21
|
-
val getClientMethod = tapAndPayClass.getMethod(
|
|
22
|
-
"getClient",
|
|
23
|
-
Activity::class.java)
|
|
22
|
+
val getClientMethod = tapAndPayClass.getMethod("getClient", Activity::class.java)
|
|
24
23
|
val client = getClientMethod.invoke(null, activity)
|
|
25
24
|
|
|
26
25
|
val tapAndPayClientClass = Class.forName("com.google.android.gms.tapandpay.TapAndPayClient")
|
|
@@ -31,21 +30,28 @@ object TapAndPayProxy {
|
|
|
31
30
|
Log.e(TAG, "There was a problem listing tokens with Google TapAndPay: " + e.message)
|
|
32
31
|
null
|
|
33
32
|
}
|
|
34
|
-
}
|
|
35
33
|
|
|
36
|
-
internal fun isTokenInWallet(
|
|
37
|
-
|
|
38
|
-
|
|
34
|
+
internal fun isTokenInWallet(
|
|
35
|
+
token: Any,
|
|
36
|
+
newLastFour: String,
|
|
37
|
+
): Boolean =
|
|
38
|
+
try {
|
|
39
|
+
val getFpanLastFourMethod =
|
|
40
|
+
Class
|
|
41
|
+
.forName("com.google.android.gms.tapandpay.issuer.TokenInfo")
|
|
42
|
+
.getMethod("getFpanLastFour")
|
|
39
43
|
val existingFpanLastFour = getFpanLastFourMethod.invoke(token) as String
|
|
40
44
|
existingFpanLastFour == newLastFour
|
|
41
45
|
} catch (e: Exception) {
|
|
42
46
|
Log.e(TAG, "There was a problem getting the FPAN with Google TapAndPay: " + e.message)
|
|
43
47
|
false
|
|
44
48
|
}
|
|
45
|
-
}
|
|
46
49
|
|
|
47
|
-
|
|
48
|
-
|
|
50
|
+
fun findExistingToken(
|
|
51
|
+
activity: Activity,
|
|
52
|
+
newCardLastFour: String,
|
|
53
|
+
callback: TokenCheckHandler,
|
|
54
|
+
) {
|
|
49
55
|
val tokens = getTapandPayTokens(activity)
|
|
50
56
|
if (tokens == null) {
|
|
51
57
|
callback(false, null, createError("Failed", "Google TapAndPay dependency not found."))
|
|
@@ -56,7 +62,7 @@ object TapAndPayProxy {
|
|
|
56
62
|
if (task.isSuccessful) {
|
|
57
63
|
for (token in task.result) {
|
|
58
64
|
if (isTokenInWallet(token, newCardLastFour)) {
|
|
59
|
-
callback(true,
|
|
65
|
+
callback(true, mapFromTokenInfo(token), null)
|
|
60
66
|
return@addOnCompleteListener
|
|
61
67
|
}
|
|
62
68
|
}
|
|
@@ -67,17 +73,35 @@ object TapAndPayProxy {
|
|
|
67
73
|
}
|
|
68
74
|
}
|
|
69
75
|
|
|
70
|
-
fun tokenize(
|
|
76
|
+
fun tokenize(
|
|
77
|
+
activity: Activity,
|
|
78
|
+
tokenReferenceId: String,
|
|
79
|
+
token: ReadableMap,
|
|
80
|
+
cardDescription: String,
|
|
81
|
+
) {
|
|
71
82
|
try {
|
|
72
83
|
val tapAndPayClientClass = Class.forName("com.google.android.gms.tapandpay.TapAndPayClient")
|
|
73
|
-
val tokenizeMethod =
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
84
|
+
val tokenizeMethod =
|
|
85
|
+
tapAndPayClientClass::class
|
|
86
|
+
.java
|
|
87
|
+
.getMethod(
|
|
88
|
+
"tokenize",
|
|
89
|
+
Activity::class.java,
|
|
90
|
+
String::class.java,
|
|
91
|
+
Int::class.java,
|
|
92
|
+
String::class.java,
|
|
93
|
+
Int::class.java,
|
|
94
|
+
Int::class.java,
|
|
95
|
+
)
|
|
96
|
+
tokenizeMethod.invoke(
|
|
97
|
+
tapAndPayClient,
|
|
98
|
+
activity,
|
|
99
|
+
tokenReferenceId,
|
|
100
|
+
token.getInt("serviceProvider"),
|
|
101
|
+
cardDescription,
|
|
102
|
+
token.getInt("network"),
|
|
103
|
+
REQUEST_CODE_TOKENIZE,
|
|
104
|
+
)
|
|
81
105
|
} catch (e: Exception) {
|
|
82
106
|
Log.e(TAG, "There was a problem tokenizing with Google TapAndPay: " + e.message)
|
|
83
107
|
}
|
|
@@ -88,33 +112,29 @@ object TapAndPayProxy {
|
|
|
88
112
|
token?.let {
|
|
89
113
|
try {
|
|
90
114
|
val tokenInfoClass = Class.forName("com.google.android.gms.tapandpay.issuer.TokenInfo")
|
|
91
|
-
result.putString(
|
|
92
|
-
"id",
|
|
93
|
-
tokenInfoClass.getMethod("getIssuerTokenId").invoke(it) as String)
|
|
115
|
+
result.putString("id", tokenInfoClass.getMethod("getIssuerTokenId").invoke(it) as String)
|
|
94
116
|
val fpan = tokenInfoClass.getMethod("getFpanLastFour").invoke(it) as String
|
|
95
|
-
result.putString(
|
|
96
|
-
|
|
97
|
-
fpan)
|
|
98
|
-
result.putString(
|
|
99
|
-
"fpanLastFour",
|
|
100
|
-
fpan)
|
|
117
|
+
result.putString("cardLastFour", fpan)
|
|
118
|
+
result.putString("fpanLastFour", fpan)
|
|
101
119
|
result.putString(
|
|
102
120
|
"dpanLastFour",
|
|
103
|
-
tokenInfoClass.getMethod("getDpanLastFour").invoke(it) as String
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
tokenInfoClass.getMethod("getIssuerName").invoke(it) as String)
|
|
121
|
+
tokenInfoClass.getMethod("getDpanLastFour").invoke(it) as String,
|
|
122
|
+
)
|
|
123
|
+
result.putString("issuer", tokenInfoClass.getMethod("getIssuerName").invoke(it) as String)
|
|
107
124
|
result.putString(
|
|
108
125
|
"status",
|
|
109
|
-
mapFromTokenState(tokenInfoClass.getMethod("getTokenState").invoke(it) as Int)
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
tokenInfoClass.getMethod("getNetwork").invoke(it) as Int)
|
|
126
|
+
mapFromTokenState(tokenInfoClass.getMethod("getTokenState").invoke(it) as Int),
|
|
127
|
+
)
|
|
128
|
+
result.putInt("network", tokenInfoClass.getMethod("getNetwork").invoke(it) as Int)
|
|
113
129
|
result.putInt(
|
|
114
130
|
"serviceProvider",
|
|
115
|
-
tokenInfoClass.getMethod("getTokenServiceProvider").invoke(it) as Int
|
|
131
|
+
tokenInfoClass.getMethod("getTokenServiceProvider").invoke(it) as Int,
|
|
132
|
+
)
|
|
116
133
|
} catch (e: Exception) {
|
|
117
|
-
Log.e(
|
|
134
|
+
Log.e(
|
|
135
|
+
TAG,
|
|
136
|
+
"There was a problem mapping the token information with Google TapAndPay: " + e.message,
|
|
137
|
+
)
|
|
118
138
|
}
|
|
119
139
|
}
|
|
120
140
|
return result
|
|
@@ -124,12 +144,16 @@ object TapAndPayProxy {
|
|
|
124
144
|
try {
|
|
125
145
|
val tapAndPayClass = Class.forName("com.google.android.gms.tapandpay.TapAndPay")
|
|
126
146
|
return when (status) {
|
|
127
|
-
tapAndPayClass.getField("TOKEN_STATE_NEEDS_IDENTITY_VERIFICATION").get(tapAndPayClass) ->
|
|
147
|
+
tapAndPayClass.getField("TOKEN_STATE_NEEDS_IDENTITY_VERIFICATION").get(tapAndPayClass) ->
|
|
148
|
+
"TOKEN_STATE_NEEDS_IDENTITY_VERIFICATION"
|
|
128
149
|
tapAndPayClass.getField("TOKEN_STATE_PENDING").get(tapAndPayClass) -> "TOKEN_STATE_PENDING"
|
|
129
|
-
tapAndPayClass.getField("TOKEN_STATE_SUSPENDED").get(tapAndPayClass) ->
|
|
150
|
+
tapAndPayClass.getField("TOKEN_STATE_SUSPENDED").get(tapAndPayClass) ->
|
|
151
|
+
"TOKEN_STATE_SUSPENDED"
|
|
130
152
|
tapAndPayClass.getField("TOKEN_STATE_ACTIVE").get(tapAndPayClass) -> "TOKEN_STATE_ACTIVE"
|
|
131
|
-
tapAndPayClass.getField("TOKEN_STATE_FELICA_PENDING_PROVISIONING").get(tapAndPayClass) ->
|
|
132
|
-
|
|
153
|
+
tapAndPayClass.getField("TOKEN_STATE_FELICA_PENDING_PROVISIONING").get(tapAndPayClass) ->
|
|
154
|
+
"TOKEN_STATE_FELICA_PENDING_PROVISIONING"
|
|
155
|
+
tapAndPayClass.getField("TOKEN_STATE_UNTOKENIZED").get(tapAndPayClass) ->
|
|
156
|
+
"TOKEN_STATE_UNTOKENIZED"
|
|
133
157
|
else -> "UNKNOWN"
|
|
134
158
|
}
|
|
135
159
|
} catch (e: Exception) {
|
|
@@ -10,42 +10,62 @@ import com.stripe.android.model.PaymentIntent
|
|
|
10
10
|
import com.stripe.android.model.SetupIntent
|
|
11
11
|
|
|
12
12
|
enum class ErrorType {
|
|
13
|
-
Failed,
|
|
13
|
+
Failed,
|
|
14
|
+
Canceled,
|
|
15
|
+
Unknown,
|
|
14
16
|
}
|
|
15
17
|
|
|
16
18
|
enum class ConfirmPaymentErrorType {
|
|
17
|
-
Failed,
|
|
19
|
+
Failed,
|
|
20
|
+
Canceled,
|
|
21
|
+
Unknown,
|
|
18
22
|
}
|
|
19
23
|
|
|
20
24
|
enum class CreateTokenErrorType {
|
|
21
|
-
Failed
|
|
25
|
+
Failed,
|
|
22
26
|
}
|
|
23
27
|
|
|
24
28
|
enum class ConfirmSetupIntentErrorType {
|
|
25
|
-
Failed,
|
|
29
|
+
Failed,
|
|
30
|
+
Canceled,
|
|
31
|
+
Unknown,
|
|
26
32
|
}
|
|
27
33
|
|
|
28
34
|
enum class RetrievePaymentIntentErrorType {
|
|
29
|
-
Unknown
|
|
35
|
+
Unknown,
|
|
30
36
|
}
|
|
31
37
|
|
|
32
38
|
enum class RetrieveSetupIntentErrorType {
|
|
33
|
-
Unknown
|
|
39
|
+
Unknown,
|
|
34
40
|
}
|
|
35
41
|
|
|
36
42
|
enum class PaymentSheetErrorType {
|
|
37
|
-
Failed,
|
|
43
|
+
Failed,
|
|
44
|
+
Canceled,
|
|
45
|
+
Timeout,
|
|
38
46
|
}
|
|
39
47
|
|
|
40
48
|
enum class GooglePayErrorType {
|
|
41
|
-
Failed,
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
+
Failed,
|
|
50
|
+
Canceled,
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
class PaymentSheetAppearanceException(
|
|
54
|
+
message: String,
|
|
55
|
+
) : Exception(message)
|
|
56
|
+
|
|
57
|
+
class PaymentSheetException(
|
|
58
|
+
message: String,
|
|
59
|
+
) : Exception(message)
|
|
60
|
+
|
|
61
|
+
internal fun mapError(
|
|
62
|
+
code: String,
|
|
63
|
+
message: String?,
|
|
64
|
+
localizedMessage: String?,
|
|
65
|
+
declineCode: String?,
|
|
66
|
+
type: String?,
|
|
67
|
+
stripeErrorCode: String?,
|
|
68
|
+
): WritableMap {
|
|
49
69
|
val map: WritableMap = WritableNativeMap()
|
|
50
70
|
val details: WritableMap = WritableNativeMap()
|
|
51
71
|
details.putString("code", code)
|
|
@@ -59,61 +79,107 @@ internal fun mapError(code: String, message: String?, localizedMessage: String?,
|
|
|
59
79
|
return map
|
|
60
80
|
}
|
|
61
81
|
|
|
62
|
-
internal fun createError(
|
|
63
|
-
|
|
64
|
-
|
|
82
|
+
internal fun createError(
|
|
83
|
+
code: String,
|
|
84
|
+
message: String?,
|
|
85
|
+
): WritableMap = mapError(code, message, message, null, null, null)
|
|
65
86
|
|
|
66
|
-
internal fun createMissingActivityError(): WritableMap
|
|
67
|
-
|
|
87
|
+
internal fun createMissingActivityError(): WritableMap =
|
|
88
|
+
mapError(
|
|
68
89
|
"Failed",
|
|
69
90
|
"Activity doesn't exist yet. You can safely retry this method.",
|
|
70
91
|
null,
|
|
71
92
|
null,
|
|
72
93
|
null,
|
|
73
|
-
null
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
internal fun createError(code: String, error: PaymentIntent.Error?): WritableMap {
|
|
77
|
-
return mapError(code, error?.message, error?.message, error?.declineCode, error?.type?.code, error?.code)
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
internal fun createError(code: String, error: SetupIntent.Error?): WritableMap {
|
|
81
|
-
return mapError(code, error?.message, error?.message, error?.declineCode, error?.type?.code, error?.code)
|
|
82
|
-
}
|
|
94
|
+
null,
|
|
95
|
+
)
|
|
83
96
|
|
|
84
|
-
internal fun createError(
|
|
85
|
-
|
|
97
|
+
internal fun createError(
|
|
98
|
+
code: String,
|
|
99
|
+
error: PaymentIntent.Error?,
|
|
100
|
+
): WritableMap =
|
|
101
|
+
mapError(
|
|
102
|
+
code,
|
|
103
|
+
error?.message,
|
|
104
|
+
error?.message,
|
|
105
|
+
error?.declineCode,
|
|
106
|
+
error?.type?.code,
|
|
107
|
+
error?.code,
|
|
108
|
+
)
|
|
109
|
+
|
|
110
|
+
internal fun createError(
|
|
111
|
+
code: String,
|
|
112
|
+
error: SetupIntent.Error?,
|
|
113
|
+
): WritableMap =
|
|
114
|
+
mapError(
|
|
115
|
+
code,
|
|
116
|
+
error?.message,
|
|
117
|
+
error?.message,
|
|
118
|
+
error?.declineCode,
|
|
119
|
+
error?.type?.code,
|
|
120
|
+
error?.code,
|
|
121
|
+
)
|
|
122
|
+
|
|
123
|
+
internal fun createError(
|
|
124
|
+
code: String,
|
|
125
|
+
error: Exception,
|
|
126
|
+
): WritableMap =
|
|
127
|
+
when (error) {
|
|
86
128
|
is CardException -> {
|
|
87
|
-
mapError(
|
|
129
|
+
mapError(
|
|
130
|
+
code,
|
|
131
|
+
error.message,
|
|
132
|
+
error.localizedMessage,
|
|
133
|
+
error.declineCode,
|
|
134
|
+
error.stripeError?.type,
|
|
135
|
+
error.stripeError?.code,
|
|
136
|
+
)
|
|
88
137
|
}
|
|
89
138
|
is InvalidRequestException -> {
|
|
90
|
-
mapError(
|
|
139
|
+
mapError(
|
|
140
|
+
code,
|
|
141
|
+
error.message,
|
|
142
|
+
error.localizedMessage,
|
|
143
|
+
error.stripeError?.declineCode,
|
|
144
|
+
error.stripeError?.type,
|
|
145
|
+
error.stripeError?.code,
|
|
146
|
+
)
|
|
91
147
|
}
|
|
92
148
|
is AuthenticationException -> {
|
|
93
|
-
mapError(
|
|
149
|
+
mapError(
|
|
150
|
+
code,
|
|
151
|
+
error.message,
|
|
152
|
+
error.localizedMessage,
|
|
153
|
+
error.stripeError?.declineCode,
|
|
154
|
+
error.stripeError?.type,
|
|
155
|
+
error.stripeError?.code,
|
|
156
|
+
)
|
|
94
157
|
}
|
|
95
158
|
is APIException -> {
|
|
96
|
-
mapError(
|
|
159
|
+
mapError(
|
|
160
|
+
code,
|
|
161
|
+
error.message,
|
|
162
|
+
error.localizedMessage,
|
|
163
|
+
error.stripeError?.declineCode,
|
|
164
|
+
error.stripeError?.type,
|
|
165
|
+
error.stripeError?.code,
|
|
166
|
+
)
|
|
97
167
|
}
|
|
98
168
|
else -> mapError(code, error.message, error.localizedMessage.orEmpty(), null, null, null)
|
|
99
169
|
}
|
|
100
|
-
}
|
|
101
170
|
|
|
102
|
-
internal fun createError(
|
|
171
|
+
internal fun createError(
|
|
172
|
+
code: String,
|
|
173
|
+
error: Throwable,
|
|
174
|
+
): WritableMap {
|
|
103
175
|
(error as? Exception)?.let {
|
|
104
|
-
return createError(
|
|
105
|
-
code,
|
|
106
|
-
it)
|
|
176
|
+
return createError(code, it)
|
|
107
177
|
}
|
|
108
|
-
return mapError(
|
|
109
|
-
code,
|
|
110
|
-
error.message,
|
|
111
|
-
error.localizedMessage,
|
|
112
|
-
null,
|
|
113
|
-
null,
|
|
114
|
-
null)
|
|
178
|
+
return mapError(code, error.message, error.localizedMessage, null, null, null)
|
|
115
179
|
}
|
|
116
180
|
|
|
117
|
-
internal fun createMissingInitError(): WritableMap
|
|
118
|
-
|
|
119
|
-
|
|
181
|
+
internal fun createMissingInitError(): WritableMap =
|
|
182
|
+
createError(
|
|
183
|
+
ErrorType.Failed.toString(),
|
|
184
|
+
"Stripe has not been initialized. Initialize Stripe in your app with the StripeProvider component or the initStripe method.",
|
|
185
|
+
)
|
|
@@ -32,6 +32,7 @@ fun Fragment.removeFragment(context: ReactApplicationContext) {
|
|
|
32
32
|
}
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
-
fun ReadableMap.getBooleanOr(
|
|
36
|
-
|
|
37
|
-
|
|
35
|
+
fun ReadableMap.getBooleanOr(
|
|
36
|
+
key: String,
|
|
37
|
+
default: Boolean,
|
|
38
|
+
): Boolean = if (this.hasKey(key)) this.getBoolean(key) else default
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
package com.reactnativestripesdk.utils
|
|
2
|
+
|
|
3
|
+
import com.facebook.react.bridge.Arguments
|
|
4
|
+
import com.facebook.react.bridge.ReactContext
|
|
5
|
+
import com.facebook.react.bridge.UiThreadUtil
|
|
6
|
+
import com.facebook.react.jstasks.HeadlessJsTaskConfig
|
|
7
|
+
import com.facebook.react.jstasks.HeadlessJsTaskContext
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* When Stripe UI is presented, React Native pauses timers. This will cause issues if we need
|
|
11
|
+
* to run JS while UI is presented. This starts a HeadlessJsTask to prevent React Native from
|
|
12
|
+
* pausing timers.
|
|
13
|
+
*/
|
|
14
|
+
internal class KeepJsAwakeTask(
|
|
15
|
+
private val context: ReactContext,
|
|
16
|
+
) {
|
|
17
|
+
private var taskId: Int? = null
|
|
18
|
+
|
|
19
|
+
fun start() {
|
|
20
|
+
val headlessJsTaskContext = HeadlessJsTaskContext.getInstance(context)
|
|
21
|
+
UiThreadUtil.runOnUiThread {
|
|
22
|
+
val taskConfig =
|
|
23
|
+
HeadlessJsTaskConfig(
|
|
24
|
+
"StripeKeepJsAwakeTask",
|
|
25
|
+
Arguments.createMap(),
|
|
26
|
+
0,
|
|
27
|
+
true,
|
|
28
|
+
)
|
|
29
|
+
taskId = headlessJsTaskContext.startTask(taskConfig)
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
fun stop() {
|
|
34
|
+
val taskId = taskId ?: return
|
|
35
|
+
val headlessJsTaskContext = HeadlessJsTaskContext.getInstance(context)
|
|
36
|
+
headlessJsTaskContext.finishTask(taskId)
|
|
37
|
+
this.taskId = null
|
|
38
|
+
}
|
|
39
|
+
}
|