@stripe/stripe-react-native 0.13.1 → 0.16.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/.editorconfig +15 -0
- package/CHANGELOG.md +68 -11
- package/android/.gradle/7.1/dependencies-accessors/dependencies-accessors.lock +0 -0
- package/android/.gradle/7.1/dependencies-accessors/gc.properties +0 -0
- package/android/.gradle/7.1/fileChanges/last-build.bin +0 -0
- package/android/.gradle/7.1/fileHashes/fileHashes.lock +0 -0
- package/android/.gradle/7.1/gc.properties +0 -0
- package/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock +0 -0
- package/android/.gradle/buildOutputCleanup/cache.properties +2 -0
- package/android/.gradle/checksums/checksums.lock +0 -0
- package/android/.gradle/vcs-1/gc.properties +0 -0
- package/android/.idea/gradle.xml +13 -0
- package/android/.idea/misc.xml +9 -0
- package/android/.idea/modules/android.iml +18 -0
- package/android/.idea/modules.xml +8 -0
- package/android/.idea/vcs.xml +6 -0
- package/android/build.gradle +6 -0
- package/android/local.properties +8 -0
- package/android/src/main/java/com/reactnativestripesdk/AuBECSDebitFormView.kt +2 -0
- package/android/src/main/java/com/reactnativestripesdk/CardFieldView.kt +28 -6
- package/android/src/main/java/com/reactnativestripesdk/CardFormView.kt +34 -3
- package/android/src/main/java/com/reactnativestripesdk/CollectBankAccountLauncherFragment.kt +5 -0
- package/android/src/main/java/com/reactnativestripesdk/GooglePayButtonView.kt +17 -7
- package/android/src/main/java/com/reactnativestripesdk/GooglePayFragment.kt +4 -0
- package/android/src/main/java/com/reactnativestripesdk/PaymentLauncherFragment.kt +3 -0
- package/android/src/main/java/com/reactnativestripesdk/PaymentMethodCreateParamsFactory.kt +213 -367
- package/android/src/main/java/com/reactnativestripesdk/PaymentSheetAppearance.kt +1 -0
- package/android/src/main/java/com/reactnativestripesdk/PaymentSheetFragment.kt +48 -28
- package/android/src/main/java/com/reactnativestripesdk/StripeSdkModule.kt +69 -23
- package/android/src/main/java/com/reactnativestripesdk/pushprovisioning/AddToWalletButtonView.kt +1 -2
- package/android/src/main/java/com/reactnativestripesdk/pushprovisioning/PushProvisioningProxy.kt +19 -7
- package/android/src/main/java/com/reactnativestripesdk/pushprovisioning/TapAndPayProxy.kt +46 -39
- package/android/src/main/java/com/reactnativestripesdk/{Errors.kt → utils/Errors.kt} +1 -1
- package/android/src/main/java/com/reactnativestripesdk/{Extensions.kt → utils/Extensions.kt} +1 -1
- package/android/src/main/java/com/reactnativestripesdk/{Mappers.kt → utils/Mappers.kt} +19 -1
- package/android/src/main/java/com/reactnativestripesdk/utils/PostalCodeUtilities.kt +18 -0
- package/android/src/main/res/{drawable-night/googlepay_button_background.xml → drawable/googlepay_button_background_dark.xml} +1 -1
- package/android/src/main/res/{drawable-night/googlepay_button_content.xml → drawable/googlepay_button_content_dark.xml} +0 -0
- package/android/src/main/res/{drawable-night/googlepay_button_overlay.xml → drawable/googlepay_button_overlay_dark.xml} +0 -0
- package/android/src/main/res/{drawable-night/pay_with_googlepay_button_content.xml → drawable/pay_with_googlepay_button_content_dark.xml} +0 -0
- package/android/src/main/res/{drawable-ar-night/pay_with_googlepay_button_content.xml → drawable-ar/pay_with_googlepay_button_content_dark.xml} +0 -0
- package/android/src/main/res/{drawable-bg-night/pay_with_googlepay_button_content.xml → drawable-bg/pay_with_googlepay_button_content_dark.xml} +0 -0
- package/android/src/main/res/{drawable-ca-night/pay_with_googlepay_button_content.xml → drawable-ca/pay_with_googlepay_button_content_dark.xml} +0 -0
- package/android/src/main/res/{drawable-cs-night/pay_with_googlepay_button_content.xml → drawable-cs/pay_with_googlepay_button_content_dark.xml} +0 -0
- package/android/src/main/res/{drawable-da-night/pay_with_googlepay_button_content.xml → drawable-da/pay_with_googlepay_button_content_dark.xml} +0 -0
- package/android/src/main/res/{drawable-de-night/pay_with_googlepay_button_content.xml → drawable-de/pay_with_googlepay_button_content_dark.xml} +0 -0
- package/android/src/main/res/{drawable-el-night/pay_with_googlepay_button_content.xml → drawable-el/pay_with_googlepay_button_content_dark.xml} +0 -0
- package/android/src/main/res/{drawable-es-night/pay_with_googlepay_button_content.xml → drawable-es/pay_with_googlepay_button_content_dark.xml} +0 -0
- package/android/src/main/res/{drawable-et-night/pay_with_googlepay_button_content.xml → drawable-et/pay_with_googlepay_button_content_dark.xml} +0 -0
- package/android/src/main/res/{drawable-fi-night/pay_with_googlepay_button_content.xml → drawable-fi/pay_with_googlepay_button_content_dark.xml} +0 -0
- package/android/src/main/res/{drawable-fr-night/pay_with_googlepay_button_content.xml → drawable-fr/pay_with_googlepay_button_content_dark.xml} +0 -0
- package/android/src/main/res/{drawable-night-hdpi/googlepay_button_background_image.9.png → drawable-hdpi/googlepay_button_background_image_dark.9.png} +0 -0
- package/android/src/main/res/{drawable-hr-night/pay_with_googlepay_button_content.xml → drawable-hr/pay_with_googlepay_button_content_dark.xml} +0 -0
- package/android/src/main/res/{drawable-id-night/pay_with_googlepay_button_content.xml → drawable-id/pay_with_googlepay_button_content_dark.xml} +0 -0
- package/android/src/main/res/{drawable-it-night/pay_with_googlepay_button_content.xml → drawable-it/pay_with_googlepay_button_content_dark.xml} +0 -0
- package/android/src/main/res/{drawable-ja-night/pay_with_googlepay_button_content.xml → drawable-ja/pay_with_googlepay_button_content_dark.xml} +0 -0
- package/android/src/main/res/{drawable-ko-night/pay_with_googlepay_button_content.xml → drawable-ko/pay_with_googlepay_button_content_dark.xml} +0 -0
- package/android/src/main/res/{drawable-night-mdpi/googlepay_button_background_image.9.png → drawable-mdpi/googlepay_button_background_image_dark.9.png} +0 -0
- package/android/src/main/res/{drawable-ms-night/pay_with_googlepay_button_content.xml → drawable-ms/pay_with_googlepay_button_content_dark.xml} +0 -0
- package/android/src/main/res/{drawable-nl-night/pay_with_googlepay_button_content.xml → drawable-nl/pay_with_googlepay_button_content_dark.xml} +0 -0
- package/android/src/main/res/{drawable-no-night/pay_with_googlepay_button_content.xml → drawable-no/pay_with_googlepay_button_content_dark.xml} +0 -0
- package/android/src/main/res/{drawable-pl-night/pay_with_googlepay_button_content.xml → drawable-pl/pay_with_googlepay_button_content_dark.xml} +0 -0
- package/android/src/main/res/{drawable-pt-night/pay_with_googlepay_button_content.xml → drawable-pt/pay_with_googlepay_button_content_dark.xml} +0 -0
- package/android/src/main/res/{drawable-ru-night/pay_with_googlepay_button_content.xml → drawable-ru/pay_with_googlepay_button_content_dark.xml} +0 -0
- package/android/src/main/res/{drawable-sk-night/pay_with_googlepay_button_content.xml → drawable-sk/pay_with_googlepay_button_content_dark.xml} +0 -0
- package/android/src/main/res/{drawable-sl-night/pay_with_googlepay_button_content.xml → drawable-sl/pay_with_googlepay_button_content_dark.xml} +0 -0
- package/android/src/main/res/{drawable-sr-night/pay_with_googlepay_button_content.xml → drawable-sr/pay_with_googlepay_button_content_dark.xml} +0 -0
- package/android/src/main/res/{drawable-sv-night/pay_with_googlepay_button_content.xml → drawable-sv/pay_with_googlepay_button_content_dark.xml} +0 -0
- package/android/src/main/res/{drawable-th-night/pay_with_googlepay_button_content.xml → drawable-th/pay_with_googlepay_button_content_dark.xml} +0 -0
- package/android/src/main/res/{drawable-tr-night/pay_with_googlepay_button_content.xml → drawable-tr/pay_with_googlepay_button_content_dark.xml} +0 -0
- package/android/src/main/res/{drawable-uk-night/pay_with_googlepay_button_content.xml → drawable-uk/pay_with_googlepay_button_content_dark.xml} +0 -0
- package/android/src/main/res/{drawable-night-v21/googlepay_button_background.xml → drawable-v21/googlepay_button_background_dark.xml} +1 -1
- package/android/src/main/res/{drawable-night-xhdpi/googlepay_button_background_image.9.png → drawable-xhdpi/googlepay_button_background_image_dark.9.png} +0 -0
- package/android/src/main/res/{drawable-night-xxhdpi/googlepay_button_background_image.9.png → drawable-xxhdpi/googlepay_button_background_image_dark.9.png} +0 -0
- package/android/src/main/res/{drawable-night-xxxhdpi/googlepay_button_background_image.9.png → drawable-xxxhdpi/googlepay_button_background_image_dark.9.png} +0 -0
- package/android/src/main/res/{layout-night/googlepay_button.xml → layout/googlepay_button_dark.xml} +4 -4
- package/android/src/main/res/{layout-night/pay_with_googlepay_button.xml → layout/pay_with_googlepay_button_dark.xml} +4 -4
- package/ios/ApplePayUtils.swift +159 -0
- package/ios/CardFieldView.swift +11 -8
- package/ios/CardFormView.swift +20 -0
- package/ios/Mappers.swift +8 -13
- package/ios/PaymentMethodFactory.swift +9 -0
- package/ios/StripeSdk.m +5 -0
- package/ios/StripeSdk.swift +60 -53
- package/ios/StripeSdk.xcodeproj/project.xcworkspace/contents.xcworkspacedata +7 -0
- package/ios/StripeSdk.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +8 -0
- package/ios/StripeSdk.xcodeproj/project.xcworkspace/xcuserdata/charliecruzan.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
- package/ios/StripeSdk.xcodeproj/xcshareddata/xcschemes/Tests.xcscheme +52 -0
- package/ios/StripeSdk.xcodeproj/xcuserdata/charliecruzan.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist +22 -0
- package/ios/StripeSdk.xcodeproj/xcuserdata/charliecruzan.xcuserdatad/xcschemes/xcschememanagement.plist +27 -0
- package/ios/Tests/ApplePayUtilsTests.swift +214 -0
- package/ios/Tests/PushProvisioningTests.swift +49 -0
- package/ios/pushprovisioning/AddToWalletButtonView.swift +1 -5
- package/ios/pushprovisioning/PushProvisioningUtils.swift +64 -0
- 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/ApplePayButton.js +1 -1
- package/lib/commonjs/components/ApplePayButton.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/GooglePayButton.js +1 -1
- package/lib/commonjs/components/GooglePayButton.js.map +1 -1
- package/lib/commonjs/components/StripeContainer.js +1 -1
- package/lib/commonjs/components/StripeContainer.js.map +1 -1
- package/lib/commonjs/functions.js +1 -1
- package/lib/commonjs/functions.js.map +1 -1
- package/lib/commonjs/hooks/useStripe.js +1 -1
- package/lib/commonjs/hooks/useStripe.js.map +1 -1
- package/lib/commonjs/types/index.js.map +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/ApplePayButton.js +1 -1
- package/lib/module/components/ApplePayButton.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/GooglePayButton.js +1 -1
- package/lib/module/components/GooglePayButton.js.map +1 -1
- package/lib/module/components/StripeContainer.js +1 -1
- package/lib/module/components/StripeContainer.js.map +1 -1
- package/lib/module/functions.js +1 -1
- package/lib/module/functions.js.map +1 -1
- package/lib/module/hooks/useStripe.js +1 -1
- package/lib/module/hooks/useStripe.js.map +1 -1
- package/lib/module/types/index.js.map +1 -1
- package/lib/typescript/src/NativeStripeSdk.d.ts +2 -1
- package/lib/typescript/src/components/AddToWalletButton.d.ts +1 -1
- package/lib/typescript/src/components/CardForm.d.ts +1 -1
- package/lib/typescript/src/components/GooglePayButton.d.ts +2 -2
- package/lib/typescript/src/functions.d.ts +2 -1
- package/lib/typescript/src/hooks/useStripe.d.ts +2 -1
- package/lib/typescript/src/types/ApplePay.d.ts +31 -5
- package/lib/typescript/src/types/PaymentMethod.d.ts +9 -1
- package/lib/typescript/src/types/PaymentSheet.d.ts +19 -16
- package/lib/typescript/src/types/index.d.ts +20 -0
- package/package.json +7 -15
- package/src/NativeStripeSdk.tsx +5 -0
- package/src/components/AddToWalletButton.tsx +1 -1
- package/src/components/CardForm.tsx +2 -2
- package/src/components/GooglePayButton.tsx +8 -2
- package/src/functions.ts +25 -0
- package/src/hooks/useStripe.tsx +13 -0
- package/src/types/ApplePay.ts +39 -6
- package/src/types/PaymentMethod.ts +11 -1
- package/src/types/PaymentSheet.ts +34 -35
- package/src/types/index.ts +27 -0
- package/stripe-react-native.podspec +6 -1
- package/android/src/main/res/drawable-night/googlepay_button_no_shadow_background.xml +0 -6
- package/android/src/main/res/drawable-night-hdpi/googlepay_button_no_shadow_background_image.9.png +0 -0
- package/android/src/main/res/drawable-night-mdpi/googlepay_button_no_shadow_background_image.9.png +0 -0
- package/android/src/main/res/drawable-night-v21/googlepay_button_no_shadow_background.xml +0 -7
- package/android/src/main/res/drawable-night-xhdpi/googlepay_button_no_shadow_background_image.9.png +0 -0
- package/android/src/main/res/drawable-night-xxhdpi/googlepay_button_no_shadow_background_image.9.png +0 -0
- package/android/src/main/res/drawable-night-xxxhdpi/googlepay_button_no_shadow_background_image.9.png +0 -0
- package/android/src/main/res/values-night/googlepay_strings.xml +0 -12
- package/lib/typescript/e2e/buyNowPayLater.test.d.ts +0 -1
- package/lib/typescript/e2e/helpers.d.ts +0 -5
- package/lib/typescript/e2e/payments.test.d.ts +0 -1
- package/lib/typescript/e2e/paymentsWithRedirects.test.d.ts +0 -1
- package/lib/typescript/e2e/screenObject/BasicPaymentScreen.d.ts +0 -17
- package/lib/typescript/e2e/screenObject/HomeScreen.d.ts +0 -6
- package/lib/typescript/e2e/screenObject/components/BECSForm.d.ts +0 -8
- package/lib/typescript/e2e/screenObject/components/CardField.d.ts +0 -10
- package/lib/typescript/example/server/index.d.ts +0 -1
- package/lib/typescript/example/server/utils.d.ts +0 -11
- package/lib/typescript/example/src/App.d.ts +0 -45
- package/lib/typescript/example/src/Config.d.ts +0 -2
- package/lib/typescript/example/src/colors.d.ts +0 -8
- package/lib/typescript/example/src/components/Button.d.ts +0 -11
- package/lib/typescript/example/src/components/Collapse.d.ts +0 -6
- package/lib/typescript/example/src/components/PaymentScreen.d.ts +0 -7
- package/lib/typescript/example/src/helpers.d.ts +0 -1
- package/lib/typescript/example/src/screens/ACHPaymentScreen.d.ts +0 -1
- package/lib/typescript/example/src/screens/ACHSetupScreen.d.ts +0 -1
- package/lib/typescript/example/src/screens/AfterpayClearpayPaymentScreen.d.ts +0 -1
- package/lib/typescript/example/src/screens/AlipayPaymentScreen.d.ts +0 -1
- package/lib/typescript/example/src/screens/ApplePayScreen.d.ts +0 -1
- package/lib/typescript/example/src/screens/AuBECSDebitPaymentScreen.d.ts +0 -1
- package/lib/typescript/example/src/screens/AuBECSDebitSetupPaymentScreen.d.ts +0 -1
- package/lib/typescript/example/src/screens/BancontactPaymentScreen.d.ts +0 -1
- package/lib/typescript/example/src/screens/BancontactSetupFuturePaymentScreen.d.ts +0 -1
- package/lib/typescript/example/src/screens/CVCReCollectionScreen.d.ts +0 -1
- package/lib/typescript/example/src/screens/CreateTokenScreen.d.ts +0 -1
- package/lib/typescript/example/src/screens/EPSPaymentScreen.d.ts +0 -1
- package/lib/typescript/example/src/screens/FPXPaymentScreen.d.ts +0 -1
- package/lib/typescript/example/src/screens/GiropayPaymentScreen.d.ts +0 -1
- package/lib/typescript/example/src/screens/GooglePayScreen.d.ts +0 -1
- package/lib/typescript/example/src/screens/GrabPayPaymentScreen.d.ts +0 -1
- package/lib/typescript/example/src/screens/HomeScreen.d.ts +0 -1
- package/lib/typescript/example/src/screens/IdealPaymentScreen.d.ts +0 -1
- package/lib/typescript/example/src/screens/IdealSetupFuturePaymentScreen.d.ts +0 -1
- package/lib/typescript/example/src/screens/KlarnaPaymentScreen.d.ts +0 -1
- package/lib/typescript/example/src/screens/MultilineWebhookPaymentScreen.d.ts +0 -1
- package/lib/typescript/example/src/screens/NoWebhookPaymentScreen.d.ts +0 -1
- package/lib/typescript/example/src/screens/OxxoPaymentScreen.d.ts +0 -1
- package/lib/typescript/example/src/screens/P24PaymentScreen.d.ts +0 -1
- package/lib/typescript/example/src/screens/PayPalScreen.d.ts +0 -1
- package/lib/typescript/example/src/screens/PaymentResultScreen.d.ts +0 -8
- package/lib/typescript/example/src/screens/PaymentSheetAppearance.d.ts +0 -3
- package/lib/typescript/example/src/screens/PaymentsUICompleteScreen.d.ts +0 -1
- package/lib/typescript/example/src/screens/PaymentsUICustomScreen.d.ts +0 -1
- package/lib/typescript/example/src/screens/SepaPaymentScreen.d.ts +0 -1
- package/lib/typescript/example/src/screens/SepaSetupFuturePaymentScreen.d.ts +0 -1
- package/lib/typescript/example/src/screens/SetupFuturePaymentScreen.d.ts +0 -1
- package/lib/typescript/example/src/screens/SofortPaymentScreen.d.ts +0 -1
- package/lib/typescript/example/src/screens/SofortSetupFuturePaymentScreen.d.ts +0 -1
- package/lib/typescript/example/src/screens/WebhookPaymentScreen.d.ts +0 -1
- package/lib/typescript/src/plugin/__tests__/withStripe-test.d.ts +0 -1
- package/src/plugin/__tests__/fixtures/sample-AndroidManifest.xml +0 -24
- package/src/plugin/__tests__/withStripe-test.ts +0 -111
|
@@ -2,6 +2,7 @@ package com.reactnativestripesdk
|
|
|
2
2
|
|
|
3
3
|
import android.graphics.Color
|
|
4
4
|
import android.os.Bundle
|
|
5
|
+
import com.reactnativestripesdk.utils.PaymentSheetAppearanceException
|
|
5
6
|
import com.stripe.android.paymentsheet.PaymentSheet
|
|
6
7
|
|
|
7
8
|
fun PaymentSheetFragment.buildPaymentSheetAppearance(userParams: Bundle?): PaymentSheet.Appearance {
|
|
@@ -18,6 +18,9 @@ import com.facebook.react.bridge.Promise
|
|
|
18
18
|
import com.facebook.react.bridge.ReactApplicationContext
|
|
19
19
|
import com.facebook.react.bridge.WritableMap
|
|
20
20
|
import com.facebook.react.bridge.WritableNativeMap
|
|
21
|
+
import com.reactnativestripesdk.utils.*
|
|
22
|
+
import com.reactnativestripesdk.utils.createError
|
|
23
|
+
import com.reactnativestripesdk.utils.createResult
|
|
21
24
|
import com.stripe.android.paymentsheet.PaymentOptionCallback
|
|
22
25
|
import com.stripe.android.paymentsheet.PaymentSheet
|
|
23
26
|
import com.stripe.android.paymentsheet.PaymentSheetResult
|
|
@@ -49,12 +52,13 @@ class PaymentSheetFragment(
|
|
|
49
52
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
|
50
53
|
super.onViewCreated(view, savedInstanceState)
|
|
51
54
|
val merchantDisplayName = arguments?.getString("merchantDisplayName").orEmpty()
|
|
55
|
+
if (merchantDisplayName.isEmpty()) {
|
|
56
|
+
initPromise.resolve(createError(ErrorType.Failed.toString(), "merchantDisplayName cannot be empty or null."))
|
|
57
|
+
return
|
|
58
|
+
}
|
|
52
59
|
val customerId = arguments?.getString("customerId").orEmpty()
|
|
53
60
|
val customerEphemeralKeySecret = arguments?.getString("customerEphemeralKeySecret").orEmpty()
|
|
54
|
-
val
|
|
55
|
-
val currencyCode = arguments?.getString("currencyCode").orEmpty()
|
|
56
|
-
val googlePayEnabled = arguments?.getBoolean("googlePay")
|
|
57
|
-
val testEnv = arguments?.getBoolean("testEnv")
|
|
61
|
+
val googlePayConfig = buildGooglePayConfig(arguments?.getBundle("googlePay"))
|
|
58
62
|
val allowsDelayedPaymentMethods = arguments?.getBoolean("allowsDelayedPaymentMethods")
|
|
59
63
|
val billingDetailsBundle = arguments?.getBundle("defaultBillingDetails")
|
|
60
64
|
paymentIntentClientSecret = arguments?.getString("paymentIntentClientSecret").orEmpty()
|
|
@@ -67,40 +71,33 @@ class PaymentSheetFragment(
|
|
|
67
71
|
}
|
|
68
72
|
|
|
69
73
|
val paymentOptionCallback = PaymentOptionCallback { paymentOption ->
|
|
70
|
-
|
|
71
|
-
val bitmap = getBitmapFromVectorDrawable(context,
|
|
74
|
+
val result = paymentOption?.let {
|
|
75
|
+
val bitmap = getBitmapFromVectorDrawable(context, it.drawableResourceId)
|
|
72
76
|
val imageString = getBase64FromBitmap(bitmap)
|
|
73
77
|
val option: WritableMap = WritableNativeMap()
|
|
74
|
-
option.putString("label",
|
|
78
|
+
option.putString("label", it.label)
|
|
75
79
|
option.putString("image", imageString)
|
|
76
|
-
|
|
77
|
-
}
|
|
78
|
-
|
|
80
|
+
createResult("paymentOption", option)
|
|
81
|
+
} ?: run {
|
|
82
|
+
createError(PaymentSheetErrorType.Canceled.toString(), "The payment option selection flow has been canceled")
|
|
79
83
|
}
|
|
84
|
+
presentPromise?.resolve(result)
|
|
80
85
|
}
|
|
81
86
|
|
|
82
87
|
val paymentResultCallback = PaymentSheetResultCallback { paymentResult ->
|
|
83
88
|
when (paymentResult) {
|
|
84
89
|
is PaymentSheetResult.Canceled -> {
|
|
85
|
-
|
|
86
|
-
confirmPromise?.resolve(createError(PaymentSheetErrorType.Canceled.toString(), message))
|
|
87
|
-
?: run {
|
|
88
|
-
presentPromise?.resolve(createError(PaymentSheetErrorType.Canceled.toString(), message))
|
|
89
|
-
}
|
|
90
|
+
resolvePaymentResult(createError(PaymentSheetErrorType.Canceled.toString(), "The payment flow has been canceled"))
|
|
90
91
|
}
|
|
91
92
|
is PaymentSheetResult.Failed -> {
|
|
92
|
-
|
|
93
|
-
?: run {
|
|
94
|
-
presentPromise?.resolve(createError(PaymentSheetErrorType.Failed.toString(), paymentResult.error))
|
|
95
|
-
}
|
|
93
|
+
resolvePaymentResult(createError(PaymentSheetErrorType.Failed.toString(), paymentResult.error))
|
|
96
94
|
}
|
|
97
95
|
is PaymentSheetResult.Completed -> {
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
96
|
+
resolvePaymentResult(WritableNativeMap())
|
|
97
|
+
// Remove the fragment now, we can be sure it won't be needed again if an intent is successful
|
|
98
|
+
(context.currentActivity as? AppCompatActivity)?.supportFragmentManager?.beginTransaction()?.remove(this)?.commitAllowingStateLoss()
|
|
101
99
|
}
|
|
102
100
|
}
|
|
103
|
-
(context.currentActivity as? AppCompatActivity)?.supportFragmentManager?.beginTransaction()?.remove(this)?.commitAllowingStateLoss()
|
|
104
101
|
}
|
|
105
102
|
|
|
106
103
|
var defaultBillingDetails: PaymentSheet.BillingDetails? = null
|
|
@@ -128,11 +125,7 @@ class PaymentSheetFragment(
|
|
|
128
125
|
id = customerId,
|
|
129
126
|
ephemeralKeySecret = customerEphemeralKeySecret
|
|
130
127
|
) else null,
|
|
131
|
-
googlePay =
|
|
132
|
-
environment = if (testEnv == true) PaymentSheet.GooglePayConfiguration.Environment.Test else PaymentSheet.GooglePayConfiguration.Environment.Production,
|
|
133
|
-
countryCode = countryCode,
|
|
134
|
-
currencyCode = currencyCode
|
|
135
|
-
) else null,
|
|
128
|
+
googlePay = googlePayConfig,
|
|
136
129
|
appearance = appearance
|
|
137
130
|
)
|
|
138
131
|
|
|
@@ -192,6 +185,33 @@ class PaymentSheetFragment(
|
|
|
192
185
|
)
|
|
193
186
|
}
|
|
194
187
|
}
|
|
188
|
+
|
|
189
|
+
private fun resolvePaymentResult(map: WritableMap) {
|
|
190
|
+
confirmPromise?.let {
|
|
191
|
+
it.resolve(map)
|
|
192
|
+
confirmPromise = null
|
|
193
|
+
} ?: run {
|
|
194
|
+
presentPromise?.resolve(map)
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
companion object {
|
|
199
|
+
internal fun buildGooglePayConfig(params: Bundle?): PaymentSheet.GooglePayConfiguration? {
|
|
200
|
+
if (params == null) {
|
|
201
|
+
return null
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
val countryCode = params.getString("merchantCountryCode").orEmpty()
|
|
205
|
+
val currencyCode = params.getString("currencyCode").orEmpty()
|
|
206
|
+
val testEnv = params.getBoolean("testEnv")
|
|
207
|
+
|
|
208
|
+
return PaymentSheet.GooglePayConfiguration(
|
|
209
|
+
environment = if (testEnv) PaymentSheet.GooglePayConfiguration.Environment.Test else PaymentSheet.GooglePayConfiguration.Environment.Production,
|
|
210
|
+
countryCode = countryCode,
|
|
211
|
+
currencyCode = currencyCode
|
|
212
|
+
)
|
|
213
|
+
}
|
|
214
|
+
}
|
|
195
215
|
}
|
|
196
216
|
|
|
197
217
|
fun getBitmapFromVectorDrawable(context: Context?, drawableId: Int): Bitmap? {
|
|
@@ -7,9 +7,13 @@ import android.util.Log
|
|
|
7
7
|
import androidx.appcompat.app.AppCompatActivity
|
|
8
8
|
import com.facebook.react.bridge.*
|
|
9
9
|
import com.facebook.react.module.annotations.ReactModule
|
|
10
|
+
import com.reactnativestripesdk.pushprovisioning.PushProvisioningProxy
|
|
11
|
+
import com.reactnativestripesdk.utils.*
|
|
12
|
+
import com.reactnativestripesdk.utils.createError
|
|
13
|
+
import com.reactnativestripesdk.utils.createMissingActivityError
|
|
10
14
|
import com.stripe.android.*
|
|
11
|
-
import com.stripe.android.core.AppInfo
|
|
12
15
|
import com.stripe.android.core.ApiVersion
|
|
16
|
+
import com.stripe.android.core.AppInfo
|
|
13
17
|
import com.stripe.android.model.*
|
|
14
18
|
import com.stripe.android.payments.bankaccount.CollectBankAccountConfiguration
|
|
15
19
|
import com.stripe.android.view.AddPaymentMethodActivityStarter
|
|
@@ -17,6 +21,7 @@ import kotlinx.coroutines.CoroutineScope
|
|
|
17
21
|
import kotlinx.coroutines.Dispatchers
|
|
18
22
|
import kotlinx.coroutines.launch
|
|
19
23
|
|
|
24
|
+
|
|
20
25
|
@ReactModule(name = StripeSdkModule.NAME)
|
|
21
26
|
class StripeSdkModule(reactContext: ReactApplicationContext) : ReactContextBaseJavaModule(reactContext) {
|
|
22
27
|
override fun getName(): String {
|
|
@@ -116,6 +121,10 @@ class StripeSdkModule(reactContext: ReactApplicationContext) : ReactContextBaseJ
|
|
|
116
121
|
@ReactMethod
|
|
117
122
|
fun initPaymentSheet(params: ReadableMap, promise: Promise) {
|
|
118
123
|
getCurrentActivityOrResolveWithError(promise)?.let { activity ->
|
|
124
|
+
paymentSheetFragment?.let {
|
|
125
|
+
// If a payment sheet was already initialized, we want to remove its fragment first
|
|
126
|
+
activity.supportFragmentManager.beginTransaction().remove(it).commitAllowingStateLoss()
|
|
127
|
+
}
|
|
119
128
|
paymentSheetFragment = PaymentSheetFragment(reactApplicationContext, promise).also {
|
|
120
129
|
val bundle = toBundleObject(params)
|
|
121
130
|
it.arguments = bundle
|
|
@@ -168,7 +177,7 @@ class StripeSdkModule(reactContext: ReactApplicationContext) : ReactContextBaseJ
|
|
|
168
177
|
)
|
|
169
178
|
} else {
|
|
170
179
|
Log.e("StripeReactNative", "FPX payment failed. Promise and/or client secret is not set.")
|
|
171
|
-
confirmPromise?.resolve(createError(ConfirmPaymentErrorType.Failed.toString(), "FPX payment failed."))
|
|
180
|
+
confirmPromise?.resolve(createError(ConfirmPaymentErrorType.Failed.toString(), "FPX payment failed. Client secret is not set."))
|
|
172
181
|
}
|
|
173
182
|
}
|
|
174
183
|
is AddPaymentMethodActivityStarter.Result.Failure -> {
|
|
@@ -184,27 +193,30 @@ class StripeSdkModule(reactContext: ReactApplicationContext) : ReactContextBaseJ
|
|
|
184
193
|
|
|
185
194
|
@ReactMethod
|
|
186
195
|
fun createPaymentMethod(data: ReadableMap, options: ReadableMap, promise: Promise) {
|
|
187
|
-
val
|
|
188
|
-
promise.resolve(createError(
|
|
196
|
+
val paymentMethodType = getValOr(data, "paymentMethodType")?.let { mapToPaymentMethodType(it) } ?: run {
|
|
197
|
+
promise.resolve(createError(ConfirmPaymentErrorType.Failed.toString(), "You must provide paymentMethodType"))
|
|
189
198
|
return
|
|
190
199
|
}
|
|
191
|
-
val cardAddress = cardFieldView?.cardAddress ?: cardFormView?.cardAddress
|
|
192
200
|
val paymentMethodData = getMapOrNull(data, "paymentMethodData")
|
|
193
|
-
val
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
201
|
+
val factory = PaymentMethodCreateParamsFactory(paymentMethodData, options, cardFieldView, cardFormView)
|
|
202
|
+
try {
|
|
203
|
+
val paymentMethodCreateParams = factory.createPaymentMethodParams(paymentMethodType)
|
|
204
|
+
stripe.createPaymentMethod(
|
|
205
|
+
paymentMethodCreateParams,
|
|
206
|
+
callback = object : ApiResultCallback<PaymentMethod> {
|
|
207
|
+
override fun onError(e: Exception) {
|
|
208
|
+
promise.resolve(createError("Failed", e))
|
|
209
|
+
}
|
|
202
210
|
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
211
|
+
override fun onSuccess(result: PaymentMethod) {
|
|
212
|
+
val paymentMethodMap: WritableMap = mapFromPaymentMethod(result)
|
|
213
|
+
promise.resolve(createResult("paymentMethod", paymentMethodMap))
|
|
214
|
+
}
|
|
206
215
|
}
|
|
207
|
-
|
|
216
|
+
)
|
|
217
|
+
} catch (error: PaymentMethodCreateParamsException) {
|
|
218
|
+
promise.resolve(createError(ConfirmPaymentErrorType.Failed.toString(), error))
|
|
219
|
+
}
|
|
208
220
|
}
|
|
209
221
|
|
|
210
222
|
@ReactMethod
|
|
@@ -382,10 +394,10 @@ class StripeSdkModule(reactContext: ReactApplicationContext) : ReactContextBaseJ
|
|
|
382
394
|
// return
|
|
383
395
|
// }
|
|
384
396
|
|
|
385
|
-
val factory = PaymentMethodCreateParamsFactory(
|
|
397
|
+
val factory = PaymentMethodCreateParamsFactory(paymentMethodData, options, cardFieldView, cardFormView)
|
|
386
398
|
|
|
387
399
|
try {
|
|
388
|
-
val confirmParams = factory.
|
|
400
|
+
val confirmParams = factory.createParams(paymentIntentClientSecret, paymentMethodType, isPaymentIntent = true) as ConfirmPaymentIntentParams
|
|
389
401
|
urlScheme?.let {
|
|
390
402
|
confirmParams.returnUrl = mapToReturnURL(urlScheme)
|
|
391
403
|
}
|
|
@@ -435,10 +447,10 @@ class StripeSdkModule(reactContext: ReactApplicationContext) : ReactContextBaseJ
|
|
|
435
447
|
return
|
|
436
448
|
}
|
|
437
449
|
|
|
438
|
-
val factory = PaymentMethodCreateParamsFactory(
|
|
450
|
+
val factory = PaymentMethodCreateParamsFactory(getMapOrNull(params, "paymentMethodData"), options, cardFieldView, cardFormView)
|
|
439
451
|
|
|
440
452
|
try {
|
|
441
|
-
val confirmParams = factory.
|
|
453
|
+
val confirmParams = factory.createParams(setupIntentClientSecret, paymentMethodType, isPaymentIntent = false) as ConfirmSetupIntentParams
|
|
442
454
|
urlScheme?.let {
|
|
443
455
|
confirmParams.returnUrl = mapToReturnURL(urlScheme)
|
|
444
456
|
}
|
|
@@ -525,6 +537,31 @@ class StripeSdkModule(reactContext: ReactApplicationContext) : ReactContextBaseJ
|
|
|
525
537
|
googlePayFragment?.createPaymentMethod(currencyCode, amount, promise)
|
|
526
538
|
}
|
|
527
539
|
|
|
540
|
+
@ReactMethod
|
|
541
|
+
fun canAddCardToWallet(params: ReadableMap, promise: Promise) {
|
|
542
|
+
val last4 = getValOr(params, "cardLastFour", null) ?: run {
|
|
543
|
+
promise.resolve(createError("Failed", "You must provide cardLastFour"))
|
|
544
|
+
return
|
|
545
|
+
}
|
|
546
|
+
|
|
547
|
+
if (!PushProvisioningProxy.isNFCEnabled(reactApplicationContext)) {
|
|
548
|
+
promise.resolve(createCanAddCardResult(false, "UNSUPPORTED_DEVICE"))
|
|
549
|
+
return
|
|
550
|
+
}
|
|
551
|
+
|
|
552
|
+
getCurrentActivityOrResolveWithError(promise)?.let {
|
|
553
|
+
PushProvisioningProxy.isCardInWallet(it, last4) { isCardInWallet, token, error ->
|
|
554
|
+
val result = error?.let {
|
|
555
|
+
createCanAddCardResult(false, "MISSING_CONFIGURATION", null)
|
|
556
|
+
} ?: run {
|
|
557
|
+
val status = if (isCardInWallet) "CARD_ALREADY_EXISTS" else null
|
|
558
|
+
createCanAddCardResult(!isCardInWallet, status, token)
|
|
559
|
+
}
|
|
560
|
+
promise.resolve(result)
|
|
561
|
+
}
|
|
562
|
+
}
|
|
563
|
+
}
|
|
564
|
+
|
|
528
565
|
@ReactMethod
|
|
529
566
|
fun isCardInWallet(params: ReadableMap, promise: Promise) {
|
|
530
567
|
val last4 = getValOr(params, "cardLastFour", null) ?: run {
|
|
@@ -532,7 +569,15 @@ class StripeSdkModule(reactContext: ReactApplicationContext) : ReactContextBaseJ
|
|
|
532
569
|
return
|
|
533
570
|
}
|
|
534
571
|
getCurrentActivityOrResolveWithError(promise)?.let {
|
|
535
|
-
PushProvisioningProxy.isCardInWallet(it, last4,
|
|
572
|
+
PushProvisioningProxy.isCardInWallet(it, last4) { isCardInWallet, token, error ->
|
|
573
|
+
val result: WritableMap = error ?: run {
|
|
574
|
+
val map = WritableNativeMap()
|
|
575
|
+
map.putBoolean("isInWallet", isCardInWallet)
|
|
576
|
+
map.putMap("token", token)
|
|
577
|
+
map
|
|
578
|
+
}
|
|
579
|
+
promise.resolve(result)
|
|
580
|
+
}
|
|
536
581
|
}
|
|
537
582
|
}
|
|
538
583
|
|
|
@@ -596,6 +641,7 @@ class StripeSdkModule(reactContext: ReactApplicationContext) : ReactContextBaseJ
|
|
|
596
641
|
promise.resolve(createResult("paymentIntent", mapFromPaymentIntentResult(result)))
|
|
597
642
|
}
|
|
598
643
|
}
|
|
644
|
+
|
|
599
645
|
val setupCallback = object : ApiResultCallback<SetupIntent> {
|
|
600
646
|
override fun onError(e: Exception) {
|
|
601
647
|
promise.resolve(createError(ErrorType.Failed.toString(), e))
|
package/android/src/main/java/com/reactnativestripesdk/pushprovisioning/AddToWalletButtonView.kt
CHANGED
|
@@ -17,8 +17,7 @@ import com.facebook.react.bridge.WritableMap
|
|
|
17
17
|
import com.facebook.react.uimanager.ThemedReactContext
|
|
18
18
|
import com.facebook.react.uimanager.UIManagerModule
|
|
19
19
|
import com.facebook.react.uimanager.events.EventDispatcher
|
|
20
|
-
import com.reactnativestripesdk.
|
|
21
|
-
import com.reactnativestripesdk.createError
|
|
20
|
+
import com.reactnativestripesdk.utils.createError
|
|
22
21
|
|
|
23
22
|
|
|
24
23
|
class AddToWalletButtonView(private val context: ThemedReactContext, private val requestManager: RequestManager) : AppCompatImageView(context) {
|
package/android/src/main/java/com/reactnativestripesdk/pushprovisioning/PushProvisioningProxy.kt
CHANGED
|
@@ -1,13 +1,16 @@
|
|
|
1
|
-
package com.reactnativestripesdk
|
|
1
|
+
package com.reactnativestripesdk.pushprovisioning
|
|
2
2
|
|
|
3
3
|
import android.app.Activity
|
|
4
4
|
import android.app.Activity.RESULT_OK
|
|
5
5
|
import android.content.Intent
|
|
6
|
+
import android.content.pm.PackageManager
|
|
7
|
+
import android.nfc.NfcAdapter
|
|
6
8
|
import android.util.Log
|
|
7
|
-
import com.facebook.react.bridge
|
|
8
|
-
import com.
|
|
9
|
-
import com.
|
|
10
|
-
import com.reactnativestripesdk.
|
|
9
|
+
import com.facebook.react.bridge.BaseActivityEventListener
|
|
10
|
+
import com.facebook.react.bridge.ReactApplicationContext
|
|
11
|
+
import com.facebook.react.bridge.ReadableMap
|
|
12
|
+
import com.reactnativestripesdk.utils.createError
|
|
13
|
+
import com.reactnativestripesdk.utils.mapError
|
|
11
14
|
import com.stripe.android.pushProvisioning.PushProvisioningActivity
|
|
12
15
|
import com.stripe.android.pushProvisioning.PushProvisioningActivityStarter
|
|
13
16
|
|
|
@@ -27,6 +30,15 @@ object PushProvisioningProxy {
|
|
|
27
30
|
}
|
|
28
31
|
}
|
|
29
32
|
|
|
33
|
+
fun isNFCEnabled(context: ReactApplicationContext): Boolean {
|
|
34
|
+
return if (context.packageManager.hasSystemFeature(PackageManager.FEATURE_NFC)) {
|
|
35
|
+
val adapter = NfcAdapter.getDefaultAdapter(context)
|
|
36
|
+
adapter.isEnabled
|
|
37
|
+
} else {
|
|
38
|
+
false
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
30
42
|
fun invoke(
|
|
31
43
|
context: ReactApplicationContext,
|
|
32
44
|
view: AddToWalletButtonView,
|
|
@@ -57,8 +69,8 @@ object PushProvisioningProxy {
|
|
|
57
69
|
}
|
|
58
70
|
}
|
|
59
71
|
|
|
60
|
-
fun isCardInWallet(activity: Activity, cardLastFour: String,
|
|
61
|
-
TapAndPayProxy.
|
|
72
|
+
fun isCardInWallet(activity: Activity, cardLastFour: String, callback: TokenCheckHandler) {
|
|
73
|
+
TapAndPayProxy.findExistingToken(activity, cardLastFour, callback)
|
|
62
74
|
}
|
|
63
75
|
|
|
64
76
|
private fun createActivityEventListener(context: ReactApplicationContext, view: AddToWalletButtonView) {
|
|
@@ -2,54 +2,68 @@ package com.reactnativestripesdk.pushprovisioning
|
|
|
2
2
|
|
|
3
3
|
import android.app.Activity
|
|
4
4
|
import android.util.Log
|
|
5
|
-
import com.facebook.react.bridge.Promise
|
|
6
5
|
import com.facebook.react.bridge.ReadableMap
|
|
7
6
|
import com.facebook.react.bridge.WritableMap
|
|
8
7
|
import com.facebook.react.bridge.WritableNativeMap
|
|
9
|
-
import com.reactnativestripesdk.createError
|
|
8
|
+
import com.reactnativestripesdk.utils.createError
|
|
10
9
|
import com.google.android.gms.tasks.Task
|
|
11
10
|
|
|
11
|
+
typealias TokenCheckHandler = (isCardInWallet: Boolean, token: WritableMap?, error: WritableMap?) -> Unit
|
|
12
|
+
|
|
12
13
|
object TapAndPayProxy {
|
|
13
14
|
private const val TAG = "StripeTapAndPay"
|
|
14
15
|
private var tapAndPayClient: Any? = null
|
|
15
16
|
const val REQUEST_CODE_TOKENIZE = 90909
|
|
16
17
|
|
|
17
|
-
fun
|
|
18
|
-
try {
|
|
18
|
+
private fun getTapandPayTokens(activity: Activity): Task<List<Any>>? {
|
|
19
|
+
return try {
|
|
19
20
|
val tapAndPayClass = Class.forName("com.google.android.gms.tapandpay.TapAndPay")
|
|
20
|
-
val getClientMethod = tapAndPayClass.getMethod(
|
|
21
|
+
val getClientMethod = tapAndPayClass.getMethod(
|
|
22
|
+
"getClient",
|
|
23
|
+
Activity::class.java)
|
|
24
|
+
val client = getClientMethod.invoke(null, activity)
|
|
21
25
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
val listTokensMethod = tapAndPayClientClass.getMethod("listTokens")
|
|
26
|
+
val tapAndPayClientClass = Class.forName("com.google.android.gms.tapandpay.TapAndPayClient")
|
|
27
|
+
val listTokensMethod = tapAndPayClientClass.getMethod("listTokens")
|
|
25
28
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
29
|
+
listTokensMethod.invoke(client) as Task<List<Any>>
|
|
30
|
+
} catch (e: Exception) {
|
|
31
|
+
Log.e(TAG, "Google TapAndPay dependency not found")
|
|
32
|
+
null
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
internal fun isTokenInWallet(token: Any, newLastFour: String): Boolean {
|
|
37
|
+
return try {
|
|
38
|
+
val getFpanLastFourMethod = Class.forName("com.google.android.gms.tapandpay.issuer.TokenInfo").getMethod("getFpanLastFour")
|
|
39
|
+
val existingFpanLastFour = getFpanLastFourMethod.invoke(token) as String
|
|
40
|
+
existingFpanLastFour == newLastFour
|
|
41
|
+
} catch (e: Exception) {
|
|
42
|
+
Log.e(TAG, "There was a problem finding the class com.google.android.gms.tapandpay.issuer.TokenInfo. Make sure you've included Google's TapAndPay dependency.")
|
|
43
|
+
false
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
fun findExistingToken(activity: Activity, newCardLastFour: String, callback: TokenCheckHandler) {
|
|
49
|
+
val tokens = getTapandPayTokens(activity)
|
|
50
|
+
if (tokens == null) {
|
|
51
|
+
callback(false, null, createError("Failed", "Google TapAndPay dependency not found."))
|
|
52
|
+
return
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
tokens.addOnCompleteListener { task ->
|
|
56
|
+
if (task.isSuccessful) {
|
|
57
|
+
for (token in task.result) {
|
|
58
|
+
if (isTokenInWallet(token, newCardLastFour)) {
|
|
59
|
+
callback(true, mapFromTokenInfo(token), null)
|
|
60
|
+
return@addOnCompleteListener
|
|
46
61
|
}
|
|
47
|
-
promise.resolve(createResult(false))
|
|
48
62
|
}
|
|
63
|
+
} else {
|
|
64
|
+
Log.e(TAG, "Unable to fetch existing tokens from Google TapAndPay.")
|
|
49
65
|
}
|
|
50
|
-
|
|
51
|
-
Log.e(TAG, "Google TapAndPay dependency not found")
|
|
52
|
-
promise.resolve(createError("Failed", "Google TapAndPay dependency not found."))
|
|
66
|
+
callback(false, null, null)
|
|
53
67
|
}
|
|
54
68
|
}
|
|
55
69
|
|
|
@@ -69,13 +83,6 @@ object TapAndPayProxy {
|
|
|
69
83
|
}
|
|
70
84
|
}
|
|
71
85
|
|
|
72
|
-
private fun createResult(cardIsInWallet: Boolean, token: Any? = null): WritableMap {
|
|
73
|
-
val result = WritableNativeMap()
|
|
74
|
-
result.putBoolean("isInWallet", cardIsInWallet)
|
|
75
|
-
result.putMap("token", mapFromTokenInfo(token))
|
|
76
|
-
return result
|
|
77
|
-
}
|
|
78
|
-
|
|
79
86
|
private fun mapFromTokenInfo(token: Any?): WritableMap? {
|
|
80
87
|
if (token == null) {
|
|
81
88
|
return null
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
package com.reactnativestripesdk
|
|
1
|
+
package com.reactnativestripesdk.utils
|
|
2
2
|
|
|
3
3
|
import android.os.Bundle
|
|
4
4
|
import android.util.Log
|
|
@@ -14,6 +14,22 @@ internal fun createResult(key: String, value: WritableMap): WritableMap {
|
|
|
14
14
|
return map
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
+
internal fun createCanAddCardResult(canAddCard: Boolean, status: String? = null, token: WritableMap? = null): WritableNativeMap {
|
|
18
|
+
val result = WritableNativeMap()
|
|
19
|
+
val details = WritableNativeMap()
|
|
20
|
+
if (status != null) {
|
|
21
|
+
result.putBoolean("canAddCard", false)
|
|
22
|
+
details.putString("status", status)
|
|
23
|
+
} else {
|
|
24
|
+
result.putBoolean("canAddCard", canAddCard)
|
|
25
|
+
if (token != null) {
|
|
26
|
+
details.putMap("token", token)
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
result.putMap("details", details)
|
|
30
|
+
return result
|
|
31
|
+
}
|
|
32
|
+
|
|
17
33
|
internal fun mapIntentStatus(status: StripeIntent.Status?): String {
|
|
18
34
|
return when (status) {
|
|
19
35
|
StripeIntent.Status.Succeeded -> "Succeeded"
|
|
@@ -108,6 +124,7 @@ internal fun mapPaymentMethodType(type: PaymentMethod.Type?): String {
|
|
|
108
124
|
PaymentMethod.Type.Klarna -> "Klarna"
|
|
109
125
|
PaymentMethod.Type.USBankAccount -> "USBankAccount"
|
|
110
126
|
PaymentMethod.Type.PayPal -> "PayPal"
|
|
127
|
+
PaymentMethod.Type.Affirm -> "Affirm"
|
|
111
128
|
else -> "Unknown"
|
|
112
129
|
}
|
|
113
130
|
}
|
|
@@ -136,6 +153,7 @@ internal fun mapToPaymentMethodType(type: String?): PaymentMethod.Type? {
|
|
|
136
153
|
"Klarna" -> PaymentMethod.Type.Klarna
|
|
137
154
|
"USBankAccount" -> PaymentMethod.Type.USBankAccount
|
|
138
155
|
"PayPal" -> PaymentMethod.Type.PayPal
|
|
156
|
+
"Affirm" -> PaymentMethod.Type.Affirm
|
|
139
157
|
else -> null
|
|
140
158
|
}
|
|
141
159
|
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
package com.reactnativestripesdk.utils
|
|
2
|
+
|
|
3
|
+
class PostalCodeUtilities {
|
|
4
|
+
|
|
5
|
+
companion object {
|
|
6
|
+
internal fun isValidGlobalPostalCodeCharacter(c: Char): Boolean {
|
|
7
|
+
return Character.isLetterOrDigit(c)
|
|
8
|
+
|| c.isWhitespace()
|
|
9
|
+
|| c == '-'
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
internal fun isValidUsPostalCodeCharacter(c: Char): Boolean {
|
|
13
|
+
return Character.isDigit(c)
|
|
14
|
+
|| c.isWhitespace()
|
|
15
|
+
|| c == '-'
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<?xml version="1.0" encoding="utf-8"?>
|
|
2
2
|
<selector xmlns:android="http://schemas.android.com/apk/res/android" >
|
|
3
3
|
<item
|
|
4
|
-
android:drawable="@drawable/
|
|
4
|
+
android:drawable="@drawable/googlepay_button_background_image_dark" />
|
|
5
5
|
</selector>
|
|
6
6
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|