@stripe/stripe-react-native 0.43.0 → 0.45.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/.clang-format +90 -0
- package/.editorconfig +3 -0
- package/CHANGELOG.md +19 -1
- package/android/build.gradle +89 -17
- package/android/gradle.properties +1 -1
- package/android/src/main/java/com/reactnativestripesdk/AuBECSDebitFormViewManager.kt +15 -6
- package/android/src/main/java/com/reactnativestripesdk/CardChangeEvent.kt +56 -0
- package/android/src/main/java/com/reactnativestripesdk/CardFieldView.kt +4 -4
- package/android/src/main/java/com/reactnativestripesdk/CardFieldViewManager.kt +55 -45
- package/android/src/main/java/com/reactnativestripesdk/{CardFocusEvent.kt → CardFocusChangeEvent.kt} +2 -2
- package/android/src/main/java/com/reactnativestripesdk/CardFormCompleteEvent.kt +17 -16
- package/android/src/main/java/com/reactnativestripesdk/CardFormView.kt +5 -5
- package/android/src/main/java/com/reactnativestripesdk/CardFormViewManager.kt +39 -33
- package/android/src/main/java/com/reactnativestripesdk/CollectBankAccountLauncherFragment.kt +4 -2
- package/android/src/main/java/com/reactnativestripesdk/EmbeddedPaymentElementView.kt +182 -0
- package/android/src/main/java/com/reactnativestripesdk/EmbeddedPaymentElementViewManager.kt +231 -0
- package/android/src/main/java/com/reactnativestripesdk/FinancialConnectionsSheetFragment.kt +8 -5
- package/android/src/main/java/com/reactnativestripesdk/GooglePayButtonManager.kt +14 -6
- package/android/src/main/java/com/reactnativestripesdk/PaymentMethodCreateParamsFactory.kt +3 -1
- package/android/src/main/java/com/reactnativestripesdk/PaymentOptionDisplayDataMapper.kt +17 -0
- package/android/src/main/java/com/reactnativestripesdk/PaymentSheetAppearance.kt +266 -0
- package/android/src/main/java/com/reactnativestripesdk/PaymentSheetFragment.kt +28 -13
- package/android/src/main/java/com/reactnativestripesdk/StripeContainerManager.kt +11 -3
- package/android/src/main/java/com/reactnativestripesdk/StripeSdkModule.kt +108 -59
- package/android/src/main/java/com/reactnativestripesdk/StripeSdkPackage.kt +34 -4
- package/android/src/main/java/com/reactnativestripesdk/addresssheet/AddressSheetView.kt +33 -27
- package/android/src/main/java/com/reactnativestripesdk/addresssheet/AddressSheetViewManager.kt +49 -24
- package/android/src/main/java/com/reactnativestripesdk/customersheet/CustomerSheetFragment.kt +16 -3
- package/android/src/main/java/com/reactnativestripesdk/customersheet/ReactNativeCustomerAdapter.kt +11 -29
- package/android/src/main/java/com/reactnativestripesdk/pushprovisioning/AddToWalletButtonManager.kt +36 -12
- package/android/src/main/java/com/reactnativestripesdk/pushprovisioning/AddToWalletButtonView.kt +5 -3
- package/android/src/main/java/com/reactnativestripesdk/utils/Extensions.kt +4 -0
- package/android/src/main/java/com/reactnativestripesdk/utils/Mappers.kt +21 -0
- package/android/src/oldarch/java/com/facebook/react/viewmanagers/AddToWalletButtonManagerDelegate.java +49 -0
- package/android/src/oldarch/java/com/facebook/react/viewmanagers/AddToWalletButtonManagerInterface.java +25 -0
- package/android/src/oldarch/java/com/facebook/react/viewmanagers/AddressSheetViewManagerDelegate.java +64 -0
- package/android/src/oldarch/java/com/facebook/react/viewmanagers/AddressSheetViewManagerInterface.java +30 -0
- package/android/src/oldarch/java/com/facebook/react/viewmanagers/ApplePayButtonManagerDelegate.java +41 -0
- package/android/src/oldarch/java/com/facebook/react/viewmanagers/ApplePayButtonManagerInterface.java +20 -0
- package/android/src/oldarch/java/com/facebook/react/viewmanagers/AuBECSDebitFormManagerDelegate.java +36 -0
- package/android/src/oldarch/java/com/facebook/react/viewmanagers/AuBECSDebitFormManagerInterface.java +20 -0
- package/android/src/oldarch/java/com/facebook/react/viewmanagers/CardFieldManagerDelegate.java +73 -0
- package/android/src/oldarch/java/com/facebook/react/viewmanagers/CardFieldManagerInterface.java +31 -0
- package/android/src/oldarch/java/com/facebook/react/viewmanagers/CardFormManagerDelegate.java +67 -0
- package/android/src/oldarch/java/com/facebook/react/viewmanagers/CardFormManagerInterface.java +29 -0
- package/android/src/oldarch/java/com/facebook/react/viewmanagers/EmbeddedPaymentElementViewManagerDelegate.java +49 -0
- package/android/src/oldarch/java/com/facebook/react/viewmanagers/EmbeddedPaymentElementViewManagerInterface.java +21 -0
- package/android/src/oldarch/java/com/facebook/react/viewmanagers/GooglePayButtonManagerDelegate.java +38 -0
- package/android/src/oldarch/java/com/facebook/react/viewmanagers/GooglePayButtonManagerInterface.java +19 -0
- package/android/src/oldarch/java/com/facebook/react/viewmanagers/StripeContainerManagerDelegate.java +32 -0
- package/android/src/oldarch/java/com/facebook/react/viewmanagers/StripeContainerManagerInterface.java +17 -0
- package/android/src/oldarch/java/com/reactnativestripesdk/NativeStripeSdkModuleSpec.java +311 -0
- package/ios/AddressSheet/AddressSheetUtils.swift +21 -19
- package/ios/AddressSheet/AddressSheetView.swift +23 -17
- package/ios/ApplePayButtonManager.m +0 -1
- package/ios/ApplePayButtonManager.swift +1 -3
- package/ios/ApplePayButtonView.swift +25 -20
- package/ios/ApplePayViewController.swift +22 -22
- package/ios/AuBECSDebitFormView.swift +14 -8
- package/ios/CardFieldManager.swift +1 -4
- package/ios/CardFieldView.swift +28 -25
- package/ios/CardFormManager.swift +1 -4
- package/ios/CardFormView.swift +25 -16
- package/ios/CustomerSheet/CustomerSheetUtils.swift +6 -6
- package/ios/CustomerSheet/ReactNativeCustomerAdapter.swift +8 -8
- package/ios/EmbeddedPaymentElementManager.m +6 -0
- package/ios/EmbeddedPaymentElementView.swift +48 -0
- package/ios/NewArch/AddToWalletButtonComponentView.h +10 -0
- package/ios/NewArch/AddToWalletButtonComponentView.mm +93 -0
- package/ios/NewArch/AddressSheetViewComponentView.h +10 -0
- package/ios/NewArch/AddressSheetViewComponentView.mm +109 -0
- package/ios/NewArch/ApplePayButtonComponentView.h +10 -0
- package/ios/NewArch/ApplePayButtonComponentView.mm +124 -0
- package/ios/NewArch/AuBECSDebitFormComponentView.h +10 -0
- package/ios/NewArch/AuBECSDebitFormComponentView.mm +95 -0
- package/ios/NewArch/CardFieldComponentView.h +10 -0
- package/ios/NewArch/CardFieldComponentView.mm +125 -0
- package/ios/NewArch/CardFormComponentView.h +10 -0
- package/ios/NewArch/CardFormComponentView.mm +108 -0
- package/ios/NewArch/StripeContainerComponentView.h +10 -0
- package/ios/NewArch/StripeContainerComponentView.mm +74 -0
- package/ios/NewArch/StripeNewArchConversions.h +20 -0
- package/ios/NewArch/StripeNewArchConversions.mm +47 -0
- package/ios/OldArch/StripeSdkEventEmitterCompat.h +27 -0
- package/ios/OldArch/StripeSdkEventEmitterCompat.m +105 -0
- package/ios/PaymentOptionDisplayData+ReactNative.swift +55 -0
- package/ios/PaymentSheetAppearance.swift +194 -1
- package/ios/PushProvisioning/AddToWalletButtonView.swift +19 -13
- package/ios/StripeContainerView.swift +5 -3
- package/ios/StripeSdk.h +21 -0
- package/ios/StripeSdk.mm +415 -0
- package/ios/StripeSdkEmitter.swift +19 -0
- package/ios/{StripeSdk+CustomerSheet.swift → StripeSdkImpl+CustomerSheet.swift} +24 -24
- package/ios/StripeSdkImpl+Embedded.swift +327 -0
- package/ios/{StripeSdk+PaymentSheet.swift → StripeSdkImpl+PaymentSheet.swift} +61 -49
- package/ios/{StripeSdk.swift → StripeSdkImpl.swift} +50 -72
- package/ios/StripeSwiftInterop.h +25 -0
- package/ios/stripe_react_native.h +2 -0
- 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/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/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/events.js +2 -0
- package/lib/commonjs/events.js.map +1 -0
- 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/index.js +1 -1
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/specs/NativeAddToWalletButton.js +2 -0
- package/lib/commonjs/specs/NativeAddToWalletButton.js.map +1 -0
- package/lib/commonjs/specs/NativeAddressSheet.js +2 -0
- package/lib/commonjs/specs/NativeAddressSheet.js.map +1 -0
- package/lib/commonjs/specs/NativeApplePayButton.js +2 -0
- package/lib/commonjs/specs/NativeApplePayButton.js.map +1 -0
- package/lib/commonjs/specs/NativeAuBECSDebitForm.js +2 -0
- package/lib/commonjs/specs/NativeAuBECSDebitForm.js.map +1 -0
- package/lib/commonjs/specs/NativeCardField.js +2 -0
- package/lib/commonjs/specs/NativeCardField.js.map +1 -0
- package/lib/commonjs/specs/NativeCardForm.js +2 -0
- package/lib/commonjs/specs/NativeCardForm.js.map +1 -0
- package/lib/commonjs/specs/NativeEmbeddedPaymentElement.js +2 -0
- package/lib/commonjs/specs/NativeEmbeddedPaymentElement.js.map +1 -0
- package/lib/commonjs/specs/NativeGooglePayButton.js +2 -0
- package/lib/commonjs/specs/NativeGooglePayButton.js.map +1 -0
- package/lib/commonjs/specs/NativeStripeContainer.js +2 -0
- package/lib/commonjs/specs/NativeStripeContainer.js.map +1 -0
- package/lib/commonjs/specs/NativeStripeSdkModule.js +2 -0
- package/lib/commonjs/specs/NativeStripeSdkModule.js.map +1 -0
- package/lib/commonjs/specs/utils.js +2 -0
- package/lib/commonjs/specs/utils.js.map +1 -0
- package/lib/commonjs/types/EmbeddedPaymentElement.js +2 -0
- package/lib/commonjs/types/EmbeddedPaymentElement.js.map +1 -0
- package/lib/commonjs/types/PaymentSheet.js +1 -1
- package/lib/commonjs/types/PaymentSheet.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/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/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/events.js +2 -0
- package/lib/module/events.js.map +1 -0
- 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/index.js +1 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/specs/NativeAddToWalletButton.js +2 -0
- package/lib/module/specs/NativeAddToWalletButton.js.map +1 -0
- package/lib/module/specs/NativeAddressSheet.js +2 -0
- package/lib/module/specs/NativeAddressSheet.js.map +1 -0
- package/lib/module/specs/NativeApplePayButton.js +2 -0
- package/lib/module/specs/NativeApplePayButton.js.map +1 -0
- package/lib/module/specs/NativeAuBECSDebitForm.js +2 -0
- package/lib/module/specs/NativeAuBECSDebitForm.js.map +1 -0
- package/lib/module/specs/NativeCardField.js +2 -0
- package/lib/module/specs/NativeCardField.js.map +1 -0
- package/lib/module/specs/NativeCardForm.js +2 -0
- package/lib/module/specs/NativeCardForm.js.map +1 -0
- package/lib/module/specs/NativeEmbeddedPaymentElement.js +2 -0
- package/lib/module/specs/NativeEmbeddedPaymentElement.js.map +1 -0
- package/lib/module/specs/NativeGooglePayButton.js +2 -0
- package/lib/module/specs/NativeGooglePayButton.js.map +1 -0
- package/lib/module/specs/NativeStripeContainer.js +2 -0
- package/lib/module/specs/NativeStripeContainer.js.map +1 -0
- package/lib/module/specs/NativeStripeSdkModule.js +2 -0
- package/lib/module/specs/NativeStripeSdkModule.js.map +1 -0
- package/lib/module/specs/utils.js +2 -0
- package/lib/module/specs/utils.js.map +1 -0
- package/lib/module/types/EmbeddedPaymentElement.js +2 -0
- package/lib/module/types/EmbeddedPaymentElement.js.map +1 -0
- package/lib/module/types/PaymentSheet.js +1 -1
- package/lib/module/types/PaymentSheet.js.map +1 -1
- package/lib/typescript/src/components/AddToWalletButton.d.ts.map +1 -1
- package/lib/typescript/src/components/AddressSheet.d.ts.map +1 -1
- package/lib/typescript/src/components/AuBECSDebitForm.d.ts.map +1 -1
- package/lib/typescript/src/components/CardField.d.ts +1 -1
- package/lib/typescript/src/components/CardField.d.ts.map +1 -1
- package/lib/typescript/src/components/CardForm.d.ts +1 -1
- package/lib/typescript/src/components/CardForm.d.ts.map +1 -1
- package/lib/typescript/src/components/CustomerSheet.d.ts +1 -1
- package/lib/typescript/src/components/CustomerSheet.d.ts.map +1 -1
- package/lib/typescript/src/components/StripeContainer.d.ts.map +1 -1
- package/lib/typescript/src/events.d.ts +13 -0
- package/lib/typescript/src/events.d.ts.map +1 -0
- package/lib/typescript/src/functions.d.ts.map +1 -1
- package/lib/typescript/src/helpers.d.ts.map +1 -1
- package/lib/typescript/src/hooks/useFinancialConnectionsSheet.d.ts +4 -4
- package/lib/typescript/src/hooks/useFinancialConnectionsSheet.d.ts.map +1 -1
- package/lib/typescript/src/hooks/useStripe.d.ts +2 -2
- package/lib/typescript/src/hooks/useStripe.d.ts.map +1 -1
- package/lib/typescript/src/index.d.ts +2 -0
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/specs/NativeAddToWalletButton.d.ts +27 -0
- package/lib/typescript/src/specs/NativeAddToWalletButton.d.ts.map +1 -0
- package/lib/typescript/src/specs/NativeAddressSheet.d.ts +34 -0
- package/lib/typescript/src/specs/NativeAddressSheet.d.ts.map +1 -0
- package/lib/typescript/src/specs/NativeApplePayButton.d.ts +28 -0
- package/lib/typescript/src/specs/NativeApplePayButton.d.ts.map +1 -0
- package/lib/typescript/src/specs/NativeAuBECSDebitForm.d.ts +19 -0
- package/lib/typescript/src/specs/NativeAuBECSDebitForm.d.ts.map +1 -0
- package/lib/typescript/src/specs/NativeCardField.d.ts +33 -0
- package/lib/typescript/src/specs/NativeCardField.d.ts.map +1 -0
- package/lib/typescript/src/specs/NativeCardForm.d.ts +31 -0
- package/lib/typescript/src/specs/NativeCardForm.d.ts.map +1 -0
- package/lib/typescript/src/specs/NativeEmbeddedPaymentElement.d.ts +22 -0
- package/lib/typescript/src/specs/NativeEmbeddedPaymentElement.d.ts.map +1 -0
- package/lib/typescript/src/specs/NativeGooglePayButton.d.ts +11 -0
- package/lib/typescript/src/specs/NativeGooglePayButton.d.ts.map +1 -0
- package/lib/typescript/src/specs/NativeStripeContainer.d.ts +8 -0
- package/lib/typescript/src/specs/NativeStripeContainer.d.ts.map +1 -0
- package/lib/typescript/src/specs/NativeStripeSdkModule.d.ts +93 -0
- package/lib/typescript/src/specs/NativeStripeSdkModule.d.ts.map +1 -0
- package/lib/typescript/src/specs/utils.d.ts +20 -0
- package/lib/typescript/src/specs/utils.d.ts.map +1 -0
- package/lib/typescript/src/types/CustomerSheet.d.ts +1 -1
- package/lib/typescript/src/types/EmbeddedPaymentElement.d.ts +161 -0
- package/lib/typescript/src/types/EmbeddedPaymentElement.d.ts.map +1 -0
- package/lib/typescript/src/types/PaymentSheet.d.ts +112 -0
- package/lib/typescript/src/types/PaymentSheet.d.ts.map +1 -1
- package/lib/typescript/src/types/components/CardFieldInput.d.ts +3 -2
- package/lib/typescript/src/types/components/CardFieldInput.d.ts.map +1 -1
- package/lib/typescript/src/types/components/CardFormView.d.ts +3 -1
- package/lib/typescript/src/types/components/CardFormView.d.ts.map +1 -1
- package/package.json +20 -1
- package/src/components/AddToWalletButton.tsx +2 -5
- package/src/components/AddressSheet.tsx +5 -16
- package/src/components/AuBECSDebitForm.tsx +3 -12
- package/src/components/CardField.tsx +20 -30
- package/src/components/CardForm.tsx +14 -29
- package/src/components/CustomerSheet.tsx +23 -25
- package/src/components/PlatformPayButton.tsx +6 -6
- package/src/components/StripeContainer.tsx +5 -12
- package/src/components/StripeProvider.tsx +1 -1
- package/src/events.ts +49 -0
- package/src/functions.ts +13 -24
- package/src/helpers.ts +2 -1
- package/src/hooks/useFinancialConnectionsSheet.tsx +2 -2
- package/src/hooks/useStripe.tsx +2 -2
- package/src/index.tsx +3 -0
- package/src/specs/NativeAddToWalletButton.ts +40 -0
- package/src/specs/NativeAddressSheet.ts +50 -0
- package/src/specs/NativeApplePayButton.ts +40 -0
- package/src/specs/NativeAuBECSDebitForm.ts +24 -0
- package/src/specs/NativeCardField.ts +51 -0
- package/src/specs/NativeCardForm.ts +43 -0
- package/src/specs/NativeEmbeddedPaymentElement.ts +37 -0
- package/src/specs/NativeGooglePayButton.ts +20 -0
- package/src/specs/NativeStripeContainer.ts +12 -0
- package/src/specs/NativeStripeSdkModule.ts +219 -0
- package/src/specs/utils.ts +22 -0
- package/src/types/CustomerSheet.ts +1 -1
- package/src/types/EmbeddedPaymentElement.tsx +467 -0
- package/src/types/PaymentSheet.ts +131 -0
- package/src/types/components/CardFieldInput.ts +1 -2
- package/src/types/components/CardFormView.ts +1 -1
- package/stripe-react-native.podspec +27 -2
- package/android/.gradle/8.11.1/checksums/checksums.lock +0 -0
- package/android/.gradle/8.11.1/checksums/md5-checksums.bin +0 -0
- package/android/.gradle/8.11.1/checksums/sha1-checksums.bin +0 -0
- package/android/.gradle/8.11.1/executionHistory/executionHistory.lock +0 -0
- package/android/.gradle/8.11.1/fileChanges/last-build.bin +0 -0
- package/android/.gradle/8.11.1/fileHashes/fileHashes.lock +0 -0
- package/android/.gradle/8.11.1/gc.properties +0 -0
- package/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock +0 -0
- package/android/.gradle/buildOutputCleanup/cache.properties +0 -2
- package/android/.gradle/vcs-1/gc.properties +0 -0
- package/android/src/main/java/com/reactnativestripesdk/CardChangedEvent.kt +0 -54
- package/ios/StripeSdk.m +0 -244
- package/lib/commonjs/NativeStripeSdk.js +0 -2
- package/lib/commonjs/NativeStripeSdk.js.map +0 -1
- package/lib/commonjs/components/ApplePayButtonNative.js +0 -2
- package/lib/commonjs/components/ApplePayButtonNative.js.map +0 -1
- package/lib/commonjs/components/GooglePayButtonNative.js +0 -2
- package/lib/commonjs/components/GooglePayButtonNative.js.map +0 -1
- package/lib/module/NativeStripeSdk.js +0 -2
- package/lib/module/NativeStripeSdk.js.map +0 -1
- package/lib/module/components/ApplePayButtonNative.js +0 -2
- package/lib/module/components/ApplePayButtonNative.js.map +0 -1
- package/lib/module/components/GooglePayButtonNative.js +0 -2
- package/lib/module/components/GooglePayButtonNative.js.map +0 -1
- package/lib/typescript/src/NativeStripeSdk.d.ts +0 -58
- package/lib/typescript/src/NativeStripeSdk.d.ts.map +0 -1
- package/lib/typescript/src/components/ApplePayButtonNative.d.ts +0 -4
- package/lib/typescript/src/components/ApplePayButtonNative.d.ts.map +0 -1
- package/lib/typescript/src/components/GooglePayButtonNative.d.ts +0 -4
- package/lib/typescript/src/components/GooglePayButtonNative.d.ts.map +0 -1
- package/src/NativeStripeSdk.tsx +0 -159
- package/src/components/ApplePayButtonNative.tsx +0 -5
- package/src/components/GooglePayButtonNative.tsx +0 -7
|
@@ -0,0 +1,327 @@
|
|
|
1
|
+
//
|
|
2
|
+
// EmbeddedPaymentElementManager.swift
|
|
3
|
+
// stripe-react-native
|
|
4
|
+
//
|
|
5
|
+
// Created by Nick Porter on 4/15/25.
|
|
6
|
+
//
|
|
7
|
+
|
|
8
|
+
import Foundation
|
|
9
|
+
@_spi(EmbeddedPaymentElementPrivateBeta) @_spi(ExperimentalAllowsRemovalOfLastSavedPaymentMethodAPI) @_spi(CustomerSessionBetaAccess) @_spi(STP) import StripePaymentSheet
|
|
10
|
+
|
|
11
|
+
@objc(StripeSdkImpl)
|
|
12
|
+
extension StripeSdkImpl {
|
|
13
|
+
|
|
14
|
+
// MARK: Public API wrappers
|
|
15
|
+
|
|
16
|
+
@objc(createEmbeddedPaymentElement:configuration:resolve:reject:)
|
|
17
|
+
public func createEmbeddedPaymentElement(intentConfig: NSDictionary,
|
|
18
|
+
configuration: NSDictionary,
|
|
19
|
+
resolve: @escaping RCTPromiseResolveBlock,
|
|
20
|
+
reject: @escaping RCTPromiseRejectBlock) {
|
|
21
|
+
guard let modeParams = intentConfig["mode"] as? NSDictionary else {
|
|
22
|
+
resolve(Errors.createError(ErrorType.Failed, "One of `paymentIntentClientSecret`, `setupIntentClientSecret`, or `intentConfiguration.mode` is required"))
|
|
23
|
+
return
|
|
24
|
+
}
|
|
25
|
+
if intentConfig.object(forKey: "confirmHandler") == nil {
|
|
26
|
+
resolve(Errors.createError(ErrorType.Failed, "You must provide `intentConfiguration.confirmHandler` if you are not passing an intent client secret"))
|
|
27
|
+
return
|
|
28
|
+
}
|
|
29
|
+
let captureMethodString = intentConfig["captureMethod"] as? String
|
|
30
|
+
let intentConfig = buildIntentConfiguration(
|
|
31
|
+
modeParams: modeParams,
|
|
32
|
+
paymentMethodTypes: intentConfig["paymentMethodTypes"] as? [String],
|
|
33
|
+
captureMethod: mapCaptureMethod(captureMethodString)
|
|
34
|
+
)
|
|
35
|
+
|
|
36
|
+
guard let configuration = buildEmbeddedPaymentElementConfiguration(params: configuration).configuration else {
|
|
37
|
+
resolve(Errors.createError(ErrorType.Failed, "Invalid configuration"))
|
|
38
|
+
return
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
Task {
|
|
42
|
+
do {
|
|
43
|
+
let embeddedPaymentElement = try await EmbeddedPaymentElement.create(
|
|
44
|
+
intentConfiguration: intentConfig,
|
|
45
|
+
configuration: configuration
|
|
46
|
+
)
|
|
47
|
+
embeddedPaymentElement.delegate = embeddedInstanceDelegate
|
|
48
|
+
embeddedPaymentElement.presentingViewController = RCTPresentedViewController()
|
|
49
|
+
self.embeddedInstance = embeddedPaymentElement
|
|
50
|
+
|
|
51
|
+
// success: resolve promise
|
|
52
|
+
resolve(nil)
|
|
53
|
+
|
|
54
|
+
// publish initial state
|
|
55
|
+
embeddedInstanceDelegate.embeddedPaymentElementDidUpdateHeight(embeddedPaymentElement: embeddedPaymentElement)
|
|
56
|
+
embeddedInstanceDelegate.embeddedPaymentElementDidUpdatePaymentOption(embeddedPaymentElement: embeddedPaymentElement)
|
|
57
|
+
} catch {
|
|
58
|
+
// 1) still resolve the promise so JS hook can finish loading
|
|
59
|
+
resolve(nil)
|
|
60
|
+
|
|
61
|
+
// 2) emit a loading‐failed event with the error message
|
|
62
|
+
let msg = error.localizedDescription
|
|
63
|
+
self.emitter?.emitEmbeddedPaymentElementLoadingFailed(["message": msg])
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
@objc(confirmEmbeddedPaymentElement:reject:)
|
|
70
|
+
public func confirmEmbeddedPaymentElement(resolve: @escaping RCTPromiseResolveBlock,
|
|
71
|
+
reject: @escaping RCTPromiseRejectBlock) {
|
|
72
|
+
embeddedInstance?.presentingViewController = RCTPresentedViewController()
|
|
73
|
+
embeddedInstance?.confirm { result in
|
|
74
|
+
switch result {
|
|
75
|
+
case .completed:
|
|
76
|
+
// Return an object with { status: 'completed' }
|
|
77
|
+
resolve(["status": "completed"])
|
|
78
|
+
case .canceled:
|
|
79
|
+
// Return an object with { status: 'canceled' }
|
|
80
|
+
resolve(["status": "canceled"])
|
|
81
|
+
case .failed(let error):
|
|
82
|
+
// Return an object with { status: 'failed', error }
|
|
83
|
+
resolve([
|
|
84
|
+
"status": "failed",
|
|
85
|
+
"error": error.localizedDescription
|
|
86
|
+
])
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
@objc(updateEmbeddedPaymentElement:resolve:reject:)
|
|
92
|
+
public func updateEmbeddedPaymentElement(
|
|
93
|
+
intentConfig: NSDictionary,
|
|
94
|
+
resolve: @escaping RCTPromiseResolveBlock,
|
|
95
|
+
reject: @escaping RCTPromiseRejectBlock
|
|
96
|
+
) {
|
|
97
|
+
guard let modeParams = intentConfig["mode"] as? NSDictionary else {
|
|
98
|
+
resolve(Errors.createError(
|
|
99
|
+
ErrorType.Failed,
|
|
100
|
+
"One of `paymentIntentClientSecret`, `setupIntentClientSecret`, or `intentConfiguration.mode` is required"
|
|
101
|
+
))
|
|
102
|
+
return
|
|
103
|
+
}
|
|
104
|
+
let captureMethodString = intentConfig["captureMethod"] as? String
|
|
105
|
+
let intentConfiguration = buildIntentConfiguration(
|
|
106
|
+
modeParams: modeParams,
|
|
107
|
+
paymentMethodTypes: intentConfig["paymentMethodTypes"] as? [String],
|
|
108
|
+
captureMethod: mapCaptureMethod(captureMethodString)
|
|
109
|
+
)
|
|
110
|
+
|
|
111
|
+
Task {
|
|
112
|
+
guard let updateResult = await self.embeddedInstance?.update(intentConfiguration: intentConfiguration) else {
|
|
113
|
+
resolve(Errors.createError(
|
|
114
|
+
ErrorType.Failed,
|
|
115
|
+
"No EmbeddedPaymentElement instance — did you call create first?"
|
|
116
|
+
))
|
|
117
|
+
return
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
switch updateResult {
|
|
121
|
+
case .succeeded:
|
|
122
|
+
resolve(["status": "succeeded"])
|
|
123
|
+
case .canceled:
|
|
124
|
+
resolve(["status": "canceled"])
|
|
125
|
+
case .failed(let error):
|
|
126
|
+
self.emitter?.emitEmbeddedPaymentElementLoadingFailed(["message": error.localizedDescription])
|
|
127
|
+
// We don't resolve with an error b/c loading errors are handled via the embeddedPaymentElementLoadingFailed event
|
|
128
|
+
resolve(nil)
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
@objc(clearEmbeddedPaymentOption)
|
|
134
|
+
public func clearEmbeddedPaymentOption() {
|
|
135
|
+
DispatchQueue.main.async {
|
|
136
|
+
self.embeddedInstance?.clearPaymentOption()
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
// MARK: EmbeddedPaymentElementDelegate
|
|
143
|
+
|
|
144
|
+
class StripeSdkEmbeddedPaymentElementDelegate: EmbeddedPaymentElementDelegate {
|
|
145
|
+
weak var sdkImpl: StripeSdkImpl?
|
|
146
|
+
|
|
147
|
+
init(sdkImpl: StripeSdkImpl) {
|
|
148
|
+
self.sdkImpl = sdkImpl
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
func embeddedPaymentElementDidUpdateHeight(embeddedPaymentElement: StripePaymentSheet.EmbeddedPaymentElement) {
|
|
152
|
+
let newHeight = embeddedPaymentElement.view.systemLayoutSizeFitting(CGSize(width: embeddedPaymentElement.view.bounds.width, height: UIView.layoutFittingCompressedSize.height)).height
|
|
153
|
+
self.sdkImpl?.emitter?.emitEmbeddedPaymentElementDidUpdateHeight(["height": newHeight])
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
func embeddedPaymentElementDidUpdatePaymentOption(embeddedPaymentElement: EmbeddedPaymentElement) {
|
|
157
|
+
let displayDataDict = embeddedPaymentElement.paymentOption?.toDictionary()
|
|
158
|
+
self.sdkImpl?.emitter?.emitEmbeddedPaymentElementDidUpdatePaymentOption(["paymentOption": displayDataDict as Any])
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
func embeddedPaymentElementWillPresent(embeddedPaymentElement: EmbeddedPaymentElement) {
|
|
162
|
+
self.sdkImpl?.emitter?.emitEmbeddedPaymentElementWillPresent()
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
// MARK: Config parsing
|
|
167
|
+
|
|
168
|
+
extension StripeSdkImpl {
|
|
169
|
+
@nonobjc
|
|
170
|
+
internal func buildEmbeddedPaymentElementConfiguration(
|
|
171
|
+
params: NSDictionary
|
|
172
|
+
) -> (error: NSDictionary?, configuration: EmbeddedPaymentElement.Configuration?) {
|
|
173
|
+
var configuration = EmbeddedPaymentElement.Configuration()
|
|
174
|
+
|
|
175
|
+
configuration.primaryButtonLabel = params["primaryButtonLabel"] as? String
|
|
176
|
+
|
|
177
|
+
if let appearanceParams = params["appearance"] as? NSDictionary {
|
|
178
|
+
do {
|
|
179
|
+
configuration.appearance = try PaymentSheetAppearance.buildAppearanceFromParams(userParams: appearanceParams)
|
|
180
|
+
} catch {
|
|
181
|
+
return(error: Errors.createError(ErrorType.Failed, error.localizedDescription), configuration: nil)
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
if let applePayParams = params["applePay"] as? NSDictionary {
|
|
186
|
+
do {
|
|
187
|
+
configuration.applePay = try ApplePayUtils.buildPaymentSheetApplePayConfig(
|
|
188
|
+
merchantIdentifier: self.merchantIdentifier,
|
|
189
|
+
merchantCountryCode: applePayParams["merchantCountryCode"] as? String,
|
|
190
|
+
paymentSummaryItems: applePayParams["cartItems"] as? [[String : Any]],
|
|
191
|
+
buttonType: applePayParams["buttonType"] as? NSNumber,
|
|
192
|
+
customHandlers: buildCustomerHandlersForPaymentSheet(applePayParams: applePayParams)
|
|
193
|
+
)
|
|
194
|
+
} catch {
|
|
195
|
+
return(error: Errors.createError(ErrorType.Failed, error.localizedDescription), configuration: nil)
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
if let linkParams = params["link"] as? NSDictionary {
|
|
200
|
+
let display = StripeSdkImpl.mapToLinkDisplay(value: linkParams["display"] as? String)
|
|
201
|
+
configuration.link = PaymentSheet.LinkConfiguration(display: display)
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
if let merchantDisplayName = params["merchantDisplayName"] as? String {
|
|
205
|
+
configuration.merchantDisplayName = merchantDisplayName
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
if let returnURL = params["returnURL"] as? String {
|
|
209
|
+
configuration.returnURL = returnURL
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
if let allowsDelayedPaymentMethods = params["allowsDelayedPaymentMethods"] as? Bool {
|
|
213
|
+
configuration.allowsDelayedPaymentMethods = allowsDelayedPaymentMethods
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
if let removeSavedPaymentMethodMessage = params["removeSavedPaymentMethodMessage"] as? String {
|
|
217
|
+
configuration.removeSavedPaymentMethodMessage = removeSavedPaymentMethodMessage
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
if let billingConfigParams = params["billingDetailsCollectionConfiguration"] as? [String: Any?] {
|
|
221
|
+
configuration.billingDetailsCollectionConfiguration.name = StripeSdkImpl.mapToCollectionMode(str: billingConfigParams["name"] as? String)
|
|
222
|
+
configuration.billingDetailsCollectionConfiguration.phone = StripeSdkImpl.mapToCollectionMode(str: billingConfigParams["phone"] as? String)
|
|
223
|
+
configuration.billingDetailsCollectionConfiguration.email = StripeSdkImpl.mapToCollectionMode(str: billingConfigParams["email"] as? String)
|
|
224
|
+
configuration.billingDetailsCollectionConfiguration.address = StripeSdkImpl.mapToAddressCollectionMode(str: billingConfigParams["address"] as? String)
|
|
225
|
+
configuration.billingDetailsCollectionConfiguration.attachDefaultsToPaymentMethod = billingConfigParams["attachDefaultsToPaymentMethod"] as? Bool == true
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
if let defaultBillingDetails = params["defaultBillingDetails"] as? [String: Any?] {
|
|
229
|
+
configuration.defaultBillingDetails.name = defaultBillingDetails["name"] as? String
|
|
230
|
+
configuration.defaultBillingDetails.email = defaultBillingDetails["email"] as? String
|
|
231
|
+
configuration.defaultBillingDetails.phone = defaultBillingDetails["phone"] as? String
|
|
232
|
+
|
|
233
|
+
if let address = defaultBillingDetails["address"] as? [String: String] {
|
|
234
|
+
configuration.defaultBillingDetails.address = .init(city: address["city"],
|
|
235
|
+
country: address["country"],
|
|
236
|
+
line1: address["line1"],
|
|
237
|
+
line2: address["line2"],
|
|
238
|
+
postalCode: address["postalCode"],
|
|
239
|
+
state: address["state"])
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
if let defaultShippingDetails = params["defaultShippingDetails"] as? NSDictionary {
|
|
245
|
+
configuration.shippingDetails = {
|
|
246
|
+
return AddressSheetUtils.buildAddressDetails(params: defaultShippingDetails)
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
if #available(iOS 13.0, *) {
|
|
251
|
+
if let style = params["style"] as? String {
|
|
252
|
+
configuration.style = Mappers.mapToUserInterfaceStyle(style)
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
if let customerId = params["customerId"] as? String {
|
|
257
|
+
let customerEphemeralKeySecret = params["customerEphemeralKeySecret"] as? String
|
|
258
|
+
let customerClientSecret = params["customerSessionClientSecret"] as? String
|
|
259
|
+
if customerEphemeralKeySecret != nil && customerClientSecret != nil {
|
|
260
|
+
return(error: Errors.createError(ErrorType.Failed, "`customerEphemeralKeySecret` and `customerSessionClientSecret cannot both be set"), configuration: nil)
|
|
261
|
+
} else if let customerEphemeralKeySecret {
|
|
262
|
+
if (!Errors.isEKClientSecretValid(clientSecret: customerEphemeralKeySecret)) {
|
|
263
|
+
return(error: Errors.createError(ErrorType.Failed, "`customerEphemeralKeySecret` format does not match expected client secret formatting."), configuration: nil)
|
|
264
|
+
}
|
|
265
|
+
configuration.customer = .init(id: customerId, ephemeralKeySecret: customerEphemeralKeySecret)
|
|
266
|
+
} else if let customerClientSecret {
|
|
267
|
+
configuration.customer = .init(id: customerId, customerSessionClientSecret: customerClientSecret)
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
if let preferredNetworksAsInts = params["preferredNetworks"] as? Array<Int> {
|
|
272
|
+
configuration.preferredNetworks = preferredNetworksAsInts.map(Mappers.intToCardBrand).compactMap { $0 }
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
if let allowsRemovalOfLastSavedPaymentMethod = params["allowsRemovalOfLastSavedPaymentMethod"] as? Bool {
|
|
276
|
+
configuration.allowsRemovalOfLastSavedPaymentMethod = allowsRemovalOfLastSavedPaymentMethod
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
if let paymentMethodOrder = params["paymentMethodOrder"] as? Array<String> {
|
|
280
|
+
configuration.paymentMethodOrder = paymentMethodOrder
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
configuration.cardBrandAcceptance = computeCardBrandAcceptance(params: params)
|
|
284
|
+
|
|
285
|
+
if let formSheetActionParams = params["formSheetAction"] as? NSDictionary,
|
|
286
|
+
let actionType = formSheetActionParams["type"] as? String {
|
|
287
|
+
if actionType == "confirm" {
|
|
288
|
+
configuration.formSheetAction = .confirm { [weak self] (result: EmbeddedPaymentElementResult) in
|
|
289
|
+
guard let self = self else { return }
|
|
290
|
+
let resultDict: [String: Any]
|
|
291
|
+
switch result {
|
|
292
|
+
case .completed:
|
|
293
|
+
resultDict = ["status": "completed"]
|
|
294
|
+
case .canceled:
|
|
295
|
+
resultDict = ["status": "canceled"]
|
|
296
|
+
case .failed(let error):
|
|
297
|
+
resultDict = [
|
|
298
|
+
"status": "failed",
|
|
299
|
+
"error": error.localizedDescription
|
|
300
|
+
]
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
// Send the result back to JS via an event.
|
|
304
|
+
self.emitter?.emitEmbeddedPaymentElementFormSheetConfirmComplete(resultDict)
|
|
305
|
+
}
|
|
306
|
+
} else if actionType == "continue" {
|
|
307
|
+
configuration.formSheetAction = .continue
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
if let rowSelectionBehaviorParams = params["rowSelectionBehavior"] as? NSDictionary,
|
|
312
|
+
let behaviorType = rowSelectionBehaviorParams["type"] as? String {
|
|
313
|
+
if behaviorType == "default" {
|
|
314
|
+
configuration.rowSelectionBehavior = .default
|
|
315
|
+
} else if behaviorType == "immediateAction" {
|
|
316
|
+
configuration.rowSelectionBehavior = .immediateAction { [weak self] in
|
|
317
|
+
// Send an event back to JS to notify that a row has been selected.
|
|
318
|
+
// Replace the event name and body details as needed.
|
|
319
|
+
self?.emitter?.emitEmbeddedPaymentElementRowSelectionImmediateAction()
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
return (nil, configuration)
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
}
|
|
@@ -6,14 +6,14 @@
|
|
|
6
6
|
//
|
|
7
7
|
|
|
8
8
|
import Foundation
|
|
9
|
-
@_spi(ExperimentalAllowsRemovalOfLastSavedPaymentMethodAPI) @_spi(CustomerSessionBetaAccess) @_spi(STP) import StripePaymentSheet
|
|
9
|
+
@_spi(ExperimentalAllowsRemovalOfLastSavedPaymentMethodAPI) @_spi(CustomerSessionBetaAccess) @_spi(EmbeddedPaymentElementPrivateBeta) @_spi(STP) import StripePaymentSheet
|
|
10
10
|
|
|
11
|
-
extension
|
|
11
|
+
extension StripeSdkImpl {
|
|
12
12
|
internal func buildPaymentSheetConfiguration(
|
|
13
13
|
params: NSDictionary
|
|
14
14
|
) -> (error: NSDictionary?, configuration: PaymentSheet.Configuration?) {
|
|
15
15
|
var configuration = PaymentSheet.Configuration()
|
|
16
|
-
|
|
16
|
+
|
|
17
17
|
configuration.primaryButtonLabel = params["primaryButtonLabel"] as? String
|
|
18
18
|
|
|
19
19
|
if let appearanceParams = params["appearance"] as? NSDictionary {
|
|
@@ -37,7 +37,16 @@ extension StripeSdk {
|
|
|
37
37
|
return(error: Errors.createError(ErrorType.Failed, error.localizedDescription), configuration: nil)
|
|
38
38
|
}
|
|
39
39
|
}
|
|
40
|
-
|
|
40
|
+
|
|
41
|
+
if let linkParams = params["link"] as? NSDictionary {
|
|
42
|
+
do {
|
|
43
|
+
let display = StripeSdkImpl.mapToLinkDisplay(value: linkParams["display"] as? String)
|
|
44
|
+
configuration.link = PaymentSheet.LinkConfiguration(display: display)
|
|
45
|
+
} catch {
|
|
46
|
+
return(error: Errors.createError(ErrorType.Failed, error.localizedDescription), configuration: nil)
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
41
50
|
if let merchantDisplayName = params["merchantDisplayName"] as? String {
|
|
42
51
|
configuration.merchantDisplayName = merchantDisplayName
|
|
43
52
|
}
|
|
@@ -49,16 +58,16 @@ extension StripeSdk {
|
|
|
49
58
|
if let allowsDelayedPaymentMethods = params["allowsDelayedPaymentMethods"] as? Bool {
|
|
50
59
|
configuration.allowsDelayedPaymentMethods = allowsDelayedPaymentMethods
|
|
51
60
|
}
|
|
52
|
-
|
|
61
|
+
|
|
53
62
|
if let removeSavedPaymentMethodMessage = params["removeSavedPaymentMethodMessage"] as? String {
|
|
54
63
|
configuration.removeSavedPaymentMethodMessage = removeSavedPaymentMethodMessage
|
|
55
64
|
}
|
|
56
|
-
|
|
65
|
+
|
|
57
66
|
if let billingConfigParams = params["billingDetailsCollectionConfiguration"] as? [String: Any?] {
|
|
58
|
-
configuration.billingDetailsCollectionConfiguration.name =
|
|
59
|
-
configuration.billingDetailsCollectionConfiguration.phone =
|
|
60
|
-
configuration.billingDetailsCollectionConfiguration.email =
|
|
61
|
-
configuration.billingDetailsCollectionConfiguration.address =
|
|
67
|
+
configuration.billingDetailsCollectionConfiguration.name = StripeSdkImpl.mapToCollectionMode(str: billingConfigParams["name"] as? String)
|
|
68
|
+
configuration.billingDetailsCollectionConfiguration.phone = StripeSdkImpl.mapToCollectionMode(str: billingConfigParams["phone"] as? String)
|
|
69
|
+
configuration.billingDetailsCollectionConfiguration.email = StripeSdkImpl.mapToCollectionMode(str: billingConfigParams["email"] as? String)
|
|
70
|
+
configuration.billingDetailsCollectionConfiguration.address = StripeSdkImpl.mapToAddressCollectionMode(str: billingConfigParams["address"] as? String)
|
|
62
71
|
configuration.billingDetailsCollectionConfiguration.attachDefaultsToPaymentMethod = billingConfigParams["attachDefaultsToPaymentMethod"] as? Bool == true
|
|
63
72
|
}
|
|
64
73
|
|
|
@@ -77,19 +86,19 @@ extension StripeSdk {
|
|
|
77
86
|
}
|
|
78
87
|
|
|
79
88
|
}
|
|
80
|
-
|
|
89
|
+
|
|
81
90
|
if let defaultShippingDetails = params["defaultShippingDetails"] as? NSDictionary {
|
|
82
91
|
configuration.shippingDetails = {
|
|
83
92
|
return AddressSheetUtils.buildAddressDetails(params: defaultShippingDetails)
|
|
84
93
|
}
|
|
85
94
|
}
|
|
86
|
-
|
|
95
|
+
|
|
87
96
|
if #available(iOS 13.0, *) {
|
|
88
97
|
if let style = params["style"] as? String {
|
|
89
98
|
configuration.style = Mappers.mapToUserInterfaceStyle(style)
|
|
90
99
|
}
|
|
91
100
|
}
|
|
92
|
-
|
|
101
|
+
|
|
93
102
|
if let customerId = params["customerId"] as? String {
|
|
94
103
|
var customerEphemeralKeySecret = params["customerEphemeralKeySecret"] as? String
|
|
95
104
|
var customerClientSecret = params["customerSessionClientSecret"] as? String
|
|
@@ -104,19 +113,19 @@ extension StripeSdk {
|
|
|
104
113
|
configuration.customer = .init(id: customerId, customerSessionClientSecret: customerClientSecret)
|
|
105
114
|
}
|
|
106
115
|
}
|
|
107
|
-
|
|
116
|
+
|
|
108
117
|
if let preferredNetworksAsInts = params["preferredNetworks"] as? Array<Int> {
|
|
109
118
|
configuration.preferredNetworks = preferredNetworksAsInts.map(Mappers.intToCardBrand).compactMap { $0 }
|
|
110
119
|
}
|
|
111
|
-
|
|
120
|
+
|
|
112
121
|
if let allowsRemovalOfLastSavedPaymentMethod = params["allowsRemovalOfLastSavedPaymentMethod"] as? Bool {
|
|
113
122
|
configuration.allowsRemovalOfLastSavedPaymentMethod = allowsRemovalOfLastSavedPaymentMethod
|
|
114
123
|
}
|
|
115
|
-
|
|
124
|
+
|
|
116
125
|
if let paymentMethodOrder = params["paymentMethodOrder"] as? Array<String> {
|
|
117
126
|
configuration.paymentMethodOrder = paymentMethodOrder
|
|
118
127
|
}
|
|
119
|
-
|
|
128
|
+
|
|
120
129
|
switch params["paymentMethodLayout"] as? String? {
|
|
121
130
|
case "Horizontal":
|
|
122
131
|
configuration.paymentMethodLayout = .horizontal
|
|
@@ -125,20 +134,20 @@ extension StripeSdk {
|
|
|
125
134
|
default:
|
|
126
135
|
configuration.paymentMethodLayout = .automatic
|
|
127
136
|
}
|
|
128
|
-
|
|
137
|
+
|
|
129
138
|
configuration.cardBrandAcceptance = computeCardBrandAcceptance(params: params)
|
|
130
|
-
|
|
139
|
+
|
|
131
140
|
return (nil, configuration)
|
|
132
141
|
}
|
|
133
|
-
|
|
142
|
+
|
|
134
143
|
internal func preparePaymentSheetInstance(
|
|
135
144
|
params: NSDictionary,
|
|
136
145
|
configuration: PaymentSheet.Configuration,
|
|
137
146
|
resolve: @escaping RCTPromiseResolveBlock
|
|
138
147
|
) {
|
|
139
148
|
self.paymentSheetFlowController = nil
|
|
140
|
-
|
|
141
|
-
func handlePaymentSheetFlowControllerResult(result: Result<PaymentSheet.FlowController, Error>, stripeSdk:
|
|
149
|
+
|
|
150
|
+
func handlePaymentSheetFlowControllerResult(result: Result<PaymentSheet.FlowController, Error>, stripeSdk: StripeSdkImpl?) {
|
|
142
151
|
switch result {
|
|
143
152
|
case .failure(let error):
|
|
144
153
|
resolve(Errors.createError(ErrorType.Failed, error as NSError))
|
|
@@ -204,7 +213,7 @@ extension StripeSdk {
|
|
|
204
213
|
paymentMethodTypes: intentConfiguration["paymentMethodTypes"] as? [String],
|
|
205
214
|
captureMethod: mapCaptureMethod(captureMethodString)
|
|
206
215
|
)
|
|
207
|
-
|
|
216
|
+
|
|
208
217
|
if params["customFlow"] as? Bool == true {
|
|
209
218
|
PaymentSheet.FlowController.create(intentConfiguration: intentConfig, configuration: configuration) { [weak self] result in
|
|
210
219
|
handlePaymentSheetFlowControllerResult(result: result, stripeSdk: self)
|
|
@@ -218,7 +227,7 @@ extension StripeSdk {
|
|
|
218
227
|
}
|
|
219
228
|
}
|
|
220
229
|
}
|
|
221
|
-
|
|
230
|
+
|
|
222
231
|
internal func computeCardBrandAcceptance(params: NSDictionary) -> PaymentSheet.CardBrandAcceptance {
|
|
223
232
|
if let cardBrandAcceptanceParams = params["cardBrandAcceptance"] as? NSDictionary {
|
|
224
233
|
if let filter = cardBrandAcceptanceParams["filter"] as? String {
|
|
@@ -240,10 +249,10 @@ extension StripeSdk {
|
|
|
240
249
|
}
|
|
241
250
|
}
|
|
242
251
|
}
|
|
243
|
-
|
|
252
|
+
|
|
244
253
|
return .all
|
|
245
254
|
}
|
|
246
|
-
|
|
255
|
+
|
|
247
256
|
private func mapToCardBrandCategory(brand: String) -> PaymentSheet.CardBrandAcceptance.BrandCategory? {
|
|
248
257
|
switch brand {
|
|
249
258
|
case "visa":
|
|
@@ -258,8 +267,8 @@ extension StripeSdk {
|
|
|
258
267
|
return nil
|
|
259
268
|
}
|
|
260
269
|
}
|
|
261
|
-
|
|
262
|
-
|
|
270
|
+
|
|
271
|
+
func mapCaptureMethod(_ captureMethod: String?) -> PaymentSheet.IntentConfiguration.CaptureMethod {
|
|
263
272
|
if let captureMethod = captureMethod {
|
|
264
273
|
switch captureMethod {
|
|
265
274
|
case "Automatic": return PaymentSheet.IntentConfiguration.CaptureMethod.automatic
|
|
@@ -270,8 +279,8 @@ extension StripeSdk {
|
|
|
270
279
|
}
|
|
271
280
|
return PaymentSheet.IntentConfiguration.CaptureMethod.automatic
|
|
272
281
|
}
|
|
273
|
-
|
|
274
|
-
|
|
282
|
+
|
|
283
|
+
func buildIntentConfiguration(
|
|
275
284
|
modeParams: NSDictionary,
|
|
276
285
|
paymentMethodTypes: [String]?,
|
|
277
286
|
captureMethod: PaymentSheet.IntentConfiguration.CaptureMethod
|
|
@@ -297,19 +306,15 @@ extension StripeSdk {
|
|
|
297
306
|
mode: mode,
|
|
298
307
|
paymentMethodTypes: paymentMethodTypes,
|
|
299
308
|
confirmHandler: { paymentMethod, shouldSavePaymentMethod, intentCreationCallback in
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
])
|
|
306
|
-
} else {
|
|
307
|
-
RCTMakeAndLogError("Tried to call confirmHandler, but no callback was found. Please file an issue: https://github.com/stripe/stripe-react-native/issues", nil, nil)
|
|
308
|
-
}
|
|
309
|
+
self.paymentSheetIntentCreationCallback = intentCreationCallback
|
|
310
|
+
self.emitter?.emitOnConfirmHandlerCallback([
|
|
311
|
+
"paymentMethod": Mappers.mapFromPaymentMethod(paymentMethod) ?? NSNull(),
|
|
312
|
+
"shouldSavePaymentMethod": shouldSavePaymentMethod
|
|
313
|
+
])
|
|
309
314
|
})
|
|
310
315
|
}
|
|
311
|
-
|
|
312
|
-
|
|
316
|
+
|
|
317
|
+
func buildCustomerHandlersForPaymentSheet(applePayParams: NSDictionary) -> PaymentSheet.ApplePayConfiguration.Handlers? {
|
|
313
318
|
if (applePayParams["request"] == nil) {
|
|
314
319
|
return nil
|
|
315
320
|
}
|
|
@@ -323,18 +328,14 @@ extension StripeSdk {
|
|
|
323
328
|
return request
|
|
324
329
|
}, authorizationResultHandler: { result, completion in
|
|
325
330
|
if applePayParams.object(forKey: "setOrderTracking") != nil {
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
self.sendEvent(withName: "onOrderTrackingCallback", body: [:])
|
|
329
|
-
} else {
|
|
330
|
-
RCTMakeAndLogError("Order tracking is enabled, but no callback was found. Please file an issue: https://github.com/stripe/stripe-react-native/issues", nil, nil)
|
|
331
|
-
}
|
|
331
|
+
self.orderTrackingHandler = (result, completion)
|
|
332
|
+
self.emitter?.emitOnOrderTrackingCallback()
|
|
332
333
|
} else {
|
|
333
334
|
completion(result)
|
|
334
335
|
}
|
|
335
336
|
})
|
|
336
337
|
}
|
|
337
|
-
|
|
338
|
+
|
|
338
339
|
internal static func mapToCollectionMode(str: String?) -> PaymentSheet.BillingDetailsCollectionConfiguration.CollectionMode {
|
|
339
340
|
switch str {
|
|
340
341
|
case "automatic":
|
|
@@ -347,7 +348,7 @@ extension StripeSdk {
|
|
|
347
348
|
return .automatic
|
|
348
349
|
}
|
|
349
350
|
}
|
|
350
|
-
|
|
351
|
+
|
|
351
352
|
internal static func mapToAddressCollectionMode(str: String?) -> PaymentSheet.BillingDetailsCollectionConfiguration.AddressCollectionMode {
|
|
352
353
|
switch str {
|
|
353
354
|
case "automatic":
|
|
@@ -360,5 +361,16 @@ extension StripeSdk {
|
|
|
360
361
|
return .automatic
|
|
361
362
|
}
|
|
362
363
|
}
|
|
364
|
+
|
|
365
|
+
internal static func mapToLinkDisplay(value: String?) -> PaymentSheet.LinkConfiguration.Display {
|
|
366
|
+
switch value {
|
|
367
|
+
case "automatic":
|
|
368
|
+
return .automatic
|
|
369
|
+
case "never":
|
|
370
|
+
return .never
|
|
371
|
+
default:
|
|
372
|
+
return .automatic
|
|
373
|
+
}
|
|
374
|
+
}
|
|
363
375
|
}
|
|
364
376
|
|