@stripe/stripe-react-native 0.57.0 → 0.57.2
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/README.md +0 -8
- package/android/.idea/AndroidProjectSystem.xml +6 -0
- package/android/.idea/caches/deviceStreaming.xml +1029 -0
- package/android/.idea/compiler.xml +6 -0
- package/android/.idea/gradle.xml +19 -0
- package/android/.idea/migrations.xml +10 -0
- package/android/.idea/misc.xml +10 -0
- package/android/.idea/runConfigurations.xml +17 -0
- package/android/.idea/vcs.xml +6 -0
- package/android/build.gradle +76 -118
- package/android/gradle.properties +1 -1
- package/android/local.properties +8 -0
- package/android/settings.gradle +2 -0
- package/android/spotless.gradle +1 -1
- package/android/src/main/java/com/reactnativestripesdk/AuBECSDebitFormView.kt +20 -17
- package/android/src/main/java/com/reactnativestripesdk/CardFieldView.kt +13 -11
- package/android/src/main/java/com/reactnativestripesdk/CardFormView.kt +17 -21
- package/android/src/main/java/com/reactnativestripesdk/CollectBankAccountLauncherManager.kt +2 -0
- package/android/src/main/java/com/reactnativestripesdk/CustomPaymentMethodActivity.kt +2 -0
- package/android/src/main/java/com/reactnativestripesdk/EmbeddedPaymentElementView.kt +53 -11
- package/android/src/main/java/com/reactnativestripesdk/EmbeddedPaymentElementViewManager.kt +105 -117
- package/android/src/main/java/com/reactnativestripesdk/EventEmitterCompat.kt +4 -8
- package/android/src/main/java/com/reactnativestripesdk/FakeOnrampSdkModule.kt +154 -0
- package/android/src/main/java/com/reactnativestripesdk/FinancialConnectionsSheetManager.kt +13 -15
- package/android/src/main/java/com/reactnativestripesdk/GooglePayButtonView.kt +1 -1
- package/android/src/main/java/com/reactnativestripesdk/GooglePayLauncherManager.kt +1 -1
- package/android/src/main/java/com/reactnativestripesdk/GooglePayRequestHelper.kt +7 -5
- package/android/src/main/java/com/reactnativestripesdk/NavigationBarManager.kt +31 -0
- package/android/src/main/java/com/reactnativestripesdk/NavigationBarView.kt +120 -0
- package/android/src/main/java/com/reactnativestripesdk/PaymentElementConfig.kt +228 -0
- package/android/src/main/java/com/reactnativestripesdk/PaymentLauncherManager.kt +1 -0
- package/android/src/main/java/com/reactnativestripesdk/PaymentMethodCreateParamsFactory.kt +3 -0
- package/android/src/main/java/com/reactnativestripesdk/PaymentOptionDisplayDataMapper.kt +4 -6
- package/android/src/main/java/com/reactnativestripesdk/PaymentSheetAppearance.kt +73 -30
- package/android/src/main/java/com/reactnativestripesdk/PaymentSheetManager.kt +19 -245
- package/android/src/main/java/com/reactnativestripesdk/StripeAbstractComposeView.kt +53 -17
- package/android/src/main/java/com/reactnativestripesdk/StripeSdkModule.kt +52 -14
- package/android/src/main/java/com/reactnativestripesdk/StripeSdkPackage.kt +21 -2
- package/android/src/main/java/com/reactnativestripesdk/addresssheet/AddressSheetView.kt +4 -4
- package/android/src/main/java/com/reactnativestripesdk/addresssheet/AddressSheetViewManager.kt +2 -2
- package/android/src/main/java/com/reactnativestripesdk/customersheet/CustomerSheetManager.kt +15 -35
- package/android/src/main/java/com/reactnativestripesdk/customersheet/ReactNativeCustomerSessionProvider.kt +2 -1
- package/android/src/main/java/com/reactnativestripesdk/pushprovisioning/AddToWalletButtonManager.kt +5 -10
- package/android/src/main/java/com/reactnativestripesdk/pushprovisioning/AddToWalletButtonView.kt +90 -77
- package/android/src/main/java/com/reactnativestripesdk/pushprovisioning/TapAndPayProxy.kt +6 -4
- package/android/src/main/java/com/reactnativestripesdk/utils/Errors.kt +13 -3
- package/android/src/main/java/com/reactnativestripesdk/utils/Extensions.kt +41 -0
- package/android/src/main/java/com/reactnativestripesdk/utils/KeepJsAwakeTask.kt +1 -1
- package/android/src/main/java/com/reactnativestripesdk/utils/Mappers.kt +92 -44
- package/android/src/oldarch/java/com/facebook/react/viewmanagers/EmbeddedPaymentElementViewManagerDelegate.java +3 -0
- package/android/src/oldarch/java/com/facebook/react/viewmanagers/EmbeddedPaymentElementViewManagerInterface.java +2 -0
- package/android/src/oldarch/java/com/reactnativestripesdk/NativeOnrampSdkModuleSpec.java +118 -0
- package/android/src/oldarch/java/com/reactnativestripesdk/NativeStripeSdkModuleSpec.java +4 -0
- package/android/src/onramp/java/com/reactnativestripesdk/OnrampSdkModule.kt +922 -0
- package/android/src/test/java/com/facebook/testutils/shadows/ShadowArguments.kt +29 -0
- package/android/src/test/java/com/reactnativestripesdk/EmbeddedPaymentElementViewManagerTest.kt +163 -0
- package/android/src/test/java/com/reactnativestripesdk/PaymentElementConfigTest.kt +976 -0
- package/android/src/test/java/com/reactnativestripesdk/PaymentSheetAppearanceTest.kt +801 -0
- package/android/src/test/java/com/reactnativestripesdk/PaymentSheetManagerTest.kt +523 -0
- package/android/src/test/java/com/reactnativestripesdk/addresssheet/AddressSheetViewTest.kt +551 -0
- package/android/src/test/java/com/reactnativestripesdk/mappers/MappersTest.kt +567 -0
- package/android/src/test/java/com/reactnativestripesdk/mappers/PaymentOptionDisplayDataMapperTest.kt +456 -0
- package/android/src/test/java/com/reactnativestripesdk/pushprovisioning/PushProvisioningProxyTest.kt +43 -0
- package/android/src/test/resources/robolectric.properties +2 -0
- package/ios/AddressSheet/AddressSheetUtils.swift +3 -3
- package/ios/AddressSheet/AddressSheetView.swift +25 -25
- package/ios/AddressSheet/AddressSheetViewManager.swift +2 -2
- package/ios/ApplePayButtonManager.swift +1 -1
- package/ios/ApplePayButtonView.swift +9 -10
- package/ios/ApplePayUtils.swift +51 -51
- package/ios/ApplePayViewController.swift +25 -29
- package/ios/AuBECSDebitFormManager.swift +1 -1
- package/ios/AuBECSDebitFormView.swift +13 -15
- package/ios/CardFieldManager.swift +4 -4
- package/ios/CardFieldView.swift +9 -9
- package/ios/CardFormManager.swift +3 -3
- package/ios/CardFormView.swift +28 -28
- package/ios/ConnectAccountOnboarding/ConnectAccountOnboardingView.swift +97 -0
- package/ios/ConnectAccountOnboarding/ConnectAccountOnboardingViewController.swift +133 -0
- package/ios/ConnectAccountOnboarding/ConnectAccountOnboardingViewManager.m +16 -0
- package/ios/ConnectAccountOnboarding/ConnectAccountOnboardingViewManager.swift +17 -0
- package/ios/CustomerSheet/CustomerSheetUtils.swift +15 -16
- package/ios/CustomerSheet/ReactNativeCustomerAdapter.swift +19 -19
- package/ios/EmbeddedPaymentElementView.swift +2 -2
- package/ios/Errors.swift +22 -23
- package/ios/FinancialConnections.swift +37 -37
- package/ios/Mappers.swift +210 -71
- package/ios/NavigationBarManager.m +13 -0
- package/ios/NavigationBarManager.swift +17 -0
- package/ios/NavigationBarView.swift +65 -0
- package/ios/NewArch/NavigationBarComponentView.h +10 -0
- package/ios/NewArch/NavigationBarComponentView.mm +86 -0
- package/ios/OldArch/StripeSdkEventEmitterCompat.h +1 -0
- package/ios/OldArch/StripeSdkEventEmitterCompat.m +7 -1
- package/ios/PaymentMethodFactory.swift +24 -24
- package/ios/PaymentOptionDisplayData+ReactNative.swift +4 -4
- package/ios/PaymentPassFinder.swift +9 -10
- package/ios/PaymentSheetAppearance.swift +137 -138
- package/ios/PushProvisioning/AddToWalletButtonManager.swift +2 -2
- package/ios/PushProvisioning/AddToWalletButtonView.swift +15 -17
- package/ios/PushProvisioning/PushProvisioningUtils.swift +11 -11
- package/ios/StripeContainerManager.swift +1 -1
- package/ios/StripeContainerView.swift +3 -3
- package/ios/StripeOnrampSdk.h +17 -0
- package/ios/StripeOnrampSdk.mm +158 -0
- package/ios/StripeSdk.mm +8 -0
- package/ios/StripeSdk.xcodeproj/project.xcworkspace/contents.xcworkspacedata +7 -0
- package/ios/StripeSdk.xcodeproj/project.xcworkspace/xcuserdata/tianzhao.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
- package/ios/StripeSdk.xcodeproj/xcuserdata/tianzhao.xcuserdatad/xcschemes/xcschememanagement.plist +19 -0
- package/ios/StripeSdkEmitter.swift +4 -0
- package/ios/StripeSdkImpl+CustomerSheet.swift +30 -25
- package/ios/StripeSdkImpl+Embedded.swift +11 -9
- package/ios/StripeSdkImpl+PaymentSheet.swift +36 -34
- package/ios/StripeSdkImpl.swift +913 -185
- package/ios/UIColorExtension.swift +72 -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/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/connect/Components.js +2 -0
- package/lib/commonjs/connect/Components.js.map +1 -0
- package/lib/commonjs/connect/ConnectComponentsProvider.js +2 -0
- package/lib/commonjs/connect/ConnectComponentsProvider.js.map +1 -0
- package/lib/commonjs/connect/EmbeddedComponent.js +19 -0
- package/lib/commonjs/connect/EmbeddedComponent.js.map +1 -0
- package/lib/commonjs/connect/ModalCloseButton.js +2 -0
- package/lib/commonjs/connect/ModalCloseButton.js.map +1 -0
- package/lib/commonjs/connect/NavigationBar.js +2 -0
- package/lib/commonjs/connect/NavigationBar.js.map +1 -0
- package/lib/commonjs/connect/connectTypes.js +2 -0
- package/lib/commonjs/connect/connectTypes.js.map +1 -0
- package/lib/commonjs/events.js +1 -1
- package/lib/commonjs/events.js.map +1 -1
- package/lib/commonjs/helpers.js +1 -1
- package/lib/commonjs/helpers.js.map +1 -1
- package/lib/commonjs/hooks/useOnramp.js +2 -0
- package/lib/commonjs/hooks/useOnramp.js.map +1 -0
- package/lib/commonjs/index.js +1 -1
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/plugin/withStripe.js +1 -1
- package/lib/commonjs/plugin/withStripe.js.map +1 -1
- package/lib/commonjs/specs/NativeAddToWalletButton.js +1 -1
- package/lib/commonjs/specs/NativeAddToWalletButton.js.map +1 -1
- package/lib/commonjs/specs/NativeAddressSheet.js +1 -1
- package/lib/commonjs/specs/NativeAddressSheet.js.map +1 -1
- package/lib/commonjs/specs/NativeApplePayButton.js +1 -1
- package/lib/commonjs/specs/NativeApplePayButton.js.map +1 -1
- package/lib/commonjs/specs/NativeAuBECSDebitForm.js +1 -1
- package/lib/commonjs/specs/NativeAuBECSDebitForm.js.map +1 -1
- package/lib/commonjs/specs/NativeCardField.js +1 -1
- package/lib/commonjs/specs/NativeCardField.js.map +1 -1
- package/lib/commonjs/specs/NativeCardForm.js +1 -1
- package/lib/commonjs/specs/NativeCardForm.js.map +1 -1
- package/lib/commonjs/specs/NativeConnectAccountOnboardingView.js +2 -0
- package/lib/commonjs/specs/NativeConnectAccountOnboardingView.js.map +1 -0
- package/lib/commonjs/specs/NativeEmbeddedPaymentElement.js +1 -1
- package/lib/commonjs/specs/NativeEmbeddedPaymentElement.js.map +1 -1
- package/lib/commonjs/specs/NativeGooglePayButton.js +1 -1
- package/lib/commonjs/specs/NativeGooglePayButton.js.map +1 -1
- package/lib/commonjs/specs/NativeNavigationBar.js +2 -0
- package/lib/commonjs/specs/NativeNavigationBar.js.map +1 -0
- package/lib/commonjs/specs/NativeOnrampSdkModule.js +2 -0
- package/lib/commonjs/specs/NativeOnrampSdkModule.js.map +1 -0
- package/lib/commonjs/specs/NativeStripeContainer.js +1 -1
- package/lib/commonjs/specs/NativeStripeContainer.js.map +1 -1
- package/lib/commonjs/specs/NativeStripeSdkModule.js.map +1 -1
- package/lib/commonjs/types/EmbeddedPaymentElement.js +1 -1
- package/lib/commonjs/types/EmbeddedPaymentElement.js.map +1 -1
- package/lib/commonjs/types/Errors.js +1 -1
- package/lib/commonjs/types/Errors.js.map +1 -1
- package/lib/commonjs/types/Onramp.js +2 -0
- package/lib/commonjs/types/Onramp.js.map +1 -0
- package/lib/commonjs/types/PaymentSheet.js.map +1 -1
- package/lib/commonjs/types/index.js +1 -1
- package/lib/commonjs/types/index.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/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/connect/Components.js +2 -0
- package/lib/module/connect/Components.js.map +1 -0
- package/lib/module/connect/ConnectComponentsProvider.js +2 -0
- package/lib/module/connect/ConnectComponentsProvider.js.map +1 -0
- package/lib/module/connect/EmbeddedComponent.js +19 -0
- package/lib/module/connect/EmbeddedComponent.js.map +1 -0
- package/lib/module/connect/ModalCloseButton.js +2 -0
- package/lib/module/connect/ModalCloseButton.js.map +1 -0
- package/lib/module/connect/NavigationBar.js +2 -0
- package/lib/module/connect/NavigationBar.js.map +1 -0
- package/lib/module/connect/connectTypes.js +2 -0
- package/lib/module/connect/connectTypes.js.map +1 -0
- package/lib/module/events.js +1 -1
- package/lib/module/events.js.map +1 -1
- package/lib/module/helpers.js +1 -1
- package/lib/module/helpers.js.map +1 -1
- package/lib/module/hooks/useOnramp.js +2 -0
- package/lib/module/hooks/useOnramp.js.map +1 -0
- package/lib/module/index.js +1 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/plugin/withStripe.js +1 -1
- package/lib/module/plugin/withStripe.js.map +1 -1
- package/lib/module/specs/NativeAddToWalletButton.js +1 -1
- package/lib/module/specs/NativeAddToWalletButton.js.map +1 -1
- package/lib/module/specs/NativeAddressSheet.js +1 -1
- package/lib/module/specs/NativeAddressSheet.js.map +1 -1
- package/lib/module/specs/NativeApplePayButton.js +1 -1
- package/lib/module/specs/NativeApplePayButton.js.map +1 -1
- package/lib/module/specs/NativeAuBECSDebitForm.js +1 -1
- package/lib/module/specs/NativeAuBECSDebitForm.js.map +1 -1
- package/lib/module/specs/NativeCardField.js +1 -1
- package/lib/module/specs/NativeCardField.js.map +1 -1
- package/lib/module/specs/NativeCardForm.js +1 -1
- package/lib/module/specs/NativeCardForm.js.map +1 -1
- package/lib/module/specs/NativeConnectAccountOnboardingView.js +2 -0
- package/lib/module/specs/NativeConnectAccountOnboardingView.js.map +1 -0
- package/lib/module/specs/NativeEmbeddedPaymentElement.js +1 -1
- package/lib/module/specs/NativeEmbeddedPaymentElement.js.map +1 -1
- package/lib/module/specs/NativeGooglePayButton.js +1 -1
- package/lib/module/specs/NativeGooglePayButton.js.map +1 -1
- package/lib/module/specs/NativeNavigationBar.js +2 -0
- package/lib/module/specs/NativeNavigationBar.js.map +1 -0
- package/lib/module/specs/NativeOnrampSdkModule.js +2 -0
- package/lib/module/specs/NativeOnrampSdkModule.js.map +1 -0
- package/lib/module/specs/NativeStripeContainer.js +1 -1
- package/lib/module/specs/NativeStripeContainer.js.map +1 -1
- package/lib/module/specs/NativeStripeSdkModule.js.map +1 -1
- package/lib/module/types/EmbeddedPaymentElement.js +1 -1
- package/lib/module/types/EmbeddedPaymentElement.js.map +1 -1
- package/lib/module/types/Errors.js +1 -1
- package/lib/module/types/Errors.js.map +1 -1
- package/lib/module/types/Onramp.js +2 -0
- package/lib/module/types/Onramp.js.map +1 -0
- package/lib/module/types/PaymentSheet.js.map +1 -1
- package/lib/module/types/index.js +1 -1
- package/lib/module/types/index.js.map +1 -1
- package/lib/typescript/src/components/StripeProvider.d.ts.map +1 -1
- package/lib/typescript/src/connect/Components.d.ts +23 -0
- package/lib/typescript/src/connect/Components.d.ts.map +1 -0
- package/lib/typescript/src/connect/ConnectComponentsProvider.d.ts +22 -0
- package/lib/typescript/src/connect/ConnectComponentsProvider.d.ts.map +1 -0
- package/lib/typescript/src/connect/EmbeddedComponent.d.ts +18 -0
- package/lib/typescript/src/connect/EmbeddedComponent.d.ts.map +1 -0
- package/lib/typescript/src/connect/ModalCloseButton.d.ts +7 -0
- package/lib/typescript/src/connect/ModalCloseButton.d.ts.map +1 -0
- package/lib/typescript/src/connect/NavigationBar.d.ts +8 -0
- package/lib/typescript/src/connect/NavigationBar.d.ts.map +1 -0
- package/lib/typescript/src/connect/connectTypes.d.ts +464 -0
- package/lib/typescript/src/connect/connectTypes.d.ts.map +1 -0
- package/lib/typescript/src/events.d.ts +4 -0
- package/lib/typescript/src/events.d.ts.map +1 -1
- 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/useOnramp.d.ts +158 -0
- package/lib/typescript/src/hooks/useOnramp.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +4 -0
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/plugin/withStripe.d.ts +15 -0
- package/lib/typescript/src/plugin/withStripe.d.ts.map +1 -1
- package/lib/typescript/src/specs/NativeConnectAccountOnboardingView.d.ts +14 -0
- package/lib/typescript/src/specs/NativeConnectAccountOnboardingView.d.ts.map +1 -0
- package/lib/typescript/src/specs/NativeEmbeddedPaymentElement.d.ts +1 -0
- package/lib/typescript/src/specs/NativeEmbeddedPaymentElement.d.ts.map +1 -1
- package/lib/typescript/src/specs/NativeNavigationBar.d.ts +11 -0
- package/lib/typescript/src/specs/NativeNavigationBar.d.ts.map +1 -0
- package/lib/typescript/src/specs/NativeOnrampSdkModule.d.ts +28 -0
- package/lib/typescript/src/specs/NativeOnrampSdkModule.d.ts.map +1 -0
- package/lib/typescript/src/specs/NativeStripeSdkModule.d.ts +3 -0
- package/lib/typescript/src/specs/NativeStripeSdkModule.d.ts.map +1 -1
- package/lib/typescript/src/types/EmbeddedPaymentElement.d.ts.map +1 -1
- package/lib/typescript/src/types/Errors.d.ts +5 -0
- package/lib/typescript/src/types/Errors.d.ts.map +1 -1
- package/lib/typescript/src/types/Onramp.d.ts +275 -0
- package/lib/typescript/src/types/Onramp.d.ts.map +1 -0
- package/lib/typescript/src/types/PaymentSheet.d.ts +7 -0
- package/lib/typescript/src/types/PaymentSheet.d.ts.map +1 -1
- package/lib/typescript/src/types/index.d.ts +7 -1
- package/lib/typescript/src/types/index.d.ts.map +1 -1
- package/package.json +25 -14
- package/src/components/StripeProvider.tsx +5 -0
- package/src/connect/Components.tsx +279 -0
- package/src/connect/ConnectComponentsProvider.tsx +93 -0
- package/src/connect/EmbeddedComponent.tsx +407 -0
- package/src/connect/ModalCloseButton.tsx +44 -0
- package/src/connect/NavigationBar.tsx +29 -0
- package/src/connect/connectTypes.ts +626 -0
- package/src/events.ts +23 -0
- package/src/hooks/useOnramp.tsx +334 -0
- package/src/index.tsx +13 -0
- package/src/plugin/withStripe.ts +104 -7
- package/src/specs/NativeConnectAccountOnboardingView.ts +19 -0
- package/src/specs/NativeEmbeddedPaymentElement.ts +5 -1
- package/src/specs/NativeNavigationBar.ts +16 -0
- package/src/specs/NativeOnrampSdkModule.ts +47 -0
- package/src/specs/NativeStripeSdkModule.ts +5 -0
- package/src/types/EmbeddedPaymentElement.tsx +24 -3
- package/src/types/Errors.ts +6 -0
- package/src/types/Onramp.ts +317 -0
- package/src/types/PaymentSheet.ts +7 -0
- package/src/types/index.ts +8 -0
- package/stripe-react-native.podspec +20 -7
|
@@ -9,18 +9,18 @@ public class ApplePayButtonView: UIView {
|
|
|
9
9
|
@objc public var onShippingContactSelectedAction: RCTDirectEventBlock?
|
|
10
10
|
@objc public var onCouponCodeEnteredAction: RCTDirectEventBlock?
|
|
11
11
|
@objc public var onOrderTrackingAction: RCTDirectEventBlock?
|
|
12
|
-
|
|
12
|
+
|
|
13
13
|
// Boolean flags to track which callbacks were provided as props
|
|
14
14
|
@objc public var hasShippingMethodCallback = false
|
|
15
15
|
@objc public var hasShippingContactCallback = false
|
|
16
16
|
@objc public var hasCouponCodeCallback = false
|
|
17
17
|
@objc public var hasOrderTrackingCallback = false
|
|
18
|
-
|
|
18
|
+
|
|
19
19
|
@objc public var type: NSNumber?
|
|
20
20
|
@objc public var buttonStyle: NSNumber?
|
|
21
21
|
@objc public var buttonBorderRadius: NSNumber?
|
|
22
22
|
@objc public var disabled = false
|
|
23
|
-
|
|
23
|
+
|
|
24
24
|
@objc func handleApplePayButtonTapped() {
|
|
25
25
|
// Only set callbacks that were actually provided as props
|
|
26
26
|
StripeSdkImpl.shared.shippingMethodUpdateJSCallback = hasShippingMethodCallback ? onShippingMethodSelectedAction : nil
|
|
@@ -28,7 +28,7 @@ public class ApplePayButtonView: UIView {
|
|
|
28
28
|
StripeSdkImpl.shared.couponCodeEnteredJSCallback = hasCouponCodeCallback ? onCouponCodeEnteredAction : nil
|
|
29
29
|
StripeSdkImpl.shared.platformPayOrderTrackingJSCallback = hasOrderTrackingCallback ? onOrderTrackingAction : nil
|
|
30
30
|
}
|
|
31
|
-
|
|
31
|
+
|
|
32
32
|
@objc public func didSetProps() {
|
|
33
33
|
if let applePayButton = self.applePayButton {
|
|
34
34
|
applePayButton.removeFromSuperview()
|
|
@@ -39,31 +39,30 @@ public class ApplePayButtonView: UIView {
|
|
|
39
39
|
if #available(iOS 12.0, *) {
|
|
40
40
|
self.applePayButton?.cornerRadius = self.buttonBorderRadius as? CGFloat ?? 4.0
|
|
41
41
|
}
|
|
42
|
-
|
|
42
|
+
|
|
43
43
|
if let applePayButton = self.applePayButton {
|
|
44
44
|
applePayButton.isEnabled = !disabled
|
|
45
45
|
applePayButton.addTarget(self, action: #selector(handleApplePayButtonTapped), for: .touchUpInside)
|
|
46
46
|
self.addSubview(applePayButton)
|
|
47
47
|
}
|
|
48
48
|
}
|
|
49
|
-
|
|
49
|
+
|
|
50
50
|
override public func didSetProps(_ changedProps: [String]!) {
|
|
51
51
|
// This is only called on old arch, for new arch didSetProps() will be called
|
|
52
52
|
// by the view component.
|
|
53
53
|
self.didSetProps()
|
|
54
54
|
}
|
|
55
|
-
|
|
56
|
-
|
|
55
|
+
|
|
57
56
|
override public init(frame: CGRect) {
|
|
58
57
|
super.init(frame: frame)
|
|
59
58
|
}
|
|
60
|
-
|
|
59
|
+
|
|
61
60
|
override public func layoutSubviews() {
|
|
62
61
|
if let applePayButton = self.applePayButton {
|
|
63
62
|
applePayButton.frame = self.bounds
|
|
64
63
|
}
|
|
65
64
|
}
|
|
66
|
-
|
|
65
|
+
|
|
67
66
|
required init?(coder: NSCoder) {
|
|
68
67
|
fatalError("init(coder:) has not been implemented")
|
|
69
68
|
}
|
package/ios/ApplePayUtils.swift
CHANGED
|
@@ -9,7 +9,7 @@ import Foundation
|
|
|
9
9
|
import StripePaymentSheet
|
|
10
10
|
|
|
11
11
|
class ApplePayUtils {
|
|
12
|
-
|
|
12
|
+
|
|
13
13
|
internal class func createPaymentRequest(
|
|
14
14
|
merchantIdentifier: String?,
|
|
15
15
|
params: NSDictionary
|
|
@@ -20,17 +20,17 @@ class ApplePayUtils {
|
|
|
20
20
|
|
|
21
21
|
if let additionalEnabledNetworks = params["additionalEnabledNetworks"] as? [String] {
|
|
22
22
|
StripeAPI.additionalEnabledApplePayNetworks = ApplePayUtils.mapToArrayOfPaymentNetworks(arrayOfStrings: additionalEnabledNetworks)
|
|
23
|
-
} else if
|
|
23
|
+
} else if params["jcbEnabled"] as? Bool == true {
|
|
24
24
|
StripeAPI.additionalEnabledApplePayNetworks = [.JCB]
|
|
25
25
|
}
|
|
26
26
|
|
|
27
27
|
guard let summaryItems = params["cartItems"] as? NSArray else {
|
|
28
28
|
return (Errors.createError(ErrorType.Failed, "`cartItems` cannot be null."), nil)
|
|
29
29
|
}
|
|
30
|
-
if
|
|
30
|
+
if summaryItems.count == 0 {
|
|
31
31
|
return (Errors.createError(ErrorType.Failed, "`cartItems` cannot be empty."), nil)
|
|
32
32
|
}
|
|
33
|
-
|
|
33
|
+
|
|
34
34
|
guard let countryCode = ((params.object(forKey: "merchantCountryCode") != nil) ? params["merchantCountryCode"] : params["country"]) as? String else {
|
|
35
35
|
return (Errors.createError(ErrorType.Failed, "You must provide the country"), nil)
|
|
36
36
|
}
|
|
@@ -52,27 +52,27 @@ class ApplePayUtils {
|
|
|
52
52
|
Mappers.mapToPKContactField(field: $0 as! String)
|
|
53
53
|
})
|
|
54
54
|
|
|
55
|
-
paymentRequest.shippingMethods = ApplePayUtils.buildShippingMethods(items: shippingMethods as? [[String
|
|
55
|
+
paymentRequest.shippingMethods = ApplePayUtils.buildShippingMethods(items: shippingMethods as? [[String: Any]])
|
|
56
56
|
|
|
57
57
|
do {
|
|
58
58
|
paymentRequest.paymentSummaryItems = try ApplePayUtils
|
|
59
|
-
.buildPaymentSummaryItems(items: summaryItems as? [[String
|
|
59
|
+
.buildPaymentSummaryItems(items: summaryItems as? [[String: Any]])
|
|
60
60
|
} catch {
|
|
61
61
|
return (Errors.createError(ErrorType.Failed, error.localizedDescription), nil)
|
|
62
62
|
}
|
|
63
|
-
|
|
63
|
+
|
|
64
64
|
if let capabilities = params["merchantCapabilities"] as? [String] {
|
|
65
65
|
for capability in capabilities {
|
|
66
66
|
paymentRequest.merchantCapabilities.update(with: ApplePayUtils.getMerchantCapabilityFrom(string: capability))
|
|
67
67
|
}
|
|
68
68
|
}
|
|
69
|
-
|
|
69
|
+
|
|
70
70
|
paymentRequest.shippingType = ApplePayUtils.getShippingTypeFrom(string: params["shippingType"] as? String)
|
|
71
71
|
if let supportedCountries = params["supportedCountries"] as? Set<String> {
|
|
72
72
|
paymentRequest.supportedCountries = supportedCountries
|
|
73
73
|
}
|
|
74
74
|
if #available(iOS 15.0, *) {
|
|
75
|
-
if
|
|
75
|
+
if params["supportsCouponCode"] as? Bool == true {
|
|
76
76
|
paymentRequest.supportsCouponCode = true
|
|
77
77
|
}
|
|
78
78
|
if let couponCode = params["couponCode"] as? String {
|
|
@@ -89,8 +89,8 @@ class ApplePayUtils {
|
|
|
89
89
|
|
|
90
90
|
return (nil, paymentRequest)
|
|
91
91
|
}
|
|
92
|
-
|
|
93
|
-
#if compiler(>=5.7)
|
|
92
|
+
|
|
93
|
+
#if compiler(>=5.7)
|
|
94
94
|
@available(iOS 16.0, *)
|
|
95
95
|
internal class func buildRecurringPaymentRequest(params: NSDictionary) throws -> PKRecurringPaymentRequest {
|
|
96
96
|
guard let description = params["description"] as? String else {
|
|
@@ -102,9 +102,9 @@ class ApplePayUtils {
|
|
|
102
102
|
guard let url = URL(string: urlString) else {
|
|
103
103
|
throw ApplePayUtilsError.invalidUrl(urlString)
|
|
104
104
|
}
|
|
105
|
-
let regularBilling = try ApplePayUtils.createRecurringPaymentSummaryItem(item: params["billing"] as? [String
|
|
105
|
+
let regularBilling = try ApplePayUtils.createRecurringPaymentSummaryItem(item: params["billing"] as? [String: Any] ?? [:])
|
|
106
106
|
let request = PKRecurringPaymentRequest(paymentDescription: description, regularBilling: regularBilling, managementURL: url)
|
|
107
|
-
if let trialParams = params["trialBilling"] as? [String
|
|
107
|
+
if let trialParams = params["trialBilling"] as? [String: Any] {
|
|
108
108
|
request.trialBilling = try ApplePayUtils.createRecurringPaymentSummaryItem(item: trialParams)
|
|
109
109
|
}
|
|
110
110
|
if let tokenNotificationURL = params["tokenNotificationURL"] as? String {
|
|
@@ -113,7 +113,7 @@ class ApplePayUtils {
|
|
|
113
113
|
request.billingAgreement = params["billingAgreement"] as? String
|
|
114
114
|
return request
|
|
115
115
|
}
|
|
116
|
-
|
|
116
|
+
|
|
117
117
|
@available(iOS 16.0, *)
|
|
118
118
|
internal class func buildAutomaticReloadPaymentRequest(params: NSDictionary) throws -> PKAutomaticReloadPaymentRequest {
|
|
119
119
|
guard let description = params["description"] as? String else {
|
|
@@ -137,9 +137,9 @@ class ApplePayUtils {
|
|
|
137
137
|
request.billingAgreement = params["billingAgreement"] as? String
|
|
138
138
|
return request
|
|
139
139
|
}
|
|
140
|
-
|
|
140
|
+
|
|
141
141
|
@available(iOS 16.0, *)
|
|
142
|
-
internal class func buildPaymentTokenContexts(items: [[String
|
|
142
|
+
internal class func buildPaymentTokenContexts(items: [[String: Any]]) -> [PKPaymentTokenContext] {
|
|
143
143
|
var result: [PKPaymentTokenContext] = []
|
|
144
144
|
for item in items {
|
|
145
145
|
let context = PKPaymentTokenContext.init(merchantIdentifier: item["merchantIdentifier"] as? String ?? "",
|
|
@@ -151,8 +151,8 @@ class ApplePayUtils {
|
|
|
151
151
|
}
|
|
152
152
|
return result
|
|
153
153
|
}
|
|
154
|
-
#endif
|
|
155
|
-
|
|
154
|
+
#endif
|
|
155
|
+
|
|
156
156
|
internal class func getMerchantCapabilityFrom(string: String?) -> PKMerchantCapability {
|
|
157
157
|
switch string {
|
|
158
158
|
case "supportsDebit":
|
|
@@ -167,7 +167,7 @@ class ApplePayUtils {
|
|
|
167
167
|
return .capability3DS
|
|
168
168
|
}
|
|
169
169
|
}
|
|
170
|
-
|
|
170
|
+
|
|
171
171
|
internal class func getShippingTypeFrom(string: String?) -> PKShippingType {
|
|
172
172
|
switch string {
|
|
173
173
|
case "delivery":
|
|
@@ -182,12 +182,12 @@ class ApplePayUtils {
|
|
|
182
182
|
return .shipping
|
|
183
183
|
}
|
|
184
184
|
}
|
|
185
|
-
|
|
185
|
+
|
|
186
186
|
@available(iOS 15.0, *)
|
|
187
|
-
internal class func createDeferredPaymentSummaryItem(item: [String
|
|
187
|
+
internal class func createDeferredPaymentSummaryItem(item: [String: Any]) throws -> PKDeferredPaymentSummaryItem {
|
|
188
188
|
let label = item["label"] as? String ?? ""
|
|
189
189
|
let amount = NSDecimalNumber(string: item["amount"] as? String ?? "")
|
|
190
|
-
|
|
190
|
+
|
|
191
191
|
let deferredItem = PKDeferredPaymentSummaryItem(
|
|
192
192
|
label: label,
|
|
193
193
|
amount: amount
|
|
@@ -198,12 +198,12 @@ class ApplePayUtils {
|
|
|
198
198
|
deferredItem.deferredDate = Date(timeIntervalSince1970: date)
|
|
199
199
|
return deferredItem
|
|
200
200
|
}
|
|
201
|
-
|
|
201
|
+
|
|
202
202
|
@available(iOS 15.0, *)
|
|
203
|
-
internal class func createRecurringPaymentSummaryItem(item: [String
|
|
203
|
+
internal class func createRecurringPaymentSummaryItem(item: [String: Any]) throws -> PKRecurringPaymentSummaryItem {
|
|
204
204
|
let label = item["label"] as? String ?? ""
|
|
205
205
|
let amount = NSDecimalNumber(string: item["amount"] as? String ?? "")
|
|
206
|
-
|
|
206
|
+
|
|
207
207
|
let recurringItem = PKRecurringPaymentSummaryItem(
|
|
208
208
|
label: label,
|
|
209
209
|
amount: amount
|
|
@@ -221,7 +221,7 @@ class ApplePayUtils {
|
|
|
221
221
|
}
|
|
222
222
|
return recurringItem
|
|
223
223
|
}
|
|
224
|
-
|
|
224
|
+
|
|
225
225
|
internal class func mapToIntervalUnit(intervalString: String?) throws -> NSCalendar.Unit {
|
|
226
226
|
switch intervalString {
|
|
227
227
|
case "minute":
|
|
@@ -238,11 +238,11 @@ class ApplePayUtils {
|
|
|
238
238
|
throw ApplePayUtilsError.invalidTimeInterval(intervalString ?? "null")
|
|
239
239
|
}
|
|
240
240
|
}
|
|
241
|
-
|
|
242
|
-
internal class func createImmediatePaymentSummaryItem(item: [String
|
|
241
|
+
|
|
242
|
+
internal class func createImmediatePaymentSummaryItem(item: [String: Any]) -> PKPaymentSummaryItem {
|
|
243
243
|
let label = item["label"] as? String ?? ""
|
|
244
244
|
let amount = NSDecimalNumber(string: item["amount"] as? String ?? "")
|
|
245
|
-
|
|
245
|
+
|
|
246
246
|
return PKPaymentSummaryItem(
|
|
247
247
|
label: label,
|
|
248
248
|
amount: amount,
|
|
@@ -250,8 +250,8 @@ class ApplePayUtils {
|
|
|
250
250
|
PKPaymentSummaryItemType.pending : PKPaymentSummaryItemType.final
|
|
251
251
|
)
|
|
252
252
|
}
|
|
253
|
-
|
|
254
|
-
public class func buildPaymentSummaryItems(items: [[String
|
|
253
|
+
|
|
254
|
+
public class func buildPaymentSummaryItems(items: [[String: Any]]?) throws -> [PKPaymentSummaryItem] {
|
|
255
255
|
var paymentSummaryItems: [PKPaymentSummaryItem] = []
|
|
256
256
|
if let items = items {
|
|
257
257
|
for item in items {
|
|
@@ -259,11 +259,11 @@ class ApplePayUtils {
|
|
|
259
259
|
paymentSummaryItems.append(paymentSummaryItem)
|
|
260
260
|
}
|
|
261
261
|
}
|
|
262
|
-
|
|
262
|
+
|
|
263
263
|
return paymentSummaryItems
|
|
264
264
|
}
|
|
265
|
-
|
|
266
|
-
internal class func buildPaymentSummaryItem(item: [String
|
|
265
|
+
|
|
266
|
+
internal class func buildPaymentSummaryItem(item: [String: Any]) throws -> PKPaymentSummaryItem {
|
|
267
267
|
switch item["paymentType"] as? String {
|
|
268
268
|
case "Deferred":
|
|
269
269
|
if #available(iOS 15.0, *) {
|
|
@@ -283,8 +283,8 @@ class ApplePayUtils {
|
|
|
283
283
|
throw ApplePayUtilsError.invalidCartSummaryItemType(item["paymentType"] as? String ?? "null")
|
|
284
284
|
}
|
|
285
285
|
}
|
|
286
|
-
|
|
287
|
-
public class func buildShippingMethods(items: [[String
|
|
286
|
+
|
|
287
|
+
public class func buildShippingMethods(items: [[String: Any]]?) -> [PKShippingMethod] {
|
|
288
288
|
var shippingMethods: [PKShippingMethod] = []
|
|
289
289
|
if let items = items {
|
|
290
290
|
for item in items {
|
|
@@ -292,11 +292,11 @@ class ApplePayUtils {
|
|
|
292
292
|
shippingMethods.append(shippingMethod)
|
|
293
293
|
}
|
|
294
294
|
}
|
|
295
|
-
|
|
295
|
+
|
|
296
296
|
return shippingMethods
|
|
297
297
|
}
|
|
298
|
-
|
|
299
|
-
internal class func buildShippingMethod(item: [String
|
|
298
|
+
|
|
299
|
+
internal class func buildShippingMethod(item: [String: Any]) -> PKShippingMethod {
|
|
300
300
|
let label = item["label"] as? String ?? ""
|
|
301
301
|
let amount = NSDecimalNumber(string: item["amount"] as? String ?? "")
|
|
302
302
|
let shippingMethod = PKShippingMethod(
|
|
@@ -321,11 +321,11 @@ class ApplePayUtils {
|
|
|
321
321
|
}
|
|
322
322
|
return shippingMethod
|
|
323
323
|
}
|
|
324
|
-
|
|
324
|
+
|
|
325
325
|
public class func buildApplePayErrors(errorItems: [NSDictionary]) throws -> (shippingAddressErrors: [Error], couponCodeErrors: [Error]) {
|
|
326
326
|
var shippingAddressErrors: [Error] = []
|
|
327
327
|
var couponCodeErrors: [Error] = []
|
|
328
|
-
|
|
328
|
+
|
|
329
329
|
for item in errorItems {
|
|
330
330
|
let type = item["errorType"] as? String
|
|
331
331
|
let message = item["message"] as? String
|
|
@@ -349,18 +349,18 @@ class ApplePayUtils {
|
|
|
349
349
|
}
|
|
350
350
|
return (shippingAddressErrors, couponCodeErrors)
|
|
351
351
|
}
|
|
352
|
-
|
|
352
|
+
|
|
353
353
|
internal class func mapToArrayOfPaymentNetworks(arrayOfStrings: [String]) -> [PKPaymentNetwork] {
|
|
354
354
|
let validNetworks: [PKPaymentNetwork?] = arrayOfStrings.map { networkString in
|
|
355
355
|
return PKPaymentNetwork.init(rawValue: networkString)
|
|
356
356
|
}
|
|
357
357
|
return validNetworks.compactMap { $0 }
|
|
358
358
|
}
|
|
359
|
-
|
|
359
|
+
|
|
360
360
|
public class func buildPaymentSheetApplePayConfig(
|
|
361
361
|
merchantIdentifier: String?,
|
|
362
362
|
merchantCountryCode: String?,
|
|
363
|
-
paymentSummaryItems: [[String
|
|
363
|
+
paymentSummaryItems: [[String: Any]]?,
|
|
364
364
|
buttonType: NSNumber?,
|
|
365
365
|
customHandlers: PaymentSheet.ApplePayConfiguration.Handlers?
|
|
366
366
|
) throws -> PaymentSheet.ApplePayConfiguration {
|
|
@@ -373,7 +373,7 @@ class ApplePayUtils {
|
|
|
373
373
|
let paymentSummaryItems = try ApplePayUtils.buildPaymentSummaryItems(
|
|
374
374
|
items: paymentSummaryItems
|
|
375
375
|
)
|
|
376
|
-
|
|
376
|
+
|
|
377
377
|
return PaymentSheet.ApplePayConfiguration.init(
|
|
378
378
|
merchantId: merchantId,
|
|
379
379
|
merchantCountryCode: countryCode,
|
|
@@ -384,7 +384,7 @@ class ApplePayUtils {
|
|
|
384
384
|
}
|
|
385
385
|
}
|
|
386
386
|
|
|
387
|
-
enum ApplePayUtilsError
|
|
387
|
+
enum ApplePayUtilsError: Error, Equatable {
|
|
388
388
|
case invalidCartSummaryItemType(String)
|
|
389
389
|
case missingParameter(String?, String)
|
|
390
390
|
case invalidTimeInterval(String)
|
|
@@ -395,7 +395,7 @@ enum ApplePayUtilsError : Error, Equatable {
|
|
|
395
395
|
case missingMerchantId
|
|
396
396
|
case missingCountryCode
|
|
397
397
|
}
|
|
398
|
-
|
|
398
|
+
|
|
399
399
|
extension ApplePayUtilsError: LocalizedError {
|
|
400
400
|
public var errorDescription: String? {
|
|
401
401
|
switch self {
|
|
@@ -426,8 +426,8 @@ extension ApplePayUtilsError: LocalizedError {
|
|
|
426
426
|
}
|
|
427
427
|
|
|
428
428
|
extension PKPaymentRequest {
|
|
429
|
-
func configureRequestType(requestParams: NSDictionary?) throws
|
|
430
|
-
#if compiler(>=5.7)
|
|
429
|
+
func configureRequestType(requestParams: NSDictionary?) throws {
|
|
430
|
+
#if compiler(>=5.7)
|
|
431
431
|
if #available(iOS 16.0, *) {
|
|
432
432
|
if let requestParams = requestParams {
|
|
433
433
|
switch requestParams["type"] as? String {
|
|
@@ -436,12 +436,12 @@ extension PKPaymentRequest {
|
|
|
436
436
|
case "AutomaticReload":
|
|
437
437
|
self.automaticReloadPaymentRequest = try ApplePayUtils.buildAutomaticReloadPaymentRequest(params: requestParams)
|
|
438
438
|
case "MultiMerchant":
|
|
439
|
-
self.multiTokenContexts = ApplePayUtils.buildPaymentTokenContexts(items: requestParams["merchants"] as? [[String
|
|
439
|
+
self.multiTokenContexts = ApplePayUtils.buildPaymentTokenContexts(items: requestParams["merchants"] as? [[String: Any]] ?? [])
|
|
440
440
|
default:
|
|
441
441
|
throw ApplePayUtilsError.invalidRequestType(String(describing: requestParams["type"]))
|
|
442
442
|
}
|
|
443
443
|
}
|
|
444
444
|
}
|
|
445
|
-
#endif
|
|
445
|
+
#endif
|
|
446
446
|
}
|
|
447
447
|
}
|
|
@@ -8,15 +8,15 @@
|
|
|
8
8
|
import Foundation
|
|
9
9
|
import Stripe
|
|
10
10
|
|
|
11
|
-
extension StripeSdkImpl
|
|
11
|
+
extension StripeSdkImpl: PKPaymentAuthorizationViewControllerDelegate, STPApplePayContextDelegate {
|
|
12
12
|
public func paymentAuthorizationViewController(
|
|
13
13
|
_ controller: PKPaymentAuthorizationViewController,
|
|
14
14
|
didAuthorizePayment payment: PKPayment,
|
|
15
15
|
handler completion: @escaping (PKPaymentAuthorizationResult) -> Void
|
|
16
16
|
) {
|
|
17
17
|
applePaymentMethodFlowCanBeCanceled = false
|
|
18
|
-
|
|
19
|
-
if
|
|
18
|
+
|
|
19
|
+
if platformPayUsesDeprecatedTokenFlow {
|
|
20
20
|
STPAPIClient.shared.createToken(with: payment) { token, error in
|
|
21
21
|
if let error = error {
|
|
22
22
|
self.createPlatformPayPaymentMethodResolver?(Errors.createError(ErrorType.Failed, error))
|
|
@@ -43,24 +43,24 @@ extension StripeSdkImpl : PKPaymentAuthorizationViewControllerDelegate, STPApple
|
|
|
43
43
|
if let shippingContact = payment.shippingContact {
|
|
44
44
|
promiseResult["shippingContact"] = Mappers.mapFromShippingContact(shippingContact: shippingContact)
|
|
45
45
|
}
|
|
46
|
-
|
|
46
|
+
|
|
47
47
|
self.createPlatformPayPaymentMethodResolver?(promiseResult)
|
|
48
48
|
}
|
|
49
49
|
completion(PKPaymentAuthorizationResult.init(status: .success, errors: nil))
|
|
50
50
|
}
|
|
51
51
|
}
|
|
52
52
|
}
|
|
53
|
-
|
|
53
|
+
|
|
54
54
|
public func paymentAuthorizationViewControllerDidFinish(
|
|
55
55
|
_ controller: PKPaymentAuthorizationViewController
|
|
56
56
|
) {
|
|
57
|
-
if
|
|
57
|
+
if applePaymentMethodFlowCanBeCanceled {
|
|
58
58
|
self.createPlatformPayPaymentMethodResolver?(Errors.createError(ErrorType.Canceled, "The payment has been canceled"))
|
|
59
59
|
applePaymentMethodFlowCanBeCanceled = false
|
|
60
60
|
}
|
|
61
61
|
_ = maybeDismissApplePay()
|
|
62
62
|
}
|
|
63
|
-
|
|
63
|
+
|
|
64
64
|
func maybeDismissApplePay() -> Bool {
|
|
65
65
|
if let applePaymentAuthorizationController = applePaymentAuthorizationController {
|
|
66
66
|
DispatchQueue.main.async {
|
|
@@ -70,7 +70,7 @@ extension StripeSdkImpl : PKPaymentAuthorizationViewControllerDelegate, STPApple
|
|
|
70
70
|
}
|
|
71
71
|
return false
|
|
72
72
|
}
|
|
73
|
-
|
|
73
|
+
|
|
74
74
|
@available(iOS 15.0, *)
|
|
75
75
|
public func paymentAuthorizationViewController(
|
|
76
76
|
_ controller: PKPaymentAuthorizationViewController,
|
|
@@ -83,14 +83,14 @@ extension StripeSdkImpl : PKPaymentAuthorizationViewControllerDelegate, STPApple
|
|
|
83
83
|
} else {
|
|
84
84
|
completion(
|
|
85
85
|
PKPaymentRequestCouponCodeUpdate.init(
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
86
|
+
errors: self.applePayCouponCodeErrors,
|
|
87
|
+
paymentSummaryItems: self.applePaySummaryItems,
|
|
88
|
+
shippingMethods: self.applePayShippingMethods
|
|
89
89
|
)
|
|
90
90
|
)
|
|
91
91
|
}
|
|
92
92
|
}
|
|
93
|
-
|
|
93
|
+
|
|
94
94
|
public func paymentAuthorizationViewController(
|
|
95
95
|
_ controller: PKPaymentAuthorizationViewController,
|
|
96
96
|
didSelect shippingMethod: PKShippingMethod,
|
|
@@ -105,7 +105,7 @@ extension StripeSdkImpl : PKPaymentAuthorizationViewControllerDelegate, STPApple
|
|
|
105
105
|
)
|
|
106
106
|
}
|
|
107
107
|
}
|
|
108
|
-
|
|
108
|
+
|
|
109
109
|
public func paymentAuthorizationViewController(
|
|
110
110
|
_ controller: PKPaymentAuthorizationViewController,
|
|
111
111
|
didSelectShippingContact contact: PKContact,
|
|
@@ -124,7 +124,7 @@ extension StripeSdkImpl : PKPaymentAuthorizationViewControllerDelegate, STPApple
|
|
|
124
124
|
)
|
|
125
125
|
}
|
|
126
126
|
}
|
|
127
|
-
|
|
127
|
+
|
|
128
128
|
public func applePayContext(
|
|
129
129
|
_ context: STPApplePayContext,
|
|
130
130
|
didSelect shippingMethod: PKShippingMethod,
|
|
@@ -139,7 +139,7 @@ extension StripeSdkImpl : PKPaymentAuthorizationViewControllerDelegate, STPApple
|
|
|
139
139
|
)
|
|
140
140
|
}
|
|
141
141
|
}
|
|
142
|
-
|
|
142
|
+
|
|
143
143
|
public func applePayContext(
|
|
144
144
|
_ context: STPApplePayContext,
|
|
145
145
|
didSelectShippingContact contact: PKContact,
|
|
@@ -158,7 +158,7 @@ extension StripeSdkImpl : PKPaymentAuthorizationViewControllerDelegate, STPApple
|
|
|
158
158
|
)
|
|
159
159
|
}
|
|
160
160
|
}
|
|
161
|
-
|
|
161
|
+
|
|
162
162
|
public func applePayContext(
|
|
163
163
|
_ context: STPApplePayContext,
|
|
164
164
|
didCreatePaymentMethod paymentMethod: STPPaymentMethod,
|
|
@@ -174,7 +174,7 @@ extension StripeSdkImpl : PKPaymentAuthorizationViewControllerDelegate, STPApple
|
|
|
174
174
|
RCTMakeAndLogError("Tried to complete Apple Pay payment, but no client secret was found.", nil, nil)
|
|
175
175
|
}
|
|
176
176
|
}
|
|
177
|
-
|
|
177
|
+
|
|
178
178
|
public func applePayContext(
|
|
179
179
|
_ context: STPApplePayContext,
|
|
180
180
|
willCompleteWithResult authorizationResult: PKPaymentAuthorizationResult,
|
|
@@ -187,7 +187,7 @@ extension StripeSdkImpl : PKPaymentAuthorizationViewControllerDelegate, STPApple
|
|
|
187
187
|
handler(authorizationResult)
|
|
188
188
|
}
|
|
189
189
|
}
|
|
190
|
-
|
|
190
|
+
|
|
191
191
|
public func applePayContext(
|
|
192
192
|
_ context: STPApplePayContext,
|
|
193
193
|
didCompleteWith status: STPPaymentStatus,
|
|
@@ -209,7 +209,7 @@ extension StripeSdkImpl : PKPaymentAuthorizationViewControllerDelegate, STPApple
|
|
|
209
209
|
|
|
210
210
|
if let paymentIntent = paymentIntent {
|
|
211
211
|
let result = Mappers.mapFromPaymentIntent(paymentIntent: paymentIntent)
|
|
212
|
-
if
|
|
212
|
+
if paymentIntent.paymentMethod == nil {
|
|
213
213
|
result.setValue(Mappers.mapFromPaymentMethod(self.confirmApplePayPaymentMethod), forKey: "paymentMethod")
|
|
214
214
|
}
|
|
215
215
|
resolve(Mappers.createResult("paymentIntent", result))
|
|
@@ -231,7 +231,7 @@ extension StripeSdkImpl : PKPaymentAuthorizationViewControllerDelegate, STPApple
|
|
|
231
231
|
|
|
232
232
|
if let setupIntent = setupIntent {
|
|
233
233
|
let result = Mappers.mapFromSetupIntent(setupIntent: setupIntent)
|
|
234
|
-
if
|
|
234
|
+
if setupIntent.paymentMethod == nil {
|
|
235
235
|
result.setValue(Mappers.mapFromPaymentMethod(self.confirmApplePayPaymentMethod), forKey: "paymentMethod")
|
|
236
236
|
}
|
|
237
237
|
resolve(Mappers.createResult("setupIntent", result))
|
|
@@ -242,38 +242,34 @@ extension StripeSdkImpl : PKPaymentAuthorizationViewControllerDelegate, STPApple
|
|
|
242
242
|
}
|
|
243
243
|
}
|
|
244
244
|
}
|
|
245
|
-
break
|
|
246
245
|
case .error:
|
|
247
246
|
if let resolve = self.confirmApplePayResolver {
|
|
248
247
|
resolve(Errors.createError(ErrorType.Failed, error as NSError?))
|
|
249
248
|
}
|
|
250
|
-
break
|
|
251
249
|
case .userCancellation:
|
|
252
250
|
let message = "The payment has been canceled"
|
|
253
251
|
if let resolve = self.confirmApplePayResolver {
|
|
254
252
|
resolve(Errors.createError(ErrorType.Canceled, message))
|
|
255
253
|
}
|
|
256
|
-
break
|
|
257
254
|
@unknown default:
|
|
258
255
|
if let resolve = self.confirmApplePayResolver {
|
|
259
256
|
resolve(Errors.createError(ErrorType.Unknown, error as NSError?))
|
|
260
257
|
}
|
|
261
|
-
break
|
|
262
258
|
}
|
|
263
259
|
confirmApplePayResolver = nil
|
|
264
260
|
confirmApplePayPaymentClientSecret = nil
|
|
265
261
|
confirmApplePaySetupClientSecret = nil
|
|
266
262
|
}
|
|
267
|
-
|
|
263
|
+
|
|
268
264
|
}
|
|
269
265
|
|
|
270
266
|
extension STPPaymentMethod {
|
|
271
267
|
func splitApplePayAddressByNewline() -> STPPaymentMethod {
|
|
272
268
|
let address = self.billingDetails?.address?.line1?.split(whereSeparator: \.isNewline)
|
|
273
|
-
if
|
|
269
|
+
if address?.indices.contains(0) == true {
|
|
274
270
|
self.billingDetails?.address?.line1 = String(address?[0] ?? "")
|
|
275
271
|
}
|
|
276
|
-
if
|
|
272
|
+
if address?.indices.contains(1) == true {
|
|
277
273
|
self.billingDetails?.address?.line2 = String(address?[1] ?? "")
|
|
278
274
|
}
|
|
279
275
|
return self
|
|
@@ -283,10 +279,10 @@ extension STPPaymentMethod {
|
|
|
283
279
|
extension STPToken {
|
|
284
280
|
func splitApplePayAddressByNewline() -> STPToken {
|
|
285
281
|
let address = self.card?.address?.line1?.split(whereSeparator: \.isNewline)
|
|
286
|
-
if
|
|
282
|
+
if address?.indices.contains(0) == true {
|
|
287
283
|
self.card?.address?.line1 = String(address?[0] ?? "")
|
|
288
284
|
}
|
|
289
|
-
if
|
|
285
|
+
if address?.indices.contains(1) == true {
|
|
290
286
|
self.card?.address?.line2 = String(address?[1] ?? "")
|
|
291
287
|
}
|
|
292
288
|
return self
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import Foundation
|
|
2
|
-
import UIKit
|
|
3
2
|
import Stripe
|
|
3
|
+
import UIKit
|
|
4
4
|
|
|
5
5
|
@objc(AuBECSDebitFormView)
|
|
6
6
|
public class AuBECSDebitFormView: UIView, STPAUBECSDebitFormViewDelegate {
|
|
@@ -8,35 +8,33 @@ public class AuBECSDebitFormView: UIView, STPAUBECSDebitFormViewDelegate {
|
|
|
8
8
|
var auBecsFormView: STPAUBECSDebitFormView?
|
|
9
9
|
@objc public var onCompleteAction: RCTDirectEventBlock?
|
|
10
10
|
@objc public var companyName: NSString?
|
|
11
|
-
|
|
11
|
+
|
|
12
12
|
@objc public func didSetProps() {
|
|
13
13
|
if let auBecsFormView = self.auBecsFormView {
|
|
14
14
|
auBecsFormView.removeFromSuperview()
|
|
15
15
|
}
|
|
16
|
-
|
|
17
16
|
|
|
18
17
|
self.auBecsFormView = STPAUBECSDebitFormView(companyName: (companyName ?? "") as String)
|
|
19
18
|
self.auBecsFormView?.becsDebitFormDelegate = self
|
|
20
|
-
|
|
21
|
-
|
|
19
|
+
|
|
22
20
|
if let auBecsFormView = self.auBecsFormView {
|
|
23
21
|
self.addSubview(auBecsFormView)
|
|
24
22
|
setStyles()
|
|
25
23
|
}
|
|
26
24
|
}
|
|
27
|
-
|
|
25
|
+
|
|
28
26
|
override public func didSetProps(_ changedProps: [String]!) {
|
|
29
27
|
// This is only called on old arch, for new arch didSetProps() will be called
|
|
30
28
|
// by the view component.
|
|
31
|
-
self.didSetProps()
|
|
29
|
+
self.didSetProps()
|
|
32
30
|
}
|
|
33
|
-
|
|
31
|
+
|
|
34
32
|
@objc public var formStyle: NSDictionary = NSDictionary() {
|
|
35
33
|
didSet {
|
|
36
|
-
|
|
34
|
+
setStyles()
|
|
37
35
|
}
|
|
38
36
|
}
|
|
39
|
-
|
|
37
|
+
|
|
40
38
|
private func setStyles() {
|
|
41
39
|
auBecsFormView?.formFont = UIFont.systemFont(ofSize: CGFloat(30))
|
|
42
40
|
|
|
@@ -65,26 +63,26 @@ public class AuBECSDebitFormView: UIView, STPAUBECSDebitFormViewDelegate {
|
|
|
65
63
|
auBecsFormView?.layer.borderWidth = borderWidth
|
|
66
64
|
}
|
|
67
65
|
}
|
|
68
|
-
|
|
66
|
+
|
|
69
67
|
public func auBECSDebitForm(_ form: STPAUBECSDebitFormView, didChangeToStateComplete complete: Bool) {
|
|
70
68
|
onCompleteAction!([
|
|
71
69
|
"accountNumber": form.paymentMethodParams?.auBECSDebit?.accountNumber ?? "",
|
|
72
70
|
"bsbNumber": form.paymentMethodParams?.auBECSDebit?.bsbNumber ?? "",
|
|
73
71
|
"name": form.paymentMethodParams?.billingDetails?.name ?? "",
|
|
74
|
-
"email": form.paymentMethodParams?.billingDetails?.email ?? ""
|
|
72
|
+
"email": form.paymentMethodParams?.billingDetails?.email ?? "",
|
|
75
73
|
])
|
|
76
74
|
}
|
|
77
|
-
|
|
75
|
+
|
|
78
76
|
override public init(frame: CGRect) {
|
|
79
77
|
super.init(frame: frame)
|
|
80
78
|
}
|
|
81
|
-
|
|
79
|
+
|
|
82
80
|
override public func layoutSubviews() {
|
|
83
81
|
if let auBecsFormView = self.auBecsFormView {
|
|
84
82
|
auBecsFormView.frame = self.bounds
|
|
85
83
|
}
|
|
86
84
|
}
|
|
87
|
-
|
|
85
|
+
|
|
88
86
|
required init?(coder: NSCoder) {
|
|
89
87
|
fatalError("init(coder:) has not been implemented")
|
|
90
88
|
}
|