@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
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
package/android/src/main/res/{layout-night/googlepay_button.xml → layout/googlepay_button_dark.xml}
RENAMED
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
android:focusable="true"
|
|
5
5
|
android:layout_width="match_parent"
|
|
6
6
|
android:layout_height="48sp"
|
|
7
|
-
android:background="@drawable/
|
|
8
|
-
android:
|
|
7
|
+
android:background="@drawable/googlepay_button_background_dark"
|
|
8
|
+
android:padding="2sp"
|
|
9
9
|
android:contentDescription="@string/googlepay_button_content_description">
|
|
10
10
|
<LinearLayout
|
|
11
11
|
android:duplicateParentState="true"
|
|
@@ -20,12 +20,12 @@
|
|
|
20
20
|
android:layout_height="0dp"
|
|
21
21
|
android:scaleType="fitCenter"
|
|
22
22
|
android:duplicateParentState="true"
|
|
23
|
-
android:src="@drawable/
|
|
23
|
+
android:src="@drawable/googlepay_button_content_dark"/>
|
|
24
24
|
</LinearLayout>
|
|
25
25
|
<ImageView
|
|
26
26
|
android:layout_width="match_parent"
|
|
27
27
|
android:layout_height="match_parent"
|
|
28
28
|
android:scaleType="fitXY"
|
|
29
29
|
android:duplicateParentState="true"
|
|
30
|
-
android:src="@drawable/
|
|
30
|
+
android:src="@drawable/googlepay_button_overlay_dark"/>
|
|
31
31
|
</RelativeLayout>
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
android:focusable="true"
|
|
5
5
|
android:layout_width="match_parent"
|
|
6
6
|
android:layout_height="48sp"
|
|
7
|
-
android:background="@drawable/
|
|
7
|
+
android:background="@drawable/googlepay_button_background_dark"
|
|
8
8
|
android:padding="2sp"
|
|
9
9
|
android:contentDescription="@string/pay_with_googlepay_button_content_description">
|
|
10
10
|
<LinearLayout
|
|
@@ -20,12 +20,12 @@
|
|
|
20
20
|
android:layout_height="0dp"
|
|
21
21
|
android:scaleType="fitCenter"
|
|
22
22
|
android:duplicateParentState="true"
|
|
23
|
-
android:src="@drawable/
|
|
23
|
+
android:src="@drawable/pay_with_googlepay_button_content_dark"/>
|
|
24
24
|
</LinearLayout>
|
|
25
25
|
<ImageView
|
|
26
26
|
android:layout_width="match_parent"
|
|
27
27
|
android:layout_height="match_parent"
|
|
28
28
|
android:scaleType="fitXY"
|
|
29
29
|
android:duplicateParentState="true"
|
|
30
|
-
android:src="@drawable/
|
|
31
|
-
</RelativeLayout>
|
|
30
|
+
android:src="@drawable/googlepay_button_overlay_dark"/>
|
|
31
|
+
</RelativeLayout>
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
//
|
|
2
|
+
// ApplePayUtils.swift
|
|
3
|
+
// stripe-react-native
|
|
4
|
+
//
|
|
5
|
+
// Created by Charles Cruzan on 6/27/22.
|
|
6
|
+
//
|
|
7
|
+
|
|
8
|
+
import Foundation
|
|
9
|
+
import Stripe
|
|
10
|
+
|
|
11
|
+
class ApplePayUtils {
|
|
12
|
+
|
|
13
|
+
@available(iOS 15.0, *)
|
|
14
|
+
internal class func createDeferredPaymentSummaryItem(item: [String : Any]) throws -> PKPaymentSummaryItem {
|
|
15
|
+
let label = item["label"] as? String ?? ""
|
|
16
|
+
let amount = NSDecimalNumber(string: item["amount"] as? String ?? "")
|
|
17
|
+
|
|
18
|
+
let deferredItem = PKDeferredPaymentSummaryItem(
|
|
19
|
+
label: label,
|
|
20
|
+
amount: amount
|
|
21
|
+
)
|
|
22
|
+
guard let date = item["deferredDate"] as? Double else {
|
|
23
|
+
throw ApplePayUtilsError.missingParameter(label, "deferredDate")
|
|
24
|
+
}
|
|
25
|
+
deferredItem.deferredDate = Date(timeIntervalSince1970: date)
|
|
26
|
+
return deferredItem
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
@available(iOS 15.0, *)
|
|
30
|
+
internal class func createRecurringPaymentSummaryItem(item: [String : Any]) throws -> PKPaymentSummaryItem {
|
|
31
|
+
let label = item["label"] as? String ?? ""
|
|
32
|
+
let amount = NSDecimalNumber(string: item["amount"] as? String ?? "")
|
|
33
|
+
|
|
34
|
+
let recurringItem = PKRecurringPaymentSummaryItem(
|
|
35
|
+
label: label,
|
|
36
|
+
amount: amount
|
|
37
|
+
)
|
|
38
|
+
guard let intervalCount = item["intervalCount"] as? Int else {
|
|
39
|
+
throw ApplePayUtilsError.missingParameter(label, "intervalCount")
|
|
40
|
+
}
|
|
41
|
+
recurringItem.intervalCount = intervalCount
|
|
42
|
+
recurringItem.intervalUnit = try mapToIntervalUnit(intervalString: item["intervalUnit"] as? String)
|
|
43
|
+
if let startDate = item["startDate"] as? Double {
|
|
44
|
+
recurringItem.startDate = Date(timeIntervalSince1970: startDate)
|
|
45
|
+
}
|
|
46
|
+
if let endDate = item["endDate"] as? Double {
|
|
47
|
+
recurringItem.endDate = Date(timeIntervalSince1970: endDate)
|
|
48
|
+
}
|
|
49
|
+
return recurringItem
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
internal class func mapToIntervalUnit(intervalString: String?) throws -> NSCalendar.Unit {
|
|
53
|
+
switch intervalString {
|
|
54
|
+
case "minute":
|
|
55
|
+
return NSCalendar.Unit.minute
|
|
56
|
+
case "hour":
|
|
57
|
+
return NSCalendar.Unit.hour
|
|
58
|
+
case "day":
|
|
59
|
+
return NSCalendar.Unit.day
|
|
60
|
+
case "month":
|
|
61
|
+
return NSCalendar.Unit.month
|
|
62
|
+
case "year":
|
|
63
|
+
return NSCalendar.Unit.year
|
|
64
|
+
default:
|
|
65
|
+
throw ApplePayUtilsError.invalidTimeInterval(intervalString ?? "null")
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
internal class func createImmediatePaymentSummaryItem(item: [String : Any]) -> PKPaymentSummaryItem {
|
|
70
|
+
let label = item["label"] as? String ?? ""
|
|
71
|
+
let amount = NSDecimalNumber(string: item["amount"] as? String ?? "")
|
|
72
|
+
|
|
73
|
+
return PKPaymentSummaryItem(
|
|
74
|
+
label: label,
|
|
75
|
+
amount: amount,
|
|
76
|
+
type: item["isPending"] as? Bool ?? false ?
|
|
77
|
+
PKPaymentSummaryItemType.pending : PKPaymentSummaryItemType.final
|
|
78
|
+
)
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
public class func buildPaymentSummaryItems(items: [[String : Any]]?) throws -> [PKPaymentSummaryItem] {
|
|
82
|
+
var paymentSummaryItems: [PKPaymentSummaryItem] = []
|
|
83
|
+
if let items = items {
|
|
84
|
+
for item in items {
|
|
85
|
+
let paymentSummaryItem = try buildPaymentSummaryItem(item: item)
|
|
86
|
+
paymentSummaryItems.append(paymentSummaryItem)
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
return paymentSummaryItems
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
internal class func buildPaymentSummaryItem(item: [String : Any]) throws -> PKPaymentSummaryItem {
|
|
94
|
+
switch item["paymentType"] as? String {
|
|
95
|
+
case "Deferred":
|
|
96
|
+
if #available(iOS 15.0, *) {
|
|
97
|
+
return try createDeferredPaymentSummaryItem(item: item)
|
|
98
|
+
} else {
|
|
99
|
+
return createImmediatePaymentSummaryItem(item: item)
|
|
100
|
+
}
|
|
101
|
+
case "Recurring":
|
|
102
|
+
if #available(iOS 15.0, *) {
|
|
103
|
+
return try createRecurringPaymentSummaryItem(item: item)
|
|
104
|
+
} else {
|
|
105
|
+
return createImmediatePaymentSummaryItem(item: item)
|
|
106
|
+
}
|
|
107
|
+
case "Immediate":
|
|
108
|
+
return createImmediatePaymentSummaryItem(item: item)
|
|
109
|
+
default:
|
|
110
|
+
throw ApplePayUtilsError.invalidCartSummaryItemType(item["paymentType"] as? String ?? "null")
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
public class func buildPaymentSheetApplePayConfig(
|
|
115
|
+
merchantIdentifier: String?,
|
|
116
|
+
merchantCountryCode: String?,
|
|
117
|
+
paymentSummaryItems: [[String : Any]]?
|
|
118
|
+
) throws -> PaymentSheet.ApplePayConfiguration {
|
|
119
|
+
guard let merchantId = merchantIdentifier else {
|
|
120
|
+
throw ApplePayUtilsError.missingMerchantId
|
|
121
|
+
}
|
|
122
|
+
guard let countryCode = merchantCountryCode else {
|
|
123
|
+
throw ApplePayUtilsError.missingCountryCode
|
|
124
|
+
}
|
|
125
|
+
let paymentSummaryItems = try ApplePayUtils.buildPaymentSummaryItems(
|
|
126
|
+
items: paymentSummaryItems
|
|
127
|
+
)
|
|
128
|
+
return PaymentSheet.ApplePayConfiguration.init(
|
|
129
|
+
merchantId: merchantId,
|
|
130
|
+
merchantCountryCode: countryCode,
|
|
131
|
+
paymentSummaryItems:paymentSummaryItems.count > 0 ? paymentSummaryItems : nil
|
|
132
|
+
)
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
enum ApplePayUtilsError : Error, Equatable {
|
|
137
|
+
case invalidCartSummaryItemType(String)
|
|
138
|
+
case missingParameter(String, String)
|
|
139
|
+
case invalidTimeInterval(String)
|
|
140
|
+
case missingMerchantId
|
|
141
|
+
case missingCountryCode
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
extension ApplePayUtilsError: LocalizedError {
|
|
145
|
+
public var errorDescription: String? {
|
|
146
|
+
switch self {
|
|
147
|
+
case .invalidCartSummaryItemType(let type):
|
|
148
|
+
return "Failed to ceate Apple Pay summary item. Expected `type` to be one of 'Immediate', 'Recurring', or 'Deferred', but received: \(type)"
|
|
149
|
+
case .missingParameter(let label, let parameter):
|
|
150
|
+
return "Failed to create Apple Pay summary item with label: \(label). The \(parameter) item parameter is required, but none was provided."
|
|
151
|
+
case .invalidTimeInterval(let providedInterval):
|
|
152
|
+
return "Failed to create Apple Pay summary item. \(providedInterval) is not a valid timeInterval, must be one of: minute, hour, day, month, or year."
|
|
153
|
+
case .missingMerchantId:
|
|
154
|
+
return "`merchantIdentifier` is required, but none was found. Ensure you are passing this to initStripe your StripeProvider."
|
|
155
|
+
case .missingCountryCode:
|
|
156
|
+
return "`merchantCountryCode` is a required param, but was not provided."
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
}
|
package/ios/CardFieldView.swift
CHANGED
|
@@ -132,13 +132,16 @@ class CardFieldView: UIView, STPPaymentCardTextFieldDelegate {
|
|
|
132
132
|
|
|
133
133
|
func paymentCardTextFieldDidChange(_ textField: STPPaymentCardTextField) {
|
|
134
134
|
if onCardChange != nil {
|
|
135
|
-
let brand = STPCardValidator.brand(forNumber: textField.
|
|
136
|
-
let validExpiryDate = STPCardValidator.validationState(
|
|
137
|
-
|
|
138
|
-
|
|
135
|
+
let brand = STPCardValidator.brand(forNumber: textField.cardNumber ?? "")
|
|
136
|
+
let validExpiryDate = STPCardValidator.validationState(
|
|
137
|
+
forExpirationYear: textField.formattedExpirationYear ?? "",
|
|
138
|
+
inMonth: textField.formattedExpirationMonth ?? ""
|
|
139
|
+
)
|
|
140
|
+
let validCVC = STPCardValidator.validationState(forCVC: textField.cvc ?? "", cardBrand: brand)
|
|
141
|
+
let validNumber = STPCardValidator.validationState(forNumber: textField.cardNumber ?? "", validatingCardBrand: true)
|
|
139
142
|
var cardData: [String: Any?] = [
|
|
140
|
-
"expiryMonth": textField.
|
|
141
|
-
"expiryYear": textField.
|
|
143
|
+
"expiryMonth": textField.expirationMonth,
|
|
144
|
+
"expiryYear": textField.expirationYear,
|
|
142
145
|
"complete": textField.isValid,
|
|
143
146
|
"brand": Mappers.mapFromCardBrand(brand) ?? NSNull(),
|
|
144
147
|
"last4": textField.cardParams.last4 ?? "",
|
|
@@ -150,8 +153,8 @@ class CardFieldView: UIView, STPPaymentCardTextFieldDelegate {
|
|
|
150
153
|
cardData["postalCode"] = textField.postalCode ?? ""
|
|
151
154
|
}
|
|
152
155
|
if (dangerouslyGetFullCardDetails) {
|
|
153
|
-
cardData["number"] = textField.
|
|
154
|
-
cardData["cvc"] = textField.
|
|
156
|
+
cardData["number"] = textField.cardNumber ?? ""
|
|
157
|
+
cardData["cvc"] = textField.cvc ?? ""
|
|
155
158
|
}
|
|
156
159
|
onCardChange!(cardData as [AnyHashable : Any])
|
|
157
160
|
}
|
package/ios/CardFormView.swift
CHANGED
|
@@ -75,6 +75,26 @@ class CardFormView: UIView, STPCardFormViewDelegate {
|
|
|
75
75
|
if let backgroundColor = cardStyle["backgroundColor"] as? String {
|
|
76
76
|
cardForm?.backgroundColor = UIColor(hexString: backgroundColor)
|
|
77
77
|
}
|
|
78
|
+
/**
|
|
79
|
+
The following reveals a bug in STPCardFormView where there's a extra space in the layer,
|
|
80
|
+
and thus must remain commented out for now.
|
|
81
|
+
|
|
82
|
+
if let borderWidth = cardStyle["borderWidth"] as? Int {
|
|
83
|
+
cardForm?.layer.borderWidth = CGFloat(borderWidth)
|
|
84
|
+
} else {
|
|
85
|
+
cardForm?.layer.borderWidth = CGFloat(0)
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
*/
|
|
89
|
+
if let borderColor = cardStyle["borderColor"] as? String {
|
|
90
|
+
cardForm?.layer.borderColor = UIColor(hexString: borderColor).cgColor
|
|
91
|
+
}
|
|
92
|
+
if let borderRadius = cardStyle["borderRadius"] as? Int {
|
|
93
|
+
cardForm?.layer.cornerRadius = CGFloat(borderRadius)
|
|
94
|
+
}
|
|
95
|
+
if let cursorColor = cardStyle["cursorColor"] as? String {
|
|
96
|
+
cardForm?.tintColor = UIColor(hexString: cursorColor)
|
|
97
|
+
}
|
|
78
98
|
// if let disabledBackgroundColor = cardStyle["disabledBackgroundColor"] as? String {
|
|
79
99
|
// cardForm?.disabledBackgroundColor = UIColor(hexString: disabledBackgroundColor)
|
|
80
100
|
// }
|
package/ios/Mappers.swift
CHANGED
|
@@ -16,17 +16,6 @@ class Mappers {
|
|
|
16
16
|
}
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
-
class func mapToPaymentSummaryItemType(type: String?) -> PKPaymentSummaryItemType {
|
|
20
|
-
if let type = type {
|
|
21
|
-
switch type {
|
|
22
|
-
case "pending": return PKPaymentSummaryItemType.pending
|
|
23
|
-
case "final": return PKPaymentSummaryItemType.final
|
|
24
|
-
default: return PKPaymentSummaryItemType.final
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
return PKPaymentSummaryItemType.final
|
|
28
|
-
}
|
|
29
|
-
|
|
30
19
|
class func mapFromBankAccountHolderType(_ type: STPBankAccountHolderType?) -> String? {
|
|
31
20
|
if let type = type {
|
|
32
21
|
switch type {
|
|
@@ -171,8 +160,12 @@ class Mappers {
|
|
|
171
160
|
let amount = NSDecimalNumber(string: method["amount"] as? String ?? "")
|
|
172
161
|
let identifier = method["identifier"] as! String
|
|
173
162
|
let detail = method["detail"] as? String ?? ""
|
|
174
|
-
let
|
|
175
|
-
|
|
163
|
+
let pm = PKShippingMethod.init(
|
|
164
|
+
label: label,
|
|
165
|
+
amount: amount,
|
|
166
|
+
type: method["isPending"] as? Bool ?? false
|
|
167
|
+
? PKPaymentSummaryItemType.pending : PKPaymentSummaryItemType.final
|
|
168
|
+
)
|
|
176
169
|
pm.identifier = identifier
|
|
177
170
|
pm.detail = detail
|
|
178
171
|
shippingMethodsList.append(pm)
|
|
@@ -283,6 +276,7 @@ class Mappers {
|
|
|
283
276
|
case STPPaymentMethodType.klarna: return "Klarna"
|
|
284
277
|
case STPPaymentMethodType.USBankAccount: return "USBankAccount"
|
|
285
278
|
case STPPaymentMethodType.payPal: return "PayPal"
|
|
279
|
+
case STPPaymentMethodType.affirm: return "Affirm"
|
|
286
280
|
case STPPaymentMethodType.unknown: return "Unknown"
|
|
287
281
|
default: return "Unknown"
|
|
288
282
|
}
|
|
@@ -312,6 +306,7 @@ class Mappers {
|
|
|
312
306
|
case "WeChatPay": return STPPaymentMethodType.weChatPay
|
|
313
307
|
case "USBankAccount": return STPPaymentMethodType.USBankAccount
|
|
314
308
|
case "PayPal": return STPPaymentMethodType.payPal
|
|
309
|
+
case "Affirm": return STPPaymentMethodType.affirm
|
|
315
310
|
default: return STPPaymentMethodType.unknown
|
|
316
311
|
}
|
|
317
312
|
}
|
|
@@ -53,6 +53,8 @@ class PaymentMethodFactory {
|
|
|
53
53
|
return try createUSBankAccountPaymentMethodParams()
|
|
54
54
|
case STPPaymentMethodType.payPal:
|
|
55
55
|
return try createPayPalPaymentMethodParams()
|
|
56
|
+
case STPPaymentMethodType.affirm:
|
|
57
|
+
return try createAffirmPaymentMethodParams()
|
|
56
58
|
// case STPPaymentMethodType.weChatPay:
|
|
57
59
|
// return try createWeChatPayPaymentMethodParams()
|
|
58
60
|
default:
|
|
@@ -102,6 +104,8 @@ class PaymentMethodFactory {
|
|
|
102
104
|
return try createUSBankAccountPaymentMethodOptions()
|
|
103
105
|
case STPPaymentMethodType.payPal:
|
|
104
106
|
return nil
|
|
107
|
+
case STPPaymentMethodType.affirm:
|
|
108
|
+
return nil
|
|
105
109
|
default:
|
|
106
110
|
throw PaymentMethodError.paymentNotSupported
|
|
107
111
|
}
|
|
@@ -361,6 +365,11 @@ class PaymentMethodFactory {
|
|
|
361
365
|
private func createPayPalPaymentMethodParams() throws -> STPPaymentMethodParams {
|
|
362
366
|
return STPPaymentMethodParams(payPal: STPPaymentMethodPayPalParams(), billingDetails: billingDetailsParams, metadata: nil)
|
|
363
367
|
}
|
|
368
|
+
|
|
369
|
+
private func createAffirmPaymentMethodParams() throws -> STPPaymentMethodParams {
|
|
370
|
+
let params = STPPaymentMethodAffirmParams()
|
|
371
|
+
return STPPaymentMethodParams(affirm: params, metadata: nil)
|
|
372
|
+
}
|
|
364
373
|
}
|
|
365
374
|
|
|
366
375
|
enum PaymentMethodError: Error {
|
package/ios/StripeSdk.m
CHANGED
|
@@ -121,6 +121,11 @@ RCT_EXTERN_METHOD(
|
|
|
121
121
|
resolver: (RCTPromiseResolveBlock)resolve
|
|
122
122
|
rejecter: (RCTPromiseRejectBlock)reject
|
|
123
123
|
)
|
|
124
|
+
RCT_EXTERN_METHOD(
|
|
125
|
+
canAddCardToWallet:(NSDictionary *)params
|
|
126
|
+
resolver: (RCTPromiseResolveBlock)resolve
|
|
127
|
+
rejecter: (RCTPromiseRejectBlock)reject
|
|
128
|
+
)
|
|
124
129
|
RCT_EXTERN_METHOD(
|
|
125
130
|
isCardInWallet:(NSDictionary *)params
|
|
126
131
|
resolver: (RCTPromiseResolveBlock)resolve
|
package/ios/StripeSdk.swift
CHANGED
|
@@ -85,12 +85,15 @@ class StripeSdk: RCTEventEmitter, STPApplePayContextDelegate, STPBankSelectionVi
|
|
|
85
85
|
}
|
|
86
86
|
}
|
|
87
87
|
|
|
88
|
-
if
|
|
89
|
-
|
|
90
|
-
configuration.applePay = .
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
88
|
+
if let applePayParams = params["applePay"] as? NSDictionary {
|
|
89
|
+
do {
|
|
90
|
+
configuration.applePay = try ApplePayUtils.buildPaymentSheetApplePayConfig(
|
|
91
|
+
merchantIdentifier: self.merchantIdentifier,
|
|
92
|
+
merchantCountryCode: applePayParams["merchantCountryCode"] as? String,
|
|
93
|
+
paymentSummaryItems: applePayParams["paymentSummaryItems"] as? [[String : Any]]
|
|
94
|
+
)
|
|
95
|
+
} catch {
|
|
96
|
+
resolve(Errors.createError(ErrorType.Failed, error.localizedDescription))
|
|
94
97
|
return
|
|
95
98
|
}
|
|
96
99
|
}
|
|
@@ -145,15 +148,14 @@ class StripeSdk: RCTEventEmitter, STPApplePayContextDelegate, STPBankSelectionVi
|
|
|
145
148
|
resolve(Errors.createError(ErrorType.Failed, error as NSError))
|
|
146
149
|
case .success(let paymentSheetFlowController):
|
|
147
150
|
self.paymentSheetFlowController = paymentSheetFlowController
|
|
151
|
+
var result: NSDictionary? = nil
|
|
148
152
|
if let paymentOption = stripeSdk?.paymentSheetFlowController?.paymentOption {
|
|
149
|
-
|
|
153
|
+
result = [
|
|
150
154
|
"label": paymentOption.label,
|
|
151
155
|
"image": paymentOption.image.pngData()?.base64EncodedString() ?? ""
|
|
152
156
|
]
|
|
153
|
-
resolve(Mappers.createResult("paymentOption", option))
|
|
154
|
-
} else {
|
|
155
|
-
resolve(Mappers.createResult("paymentOption", nil))
|
|
156
157
|
}
|
|
158
|
+
resolve(Mappers.createResult("paymentOption", result))
|
|
157
159
|
}
|
|
158
160
|
}
|
|
159
161
|
|
|
@@ -285,6 +287,7 @@ class StripeSdk: RCTEventEmitter, STPApplePayContextDelegate, STPBankSelectionVi
|
|
|
285
287
|
|
|
286
288
|
if (paymentMethodType == .payPal) {
|
|
287
289
|
resolve(Errors.createError(ErrorType.Failed, "PayPal is not yet supported through SetupIntents."))
|
|
290
|
+
return
|
|
288
291
|
}
|
|
289
292
|
|
|
290
293
|
var err: NSDictionary? = nil
|
|
@@ -344,17 +347,16 @@ class StripeSdk: RCTEventEmitter, STPApplePayContextDelegate, STPBankSelectionVi
|
|
|
344
347
|
resolve(Errors.createError(ErrorType.Failed, "You can use this method only after either onDidSetShippingMethod or onDidSetShippingContact events emitted"))
|
|
345
348
|
return
|
|
346
349
|
}
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
}
|
|
350
|
+
|
|
351
|
+
var paymentSummaryItems : [PKPaymentSummaryItem] = []
|
|
352
|
+
do {
|
|
353
|
+
paymentSummaryItems = try ApplePayUtils.buildPaymentSummaryItems(items: summaryItems as? [[String : Any]])
|
|
354
|
+
} catch {
|
|
355
|
+
resolve(Errors.createError(ErrorType.Failed, error.localizedDescription))
|
|
356
|
+
return
|
|
355
357
|
}
|
|
358
|
+
|
|
356
359
|
var shippingAddressErrors: [Error] = []
|
|
357
|
-
|
|
358
360
|
for item in errorAddressFields {
|
|
359
361
|
let field = item["field"] as! String
|
|
360
362
|
let message = item["message"] as? String ?? field + " error"
|
|
@@ -513,18 +515,14 @@ class StripeSdk: RCTEventEmitter, STPApplePayContextDelegate, STPBankSelectionVi
|
|
|
513
515
|
|
|
514
516
|
paymentRequest.shippingMethods = Mappers.mapToShippingMethods(shippingMethods: shippingMethods)
|
|
515
517
|
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
let type = Mappers.mapToPaymentSummaryItemType(type: item["type"] as? String)
|
|
523
|
-
paymentSummaryItems.append(PKPaymentSummaryItem(label: label, amount: amount, type: type))
|
|
524
|
-
}
|
|
518
|
+
do {
|
|
519
|
+
paymentRequest.paymentSummaryItems = try ApplePayUtils
|
|
520
|
+
.buildPaymentSummaryItems(items: summaryItems as? [[String : Any]])
|
|
521
|
+
} catch {
|
|
522
|
+
resolve(Errors.createError(ErrorType.Failed, error.localizedDescription))
|
|
523
|
+
return
|
|
525
524
|
}
|
|
526
525
|
|
|
527
|
-
paymentRequest.paymentSummaryItems = paymentSummaryItems
|
|
528
526
|
if let applePayContext = STPApplePayContext(paymentRequest: paymentRequest, delegate: self) {
|
|
529
527
|
DispatchQueue.main.async {
|
|
530
528
|
applePayContext.presentApplePay(completion: nil)
|
|
@@ -572,12 +570,10 @@ class StripeSdk: RCTEventEmitter, STPApplePayContextDelegate, STPBankSelectionVi
|
|
|
572
570
|
STPAPIClient.shared.createPaymentMethod(with: paymentMethodParams) { paymentMethod, error in
|
|
573
571
|
if let createError = error {
|
|
574
572
|
resolve(Errors.createError(ErrorType.Failed, createError.localizedDescription))
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
let method = Mappers.mapFromPaymentMethod(paymentMethod)
|
|
580
|
-
resolve(Mappers.createResult("paymentMethod", method))
|
|
573
|
+
} else {
|
|
574
|
+
resolve(
|
|
575
|
+
Mappers.createResult("paymentMethod", Mappers.mapFromPaymentMethod(paymentMethod))
|
|
576
|
+
)
|
|
581
577
|
}
|
|
582
578
|
}
|
|
583
579
|
} else {
|
|
@@ -763,10 +759,11 @@ class StripeSdk: RCTEventEmitter, STPApplePayContextDelegate, STPBankSelectionVi
|
|
|
763
759
|
if let intent = intent {
|
|
764
760
|
if (intent.status == .requiresPaymentMethod) {
|
|
765
761
|
resolve(Errors.createError(ErrorType.Canceled, "Bank account collection was canceled."))
|
|
762
|
+
} else {
|
|
763
|
+
resolve(
|
|
764
|
+
Mappers.createResult("paymentIntent", Mappers.mapFromPaymentIntent(paymentIntent: intent))
|
|
765
|
+
)
|
|
766
766
|
}
|
|
767
|
-
resolve(
|
|
768
|
-
Mappers.createResult("paymentIntent", Mappers.mapFromPaymentIntent(paymentIntent: intent))
|
|
769
|
-
)
|
|
770
767
|
} else {
|
|
771
768
|
resolve(Errors.createError(ErrorType.Unknown, "There was unexpected error while collecting bank account information."))
|
|
772
769
|
}
|
|
@@ -787,10 +784,11 @@ class StripeSdk: RCTEventEmitter, STPApplePayContextDelegate, STPBankSelectionVi
|
|
|
787
784
|
if let intent = intent {
|
|
788
785
|
if (intent.status == .requiresPaymentMethod) {
|
|
789
786
|
resolve(Errors.createError(ErrorType.Canceled, "Bank account collection was canceled."))
|
|
787
|
+
} else {
|
|
788
|
+
resolve(
|
|
789
|
+
Mappers.createResult("setupIntent", Mappers.mapFromSetupIntent(setupIntent: intent))
|
|
790
|
+
)
|
|
790
791
|
}
|
|
791
|
-
resolve(
|
|
792
|
-
Mappers.createResult("setupIntent", Mappers.mapFromSetupIntent(setupIntent: intent))
|
|
793
|
-
)
|
|
794
792
|
} else {
|
|
795
793
|
resolve(Errors.createError(ErrorType.Unknown, "There was unexpected error while collecting bank account information."))
|
|
796
794
|
}
|
|
@@ -891,7 +889,6 @@ class StripeSdk: RCTEventEmitter, STPApplePayContextDelegate, STPBankSelectionVi
|
|
|
891
889
|
} else {
|
|
892
890
|
resolve(Errors.createError(ErrorType.Unknown, error?.localizedDescription))
|
|
893
891
|
}
|
|
894
|
-
|
|
895
892
|
return
|
|
896
893
|
}
|
|
897
894
|
|
|
@@ -916,7 +913,6 @@ class StripeSdk: RCTEventEmitter, STPApplePayContextDelegate, STPBankSelectionVi
|
|
|
916
913
|
} else {
|
|
917
914
|
resolve(Errors.createError(ErrorType.Unknown, error?.localizedDescription))
|
|
918
915
|
}
|
|
919
|
-
|
|
920
916
|
return
|
|
921
917
|
}
|
|
922
918
|
|
|
@@ -995,7 +991,26 @@ class StripeSdk: RCTEventEmitter, STPApplePayContextDelegate, STPBankSelectionVi
|
|
|
995
991
|
}
|
|
996
992
|
}
|
|
997
993
|
}
|
|
998
|
-
|
|
994
|
+
|
|
995
|
+
@objc(canAddCardToWallet:resolver:rejecter:)
|
|
996
|
+
func canAddCardToWallet(
|
|
997
|
+
params: NSDictionary,
|
|
998
|
+
resolver resolve: @escaping RCTPromiseResolveBlock,
|
|
999
|
+
rejecter reject: @escaping RCTPromiseRejectBlock
|
|
1000
|
+
) -> Void {
|
|
1001
|
+
guard let last4 = params["cardLastFour"] as? String else {
|
|
1002
|
+
resolve(Errors.createError(ErrorType.Failed, "You must provide `cardLastFour`"))
|
|
1003
|
+
return
|
|
1004
|
+
}
|
|
1005
|
+
let (canAddCard, status) = PushProvisioningUtils.canAddCardToWallet(last4: last4,
|
|
1006
|
+
primaryAccountIdentifier: params["primaryAccountIdentifier"] as? String ?? "",
|
|
1007
|
+
testEnv: params["testEnv"] as? Bool ?? false)
|
|
1008
|
+
resolve([
|
|
1009
|
+
"canAddCard": canAddCard,
|
|
1010
|
+
"details": ["status": status?.rawValue],
|
|
1011
|
+
])
|
|
1012
|
+
}
|
|
1013
|
+
|
|
999
1014
|
@objc(isCardInWallet:resolver:rejecter:)
|
|
1000
1015
|
func isCardInWallet(
|
|
1001
1016
|
params: NSDictionary,
|
|
@@ -1006,15 +1021,7 @@ class StripeSdk: RCTEventEmitter, STPApplePayContextDelegate, STPBankSelectionVi
|
|
|
1006
1021
|
resolve(Errors.createError(ErrorType.Failed, "You must provide `cardLastFour`"))
|
|
1007
1022
|
return
|
|
1008
1023
|
}
|
|
1009
|
-
|
|
1010
|
-
let existingPass: PKPass? = {
|
|
1011
|
-
if #available(iOS 13.4, *) {
|
|
1012
|
-
return PKPassLibrary().passes(of: PKPassType.secureElement).first(where: {$0.secureElementPass?.primaryAccountNumberSuffix == last4})
|
|
1013
|
-
} else {
|
|
1014
|
-
return PKPassLibrary().passes(of: PKPassType.payment).first(where: {$0.paymentPass?.primaryAccountNumberSuffix == last4})
|
|
1015
|
-
}
|
|
1016
|
-
}()
|
|
1017
|
-
resolve(["isInWallet": existingPass != nil])
|
|
1024
|
+
resolve(["isInWallet": PushProvisioningUtils.passExistsWith(last4: last4)])
|
|
1018
1025
|
}
|
|
1019
1026
|
|
|
1020
1027
|
func presentationControllerDidDismiss(_ presentationController: UIPresentationController) {
|