@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
|
@@ -7,20 +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
|
|
15
22
|
import com.stripe.android.financialconnections.FinancialConnections
|
|
16
23
|
import com.stripe.android.financialconnections.FinancialConnectionsSheet
|
|
17
24
|
import com.stripe.android.financialconnections.FinancialConnectionsSheetForTokenResult
|
|
18
25
|
import com.stripe.android.financialconnections.FinancialConnectionsSheetResult
|
|
19
|
-
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
|
|
20
31
|
|
|
21
32
|
class FinancialConnectionsSheetFragment : Fragment() {
|
|
22
33
|
enum class Mode {
|
|
23
|
-
ForToken,
|
|
34
|
+
ForToken,
|
|
35
|
+
ForSession,
|
|
24
36
|
}
|
|
25
37
|
|
|
26
38
|
private lateinit var promise: Promise
|
|
@@ -40,30 +52,28 @@ class FinancialConnectionsSheetFragment : Fragment() {
|
|
|
40
52
|
}
|
|
41
53
|
}
|
|
42
54
|
|
|
43
|
-
override fun onCreateView(
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
}
|
|
55
|
+
override fun onCreateView(
|
|
56
|
+
inflater: LayoutInflater,
|
|
57
|
+
container: ViewGroup?,
|
|
58
|
+
savedInstanceState: Bundle?,
|
|
59
|
+
): View = FrameLayout(requireActivity()).also { it.visibility = View.GONE }
|
|
49
60
|
|
|
50
|
-
override fun onViewCreated(
|
|
61
|
+
override fun onViewCreated(
|
|
62
|
+
view: View,
|
|
63
|
+
savedInstanceState: Bundle?,
|
|
64
|
+
) {
|
|
51
65
|
when (mode) {
|
|
52
66
|
Mode.ForToken -> {
|
|
53
|
-
FinancialConnectionsSheet
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
configuration = configuration
|
|
58
|
-
)
|
|
67
|
+
FinancialConnectionsSheet
|
|
68
|
+
.createForBankAccountToken(
|
|
69
|
+
this,
|
|
70
|
+
::onFinancialConnectionsSheetForTokenResult,
|
|
71
|
+
).present(configuration = configuration)
|
|
59
72
|
}
|
|
60
73
|
Mode.ForSession -> {
|
|
61
|
-
FinancialConnectionsSheet
|
|
62
|
-
this,
|
|
63
|
-
|
|
64
|
-
).present(
|
|
65
|
-
configuration = configuration
|
|
66
|
-
)
|
|
74
|
+
FinancialConnectionsSheet
|
|
75
|
+
.create(this, ::onFinancialConnectionsSheetForDataResult)
|
|
76
|
+
.present(configuration = configuration)
|
|
67
77
|
}
|
|
68
78
|
}
|
|
69
79
|
}
|
|
@@ -76,75 +86,86 @@ class FinancialConnectionsSheetFragment : Fragment() {
|
|
|
76
86
|
}
|
|
77
87
|
|
|
78
88
|
private fun onFinancialConnectionsSheetForTokenResult(result: FinancialConnectionsSheetForTokenResult) {
|
|
79
|
-
when(result) {
|
|
89
|
+
when (result) {
|
|
80
90
|
is FinancialConnectionsSheetForTokenResult.Canceled -> {
|
|
81
|
-
promise.resolve(
|
|
82
|
-
createError(ErrorType.Canceled.toString(), "The flow has been canceled")
|
|
83
|
-
)
|
|
91
|
+
promise.resolve(createError(ErrorType.Canceled.toString(), "The flow has been canceled"))
|
|
84
92
|
}
|
|
85
93
|
is FinancialConnectionsSheetForTokenResult.Failed -> {
|
|
86
|
-
promise.resolve(
|
|
87
|
-
createError(ErrorType.Failed.toString(), result.error)
|
|
88
|
-
)
|
|
94
|
+
promise.resolve(createError(ErrorType.Failed.toString(), result.error))
|
|
89
95
|
}
|
|
90
96
|
is FinancialConnectionsSheetForTokenResult.Completed -> {
|
|
91
97
|
promise.resolve(createTokenResult(result))
|
|
92
|
-
(context.currentActivity as? FragmentActivity)
|
|
98
|
+
(context.currentActivity as? FragmentActivity)
|
|
99
|
+
?.supportFragmentManager
|
|
100
|
+
?.beginTransaction()
|
|
101
|
+
?.remove(this)
|
|
102
|
+
?.commitAllowingStateLoss()
|
|
93
103
|
}
|
|
94
104
|
}
|
|
95
105
|
}
|
|
96
106
|
|
|
97
107
|
private fun onFinancialConnectionsSheetForDataResult(result: FinancialConnectionsSheetResult) {
|
|
98
|
-
when(result) {
|
|
108
|
+
when (result) {
|
|
99
109
|
is FinancialConnectionsSheetResult.Canceled -> {
|
|
100
|
-
promise.resolve(
|
|
101
|
-
createError(ErrorType.Canceled.toString(), "The flow has been canceled")
|
|
102
|
-
)
|
|
110
|
+
promise.resolve(createError(ErrorType.Canceled.toString(), "The flow has been canceled"))
|
|
103
111
|
}
|
|
104
112
|
is FinancialConnectionsSheetResult.Failed -> {
|
|
105
|
-
promise.resolve(
|
|
106
|
-
createError(ErrorType.Failed.toString(), result.error)
|
|
107
|
-
)
|
|
113
|
+
promise.resolve(createError(ErrorType.Failed.toString(), result.error))
|
|
108
114
|
}
|
|
109
115
|
is FinancialConnectionsSheetResult.Completed -> {
|
|
110
116
|
promise.resolve(
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
117
|
+
WritableNativeMap().also {
|
|
118
|
+
it.putMap("session", mapFromSession(result.financialConnectionsSession))
|
|
119
|
+
},
|
|
114
120
|
)
|
|
115
|
-
(context.currentActivity as? FragmentActivity)
|
|
121
|
+
(context.currentActivity as? FragmentActivity)
|
|
122
|
+
?.supportFragmentManager
|
|
123
|
+
?.beginTransaction()
|
|
124
|
+
?.remove(this)
|
|
125
|
+
?.commitAllowingStateLoss()
|
|
116
126
|
}
|
|
117
127
|
}
|
|
118
128
|
}
|
|
119
129
|
|
|
120
|
-
fun presentFinancialConnectionsSheet(
|
|
130
|
+
fun presentFinancialConnectionsSheet(
|
|
131
|
+
clientSecret: String,
|
|
132
|
+
mode: Mode,
|
|
133
|
+
publishableKey: String,
|
|
134
|
+
stripeAccountId: String?,
|
|
135
|
+
promise: Promise,
|
|
136
|
+
context: ReactApplicationContext,
|
|
137
|
+
) {
|
|
121
138
|
this.promise = promise
|
|
122
139
|
this.context = context
|
|
123
140
|
this.mode = mode
|
|
124
|
-
this.configuration =
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
141
|
+
this.configuration =
|
|
142
|
+
FinancialConnectionsSheet.Configuration(
|
|
143
|
+
financialConnectionsSessionClientSecret = clientSecret,
|
|
144
|
+
publishableKey = publishableKey,
|
|
145
|
+
stripeAccountId = stripeAccountId,
|
|
146
|
+
)
|
|
129
147
|
|
|
130
148
|
(context.currentActivity as? FragmentActivity)?.let {
|
|
131
149
|
attemptToCleanupPreviousFragment(it)
|
|
132
150
|
commitFragmentAndStartFlow(it)
|
|
133
|
-
} ?: run {
|
|
134
|
-
promise.resolve(createMissingActivityError())
|
|
135
|
-
return
|
|
136
151
|
}
|
|
152
|
+
?: run {
|
|
153
|
+
promise.resolve(createMissingActivityError())
|
|
154
|
+
return
|
|
155
|
+
}
|
|
137
156
|
}
|
|
138
157
|
|
|
139
158
|
private fun attemptToCleanupPreviousFragment(currentActivity: FragmentActivity) {
|
|
140
|
-
currentActivity.supportFragmentManager
|
|
159
|
+
currentActivity.supportFragmentManager
|
|
160
|
+
.beginTransaction()
|
|
141
161
|
.remove(this)
|
|
142
162
|
.commitAllowingStateLoss()
|
|
143
163
|
}
|
|
144
164
|
|
|
145
165
|
private fun commitFragmentAndStartFlow(currentActivity: FragmentActivity) {
|
|
146
166
|
try {
|
|
147
|
-
currentActivity.supportFragmentManager
|
|
167
|
+
currentActivity.supportFragmentManager
|
|
168
|
+
.beginTransaction()
|
|
148
169
|
.add(this, TAG)
|
|
149
170
|
.commit()
|
|
150
171
|
} catch (error: IllegalStateException) {
|
|
@@ -155,12 +176,11 @@ class FinancialConnectionsSheetFragment : Fragment() {
|
|
|
155
176
|
companion object {
|
|
156
177
|
internal const val TAG = "financial_connections_sheet_launch_fragment"
|
|
157
178
|
|
|
158
|
-
private fun createTokenResult(result: FinancialConnectionsSheetForTokenResult.Completed): WritableMap
|
|
159
|
-
|
|
179
|
+
private fun createTokenResult(result: FinancialConnectionsSheetForTokenResult.Completed): WritableMap =
|
|
180
|
+
WritableNativeMap().also {
|
|
160
181
|
it.putMap("session", mapFromSession(result.financialConnectionsSession))
|
|
161
182
|
it.putMap("token", mapFromToken(result.token))
|
|
162
183
|
}
|
|
163
|
-
}
|
|
164
184
|
|
|
165
185
|
private fun mapFromSession(financialConnectionsSession: FinancialConnectionsSession): WritableMap {
|
|
166
186
|
val session = WritableNativeMap()
|
|
@@ -186,8 +206,19 @@ class FinancialConnectionsSheetFragment : Fragment() {
|
|
|
186
206
|
map.putMap("balanceRefresh", mapFromAccountBalanceRefresh(account.balanceRefresh))
|
|
187
207
|
map.putString("category", mapFromCategory(account.category))
|
|
188
208
|
map.putString("subcategory", mapFromSubcategory(account.subcategory))
|
|
189
|
-
map.putArray(
|
|
190
|
-
|
|
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
|
+
)
|
|
191
222
|
results.pushMap(map)
|
|
192
223
|
}
|
|
193
224
|
return results
|
|
@@ -212,8 +243,8 @@ class FinancialConnectionsSheetFragment : Fragment() {
|
|
|
212
243
|
return map
|
|
213
244
|
}
|
|
214
245
|
|
|
215
|
-
private fun mapFromCashAvailable(balance: Balance): WritableNativeMap
|
|
216
|
-
|
|
246
|
+
private fun mapFromCashAvailable(balance: Balance): WritableNativeMap =
|
|
247
|
+
WritableNativeMap().also { cashMap ->
|
|
217
248
|
WritableNativeMap().also { availableMap ->
|
|
218
249
|
balance.cash?.available?.entries?.let { entries ->
|
|
219
250
|
for (entry in entries) {
|
|
@@ -223,10 +254,9 @@ class FinancialConnectionsSheetFragment : Fragment() {
|
|
|
223
254
|
cashMap.putMap("available", availableMap)
|
|
224
255
|
}
|
|
225
256
|
}
|
|
226
|
-
}
|
|
227
257
|
|
|
228
|
-
private fun mapFromCreditUsed(balance: Balance): WritableNativeMap
|
|
229
|
-
|
|
258
|
+
private fun mapFromCreditUsed(balance: Balance): WritableNativeMap =
|
|
259
|
+
WritableNativeMap().also { creditMap ->
|
|
230
260
|
WritableNativeMap().also { usedMap ->
|
|
231
261
|
balance.credit?.used?.entries?.let { entries ->
|
|
232
262
|
for (entry in entries) {
|
|
@@ -236,7 +266,6 @@ class FinancialConnectionsSheetFragment : Fragment() {
|
|
|
236
266
|
creditMap.putMap("used", usedMap)
|
|
237
267
|
}
|
|
238
268
|
}
|
|
239
|
-
}
|
|
240
269
|
|
|
241
270
|
private fun mapFromAccountBalanceRefresh(balanceRefresh: BalanceRefresh?): WritableMap? {
|
|
242
271
|
if (balanceRefresh == null) {
|
|
@@ -248,27 +277,25 @@ class FinancialConnectionsSheetFragment : Fragment() {
|
|
|
248
277
|
return map
|
|
249
278
|
}
|
|
250
279
|
|
|
251
|
-
private fun mapFromStatus(status: FinancialConnectionsAccount.Status): String
|
|
252
|
-
|
|
280
|
+
private fun mapFromStatus(status: FinancialConnectionsAccount.Status): String =
|
|
281
|
+
when (status) {
|
|
253
282
|
FinancialConnectionsAccount.Status.ACTIVE -> "active"
|
|
254
283
|
FinancialConnectionsAccount.Status.DISCONNECTED -> "disconnected"
|
|
255
284
|
FinancialConnectionsAccount.Status.INACTIVE -> "inactive"
|
|
256
285
|
FinancialConnectionsAccount.Status.UNKNOWN -> "unparsable"
|
|
257
286
|
}
|
|
258
|
-
}
|
|
259
287
|
|
|
260
|
-
private fun mapFromCategory(category: FinancialConnectionsAccount.Category): String
|
|
261
|
-
|
|
288
|
+
private fun mapFromCategory(category: FinancialConnectionsAccount.Category): String =
|
|
289
|
+
when (category) {
|
|
262
290
|
FinancialConnectionsAccount.Category.CASH -> "cash"
|
|
263
291
|
FinancialConnectionsAccount.Category.CREDIT -> "credit"
|
|
264
292
|
FinancialConnectionsAccount.Category.INVESTMENT -> "investment"
|
|
265
293
|
FinancialConnectionsAccount.Category.OTHER -> "other"
|
|
266
294
|
FinancialConnectionsAccount.Category.UNKNOWN -> "unparsable"
|
|
267
295
|
}
|
|
268
|
-
}
|
|
269
296
|
|
|
270
|
-
private fun mapFromSubcategory(subcategory: FinancialConnectionsAccount.Subcategory): String
|
|
271
|
-
|
|
297
|
+
private fun mapFromSubcategory(subcategory: FinancialConnectionsAccount.Subcategory): String =
|
|
298
|
+
when (subcategory) {
|
|
272
299
|
FinancialConnectionsAccount.Subcategory.CHECKING -> "checking"
|
|
273
300
|
FinancialConnectionsAccount.Subcategory.CREDIT_CARD -> "creditCard"
|
|
274
301
|
FinancialConnectionsAccount.Subcategory.LINE_OF_CREDIT -> "lineOfCredit"
|
|
@@ -277,10 +304,9 @@ class FinancialConnectionsSheetFragment : Fragment() {
|
|
|
277
304
|
FinancialConnectionsAccount.Subcategory.SAVINGS -> "savings"
|
|
278
305
|
FinancialConnectionsAccount.Subcategory.UNKNOWN -> "unparsable"
|
|
279
306
|
}
|
|
280
|
-
}
|
|
281
307
|
|
|
282
|
-
private fun mapFromPermission(permission: FinancialConnectionsAccount.Permissions): String
|
|
283
|
-
|
|
308
|
+
private fun mapFromPermission(permission: FinancialConnectionsAccount.Permissions): String =
|
|
309
|
+
when (permission) {
|
|
284
310
|
FinancialConnectionsAccount.Permissions.PAYMENT_METHOD -> "paymentMethod"
|
|
285
311
|
FinancialConnectionsAccount.Permissions.BALANCES -> "balances"
|
|
286
312
|
FinancialConnectionsAccount.Permissions.OWNERSHIP -> "ownership"
|
|
@@ -289,33 +315,29 @@ class FinancialConnectionsSheetFragment : Fragment() {
|
|
|
289
315
|
FinancialConnectionsAccount.Permissions.UNKNOWN -> "unparsable"
|
|
290
316
|
FinancialConnectionsAccount.Permissions.ACCOUNT_NUMBERS -> "accountNumbers"
|
|
291
317
|
}
|
|
292
|
-
}
|
|
293
318
|
|
|
294
|
-
private fun mapFromSupportedPaymentMethodTypes(type: FinancialConnectionsAccount.SupportedPaymentMethodTypes): String
|
|
295
|
-
|
|
319
|
+
private fun mapFromSupportedPaymentMethodTypes(type: FinancialConnectionsAccount.SupportedPaymentMethodTypes): String =
|
|
320
|
+
when (type) {
|
|
296
321
|
FinancialConnectionsAccount.SupportedPaymentMethodTypes.US_BANK_ACCOUNT -> "usBankAccount"
|
|
297
322
|
FinancialConnectionsAccount.SupportedPaymentMethodTypes.LINK -> "link"
|
|
298
323
|
FinancialConnectionsAccount.SupportedPaymentMethodTypes.UNKNOWN -> "unparsable"
|
|
299
324
|
}
|
|
300
|
-
}
|
|
301
325
|
|
|
302
|
-
private fun mapFromBalanceType(type: Balance.Type): String
|
|
303
|
-
|
|
326
|
+
private fun mapFromBalanceType(type: Balance.Type): String =
|
|
327
|
+
when (type) {
|
|
304
328
|
Balance.Type.CASH -> "cash"
|
|
305
329
|
Balance.Type.CREDIT -> "credit"
|
|
306
330
|
Balance.Type.UNKNOWN -> "unparsable"
|
|
307
331
|
}
|
|
308
|
-
}
|
|
309
332
|
|
|
310
|
-
private fun mapFromBalanceRefreshStatus(status: BalanceRefresh.BalanceRefreshStatus?): String
|
|
311
|
-
|
|
333
|
+
private fun mapFromBalanceRefreshStatus(status: BalanceRefresh.BalanceRefreshStatus?): String =
|
|
334
|
+
when (status) {
|
|
312
335
|
BalanceRefresh.BalanceRefreshStatus.SUCCEEDED -> "succeeded"
|
|
313
336
|
BalanceRefresh.BalanceRefreshStatus.FAILED -> "failed"
|
|
314
337
|
BalanceRefresh.BalanceRefreshStatus.PENDING -> "pending"
|
|
315
338
|
BalanceRefresh.BalanceRefreshStatus.UNKNOWN -> "unparsable"
|
|
316
339
|
null -> "null"
|
|
317
340
|
}
|
|
318
|
-
}
|
|
319
341
|
}
|
|
320
342
|
}
|
|
321
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
|