@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
|
@@ -41,9 +41,8 @@ internal class PaymentSheetAppearance {
|
|
|
41
41
|
appearance.primaryButton = try buildPrimaryButton(params: primaryButtonParams)
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
-
|
|
45
44
|
if let embeddedPaymentElementParams = userParams[PaymentSheetAppearanceKeys.EMBEDDED_PAYMENT_ELEMENT] as? NSDictionary {
|
|
46
|
-
|
|
45
|
+
appearance.embeddedPaymentElement = try buildEmbeddedPaymentElementAppearance(params: embeddedPaymentElementParams)
|
|
47
46
|
}
|
|
48
47
|
|
|
49
48
|
if let formInsetParams = userParams[PaymentSheetAppearanceKeys.FORM_INSETS] as? NSDictionary {
|
|
@@ -68,8 +67,8 @@ internal class PaymentSheetAppearance {
|
|
|
68
67
|
private class func buildColors(params: NSDictionary) throws -> PaymentSheet.Appearance.Colors {
|
|
69
68
|
var colors = PaymentSheet.Appearance.Colors()
|
|
70
69
|
|
|
71
|
-
if
|
|
72
|
-
params.object(forKey: PaymentSheetAppearanceKeys.DARK) != nil && params.object(forKey: PaymentSheetAppearanceKeys.LIGHT) == nil
|
|
70
|
+
if params.object(forKey: PaymentSheetAppearanceKeys.LIGHT) != nil && params.object(forKey: PaymentSheetAppearanceKeys.DARK) == nil ||
|
|
71
|
+
params.object(forKey: PaymentSheetAppearanceKeys.DARK) != nil && params.object(forKey: PaymentSheetAppearanceKeys.LIGHT) == nil {
|
|
73
72
|
throw PaymentSheetAppearanceError.missingAppearanceMode
|
|
74
73
|
}
|
|
75
74
|
|
|
@@ -105,7 +104,7 @@ internal class PaymentSheetAppearance {
|
|
|
105
104
|
}
|
|
106
105
|
if let offsetParams = params[PaymentSheetAppearanceKeys.OFFSET] as? NSDictionary {
|
|
107
106
|
if let x = offsetParams[PaymentSheetAppearanceKeys.X] as? CGFloat, let y = offsetParams[PaymentSheetAppearanceKeys.Y] as? CGFloat {
|
|
108
|
-
shadow.offset = CGSize(width: x, height
|
|
107
|
+
shadow.offset = CGSize(width: x, height: -y)
|
|
109
108
|
}
|
|
110
109
|
}
|
|
111
110
|
|
|
@@ -136,8 +135,8 @@ internal class PaymentSheetAppearance {
|
|
|
136
135
|
}
|
|
137
136
|
}
|
|
138
137
|
if let colorParams = params[PaymentSheetAppearanceKeys.COLORS] as? NSDictionary {
|
|
139
|
-
if
|
|
140
|
-
colorParams.object(forKey: PaymentSheetAppearanceKeys.DARK) != nil && colorParams.object(forKey: PaymentSheetAppearanceKeys.LIGHT) == nil
|
|
138
|
+
if colorParams.object(forKey: PaymentSheetAppearanceKeys.LIGHT) != nil && colorParams.object(forKey: PaymentSheetAppearanceKeys.DARK) == nil ||
|
|
139
|
+
colorParams.object(forKey: PaymentSheetAppearanceKeys.DARK) != nil && colorParams.object(forKey: PaymentSheetAppearanceKeys.LIGHT) == nil {
|
|
141
140
|
throw PaymentSheetAppearanceError.missingAppearanceMode
|
|
142
141
|
}
|
|
143
142
|
|
|
@@ -161,9 +160,9 @@ internal class PaymentSheetAppearance {
|
|
|
161
160
|
|
|
162
161
|
let darkCount = darkHexString.trimmingCharacters(in: CharacterSet.alphanumerics.inverted).count
|
|
163
162
|
let lightCount = lightHexString.trimmingCharacters(in: CharacterSet.alphanumerics.inverted).count
|
|
164
|
-
if
|
|
163
|
+
if lightCount != 6 && lightCount != 8 {
|
|
165
164
|
throw PaymentSheetAppearanceError.unexpectedHexStringLength(lightHexString)
|
|
166
|
-
} else if
|
|
165
|
+
} else if darkCount != 6 && darkCount != 8 {
|
|
167
166
|
throw PaymentSheetAppearanceError.unexpectedHexStringLength(darkHexString)
|
|
168
167
|
}
|
|
169
168
|
|
|
@@ -179,196 +178,196 @@ internal class PaymentSheetAppearance {
|
|
|
179
178
|
}
|
|
180
179
|
}
|
|
181
180
|
|
|
182
|
-
|
|
183
|
-
|
|
181
|
+
private class func buildEmbeddedPaymentElementAppearance(params: NSDictionary) throws -> PaymentSheet.Appearance.EmbeddedPaymentElement {
|
|
182
|
+
var embeddedAppearance = PaymentSheet.Appearance.EmbeddedPaymentElement()
|
|
184
183
|
|
|
185
|
-
|
|
184
|
+
if let rowParams = params[PaymentSheetAppearanceKeys.ROW] as? NSDictionary {
|
|
186
185
|
embeddedAppearance.row = try buildEmbeddedRow(params: rowParams)
|
|
187
|
-
|
|
186
|
+
}
|
|
188
187
|
|
|
189
|
-
|
|
190
|
-
|
|
188
|
+
return embeddedAppearance
|
|
189
|
+
}
|
|
191
190
|
|
|
192
|
-
|
|
191
|
+
private class func buildEmbeddedRow(params: NSDictionary) throws -> PaymentSheet.Appearance.EmbeddedPaymentElement.Row {
|
|
193
192
|
var row = PaymentSheet.Appearance.default.embeddedPaymentElement.row
|
|
194
193
|
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
194
|
+
if let styleString = params[PaymentSheetAppearanceKeys.STYLE] as? String {
|
|
195
|
+
switch styleString {
|
|
196
|
+
case PaymentSheetAppearanceKeys.ROW_STYLE_FLAT_WITH_RADIO:
|
|
197
|
+
row.style = .flatWithRadio
|
|
198
|
+
case PaymentSheetAppearanceKeys.ROW_STYLE_FLOATING_BUTTON:
|
|
199
|
+
row.style = .floatingButton
|
|
200
|
+
case PaymentSheetAppearanceKeys.ROW_STYLE_FLAT_WITH_CHECKMARK:
|
|
201
|
+
row.style = .flatWithCheckmark
|
|
202
|
+
case PaymentSheetAppearanceKeys.ROW_STYLE_FLAT_WITH_DISCLOSURE:
|
|
203
|
+
row.style = .flatWithDisclosure
|
|
204
|
+
default:
|
|
205
|
+
throw PaymentSheetAppearanceError.invalidRowStyle(styleString)
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
if let additionalInsets = params[PaymentSheetAppearanceKeys.ADDITIONAL_INSETS] as? CGFloat {
|
|
210
|
+
row.additionalInsets = additionalInsets
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
if let flatParams = params[PaymentSheetAppearanceKeys.FLAT] as? NSDictionary {
|
|
214
|
+
row.flat = try buildEmbeddedFlat(params: flatParams)
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
if let floatingParams = params[PaymentSheetAppearanceKeys.FLOATING] as? NSDictionary {
|
|
218
|
+
row.floating = try buildEmbeddedFloating(params: floatingParams)
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
return row
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
private class func buildEmbeddedFlat(params: NSDictionary) throws -> PaymentSheet.Appearance.EmbeddedPaymentElement.Row.Flat {
|
|
225
|
+
var flat = PaymentSheet.Appearance.default.embeddedPaymentElement.row.flat
|
|
226
|
+
|
|
227
|
+
if let thickness = params[PaymentSheetAppearanceKeys.SEPARATOR_THICKNESS] as? CGFloat {
|
|
228
|
+
flat.separatorThickness = thickness
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
flat.separatorColor = parseThemedColor(
|
|
233
232
|
params: params,
|
|
234
233
|
key: PaymentSheetAppearanceKeys.SEPARATOR_COLOR,
|
|
235
234
|
default: PaymentSheet.Appearance.default.colors.componentBorder
|
|
236
|
-
|
|
235
|
+
)
|
|
237
236
|
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
237
|
+
if let insetsParams = params[PaymentSheetAppearanceKeys.SEPARATOR_INSETS] as? NSDictionary {
|
|
238
|
+
flat.separatorInsets = try buildEdgeInsets(params: insetsParams)
|
|
239
|
+
}
|
|
241
240
|
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
241
|
+
if let topEnabled = params[PaymentSheetAppearanceKeys.TOP_SEPARATOR_ENABLED] as? Bool {
|
|
242
|
+
flat.topSeparatorEnabled = topEnabled
|
|
243
|
+
}
|
|
245
244
|
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
245
|
+
if let bottomEnabled = params[PaymentSheetAppearanceKeys.BOTTOM_SEPARATOR_ENABLED] as? Bool {
|
|
246
|
+
flat.bottomSeparatorEnabled = bottomEnabled
|
|
247
|
+
}
|
|
249
248
|
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
249
|
+
if let radioParams = params[PaymentSheetAppearanceKeys.RADIO] as? NSDictionary {
|
|
250
|
+
flat.radio = try buildEmbeddedRadio(params: radioParams)
|
|
251
|
+
}
|
|
253
252
|
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
253
|
+
if let checkmarkParams = params[PaymentSheetAppearanceKeys.CHECKMARK] as? NSDictionary {
|
|
254
|
+
flat.checkmark = try buildEmbeddedCheckmark(params: checkmarkParams)
|
|
255
|
+
}
|
|
257
256
|
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
257
|
+
if let disclosureParams = params[PaymentSheetAppearanceKeys.DISCLOSURE] as? NSDictionary {
|
|
258
|
+
flat.disclosure = try buildEmbeddedDisclosure(params: disclosureParams)
|
|
259
|
+
}
|
|
261
260
|
|
|
262
|
-
|
|
263
|
-
|
|
261
|
+
return flat
|
|
262
|
+
}
|
|
264
263
|
|
|
265
|
-
|
|
266
|
-
|
|
264
|
+
private class func buildEmbeddedRadio(params: NSDictionary) throws -> PaymentSheet.Appearance.EmbeddedPaymentElement.Row.Flat.Radio {
|
|
265
|
+
var radio = PaymentSheet.Appearance.default.embeddedPaymentElement.row.flat.radio
|
|
267
266
|
|
|
268
|
-
|
|
267
|
+
// Selected‐state color
|
|
269
268
|
radio.selectedColor = parseThemedColor(
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
269
|
+
params: params,
|
|
270
|
+
key: PaymentSheetAppearanceKeys.SELECTED_COLOR,
|
|
271
|
+
default: PaymentSheet.Appearance.default.colors.primary
|
|
273
272
|
)
|
|
274
273
|
|
|
275
274
|
// Unselected‐state color
|
|
276
275
|
radio.unselectedColor = parseThemedColor(
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
276
|
+
params: params,
|
|
277
|
+
key: PaymentSheetAppearanceKeys.UNSELECTED_COLOR,
|
|
278
|
+
default: PaymentSheet.Appearance.default.colors.componentBorder
|
|
280
279
|
)
|
|
281
280
|
|
|
282
|
-
|
|
283
|
-
|
|
281
|
+
return radio
|
|
282
|
+
}
|
|
284
283
|
|
|
285
|
-
|
|
284
|
+
private class func buildEmbeddedCheckmark(params: NSDictionary) throws -> PaymentSheet.Appearance.EmbeddedPaymentElement.Row.Flat.Checkmark {
|
|
286
285
|
var checkmark = PaymentSheet.Appearance.default.embeddedPaymentElement.row.flat.checkmark
|
|
287
286
|
|
|
288
287
|
checkmark.color = parseThemedColor(
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
288
|
+
params: params,
|
|
289
|
+
key: PaymentSheetAppearanceKeys.COLOR,
|
|
290
|
+
default: PaymentSheet.Appearance.default.colors.primary
|
|
292
291
|
)
|
|
293
292
|
|
|
294
|
-
|
|
295
|
-
|
|
293
|
+
return checkmark
|
|
294
|
+
}
|
|
296
295
|
|
|
297
296
|
private class func buildEmbeddedDisclosure(params: NSDictionary) throws -> PaymentSheet.Appearance.EmbeddedPaymentElement.Row.Flat.Disclosure {
|
|
298
297
|
var disclosure = PaymentSheet.Appearance.default.embeddedPaymentElement.row.flat.disclosure
|
|
299
298
|
|
|
300
299
|
disclosure.color = parseThemedColor(
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
300
|
+
params: params,
|
|
301
|
+
key: PaymentSheetAppearanceKeys.COLOR,
|
|
302
|
+
default: UIColor.systemGray // Default iOS system gray color
|
|
304
303
|
)
|
|
305
304
|
|
|
306
305
|
return disclosure
|
|
307
|
-
|
|
306
|
+
}
|
|
308
307
|
|
|
309
|
-
|
|
310
|
-
|
|
308
|
+
private class func buildEmbeddedFloating(params: NSDictionary) throws -> PaymentSheet.Appearance.EmbeddedPaymentElement.Row.Floating {
|
|
309
|
+
var floating = PaymentSheet.Appearance.default.embeddedPaymentElement.row.floating
|
|
311
310
|
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
311
|
+
if let spacing = params[PaymentSheetAppearanceKeys.SPACING] as? CGFloat {
|
|
312
|
+
floating.spacing = spacing
|
|
313
|
+
}
|
|
315
314
|
|
|
316
|
-
|
|
317
|
-
|
|
315
|
+
return floating
|
|
316
|
+
}
|
|
318
317
|
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
318
|
+
private class func buildEdgeInsets(params: NSDictionary) throws -> UIEdgeInsets {
|
|
319
|
+
let top = params[PaymentSheetAppearanceKeys.TOP] as? CGFloat ?? 0
|
|
320
|
+
let left = params[PaymentSheetAppearanceKeys.LEFT] as? CGFloat ?? 0
|
|
321
|
+
let bottom = params[PaymentSheetAppearanceKeys.BOTTOM] as? CGFloat ?? 0
|
|
322
|
+
let right = params[PaymentSheetAppearanceKeys.RIGHT] as? CGFloat ?? 0
|
|
324
323
|
|
|
325
|
-
|
|
324
|
+
return UIEdgeInsets(
|
|
326
325
|
top: top,
|
|
327
326
|
left: left,
|
|
328
327
|
bottom: bottom,
|
|
329
328
|
right: right
|
|
330
|
-
|
|
331
|
-
|
|
329
|
+
)
|
|
330
|
+
}
|
|
332
331
|
|
|
333
|
-
|
|
332
|
+
private class func dynamicColor(
|
|
334
333
|
from hexDict: [String: String],
|
|
335
334
|
default defaultColor: UIColor
|
|
336
|
-
|
|
335
|
+
) -> UIColor {
|
|
337
336
|
return UIColor(
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
337
|
+
dynamicProvider: { traitCollection in
|
|
338
|
+
if traitCollection.userInterfaceStyle == .dark,
|
|
339
|
+
let darkHex = hexDict[PaymentSheetAppearanceKeys.DARK] {
|
|
340
|
+
return .init(
|
|
341
|
+
hexString: darkHex
|
|
342
|
+
)
|
|
343
|
+
}
|
|
344
|
+
if let lightHex = hexDict[PaymentSheetAppearanceKeys.LIGHT] {
|
|
345
|
+
return .init(
|
|
346
|
+
hexString: lightHex
|
|
347
|
+
)
|
|
348
|
+
}
|
|
349
|
+
return defaultColor
|
|
350
|
+
})
|
|
351
|
+
}
|
|
353
352
|
|
|
354
|
-
|
|
353
|
+
private class func parseThemedColor(
|
|
355
354
|
params: NSDictionary,
|
|
356
355
|
key: String,
|
|
357
356
|
default defaultColor: UIColor
|
|
358
|
-
|
|
357
|
+
) -> UIColor {
|
|
359
358
|
// Check if it's a dictionary with light/dark keys
|
|
360
359
|
if let colorDict = params[key] as? [String: String] {
|
|
361
|
-
|
|
360
|
+
return dynamicColor(from: colorDict, default: defaultColor)
|
|
362
361
|
}
|
|
363
362
|
|
|
364
363
|
// Check if it's a plain string
|
|
365
364
|
if let colorString = params[key] as? String {
|
|
366
|
-
|
|
365
|
+
return UIColor(hexString: colorString)
|
|
367
366
|
}
|
|
368
367
|
|
|
369
368
|
// Fall back to default if no color provided
|
|
370
369
|
return defaultColor
|
|
371
|
-
|
|
370
|
+
}
|
|
372
371
|
|
|
373
372
|
private class func buildFormInsets(params: NSDictionary) throws -> NSDirectionalEdgeInsets {
|
|
374
373
|
let top = params[PaymentSheetAppearanceKeys.TOP] as? CGFloat ?? PaymentSheet.Appearance.default.formInsets.top
|
|
@@ -377,15 +376,15 @@ internal class PaymentSheetAppearance {
|
|
|
377
376
|
let trailing = params[PaymentSheetAppearanceKeys.RIGHT] as? CGFloat ?? PaymentSheet.Appearance.default.formInsets.trailing
|
|
378
377
|
|
|
379
378
|
return NSDirectionalEdgeInsets(
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
379
|
+
top: top,
|
|
380
|
+
leading: leading,
|
|
381
|
+
bottom: bottom,
|
|
382
|
+
trailing: trailing
|
|
384
383
|
)
|
|
385
384
|
}
|
|
386
385
|
}
|
|
387
386
|
|
|
388
|
-
enum PaymentSheetAppearanceError
|
|
387
|
+
enum PaymentSheetAppearanceError: Error {
|
|
389
388
|
case missingFont(String)
|
|
390
389
|
case missingAppearanceMode
|
|
391
390
|
case unexpectedHexStringLength(String)
|
|
@@ -8,11 +8,11 @@
|
|
|
8
8
|
import Foundation
|
|
9
9
|
|
|
10
10
|
@objc(AddToWalletButtonManager)
|
|
11
|
-
class AddToWalletButtonManager
|
|
11
|
+
class AddToWalletButtonManager: RCTViewManager {
|
|
12
12
|
override func view() -> UIView! {
|
|
13
13
|
return AddToWalletButtonView()
|
|
14
14
|
}
|
|
15
|
-
|
|
15
|
+
|
|
16
16
|
override class func requiresMainQueueSetup() -> Bool {
|
|
17
17
|
return true
|
|
18
18
|
}
|
|
@@ -10,8 +10,8 @@ import Stripe
|
|
|
10
10
|
|
|
11
11
|
@objc(AddToWalletButtonView)
|
|
12
12
|
public class AddToWalletButtonView: UIView {
|
|
13
|
-
var pushProvisioningContext: STPPushProvisioningContext?
|
|
14
|
-
var addToWalletButton: PKAddPassButton?
|
|
13
|
+
var pushProvisioningContext: STPPushProvisioningContext?
|
|
14
|
+
var addToWalletButton: PKAddPassButton?
|
|
15
15
|
|
|
16
16
|
@objc public var testEnv: Bool = false
|
|
17
17
|
@objc public var iOSButtonStyle: NSString?
|
|
@@ -22,7 +22,7 @@ public class AddToWalletButtonView: UIView {
|
|
|
22
22
|
required init?(coder: NSCoder) {
|
|
23
23
|
fatalError("init(coder:) has not been implemented")
|
|
24
24
|
}
|
|
25
|
-
|
|
25
|
+
|
|
26
26
|
@objc public func didSetProps() {
|
|
27
27
|
if let addToWalletButton = addToWalletButton {
|
|
28
28
|
addToWalletButton.removeFromSuperview()
|
|
@@ -45,12 +45,12 @@ public class AddToWalletButtonView: UIView {
|
|
|
45
45
|
}
|
|
46
46
|
|
|
47
47
|
@objc func beginPushProvisioning() {
|
|
48
|
-
if
|
|
48
|
+
if !PushProvisioningUtils.canAddPaymentPass(isTestMode: self.testEnv) {
|
|
49
49
|
onCompleteAction!(
|
|
50
50
|
Errors.createError(
|
|
51
51
|
ErrorType.Failed,
|
|
52
52
|
"This app cannot add cards to Apple Pay. For information on requesting the necessary entitlement, see the Card Issuers section at developer.apple.com/apple-pay/."
|
|
53
|
-
) as? [AnyHashable
|
|
53
|
+
) as? [AnyHashable: Any]
|
|
54
54
|
)
|
|
55
55
|
return
|
|
56
56
|
}
|
|
@@ -60,17 +60,17 @@ public class AddToWalletButtonView: UIView {
|
|
|
60
60
|
Errors.createError(
|
|
61
61
|
ErrorType.Failed,
|
|
62
62
|
"Missing parameters. `cardDetails.name` must be supplied in the props to <AddToWalletButton />"
|
|
63
|
-
) as? [AnyHashable
|
|
63
|
+
) as? [AnyHashable: Any]
|
|
64
64
|
)
|
|
65
65
|
return
|
|
66
66
|
}
|
|
67
67
|
|
|
68
|
-
if
|
|
68
|
+
if cardHolderName.isEmpty {
|
|
69
69
|
onCompleteAction!(
|
|
70
70
|
Errors.createError(
|
|
71
71
|
ErrorType.Failed,
|
|
72
72
|
"`cardDetails.name` is required, but the passed string was empty"
|
|
73
|
-
) as? [AnyHashable
|
|
73
|
+
) as? [AnyHashable: Any]
|
|
74
74
|
)
|
|
75
75
|
return
|
|
76
76
|
}
|
|
@@ -92,11 +92,11 @@ public class AddToWalletButtonView: UIView {
|
|
|
92
92
|
let vc = findViewControllerPresenter(from: RCTKeyWindow()?.rootViewController ?? UIViewController())
|
|
93
93
|
vc.present(controller!, animated: true, completion: nil)
|
|
94
94
|
}
|
|
95
|
-
|
|
95
|
+
|
|
96
96
|
override public init(frame: CGRect) {
|
|
97
97
|
super.init(frame: frame)
|
|
98
98
|
}
|
|
99
|
-
|
|
99
|
+
|
|
100
100
|
override public func layoutSubviews() {
|
|
101
101
|
if let addToWalletButton = self.addToWalletButton {
|
|
102
102
|
addToWalletButton.frame = self.bounds
|
|
@@ -104,12 +104,11 @@ public class AddToWalletButtonView: UIView {
|
|
|
104
104
|
}
|
|
105
105
|
}
|
|
106
106
|
|
|
107
|
-
|
|
108
107
|
extension AddToWalletButtonView: PKAddPaymentPassViewControllerDelegate {
|
|
109
108
|
public func addPaymentPassViewController(_ controller: PKAddPaymentPassViewController, generateRequestWithCertificateChain certificates: [Data], nonce: Data, nonceSignature: Data, completionHandler handler: @escaping (PKAddPaymentPassRequest) -> Void) {
|
|
110
109
|
self.pushProvisioningContext = STPPushProvisioningContext(keyProvider: self)
|
|
111
110
|
|
|
112
|
-
self.pushProvisioningContext?.addPaymentPassViewController(controller, generateRequestWithCertificateChain: certificates, nonce: nonce, nonceSignature: nonceSignature, completionHandler: handler)
|
|
111
|
+
self.pushProvisioningContext?.addPaymentPassViewController(controller, generateRequestWithCertificateChain: certificates, nonce: nonce, nonceSignature: nonceSignature, completionHandler: handler)
|
|
113
112
|
}
|
|
114
113
|
|
|
115
114
|
public func addPaymentPassViewController(_ controller: PKAddPaymentPassViewController, didFinishAdding pass: PKPaymentPass?, error: Error?) {
|
|
@@ -118,28 +117,27 @@ extension AddToWalletButtonView: PKAddPaymentPassViewControllerDelegate {
|
|
|
118
117
|
Errors.createError(
|
|
119
118
|
error.code == PKAddPaymentPassError.userCancelled.rawValue ? ErrorType.Canceled : ErrorType.Failed,
|
|
120
119
|
error as NSError?
|
|
121
|
-
) as? [AnyHashable
|
|
120
|
+
) as? [AnyHashable: Any]
|
|
122
121
|
)
|
|
123
122
|
} else {
|
|
124
123
|
onCompleteAction!([
|
|
125
124
|
"error": NSNull(),
|
|
126
|
-
] as [AnyHashable
|
|
125
|
+
] as [AnyHashable: Any])
|
|
127
126
|
}
|
|
128
127
|
controller.dismiss(animated: true, completion: nil)
|
|
129
128
|
}
|
|
130
129
|
}
|
|
131
130
|
|
|
132
|
-
|
|
133
131
|
extension AddToWalletButtonView: STPIssuingCardEphemeralKeyProvider {
|
|
134
132
|
public func createIssuingCardKey(withAPIVersion apiVersion: String, completion: @escaping STPJSONResponseCompletionBlock) {
|
|
135
|
-
if let ephemeralKey = self.ephemeralKey as? [AnyHashable
|
|
133
|
+
if let ephemeralKey = self.ephemeralKey as? [AnyHashable: Any] {
|
|
136
134
|
completion(ephemeralKey, nil)
|
|
137
135
|
} else {
|
|
138
136
|
onCompleteAction!(
|
|
139
137
|
Errors.createError(
|
|
140
138
|
ErrorType.Failed,
|
|
141
139
|
"Missing parameters. `ephemeralKey` must be supplied in the props to <AddToWalletButton />"
|
|
142
|
-
) as? [AnyHashable
|
|
140
|
+
) as? [AnyHashable: Any]
|
|
143
141
|
)
|
|
144
142
|
completion(nil, nil)
|
|
145
143
|
}
|
|
@@ -15,34 +15,34 @@ internal class PushProvisioningUtils {
|
|
|
15
15
|
hasPairedAppleWatch: Bool,
|
|
16
16
|
completion: @escaping (_ canAddCard: Bool, _ status: AddCardToWalletStatus?) -> Void
|
|
17
17
|
) {
|
|
18
|
-
if
|
|
18
|
+
if !canAddPaymentPass(isTestMode: testEnv) {
|
|
19
19
|
completion(false, AddCardToWalletStatus.UNSUPPORTED_DEVICE)
|
|
20
20
|
} else {
|
|
21
21
|
PaymentPassFinder.findPassWith(
|
|
22
22
|
primaryAccountIdentifier: primaryAccountIdentifier,
|
|
23
23
|
hasPairedAppleWatch: hasPairedAppleWatch)
|
|
24
24
|
{ canAddCardToADevice, passLocations in
|
|
25
|
-
var status: AddCardToWalletStatus?
|
|
26
|
-
if
|
|
25
|
+
var status: AddCardToWalletStatus?
|
|
26
|
+
if !canAddCardToADevice {
|
|
27
27
|
status = AddCardToWalletStatus.CARD_ALREADY_EXISTS
|
|
28
|
-
} else if
|
|
28
|
+
} else if passLocations.contains(.PAIRED_DEVICE) {
|
|
29
29
|
status = AddCardToWalletStatus.CARD_EXISTS_ON_PAIRED_DEVICE
|
|
30
|
-
} else if
|
|
30
|
+
} else if passLocations.contains(.CURRENT_DEVICE) {
|
|
31
31
|
status = AddCardToWalletStatus.CARD_EXISTS_ON_CURRENT_DEVICE
|
|
32
32
|
}
|
|
33
33
|
completion(canAddCardToADevice, status)
|
|
34
34
|
}
|
|
35
35
|
}
|
|
36
36
|
}
|
|
37
|
-
|
|
37
|
+
|
|
38
38
|
class func canAddPaymentPass(isTestMode: Bool) -> Bool {
|
|
39
|
-
if
|
|
39
|
+
if isTestMode {
|
|
40
40
|
return STPFakeAddPaymentPassViewController.canAddPaymentPass()
|
|
41
41
|
}
|
|
42
42
|
|
|
43
43
|
return PKAddPaymentPassViewController.canAddPaymentPass()
|
|
44
44
|
}
|
|
45
|
-
|
|
45
|
+
|
|
46
46
|
class func getPassLocation(last4: String) -> PaymentPassFinder.PassLocation? {
|
|
47
47
|
let existingPassOnDevice: PKPass? = {
|
|
48
48
|
if #available(iOS 13.4, *) {
|
|
@@ -53,7 +53,7 @@ internal class PushProvisioningUtils {
|
|
|
53
53
|
.first(where: { $0.paymentPass?.primaryAccountNumberSuffix == last4 && $0.paymentPass?.passActivationState != .suspended && !$0.isRemotePass })
|
|
54
54
|
}
|
|
55
55
|
}()
|
|
56
|
-
|
|
56
|
+
|
|
57
57
|
let existingPassOnPairedDevices: PKPass? = {
|
|
58
58
|
if #available(iOS 13.4, *) {
|
|
59
59
|
return PKPassLibrary().remoteSecureElementPasses
|
|
@@ -63,10 +63,10 @@ internal class PushProvisioningUtils {
|
|
|
63
63
|
.first(where: { $0.paymentPass?.primaryAccountNumberSuffix == last4 && $0.paymentPass?.passActivationState != .suspended })
|
|
64
64
|
}
|
|
65
65
|
}()
|
|
66
|
-
|
|
66
|
+
|
|
67
67
|
return existingPassOnDevice != nil ? PaymentPassFinder.PassLocation.CURRENT_DEVICE : (existingPassOnPairedDevices != nil ? PaymentPassFinder.PassLocation.PAIRED_DEVICE : nil)
|
|
68
68
|
}
|
|
69
|
-
|
|
69
|
+
|
|
70
70
|
enum AddCardToWalletStatus: String {
|
|
71
71
|
case UNSUPPORTED_DEVICE
|
|
72
72
|
case CARD_ALREADY_EXISTS
|
|
@@ -3,18 +3,18 @@ import UIKit
|
|
|
3
3
|
|
|
4
4
|
@objc(StripeContainerView)
|
|
5
5
|
public class StripeContainerView: UIView {
|
|
6
|
-
var tapRecognizer: UITapGestureRecognizer?
|
|
6
|
+
var tapRecognizer: UITapGestureRecognizer?
|
|
7
7
|
|
|
8
8
|
@objc public var keyboardShouldPersistTaps: Bool = true {
|
|
9
9
|
didSet {
|
|
10
|
-
if
|
|
10
|
+
if keyboardShouldPersistTaps == true {
|
|
11
11
|
removeListener()
|
|
12
12
|
} else {
|
|
13
13
|
setListener()
|
|
14
14
|
}
|
|
15
15
|
}
|
|
16
16
|
}
|
|
17
|
-
|
|
17
|
+
|
|
18
18
|
public override init(frame: CGRect) {
|
|
19
19
|
super.init(frame: frame)
|
|
20
20
|
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
#ifdef RCT_NEW_ARCH_ENABLED
|
|
2
|
+
#import <rnstripe/rnstripe.h>
|
|
3
|
+
#else
|
|
4
|
+
#import <React/RCTBridgeModule.h>
|
|
5
|
+
#import "StripeSdkEventEmitterCompat.h"
|
|
6
|
+
#endif
|
|
7
|
+
|
|
8
|
+
NS_ASSUME_NONNULL_BEGIN
|
|
9
|
+
|
|
10
|
+
#ifdef RCT_NEW_ARCH_ENABLED
|
|
11
|
+
@interface StripeOnrampSdk : NativeOnrampSdkModuleSpecBase <NativeOnrampSdkModuleSpec>
|
|
12
|
+
#else
|
|
13
|
+
@interface StripeOnrampSdk : StripeSdkEventEmitterCompat <RCTBridgeModule>
|
|
14
|
+
#endif
|
|
15
|
+
@end
|
|
16
|
+
|
|
17
|
+
NS_ASSUME_NONNULL_END
|