@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
|
@@ -7,19 +7,32 @@ import android.view.ViewGroup
|
|
|
7
7
|
import android.widget.FrameLayout
|
|
8
8
|
import androidx.fragment.app.Fragment
|
|
9
9
|
import androidx.fragment.app.FragmentActivity
|
|
10
|
-
import com.facebook.react.bridge
|
|
11
|
-
import com.
|
|
10
|
+
import com.facebook.react.bridge.Arguments
|
|
11
|
+
import com.facebook.react.bridge.Promise
|
|
12
|
+
import com.facebook.react.bridge.ReactApplicationContext
|
|
13
|
+
import com.facebook.react.bridge.ReadableArray
|
|
14
|
+
import com.facebook.react.bridge.WritableArray
|
|
15
|
+
import com.facebook.react.bridge.WritableMap
|
|
16
|
+
import com.facebook.react.bridge.WritableNativeMap
|
|
17
|
+
import com.reactnativestripesdk.utils.ErrorType
|
|
12
18
|
import com.reactnativestripesdk.utils.createError
|
|
13
19
|
import com.reactnativestripesdk.utils.createMissingActivityError
|
|
20
|
+
import com.reactnativestripesdk.utils.mapFromFinancialConnectionsEvent
|
|
14
21
|
import com.reactnativestripesdk.utils.mapFromToken
|
|
22
|
+
import com.stripe.android.financialconnections.FinancialConnections
|
|
15
23
|
import com.stripe.android.financialconnections.FinancialConnectionsSheet
|
|
16
24
|
import com.stripe.android.financialconnections.FinancialConnectionsSheetForTokenResult
|
|
17
25
|
import com.stripe.android.financialconnections.FinancialConnectionsSheetResult
|
|
18
|
-
import com.stripe.android.financialconnections.model
|
|
26
|
+
import com.stripe.android.financialconnections.model.Balance
|
|
27
|
+
import com.stripe.android.financialconnections.model.BalanceRefresh
|
|
28
|
+
import com.stripe.android.financialconnections.model.FinancialConnectionsAccount
|
|
29
|
+
import com.stripe.android.financialconnections.model.FinancialConnectionsAccountList
|
|
30
|
+
import com.stripe.android.financialconnections.model.FinancialConnectionsSession
|
|
19
31
|
|
|
20
32
|
class FinancialConnectionsSheetFragment : Fragment() {
|
|
21
33
|
enum class Mode {
|
|
22
|
-
ForToken,
|
|
34
|
+
ForToken,
|
|
35
|
+
ForSession,
|
|
23
36
|
}
|
|
24
37
|
|
|
25
38
|
private lateinit var promise: Promise
|
|
@@ -27,104 +40,132 @@ class FinancialConnectionsSheetFragment : Fragment() {
|
|
|
27
40
|
private lateinit var configuration: FinancialConnectionsSheet.Configuration
|
|
28
41
|
private lateinit var mode: Mode
|
|
29
42
|
|
|
30
|
-
override fun
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
43
|
+
override fun onCreate(savedInstanceState: Bundle?) {
|
|
44
|
+
super.onCreate(savedInstanceState)
|
|
45
|
+
|
|
46
|
+
val stripeSdkModule: StripeSdkModule? = context.getNativeModule(StripeSdkModule::class.java)
|
|
47
|
+
if (stripeSdkModule != null && stripeSdkModule.eventListenerCount > 0) {
|
|
48
|
+
FinancialConnections.setEventListener { event ->
|
|
49
|
+
val params = mapFromFinancialConnectionsEvent(event)
|
|
50
|
+
stripeSdkModule.sendEvent(context, "onFinancialConnectionsEvent", params)
|
|
51
|
+
}
|
|
34
52
|
}
|
|
35
53
|
}
|
|
36
54
|
|
|
37
|
-
override fun
|
|
55
|
+
override fun onCreateView(
|
|
56
|
+
inflater: LayoutInflater,
|
|
57
|
+
container: ViewGroup?,
|
|
58
|
+
savedInstanceState: Bundle?,
|
|
59
|
+
): View = FrameLayout(requireActivity()).also { it.visibility = View.GONE }
|
|
60
|
+
|
|
61
|
+
override fun onViewCreated(
|
|
62
|
+
view: View,
|
|
63
|
+
savedInstanceState: Bundle?,
|
|
64
|
+
) {
|
|
38
65
|
when (mode) {
|
|
39
66
|
Mode.ForToken -> {
|
|
40
|
-
FinancialConnectionsSheet
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
configuration = configuration
|
|
45
|
-
)
|
|
67
|
+
FinancialConnectionsSheet
|
|
68
|
+
.createForBankAccountToken(
|
|
69
|
+
this,
|
|
70
|
+
::onFinancialConnectionsSheetForTokenResult,
|
|
71
|
+
).present(configuration = configuration)
|
|
46
72
|
}
|
|
47
73
|
Mode.ForSession -> {
|
|
48
|
-
FinancialConnectionsSheet
|
|
49
|
-
this,
|
|
50
|
-
|
|
51
|
-
).present(
|
|
52
|
-
configuration = configuration
|
|
53
|
-
)
|
|
74
|
+
FinancialConnectionsSheet
|
|
75
|
+
.create(this, ::onFinancialConnectionsSheetForDataResult)
|
|
76
|
+
.present(configuration = configuration)
|
|
54
77
|
}
|
|
55
78
|
}
|
|
56
79
|
}
|
|
57
80
|
|
|
81
|
+
override fun onDestroy() {
|
|
82
|
+
super.onDestroy()
|
|
83
|
+
|
|
84
|
+
// Remove any event listener that might be set
|
|
85
|
+
FinancialConnections.clearEventListener()
|
|
86
|
+
}
|
|
87
|
+
|
|
58
88
|
private fun onFinancialConnectionsSheetForTokenResult(result: FinancialConnectionsSheetForTokenResult) {
|
|
59
|
-
when(result) {
|
|
89
|
+
when (result) {
|
|
60
90
|
is FinancialConnectionsSheetForTokenResult.Canceled -> {
|
|
61
|
-
promise.resolve(
|
|
62
|
-
createError(ErrorType.Canceled.toString(), "The flow has been canceled")
|
|
63
|
-
)
|
|
91
|
+
promise.resolve(createError(ErrorType.Canceled.toString(), "The flow has been canceled"))
|
|
64
92
|
}
|
|
65
93
|
is FinancialConnectionsSheetForTokenResult.Failed -> {
|
|
66
|
-
promise.resolve(
|
|
67
|
-
createError(ErrorType.Failed.toString(), result.error)
|
|
68
|
-
)
|
|
94
|
+
promise.resolve(createError(ErrorType.Failed.toString(), result.error))
|
|
69
95
|
}
|
|
70
96
|
is FinancialConnectionsSheetForTokenResult.Completed -> {
|
|
71
97
|
promise.resolve(createTokenResult(result))
|
|
72
|
-
(context.currentActivity as? FragmentActivity)
|
|
98
|
+
(context.currentActivity as? FragmentActivity)
|
|
99
|
+
?.supportFragmentManager
|
|
100
|
+
?.beginTransaction()
|
|
101
|
+
?.remove(this)
|
|
102
|
+
?.commitAllowingStateLoss()
|
|
73
103
|
}
|
|
74
104
|
}
|
|
75
105
|
}
|
|
76
106
|
|
|
77
107
|
private fun onFinancialConnectionsSheetForDataResult(result: FinancialConnectionsSheetResult) {
|
|
78
|
-
when(result) {
|
|
108
|
+
when (result) {
|
|
79
109
|
is FinancialConnectionsSheetResult.Canceled -> {
|
|
80
|
-
promise.resolve(
|
|
81
|
-
createError(ErrorType.Canceled.toString(), "The flow has been canceled")
|
|
82
|
-
)
|
|
110
|
+
promise.resolve(createError(ErrorType.Canceled.toString(), "The flow has been canceled"))
|
|
83
111
|
}
|
|
84
112
|
is FinancialConnectionsSheetResult.Failed -> {
|
|
85
|
-
promise.resolve(
|
|
86
|
-
createError(ErrorType.Failed.toString(), result.error)
|
|
87
|
-
)
|
|
113
|
+
promise.resolve(createError(ErrorType.Failed.toString(), result.error))
|
|
88
114
|
}
|
|
89
115
|
is FinancialConnectionsSheetResult.Completed -> {
|
|
90
116
|
promise.resolve(
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
117
|
+
WritableNativeMap().also {
|
|
118
|
+
it.putMap("session", mapFromSession(result.financialConnectionsSession))
|
|
119
|
+
},
|
|
94
120
|
)
|
|
95
|
-
(context.currentActivity as? FragmentActivity)
|
|
121
|
+
(context.currentActivity as? FragmentActivity)
|
|
122
|
+
?.supportFragmentManager
|
|
123
|
+
?.beginTransaction()
|
|
124
|
+
?.remove(this)
|
|
125
|
+
?.commitAllowingStateLoss()
|
|
96
126
|
}
|
|
97
127
|
}
|
|
98
128
|
}
|
|
99
129
|
|
|
100
|
-
fun presentFinancialConnectionsSheet(
|
|
130
|
+
fun presentFinancialConnectionsSheet(
|
|
131
|
+
clientSecret: String,
|
|
132
|
+
mode: Mode,
|
|
133
|
+
publishableKey: String,
|
|
134
|
+
stripeAccountId: String?,
|
|
135
|
+
promise: Promise,
|
|
136
|
+
context: ReactApplicationContext,
|
|
137
|
+
) {
|
|
101
138
|
this.promise = promise
|
|
102
139
|
this.context = context
|
|
103
140
|
this.mode = mode
|
|
104
|
-
this.configuration =
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
141
|
+
this.configuration =
|
|
142
|
+
FinancialConnectionsSheet.Configuration(
|
|
143
|
+
financialConnectionsSessionClientSecret = clientSecret,
|
|
144
|
+
publishableKey = publishableKey,
|
|
145
|
+
stripeAccountId = stripeAccountId,
|
|
146
|
+
)
|
|
109
147
|
|
|
110
148
|
(context.currentActivity as? FragmentActivity)?.let {
|
|
111
149
|
attemptToCleanupPreviousFragment(it)
|
|
112
150
|
commitFragmentAndStartFlow(it)
|
|
113
|
-
} ?: run {
|
|
114
|
-
promise.resolve(createMissingActivityError())
|
|
115
|
-
return
|
|
116
151
|
}
|
|
152
|
+
?: run {
|
|
153
|
+
promise.resolve(createMissingActivityError())
|
|
154
|
+
return
|
|
155
|
+
}
|
|
117
156
|
}
|
|
118
157
|
|
|
119
158
|
private fun attemptToCleanupPreviousFragment(currentActivity: FragmentActivity) {
|
|
120
|
-
currentActivity.supportFragmentManager
|
|
159
|
+
currentActivity.supportFragmentManager
|
|
160
|
+
.beginTransaction()
|
|
121
161
|
.remove(this)
|
|
122
162
|
.commitAllowingStateLoss()
|
|
123
163
|
}
|
|
124
164
|
|
|
125
165
|
private fun commitFragmentAndStartFlow(currentActivity: FragmentActivity) {
|
|
126
166
|
try {
|
|
127
|
-
currentActivity.supportFragmentManager
|
|
167
|
+
currentActivity.supportFragmentManager
|
|
168
|
+
.beginTransaction()
|
|
128
169
|
.add(this, TAG)
|
|
129
170
|
.commit()
|
|
130
171
|
} catch (error: IllegalStateException) {
|
|
@@ -135,12 +176,11 @@ class FinancialConnectionsSheetFragment : Fragment() {
|
|
|
135
176
|
companion object {
|
|
136
177
|
internal const val TAG = "financial_connections_sheet_launch_fragment"
|
|
137
178
|
|
|
138
|
-
private fun createTokenResult(result: FinancialConnectionsSheetForTokenResult.Completed): WritableMap
|
|
139
|
-
|
|
179
|
+
private fun createTokenResult(result: FinancialConnectionsSheetForTokenResult.Completed): WritableMap =
|
|
180
|
+
WritableNativeMap().also {
|
|
140
181
|
it.putMap("session", mapFromSession(result.financialConnectionsSession))
|
|
141
182
|
it.putMap("token", mapFromToken(result.token))
|
|
142
183
|
}
|
|
143
|
-
}
|
|
144
184
|
|
|
145
185
|
private fun mapFromSession(financialConnectionsSession: FinancialConnectionsSession): WritableMap {
|
|
146
186
|
val session = WritableNativeMap()
|
|
@@ -166,8 +206,19 @@ class FinancialConnectionsSheetFragment : Fragment() {
|
|
|
166
206
|
map.putMap("balanceRefresh", mapFromAccountBalanceRefresh(account.balanceRefresh))
|
|
167
207
|
map.putString("category", mapFromCategory(account.category))
|
|
168
208
|
map.putString("subcategory", mapFromSubcategory(account.subcategory))
|
|
169
|
-
map.putArray(
|
|
170
|
-
|
|
209
|
+
map.putArray(
|
|
210
|
+
"permissions",
|
|
211
|
+
(account.permissions?.map { permission -> mapFromPermission(permission) })
|
|
212
|
+
?.toReadableArray(),
|
|
213
|
+
)
|
|
214
|
+
map.putArray(
|
|
215
|
+
"supportedPaymentMethodTypes",
|
|
216
|
+
(
|
|
217
|
+
account.supportedPaymentMethodTypes.map { type ->
|
|
218
|
+
mapFromSupportedPaymentMethodTypes(type)
|
|
219
|
+
}
|
|
220
|
+
).toReadableArray(),
|
|
221
|
+
)
|
|
171
222
|
results.pushMap(map)
|
|
172
223
|
}
|
|
173
224
|
return results
|
|
@@ -192,8 +243,8 @@ class FinancialConnectionsSheetFragment : Fragment() {
|
|
|
192
243
|
return map
|
|
193
244
|
}
|
|
194
245
|
|
|
195
|
-
private fun mapFromCashAvailable(balance: Balance): WritableNativeMap
|
|
196
|
-
|
|
246
|
+
private fun mapFromCashAvailable(balance: Balance): WritableNativeMap =
|
|
247
|
+
WritableNativeMap().also { cashMap ->
|
|
197
248
|
WritableNativeMap().also { availableMap ->
|
|
198
249
|
balance.cash?.available?.entries?.let { entries ->
|
|
199
250
|
for (entry in entries) {
|
|
@@ -203,10 +254,9 @@ class FinancialConnectionsSheetFragment : Fragment() {
|
|
|
203
254
|
cashMap.putMap("available", availableMap)
|
|
204
255
|
}
|
|
205
256
|
}
|
|
206
|
-
}
|
|
207
257
|
|
|
208
|
-
private fun mapFromCreditUsed(balance: Balance): WritableNativeMap
|
|
209
|
-
|
|
258
|
+
private fun mapFromCreditUsed(balance: Balance): WritableNativeMap =
|
|
259
|
+
WritableNativeMap().also { creditMap ->
|
|
210
260
|
WritableNativeMap().also { usedMap ->
|
|
211
261
|
balance.credit?.used?.entries?.let { entries ->
|
|
212
262
|
for (entry in entries) {
|
|
@@ -216,7 +266,6 @@ class FinancialConnectionsSheetFragment : Fragment() {
|
|
|
216
266
|
creditMap.putMap("used", usedMap)
|
|
217
267
|
}
|
|
218
268
|
}
|
|
219
|
-
}
|
|
220
269
|
|
|
221
270
|
private fun mapFromAccountBalanceRefresh(balanceRefresh: BalanceRefresh?): WritableMap? {
|
|
222
271
|
if (balanceRefresh == null) {
|
|
@@ -228,27 +277,25 @@ class FinancialConnectionsSheetFragment : Fragment() {
|
|
|
228
277
|
return map
|
|
229
278
|
}
|
|
230
279
|
|
|
231
|
-
private fun mapFromStatus(status: FinancialConnectionsAccount.Status): String
|
|
232
|
-
|
|
280
|
+
private fun mapFromStatus(status: FinancialConnectionsAccount.Status): String =
|
|
281
|
+
when (status) {
|
|
233
282
|
FinancialConnectionsAccount.Status.ACTIVE -> "active"
|
|
234
283
|
FinancialConnectionsAccount.Status.DISCONNECTED -> "disconnected"
|
|
235
284
|
FinancialConnectionsAccount.Status.INACTIVE -> "inactive"
|
|
236
285
|
FinancialConnectionsAccount.Status.UNKNOWN -> "unparsable"
|
|
237
286
|
}
|
|
238
|
-
}
|
|
239
287
|
|
|
240
|
-
private fun mapFromCategory(category: FinancialConnectionsAccount.Category): String
|
|
241
|
-
|
|
288
|
+
private fun mapFromCategory(category: FinancialConnectionsAccount.Category): String =
|
|
289
|
+
when (category) {
|
|
242
290
|
FinancialConnectionsAccount.Category.CASH -> "cash"
|
|
243
291
|
FinancialConnectionsAccount.Category.CREDIT -> "credit"
|
|
244
292
|
FinancialConnectionsAccount.Category.INVESTMENT -> "investment"
|
|
245
293
|
FinancialConnectionsAccount.Category.OTHER -> "other"
|
|
246
294
|
FinancialConnectionsAccount.Category.UNKNOWN -> "unparsable"
|
|
247
295
|
}
|
|
248
|
-
}
|
|
249
296
|
|
|
250
|
-
private fun mapFromSubcategory(subcategory: FinancialConnectionsAccount.Subcategory): String
|
|
251
|
-
|
|
297
|
+
private fun mapFromSubcategory(subcategory: FinancialConnectionsAccount.Subcategory): String =
|
|
298
|
+
when (subcategory) {
|
|
252
299
|
FinancialConnectionsAccount.Subcategory.CHECKING -> "checking"
|
|
253
300
|
FinancialConnectionsAccount.Subcategory.CREDIT_CARD -> "creditCard"
|
|
254
301
|
FinancialConnectionsAccount.Subcategory.LINE_OF_CREDIT -> "lineOfCredit"
|
|
@@ -257,10 +304,9 @@ class FinancialConnectionsSheetFragment : Fragment() {
|
|
|
257
304
|
FinancialConnectionsAccount.Subcategory.SAVINGS -> "savings"
|
|
258
305
|
FinancialConnectionsAccount.Subcategory.UNKNOWN -> "unparsable"
|
|
259
306
|
}
|
|
260
|
-
}
|
|
261
307
|
|
|
262
|
-
private fun mapFromPermission(permission: FinancialConnectionsAccount.Permissions): String
|
|
263
|
-
|
|
308
|
+
private fun mapFromPermission(permission: FinancialConnectionsAccount.Permissions): String =
|
|
309
|
+
when (permission) {
|
|
264
310
|
FinancialConnectionsAccount.Permissions.PAYMENT_METHOD -> "paymentMethod"
|
|
265
311
|
FinancialConnectionsAccount.Permissions.BALANCES -> "balances"
|
|
266
312
|
FinancialConnectionsAccount.Permissions.OWNERSHIP -> "ownership"
|
|
@@ -269,33 +315,29 @@ class FinancialConnectionsSheetFragment : Fragment() {
|
|
|
269
315
|
FinancialConnectionsAccount.Permissions.UNKNOWN -> "unparsable"
|
|
270
316
|
FinancialConnectionsAccount.Permissions.ACCOUNT_NUMBERS -> "accountNumbers"
|
|
271
317
|
}
|
|
272
|
-
}
|
|
273
318
|
|
|
274
|
-
private fun mapFromSupportedPaymentMethodTypes(type: FinancialConnectionsAccount.SupportedPaymentMethodTypes): String
|
|
275
|
-
|
|
319
|
+
private fun mapFromSupportedPaymentMethodTypes(type: FinancialConnectionsAccount.SupportedPaymentMethodTypes): String =
|
|
320
|
+
when (type) {
|
|
276
321
|
FinancialConnectionsAccount.SupportedPaymentMethodTypes.US_BANK_ACCOUNT -> "usBankAccount"
|
|
277
322
|
FinancialConnectionsAccount.SupportedPaymentMethodTypes.LINK -> "link"
|
|
278
323
|
FinancialConnectionsAccount.SupportedPaymentMethodTypes.UNKNOWN -> "unparsable"
|
|
279
324
|
}
|
|
280
|
-
}
|
|
281
325
|
|
|
282
|
-
private fun mapFromBalanceType(type: Balance.Type): String
|
|
283
|
-
|
|
326
|
+
private fun mapFromBalanceType(type: Balance.Type): String =
|
|
327
|
+
when (type) {
|
|
284
328
|
Balance.Type.CASH -> "cash"
|
|
285
329
|
Balance.Type.CREDIT -> "credit"
|
|
286
330
|
Balance.Type.UNKNOWN -> "unparsable"
|
|
287
331
|
}
|
|
288
|
-
}
|
|
289
332
|
|
|
290
|
-
private fun mapFromBalanceRefreshStatus(status: BalanceRefresh.BalanceRefreshStatus?): String
|
|
291
|
-
|
|
333
|
+
private fun mapFromBalanceRefreshStatus(status: BalanceRefresh.BalanceRefreshStatus?): String =
|
|
334
|
+
when (status) {
|
|
292
335
|
BalanceRefresh.BalanceRefreshStatus.SUCCEEDED -> "succeeded"
|
|
293
336
|
BalanceRefresh.BalanceRefreshStatus.FAILED -> "failed"
|
|
294
337
|
BalanceRefresh.BalanceRefreshStatus.PENDING -> "pending"
|
|
295
338
|
BalanceRefresh.BalanceRefreshStatus.UNKNOWN -> "unparsable"
|
|
296
339
|
null -> "null"
|
|
297
340
|
}
|
|
298
|
-
}
|
|
299
341
|
}
|
|
300
342
|
}
|
|
301
343
|
|
|
@@ -1,19 +1,17 @@
|
|
|
1
1
|
package com.reactnativestripesdk
|
|
2
|
+
|
|
2
3
|
import com.facebook.react.bridge.Arguments
|
|
3
4
|
import com.facebook.react.bridge.WritableMap
|
|
4
5
|
import com.facebook.react.uimanager.events.Event
|
|
5
|
-
import com.facebook.react.uimanager.events.RCTEventEmitter
|
|
6
|
-
|
|
7
|
-
internal class FormCompleteEvent constructor(viewTag: Int, private val formDetails: MutableMap<String, Any>) : Event<FormCompleteEvent>(viewTag) {
|
|
8
|
-
override fun getEventName(): String {
|
|
9
|
-
return EVENT_NAME
|
|
10
|
-
}
|
|
11
6
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
7
|
+
internal class FormCompleteEvent(
|
|
8
|
+
surfaceId: Int,
|
|
9
|
+
viewTag: Int,
|
|
10
|
+
private val formDetails: MutableMap<String, Any>,
|
|
11
|
+
) : Event<FormCompleteEvent>(surfaceId, viewTag) {
|
|
12
|
+
override fun getEventName() = EVENT_NAME
|
|
15
13
|
|
|
16
|
-
|
|
14
|
+
override fun getEventData(): WritableMap? {
|
|
17
15
|
val eventData = Arguments.createMap()
|
|
18
16
|
eventData.putString("accountNumber", formDetails["accountNumber"].toString())
|
|
19
17
|
eventData.putString("bsbNumber", formDetails["bsbNumber"].toString())
|
|
@@ -24,6 +22,6 @@ internal class FormCompleteEvent constructor(viewTag: Int, private val formDetai
|
|
|
24
22
|
}
|
|
25
23
|
|
|
26
24
|
companion object {
|
|
27
|
-
const val EVENT_NAME = "
|
|
25
|
+
const val EVENT_NAME = "topCompleteAction"
|
|
28
26
|
}
|
|
29
27
|
}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
package com.reactnativestripesdk
|
|
2
2
|
|
|
3
|
+
import com.facebook.react.module.annotations.ReactModule
|
|
3
4
|
import com.facebook.react.uimanager.SimpleViewManager
|
|
4
5
|
import com.facebook.react.uimanager.ThemedReactContext
|
|
5
6
|
import com.facebook.react.uimanager.annotations.ReactProp
|
|
6
7
|
|
|
8
|
+
@ReactModule(name = GooglePayButtonManager.REACT_CLASS)
|
|
7
9
|
class GooglePayButtonManager : SimpleViewManager<GooglePayButtonView>() {
|
|
8
|
-
override fun getName()
|
|
9
|
-
return REACT_CLASS
|
|
10
|
-
}
|
|
10
|
+
override fun getName() = REACT_CLASS
|
|
11
11
|
|
|
12
12
|
override fun onAfterUpdateTransaction(view: GooglePayButtonView) {
|
|
13
13
|
super.onAfterUpdateTransaction(view)
|
|
@@ -16,23 +16,30 @@ class GooglePayButtonManager : SimpleViewManager<GooglePayButtonView>() {
|
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
@ReactProp(name = "type")
|
|
19
|
-
fun type(
|
|
19
|
+
fun type(
|
|
20
|
+
view: GooglePayButtonView,
|
|
21
|
+
buttonType: Int,
|
|
22
|
+
) {
|
|
20
23
|
view.setType(buttonType)
|
|
21
24
|
}
|
|
22
25
|
|
|
23
26
|
@ReactProp(name = "appearance")
|
|
24
|
-
fun appearance(
|
|
27
|
+
fun appearance(
|
|
28
|
+
view: GooglePayButtonView,
|
|
29
|
+
appearance: Int,
|
|
30
|
+
) {
|
|
25
31
|
view.setAppearance(appearance)
|
|
26
32
|
}
|
|
27
33
|
|
|
28
34
|
@ReactProp(name = "borderRadius")
|
|
29
|
-
fun borderRadius(
|
|
35
|
+
fun borderRadius(
|
|
36
|
+
view: GooglePayButtonView,
|
|
37
|
+
borderRadius: Int,
|
|
38
|
+
) {
|
|
30
39
|
view.setBorderRadius(borderRadius)
|
|
31
40
|
}
|
|
32
41
|
|
|
33
|
-
override fun createViewInstance(reactContext: ThemedReactContext): GooglePayButtonView
|
|
34
|
-
return GooglePayButtonView(reactContext)
|
|
35
|
-
}
|
|
42
|
+
override fun createViewInstance(reactContext: ThemedReactContext): GooglePayButtonView = GooglePayButtonView(reactContext)
|
|
36
43
|
|
|
37
44
|
companion object {
|
|
38
45
|
const val REACT_CLASS = "GooglePayButton"
|
|
@@ -13,7 +13,10 @@ import com.google.android.gms.wallet.button.PayButton
|
|
|
13
13
|
import com.stripe.android.GooglePayJsonFactory
|
|
14
14
|
import org.json.JSONArray
|
|
15
15
|
|
|
16
|
-
|
|
16
|
+
@SuppressLint("ViewConstructor")
|
|
17
|
+
class GooglePayButtonView(
|
|
18
|
+
private val context: ThemedReactContext,
|
|
19
|
+
) : FrameLayout(context) {
|
|
17
20
|
private var type: Int? = null
|
|
18
21
|
private var appearance: Int? = null
|
|
19
22
|
private var borderRadius: Int = 4 // Matches the default on iOS's ApplePayButton
|
|
@@ -29,30 +32,35 @@ class GooglePayButtonView(private val context: ThemedReactContext) : FrameLayout
|
|
|
29
32
|
}
|
|
30
33
|
|
|
31
34
|
private fun configureGooglePayButton(): PayButton {
|
|
32
|
-
val googlePayButton =
|
|
33
|
-
|
|
34
|
-
|
|
35
|
+
val googlePayButton =
|
|
36
|
+
PayButton(
|
|
37
|
+
context,
|
|
38
|
+
)
|
|
35
39
|
googlePayButton.initialize(buildButtonOptions())
|
|
36
40
|
googlePayButton.setOnClickListener { _ ->
|
|
37
41
|
// Call the Javascript TouchableOpacity parent where the onClick handler is set
|
|
38
42
|
(this.parent as? View)?.performClick() ?: run {
|
|
39
43
|
Log.e("StripeReactNative", "Unable to find parent of GooglePayButtonView.")
|
|
40
44
|
}
|
|
41
|
-
}
|
|
45
|
+
}
|
|
42
46
|
return googlePayButton
|
|
43
47
|
}
|
|
44
48
|
|
|
45
49
|
@SuppressLint("RestrictedApi")
|
|
46
50
|
private fun buildButtonOptions(): ButtonOptions {
|
|
47
|
-
val allowedPaymentMethods =
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
51
|
+
val allowedPaymentMethods =
|
|
52
|
+
JSONArray()
|
|
53
|
+
.put(
|
|
54
|
+
GooglePayJsonFactory(context).createCardPaymentMethod(
|
|
55
|
+
billingAddressParameters = null,
|
|
56
|
+
allowCreditCards = null,
|
|
57
|
+
),
|
|
58
|
+
).toString()
|
|
59
|
+
|
|
60
|
+
val options =
|
|
61
|
+
ButtonOptions
|
|
62
|
+
.newBuilder()
|
|
63
|
+
.setAllowedPaymentMethods(allowedPaymentMethods)
|
|
56
64
|
|
|
57
65
|
getButtonType()?.let {
|
|
58
66
|
options.setButtonType(it)
|
|
@@ -67,10 +75,11 @@ class GooglePayButtonView(private val context: ThemedReactContext) : FrameLayout
|
|
|
67
75
|
return options.build()
|
|
68
76
|
}
|
|
69
77
|
|
|
70
|
-
private fun getButtonType(): Int?
|
|
71
|
-
|
|
78
|
+
private fun getButtonType(): Int? =
|
|
79
|
+
when (this.type) {
|
|
72
80
|
0,
|
|
73
|
-
1
|
|
81
|
+
1,
|
|
82
|
+
-> ButtonType.BUY
|
|
74
83
|
6 -> ButtonType.BOOK
|
|
75
84
|
5 -> ButtonType.CHECKOUT
|
|
76
85
|
4 -> ButtonType.DONATE
|
|
@@ -80,28 +89,27 @@ class GooglePayButtonView(private val context: ThemedReactContext) : FrameLayout
|
|
|
80
89
|
1001 -> ButtonType.PLAIN
|
|
81
90
|
else -> null
|
|
82
91
|
}
|
|
83
|
-
}
|
|
84
92
|
|
|
85
|
-
private fun getButtonTheme(): Int?
|
|
86
|
-
|
|
93
|
+
private fun getButtonTheme(): Int? =
|
|
94
|
+
when (this.appearance) {
|
|
87
95
|
0, 1 -> ButtonTheme.LIGHT
|
|
88
96
|
2 -> ButtonTheme.DARK
|
|
89
97
|
else -> null
|
|
90
98
|
}
|
|
91
|
-
}
|
|
92
99
|
|
|
93
100
|
override fun requestLayout() {
|
|
94
101
|
super.requestLayout()
|
|
95
102
|
post(mLayoutRunnable)
|
|
96
103
|
}
|
|
97
104
|
|
|
98
|
-
private val mLayoutRunnable =
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
+
private val mLayoutRunnable =
|
|
106
|
+
Runnable {
|
|
107
|
+
measure(
|
|
108
|
+
MeasureSpec.makeMeasureSpec(width, MeasureSpec.EXACTLY),
|
|
109
|
+
MeasureSpec.makeMeasureSpec(height, MeasureSpec.EXACTLY),
|
|
110
|
+
)
|
|
111
|
+
button?.layout(left, top, right, bottom)
|
|
112
|
+
}
|
|
105
113
|
|
|
106
114
|
fun setType(type: Int) {
|
|
107
115
|
this.type = type
|