@stripe/stripe-react-native 0.42.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 +14 -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 +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 +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 +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 +295 -258
- package/android/src/main/java/com/reactnativestripesdk/utils/PostalCodeUtilities.kt +2 -11
- package/ios/CustomerSheet/CustomerSheetUtils.swift +3 -1
- package/ios/FinancialConnections.swift +6 -2
- package/ios/StripeSdk+CustomerSheet.swift +2 -1
- package/ios/StripeSdk+PaymentSheet.swift +42 -0
- 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 +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 +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 +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 +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/types/Common.ts +3 -0
- package/src/types/CustomerSheet.ts +7 -0
- package/src/types/FinancialConnections.ts +3 -0
- package/src/types/PaymentMethod.ts +5 -1
- package/src/types/PaymentSheet.ts +64 -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,16 +7,22 @@ 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.ReactApplicationContext
|
|
11
|
+
import com.facebook.react.bridge.ReadableMap
|
|
12
|
+
import com.facebook.react.bridge.WritableMap
|
|
13
|
+
import com.reactnativestripesdk.utils.ErrorType
|
|
14
|
+
import com.reactnativestripesdk.utils.GooglePayErrorType
|
|
12
15
|
import com.reactnativestripesdk.utils.createError
|
|
13
16
|
import com.reactnativestripesdk.utils.createMissingActivityError
|
|
17
|
+
import com.reactnativestripesdk.utils.getBooleanOr
|
|
18
|
+
import com.reactnativestripesdk.utils.getIntOrNull
|
|
14
19
|
import com.stripe.android.googlepaylauncher.GooglePayEnvironment
|
|
15
20
|
import com.stripe.android.googlepaylauncher.GooglePayLauncher
|
|
16
21
|
|
|
17
22
|
class GooglePayLauncherFragment : Fragment() {
|
|
18
23
|
enum class Mode {
|
|
19
|
-
ForSetup,
|
|
24
|
+
ForSetup,
|
|
25
|
+
ForPayment,
|
|
20
26
|
}
|
|
21
27
|
|
|
22
28
|
private lateinit var launcher: GooglePayLauncher
|
|
@@ -28,64 +34,81 @@ class GooglePayLauncherFragment : Fragment() {
|
|
|
28
34
|
private var label: String? = null
|
|
29
35
|
private lateinit var callback: (result: GooglePayLauncher.Result?, error: WritableMap?) -> Unit
|
|
30
36
|
|
|
31
|
-
override fun onCreateView(
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
}
|
|
37
|
+
override fun onCreateView(
|
|
38
|
+
inflater: LayoutInflater,
|
|
39
|
+
container: ViewGroup?,
|
|
40
|
+
savedInstanceState: Bundle?,
|
|
41
|
+
): View = FrameLayout(requireActivity()).also { it.visibility = View.GONE }
|
|
37
42
|
|
|
38
|
-
override fun onViewCreated(
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
43
|
+
override fun onViewCreated(
|
|
44
|
+
view: View,
|
|
45
|
+
savedInstanceState: Bundle?,
|
|
46
|
+
) {
|
|
47
|
+
launcher =
|
|
48
|
+
GooglePayLauncher(
|
|
49
|
+
fragment = this,
|
|
50
|
+
config = configuration,
|
|
51
|
+
readyCallback = ::onGooglePayReady,
|
|
52
|
+
resultCallback = ::onGooglePayResult,
|
|
53
|
+
)
|
|
45
54
|
}
|
|
46
55
|
|
|
47
|
-
fun presentGooglePaySheet(
|
|
56
|
+
fun presentGooglePaySheet(
|
|
57
|
+
clientSecret: String,
|
|
58
|
+
mode: Mode,
|
|
59
|
+
googlePayParams: ReadableMap,
|
|
60
|
+
context: ReactApplicationContext,
|
|
61
|
+
callback: (GooglePayLauncher.Result?, error: WritableMap?) -> Unit,
|
|
62
|
+
) {
|
|
48
63
|
this.clientSecret = clientSecret
|
|
49
64
|
this.mode = mode
|
|
50
65
|
this.callback = callback
|
|
51
66
|
this.currencyCode = googlePayParams.getString("currencyCode") ?: "USD"
|
|
52
67
|
this.amount = getIntOrNull(googlePayParams, "amount")
|
|
53
68
|
this.label = googlePayParams.getString("label")
|
|
54
|
-
this.configuration =
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
69
|
+
this.configuration =
|
|
70
|
+
GooglePayLauncher.Config(
|
|
71
|
+
environment =
|
|
72
|
+
if (googlePayParams.getBoolean("testEnv")) {
|
|
73
|
+
GooglePayEnvironment.Test
|
|
74
|
+
} else {
|
|
75
|
+
GooglePayEnvironment.Production
|
|
76
|
+
},
|
|
77
|
+
merchantCountryCode = googlePayParams.getString("merchantCountryCode").orEmpty(),
|
|
78
|
+
merchantName = googlePayParams.getString("merchantName").orEmpty(),
|
|
79
|
+
isEmailRequired = googlePayParams.getBooleanOr("isEmailRequired", false),
|
|
80
|
+
billingAddressConfig =
|
|
81
|
+
buildBillingAddressParameters(googlePayParams.getMap("billingAddressConfig")),
|
|
82
|
+
existingPaymentMethodRequired =
|
|
83
|
+
googlePayParams.getBooleanOr("existingPaymentMethodRequired", false),
|
|
84
|
+
allowCreditCards = googlePayParams.getBooleanOr("allowCreditCards", true),
|
|
85
|
+
)
|
|
63
86
|
|
|
64
87
|
(context.currentActivity as? FragmentActivity)?.let {
|
|
65
88
|
attemptToCleanupPreviousFragment(it)
|
|
66
89
|
commitFragmentAndStartFlow(it)
|
|
67
|
-
} ?: run {
|
|
68
|
-
callback(null, createMissingActivityError())
|
|
69
|
-
return
|
|
70
90
|
}
|
|
91
|
+
?: run {
|
|
92
|
+
callback(null, createMissingActivityError())
|
|
93
|
+
return
|
|
94
|
+
}
|
|
71
95
|
}
|
|
72
96
|
|
|
73
97
|
private fun attemptToCleanupPreviousFragment(currentActivity: FragmentActivity) {
|
|
74
|
-
currentActivity.supportFragmentManager
|
|
98
|
+
currentActivity.supportFragmentManager
|
|
99
|
+
.beginTransaction()
|
|
75
100
|
.remove(this)
|
|
76
101
|
.commitAllowingStateLoss()
|
|
77
102
|
}
|
|
78
103
|
|
|
79
104
|
private fun commitFragmentAndStartFlow(currentActivity: FragmentActivity) {
|
|
80
105
|
try {
|
|
81
|
-
currentActivity.supportFragmentManager
|
|
106
|
+
currentActivity.supportFragmentManager
|
|
107
|
+
.beginTransaction()
|
|
82
108
|
.add(this, TAG)
|
|
83
109
|
.commit()
|
|
84
110
|
} catch (error: IllegalStateException) {
|
|
85
|
-
callback(
|
|
86
|
-
null,
|
|
87
|
-
createError(ErrorType.Failed.toString(), error.message)
|
|
88
|
-
)
|
|
111
|
+
callback(null, createError(ErrorType.Failed.toString(), error.message))
|
|
89
112
|
}
|
|
90
113
|
}
|
|
91
114
|
|
|
@@ -104,8 +127,8 @@ class GooglePayLauncherFragment : Fragment() {
|
|
|
104
127
|
null,
|
|
105
128
|
createError(
|
|
106
129
|
GooglePayErrorType.Failed.toString(),
|
|
107
|
-
"Google Pay is not available on this device. You can use isPlatformPaySupported to preemptively check for Google Pay support."
|
|
108
|
-
)
|
|
130
|
+
"Google Pay is not available on this device. You can use isPlatformPaySupported to preemptively check for Google Pay support.",
|
|
131
|
+
),
|
|
109
132
|
)
|
|
110
133
|
}
|
|
111
134
|
}
|
|
@@ -120,16 +143,17 @@ class GooglePayLauncherFragment : Fragment() {
|
|
|
120
143
|
private fun buildBillingAddressParameters(params: ReadableMap?): GooglePayLauncher.BillingAddressConfig {
|
|
121
144
|
val isRequired = params?.getBooleanOr("isRequired", false)
|
|
122
145
|
val isPhoneNumberRequired = params?.getBooleanOr("isPhoneNumberRequired", false)
|
|
123
|
-
val format =
|
|
124
|
-
"
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
146
|
+
val format =
|
|
147
|
+
when (params?.getString("format").orEmpty()) {
|
|
148
|
+
"FULL" -> GooglePayLauncher.BillingAddressConfig.Format.Full
|
|
149
|
+
"MIN" -> GooglePayLauncher.BillingAddressConfig.Format.Min
|
|
150
|
+
else -> GooglePayLauncher.BillingAddressConfig.Format.Min
|
|
151
|
+
}
|
|
128
152
|
|
|
129
153
|
return GooglePayLauncher.BillingAddressConfig(
|
|
130
154
|
isRequired = isRequired ?: false,
|
|
131
155
|
format = format,
|
|
132
|
-
isPhoneNumberRequired = isPhoneNumberRequired ?: false
|
|
156
|
+
isPhoneNumberRequired = isPhoneNumberRequired ?: false,
|
|
133
157
|
)
|
|
134
158
|
}
|
|
135
159
|
}
|
package/android/src/main/java/com/reactnativestripesdk/GooglePayPaymentMethodLauncherFragment.kt
CHANGED
|
@@ -16,30 +16,35 @@ class GooglePayPaymentMethodLauncherFragment(
|
|
|
16
16
|
private val context: ReactApplicationContext,
|
|
17
17
|
private val isTestEnv: Boolean,
|
|
18
18
|
private val paymentMethodRequired: Boolean,
|
|
19
|
-
private val promise: Promise
|
|
20
|
-
|
|
21
|
-
override fun onCreateView(
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
}
|
|
19
|
+
private val promise: Promise,
|
|
20
|
+
) : Fragment() {
|
|
21
|
+
override fun onCreateView(
|
|
22
|
+
inflater: LayoutInflater,
|
|
23
|
+
container: ViewGroup?,
|
|
24
|
+
savedInstanceState: Bundle?,
|
|
25
|
+
): View = FrameLayout(requireActivity()).also { it.visibility = View.GONE }
|
|
27
26
|
|
|
28
|
-
override fun onViewCreated(
|
|
27
|
+
override fun onViewCreated(
|
|
28
|
+
view: View,
|
|
29
|
+
savedInstanceState: Bundle?,
|
|
30
|
+
) {
|
|
29
31
|
super.onViewCreated(view, savedInstanceState)
|
|
30
32
|
GooglePayPaymentMethodLauncher(
|
|
31
33
|
this,
|
|
32
|
-
config =
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
34
|
+
config =
|
|
35
|
+
GooglePayPaymentMethodLauncher.Config(
|
|
36
|
+
environment =
|
|
37
|
+
if (isTestEnv) GooglePayEnvironment.Test else GooglePayEnvironment.Production,
|
|
38
|
+
existingPaymentMethodRequired = paymentMethodRequired,
|
|
39
|
+
merchantCountryCode =
|
|
40
|
+
"", // Unnecessary since all we are checking for is Google Pay availability
|
|
41
|
+
merchantName = "", // Same as above
|
|
42
|
+
),
|
|
38
43
|
readyCallback = {
|
|
39
44
|
promise.resolve(it)
|
|
40
45
|
removeFragment(context)
|
|
41
46
|
},
|
|
42
|
-
resultCallback = {}
|
|
47
|
+
resultCallback = {},
|
|
43
48
|
)
|
|
44
49
|
}
|
|
45
50
|
|
|
@@ -7,10 +7,16 @@ import com.facebook.react.bridge.Promise
|
|
|
7
7
|
import com.facebook.react.bridge.ReadableMap
|
|
8
8
|
import com.facebook.react.bridge.WritableNativeMap
|
|
9
9
|
import com.google.android.gms.tasks.Task
|
|
10
|
-
import com.google.android.gms.wallet
|
|
11
|
-
import com.
|
|
10
|
+
import com.google.android.gms.wallet.AutoResolveHelper
|
|
11
|
+
import com.google.android.gms.wallet.PaymentData
|
|
12
|
+
import com.google.android.gms.wallet.PaymentDataRequest
|
|
13
|
+
import com.google.android.gms.wallet.Wallet
|
|
14
|
+
import com.google.android.gms.wallet.WalletConstants
|
|
15
|
+
import com.reactnativestripesdk.utils.ErrorType
|
|
12
16
|
import com.reactnativestripesdk.utils.createError
|
|
17
|
+
import com.reactnativestripesdk.utils.getBooleanOr
|
|
13
18
|
import com.reactnativestripesdk.utils.mapFromPaymentMethod
|
|
19
|
+
import com.reactnativestripesdk.utils.mapFromShippingContact
|
|
14
20
|
import com.reactnativestripesdk.utils.mapFromToken
|
|
15
21
|
import com.stripe.android.ApiResultCallback
|
|
16
22
|
import com.stripe.android.GooglePayJsonFactory
|
|
@@ -19,60 +25,82 @@ import com.stripe.android.model.GooglePayResult
|
|
|
19
25
|
import com.stripe.android.model.PaymentMethod
|
|
20
26
|
import com.stripe.android.model.PaymentMethodCreateParams
|
|
21
27
|
import org.json.JSONObject
|
|
22
|
-
import java.util
|
|
28
|
+
import java.util.Locale
|
|
23
29
|
|
|
24
30
|
class GooglePayRequestHelper {
|
|
25
31
|
companion object {
|
|
26
32
|
internal const val LOAD_PAYMENT_DATA_REQUEST_CODE = 414243
|
|
27
33
|
|
|
28
|
-
internal fun createPaymentRequest(
|
|
34
|
+
internal fun createPaymentRequest(
|
|
35
|
+
activity: FragmentActivity,
|
|
36
|
+
factory: GooglePayJsonFactory,
|
|
37
|
+
googlePayParams: ReadableMap,
|
|
38
|
+
): Task<PaymentData> {
|
|
29
39
|
val transactionInfo = buildTransactionInfo(googlePayParams)
|
|
30
|
-
val merchantInfo =
|
|
31
|
-
|
|
32
|
-
val
|
|
33
|
-
|
|
34
|
-
val
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
40
|
+
val merchantInfo =
|
|
41
|
+
GooglePayJsonFactory.MerchantInfo(googlePayParams.getString("merchantName").orEmpty())
|
|
42
|
+
val billingAddressParameters =
|
|
43
|
+
buildBillingAddressParameters(googlePayParams.getMap("billingAddressConfig"))
|
|
44
|
+
val shippingAddressParameters =
|
|
45
|
+
buildShippingAddressParameters(googlePayParams.getMap("shippingAddressConfig"))
|
|
46
|
+
|
|
47
|
+
val request =
|
|
48
|
+
factory.createPaymentDataRequest(
|
|
49
|
+
transactionInfo = transactionInfo,
|
|
50
|
+
merchantInfo = merchantInfo,
|
|
51
|
+
billingAddressParameters = billingAddressParameters,
|
|
52
|
+
shippingAddressParameters = shippingAddressParameters,
|
|
53
|
+
isEmailRequired = googlePayParams.getBooleanOr("isEmailRequired", false),
|
|
54
|
+
allowCreditCards = googlePayParams.getBooleanOr("allowCreditCards", true),
|
|
55
|
+
)
|
|
56
|
+
|
|
57
|
+
val walletOptions =
|
|
58
|
+
Wallet.WalletOptions
|
|
59
|
+
.Builder()
|
|
60
|
+
.setEnvironment(
|
|
61
|
+
if (googlePayParams.getBoolean("testEnv")) {
|
|
62
|
+
WalletConstants.ENVIRONMENT_TEST
|
|
63
|
+
} else {
|
|
64
|
+
WalletConstants.ENVIRONMENT_PRODUCTION
|
|
65
|
+
},
|
|
66
|
+
).build()
|
|
67
|
+
return Wallet
|
|
68
|
+
.getPaymentsClient(activity, walletOptions)
|
|
69
|
+
.loadPaymentData(PaymentDataRequest.fromJson(request.toString()))
|
|
47
70
|
}
|
|
48
71
|
|
|
49
72
|
@Suppress("UNCHECKED_CAST")
|
|
50
73
|
private fun buildShippingAddressParameters(params: ReadableMap?): GooglePayJsonFactory.ShippingAddressParameters {
|
|
51
74
|
val isPhoneNumberRequired = params?.getBooleanOr("isPhoneNumberRequired", false)
|
|
52
75
|
val isRequired = params?.getBooleanOr("isRequired", false)
|
|
53
|
-
val allowedCountryCodes =
|
|
54
|
-
params
|
|
76
|
+
val allowedCountryCodes =
|
|
77
|
+
if (params?.hasKey("allowedCountryCodes") == true) {
|
|
78
|
+
params.getArray("allowedCountryCodes")?.toArrayList()?.toSet() as? Set<String>
|
|
79
|
+
} else {
|
|
80
|
+
null
|
|
81
|
+
}
|
|
55
82
|
|
|
56
83
|
return GooglePayJsonFactory.ShippingAddressParameters(
|
|
57
84
|
isRequired = isRequired ?: false,
|
|
58
85
|
allowedCountryCodes = allowedCountryCodes ?: Locale.getISOCountries().toSet(),
|
|
59
|
-
phoneNumberRequired = isPhoneNumberRequired ?: false
|
|
86
|
+
phoneNumberRequired = isPhoneNumberRequired ?: false,
|
|
60
87
|
)
|
|
61
88
|
}
|
|
62
89
|
|
|
63
90
|
private fun buildBillingAddressParameters(params: ReadableMap?): GooglePayJsonFactory.BillingAddressParameters {
|
|
64
91
|
val isRequired = params?.getBooleanOr("isRequired", false)
|
|
65
92
|
val isPhoneNumberRequired = params?.getBooleanOr("isPhoneNumberRequired", false)
|
|
66
|
-
val format =
|
|
67
|
-
"
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
93
|
+
val format =
|
|
94
|
+
when (params?.getString("format").orEmpty()) {
|
|
95
|
+
"FULL" -> GooglePayJsonFactory.BillingAddressParameters.Format.Full
|
|
96
|
+
"MIN" -> GooglePayJsonFactory.BillingAddressParameters.Format.Min
|
|
97
|
+
else -> GooglePayJsonFactory.BillingAddressParameters.Format.Min
|
|
98
|
+
}
|
|
71
99
|
|
|
72
100
|
return GooglePayJsonFactory.BillingAddressParameters(
|
|
73
101
|
isRequired = isRequired ?: false,
|
|
74
102
|
format = format,
|
|
75
|
-
isPhoneNumberRequired = isPhoneNumberRequired ?: false
|
|
103
|
+
isPhoneNumberRequired = isPhoneNumberRequired ?: false,
|
|
76
104
|
)
|
|
77
105
|
}
|
|
78
106
|
|
|
@@ -88,19 +116,24 @@ class GooglePayRequestHelper {
|
|
|
88
116
|
countryCode = countryCode,
|
|
89
117
|
totalPrice = amount,
|
|
90
118
|
totalPriceLabel = label,
|
|
91
|
-
checkoutOption = GooglePayJsonFactory.TransactionInfo.CheckoutOption.Default
|
|
119
|
+
checkoutOption = GooglePayJsonFactory.TransactionInfo.CheckoutOption.Default,
|
|
92
120
|
)
|
|
93
121
|
}
|
|
94
122
|
|
|
95
|
-
internal fun createPaymentMethod(
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
)
|
|
123
|
+
internal fun createPaymentMethod(
|
|
124
|
+
request: Task<PaymentData>,
|
|
125
|
+
activity: FragmentActivity,
|
|
126
|
+
) {
|
|
127
|
+
AutoResolveHelper.resolveTask(request, activity, LOAD_PAYMENT_DATA_REQUEST_CODE)
|
|
101
128
|
}
|
|
102
129
|
|
|
103
|
-
internal fun handleGooglePaymentMethodResult(
|
|
130
|
+
internal fun handleGooglePaymentMethodResult(
|
|
131
|
+
resultCode: Int,
|
|
132
|
+
data: Intent?,
|
|
133
|
+
stripe: Stripe,
|
|
134
|
+
forToken: Boolean,
|
|
135
|
+
promise: Promise,
|
|
136
|
+
) {
|
|
104
137
|
when (resultCode) {
|
|
105
138
|
Activity.RESULT_OK -> {
|
|
106
139
|
data?.let { intent ->
|
|
@@ -114,7 +147,9 @@ class GooglePayRequestHelper {
|
|
|
114
147
|
}
|
|
115
148
|
}
|
|
116
149
|
Activity.RESULT_CANCELED -> {
|
|
117
|
-
promise.resolve(
|
|
150
|
+
promise.resolve(
|
|
151
|
+
createError(ErrorType.Canceled.toString(), "The payment has been canceled"),
|
|
152
|
+
)
|
|
118
153
|
}
|
|
119
154
|
AutoResolveHelper.RESULT_ERROR -> {
|
|
120
155
|
AutoResolveHelper.getStatusFromIntent(data)?.let {
|
|
@@ -124,30 +159,38 @@ class GooglePayRequestHelper {
|
|
|
124
159
|
}
|
|
125
160
|
}
|
|
126
161
|
|
|
127
|
-
private fun resolveWithPaymentMethod(
|
|
162
|
+
private fun resolveWithPaymentMethod(
|
|
163
|
+
paymentData: PaymentData,
|
|
164
|
+
stripe: Stripe,
|
|
165
|
+
promise: Promise,
|
|
166
|
+
) {
|
|
128
167
|
val paymentInformation = JSONObject(paymentData.toJson())
|
|
129
168
|
val promiseResult = WritableNativeMap()
|
|
130
169
|
stripe.createPaymentMethod(
|
|
131
170
|
PaymentMethodCreateParams.createFromGooglePay(paymentInformation),
|
|
132
|
-
callback =
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
171
|
+
callback =
|
|
172
|
+
object : ApiResultCallback<PaymentMethod> {
|
|
173
|
+
override fun onError(e: Exception) {
|
|
174
|
+
promise.resolve(createError("Failed", e))
|
|
175
|
+
}
|
|
136
176
|
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
177
|
+
override fun onSuccess(result: PaymentMethod) {
|
|
178
|
+
promiseResult.putMap("paymentMethod", mapFromPaymentMethod(result))
|
|
179
|
+
GooglePayResult.fromJson(paymentInformation).let {
|
|
180
|
+
if (it.shippingInformation != null) {
|
|
181
|
+
promiseResult.putMap("shippingContact", mapFromShippingContact(it))
|
|
182
|
+
}
|
|
142
183
|
}
|
|
184
|
+
promise.resolve(promiseResult)
|
|
143
185
|
}
|
|
144
|
-
|
|
145
|
-
}
|
|
146
|
-
}
|
|
186
|
+
},
|
|
147
187
|
)
|
|
148
188
|
}
|
|
149
189
|
|
|
150
|
-
private fun resolveWithToken(
|
|
190
|
+
private fun resolveWithToken(
|
|
191
|
+
paymentData: PaymentData,
|
|
192
|
+
promise: Promise,
|
|
193
|
+
) {
|
|
151
194
|
val paymentInformation = JSONObject(paymentData.toJson())
|
|
152
195
|
val googlePayResult = GooglePayResult.fromJson(paymentInformation)
|
|
153
196
|
val promiseResult = WritableNativeMap()
|
|
@@ -157,10 +200,12 @@ class GooglePayRequestHelper {
|
|
|
157
200
|
promiseResult.putMap("shippingContact", mapFromShippingContact(googlePayResult))
|
|
158
201
|
}
|
|
159
202
|
promise.resolve(promiseResult)
|
|
160
|
-
} ?: run {
|
|
161
|
-
promise.resolve(createError("Failed", "Unexpected response from Google Pay. No token was found."))
|
|
162
203
|
}
|
|
204
|
+
?: run {
|
|
205
|
+
promise.resolve(
|
|
206
|
+
createError("Failed", "Unexpected response from Google Pay. No token was found."),
|
|
207
|
+
)
|
|
208
|
+
}
|
|
163
209
|
}
|
|
164
210
|
}
|
|
165
211
|
}
|
|
166
|
-
|