@stripe/stripe-react-native 0.44.0 → 0.45.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.clang-format +90 -0
- package/.editorconfig +3 -0
- package/CHANGELOG.md +7 -1
- package/android/build.gradle +89 -18
- package/android/gradle.properties +1 -1
- package/android/src/main/java/com/reactnativestripesdk/AuBECSDebitFormViewManager.kt +15 -6
- package/android/src/main/java/com/reactnativestripesdk/CardChangeEvent.kt +56 -0
- package/android/src/main/java/com/reactnativestripesdk/CardFieldView.kt +4 -4
- package/android/src/main/java/com/reactnativestripesdk/CardFieldViewManager.kt +55 -45
- package/android/src/main/java/com/reactnativestripesdk/{CardFocusEvent.kt → CardFocusChangeEvent.kt} +2 -2
- package/android/src/main/java/com/reactnativestripesdk/CardFormCompleteEvent.kt +17 -16
- package/android/src/main/java/com/reactnativestripesdk/CardFormView.kt +5 -5
- package/android/src/main/java/com/reactnativestripesdk/CardFormViewManager.kt +39 -33
- package/android/src/main/java/com/reactnativestripesdk/CollectBankAccountLauncherFragment.kt +4 -2
- package/android/src/main/java/com/reactnativestripesdk/EmbeddedPaymentElementView.kt +182 -0
- package/android/src/main/java/com/reactnativestripesdk/EmbeddedPaymentElementViewManager.kt +231 -0
- package/android/src/main/java/com/reactnativestripesdk/FinancialConnectionsSheetFragment.kt +8 -5
- package/android/src/main/java/com/reactnativestripesdk/GooglePayButtonManager.kt +14 -6
- package/android/src/main/java/com/reactnativestripesdk/PaymentMethodCreateParamsFactory.kt +3 -1
- package/android/src/main/java/com/reactnativestripesdk/PaymentOptionDisplayDataMapper.kt +17 -0
- package/android/src/main/java/com/reactnativestripesdk/PaymentSheetAppearance.kt +266 -0
- package/android/src/main/java/com/reactnativestripesdk/PaymentSheetFragment.kt +8 -13
- package/android/src/main/java/com/reactnativestripesdk/StripeContainerManager.kt +11 -3
- package/android/src/main/java/com/reactnativestripesdk/StripeSdkModule.kt +106 -59
- package/android/src/main/java/com/reactnativestripesdk/StripeSdkPackage.kt +34 -4
- package/android/src/main/java/com/reactnativestripesdk/addresssheet/AddressSheetView.kt +33 -27
- package/android/src/main/java/com/reactnativestripesdk/addresssheet/AddressSheetViewManager.kt +49 -24
- package/android/src/main/java/com/reactnativestripesdk/customersheet/CustomerSheetFragment.kt +16 -3
- package/android/src/main/java/com/reactnativestripesdk/customersheet/ReactNativeCustomerAdapter.kt +11 -29
- package/android/src/main/java/com/reactnativestripesdk/pushprovisioning/AddToWalletButtonManager.kt +36 -12
- package/android/src/main/java/com/reactnativestripesdk/pushprovisioning/AddToWalletButtonView.kt +5 -3
- package/android/src/main/java/com/reactnativestripesdk/utils/Extensions.kt +4 -0
- package/android/src/main/java/com/reactnativestripesdk/utils/Mappers.kt +21 -0
- package/android/src/oldarch/java/com/facebook/react/viewmanagers/AddToWalletButtonManagerDelegate.java +49 -0
- package/android/src/oldarch/java/com/facebook/react/viewmanagers/AddToWalletButtonManagerInterface.java +25 -0
- package/android/src/oldarch/java/com/facebook/react/viewmanagers/AddressSheetViewManagerDelegate.java +64 -0
- package/android/src/oldarch/java/com/facebook/react/viewmanagers/AddressSheetViewManagerInterface.java +30 -0
- package/android/src/oldarch/java/com/facebook/react/viewmanagers/ApplePayButtonManagerDelegate.java +41 -0
- package/android/src/oldarch/java/com/facebook/react/viewmanagers/ApplePayButtonManagerInterface.java +20 -0
- package/android/src/oldarch/java/com/facebook/react/viewmanagers/AuBECSDebitFormManagerDelegate.java +36 -0
- package/android/src/oldarch/java/com/facebook/react/viewmanagers/AuBECSDebitFormManagerInterface.java +20 -0
- package/android/src/oldarch/java/com/facebook/react/viewmanagers/CardFieldManagerDelegate.java +73 -0
- package/android/src/oldarch/java/com/facebook/react/viewmanagers/CardFieldManagerInterface.java +31 -0
- package/android/src/oldarch/java/com/facebook/react/viewmanagers/CardFormManagerDelegate.java +67 -0
- package/android/src/oldarch/java/com/facebook/react/viewmanagers/CardFormManagerInterface.java +29 -0
- package/android/src/oldarch/java/com/facebook/react/viewmanagers/EmbeddedPaymentElementViewManagerDelegate.java +49 -0
- package/android/src/oldarch/java/com/facebook/react/viewmanagers/EmbeddedPaymentElementViewManagerInterface.java +21 -0
- package/android/src/oldarch/java/com/facebook/react/viewmanagers/GooglePayButtonManagerDelegate.java +38 -0
- package/android/src/oldarch/java/com/facebook/react/viewmanagers/GooglePayButtonManagerInterface.java +19 -0
- package/android/src/oldarch/java/com/facebook/react/viewmanagers/StripeContainerManagerDelegate.java +32 -0
- package/android/src/oldarch/java/com/facebook/react/viewmanagers/StripeContainerManagerInterface.java +17 -0
- package/android/src/oldarch/java/com/reactnativestripesdk/NativeStripeSdkModuleSpec.java +311 -0
- package/ios/AddressSheet/AddressSheetUtils.swift +21 -19
- package/ios/AddressSheet/AddressSheetView.swift +23 -17
- package/ios/ApplePayButtonManager.m +0 -1
- package/ios/ApplePayButtonManager.swift +1 -3
- package/ios/ApplePayButtonView.swift +25 -20
- package/ios/ApplePayViewController.swift +22 -22
- package/ios/AuBECSDebitFormView.swift +14 -8
- package/ios/CardFieldManager.swift +1 -4
- package/ios/CardFieldView.swift +28 -25
- package/ios/CardFormManager.swift +1 -4
- package/ios/CardFormView.swift +25 -16
- package/ios/CustomerSheet/CustomerSheetUtils.swift +12 -16
- package/ios/CustomerSheet/ReactNativeCustomerAdapter.swift +8 -8
- package/ios/EmbeddedPaymentElementManager.m +6 -0
- package/ios/EmbeddedPaymentElementView.swift +48 -0
- package/ios/NewArch/AddToWalletButtonComponentView.h +10 -0
- package/ios/NewArch/AddToWalletButtonComponentView.mm +93 -0
- package/ios/NewArch/AddressSheetViewComponentView.h +10 -0
- package/ios/NewArch/AddressSheetViewComponentView.mm +109 -0
- package/ios/NewArch/ApplePayButtonComponentView.h +10 -0
- package/ios/NewArch/ApplePayButtonComponentView.mm +124 -0
- package/ios/NewArch/AuBECSDebitFormComponentView.h +10 -0
- package/ios/NewArch/AuBECSDebitFormComponentView.mm +95 -0
- package/ios/NewArch/CardFieldComponentView.h +10 -0
- package/ios/NewArch/CardFieldComponentView.mm +125 -0
- package/ios/NewArch/CardFormComponentView.h +10 -0
- package/ios/NewArch/CardFormComponentView.mm +108 -0
- package/ios/NewArch/StripeContainerComponentView.h +10 -0
- package/ios/NewArch/StripeContainerComponentView.mm +74 -0
- package/ios/NewArch/StripeNewArchConversions.h +20 -0
- package/ios/NewArch/StripeNewArchConversions.mm +47 -0
- package/ios/OldArch/StripeSdkEventEmitterCompat.h +27 -0
- package/ios/OldArch/StripeSdkEventEmitterCompat.m +105 -0
- package/ios/PaymentOptionDisplayData+ReactNative.swift +55 -0
- package/ios/PaymentSheetAppearance.swift +194 -1
- package/ios/PushProvisioning/AddToWalletButtonView.swift +19 -13
- package/ios/StripeContainerView.swift +5 -3
- package/ios/StripeSdk.h +21 -0
- package/ios/StripeSdk.mm +415 -0
- package/ios/StripeSdkEmitter.swift +19 -0
- package/ios/{StripeSdk+CustomerSheet.swift → StripeSdkImpl+CustomerSheet.swift} +24 -25
- package/ios/StripeSdkImpl+Embedded.swift +327 -0
- package/ios/{StripeSdk+PaymentSheet.swift → StripeSdkImpl+PaymentSheet.swift} +18 -29
- package/ios/{StripeSdk.swift → StripeSdkImpl.swift} +50 -72
- package/ios/StripeSwiftInterop.h +25 -0
- package/ios/stripe_react_native.h +2 -0
- package/lib/commonjs/components/AddToWalletButton.js +1 -1
- package/lib/commonjs/components/AddToWalletButton.js.map +1 -1
- package/lib/commonjs/components/AddressSheet.js +1 -1
- package/lib/commonjs/components/AddressSheet.js.map +1 -1
- package/lib/commonjs/components/AuBECSDebitForm.js +1 -1
- package/lib/commonjs/components/AuBECSDebitForm.js.map +1 -1
- package/lib/commonjs/components/CardField.js +1 -1
- package/lib/commonjs/components/CardField.js.map +1 -1
- package/lib/commonjs/components/CardForm.js +1 -1
- package/lib/commonjs/components/CardForm.js.map +1 -1
- package/lib/commonjs/components/CustomerSheet.js +1 -1
- package/lib/commonjs/components/CustomerSheet.js.map +1 -1
- package/lib/commonjs/components/PlatformPayButton.js +1 -1
- package/lib/commonjs/components/PlatformPayButton.js.map +1 -1
- package/lib/commonjs/components/StripeContainer.js +1 -1
- package/lib/commonjs/components/StripeContainer.js.map +1 -1
- package/lib/commonjs/components/StripeProvider.js +1 -1
- package/lib/commonjs/components/StripeProvider.js.map +1 -1
- package/lib/commonjs/events.js +2 -0
- package/lib/commonjs/events.js.map +1 -0
- package/lib/commonjs/functions.js +1 -1
- package/lib/commonjs/functions.js.map +1 -1
- package/lib/commonjs/index.js +1 -1
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/specs/NativeAddToWalletButton.js +2 -0
- package/lib/commonjs/specs/NativeAddToWalletButton.js.map +1 -0
- package/lib/commonjs/specs/NativeAddressSheet.js +2 -0
- package/lib/commonjs/specs/NativeAddressSheet.js.map +1 -0
- package/lib/commonjs/specs/NativeApplePayButton.js +2 -0
- package/lib/commonjs/specs/NativeApplePayButton.js.map +1 -0
- package/lib/commonjs/specs/NativeAuBECSDebitForm.js +2 -0
- package/lib/commonjs/specs/NativeAuBECSDebitForm.js.map +1 -0
- package/lib/commonjs/specs/NativeCardField.js +2 -0
- package/lib/commonjs/specs/NativeCardField.js.map +1 -0
- package/lib/commonjs/specs/NativeCardForm.js +2 -0
- package/lib/commonjs/specs/NativeCardForm.js.map +1 -0
- package/lib/commonjs/specs/NativeEmbeddedPaymentElement.js +2 -0
- package/lib/commonjs/specs/NativeEmbeddedPaymentElement.js.map +1 -0
- package/lib/commonjs/specs/NativeGooglePayButton.js +2 -0
- package/lib/commonjs/specs/NativeGooglePayButton.js.map +1 -0
- package/lib/commonjs/specs/NativeStripeContainer.js +2 -0
- package/lib/commonjs/specs/NativeStripeContainer.js.map +1 -0
- package/lib/commonjs/specs/NativeStripeSdkModule.js +2 -0
- package/lib/commonjs/specs/NativeStripeSdkModule.js.map +1 -0
- package/lib/commonjs/specs/utils.js +2 -0
- package/lib/commonjs/specs/utils.js.map +1 -0
- package/lib/commonjs/types/EmbeddedPaymentElement.js +2 -0
- package/lib/commonjs/types/EmbeddedPaymentElement.js.map +1 -0
- package/lib/commonjs/types/PaymentSheet.js +1 -1
- package/lib/commonjs/types/PaymentSheet.js.map +1 -1
- package/lib/module/components/AddToWalletButton.js +1 -1
- package/lib/module/components/AddToWalletButton.js.map +1 -1
- package/lib/module/components/AddressSheet.js +1 -1
- package/lib/module/components/AddressSheet.js.map +1 -1
- package/lib/module/components/AuBECSDebitForm.js +1 -1
- package/lib/module/components/AuBECSDebitForm.js.map +1 -1
- package/lib/module/components/CardField.js +1 -1
- package/lib/module/components/CardField.js.map +1 -1
- package/lib/module/components/CardForm.js +1 -1
- package/lib/module/components/CardForm.js.map +1 -1
- package/lib/module/components/CustomerSheet.js +1 -1
- package/lib/module/components/CustomerSheet.js.map +1 -1
- package/lib/module/components/PlatformPayButton.js +1 -1
- package/lib/module/components/PlatformPayButton.js.map +1 -1
- package/lib/module/components/StripeContainer.js +1 -1
- package/lib/module/components/StripeContainer.js.map +1 -1
- package/lib/module/components/StripeProvider.js +1 -1
- package/lib/module/components/StripeProvider.js.map +1 -1
- package/lib/module/events.js +2 -0
- package/lib/module/events.js.map +1 -0
- package/lib/module/functions.js +1 -1
- package/lib/module/functions.js.map +1 -1
- package/lib/module/index.js +1 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/specs/NativeAddToWalletButton.js +2 -0
- package/lib/module/specs/NativeAddToWalletButton.js.map +1 -0
- package/lib/module/specs/NativeAddressSheet.js +2 -0
- package/lib/module/specs/NativeAddressSheet.js.map +1 -0
- package/lib/module/specs/NativeApplePayButton.js +2 -0
- package/lib/module/specs/NativeApplePayButton.js.map +1 -0
- package/lib/module/specs/NativeAuBECSDebitForm.js +2 -0
- package/lib/module/specs/NativeAuBECSDebitForm.js.map +1 -0
- package/lib/module/specs/NativeCardField.js +2 -0
- package/lib/module/specs/NativeCardField.js.map +1 -0
- package/lib/module/specs/NativeCardForm.js +2 -0
- package/lib/module/specs/NativeCardForm.js.map +1 -0
- package/lib/module/specs/NativeEmbeddedPaymentElement.js +2 -0
- package/lib/module/specs/NativeEmbeddedPaymentElement.js.map +1 -0
- package/lib/module/specs/NativeGooglePayButton.js +2 -0
- package/lib/module/specs/NativeGooglePayButton.js.map +1 -0
- package/lib/module/specs/NativeStripeContainer.js +2 -0
- package/lib/module/specs/NativeStripeContainer.js.map +1 -0
- package/lib/module/specs/NativeStripeSdkModule.js +2 -0
- package/lib/module/specs/NativeStripeSdkModule.js.map +1 -0
- package/lib/module/specs/utils.js +2 -0
- package/lib/module/specs/utils.js.map +1 -0
- package/lib/module/types/EmbeddedPaymentElement.js +2 -0
- package/lib/module/types/EmbeddedPaymentElement.js.map +1 -0
- package/lib/module/types/PaymentSheet.js +1 -1
- package/lib/module/types/PaymentSheet.js.map +1 -1
- package/lib/typescript/src/components/AddToWalletButton.d.ts.map +1 -1
- package/lib/typescript/src/components/AddressSheet.d.ts.map +1 -1
- package/lib/typescript/src/components/AuBECSDebitForm.d.ts.map +1 -1
- package/lib/typescript/src/components/CardField.d.ts +1 -1
- package/lib/typescript/src/components/CardField.d.ts.map +1 -1
- package/lib/typescript/src/components/CardForm.d.ts +1 -1
- package/lib/typescript/src/components/CardForm.d.ts.map +1 -1
- package/lib/typescript/src/components/CustomerSheet.d.ts +1 -1
- package/lib/typescript/src/components/CustomerSheet.d.ts.map +1 -1
- package/lib/typescript/src/components/StripeContainer.d.ts.map +1 -1
- package/lib/typescript/src/events.d.ts +13 -0
- package/lib/typescript/src/events.d.ts.map +1 -0
- package/lib/typescript/src/functions.d.ts.map +1 -1
- package/lib/typescript/src/hooks/useFinancialConnectionsSheet.d.ts +4 -4
- package/lib/typescript/src/hooks/useFinancialConnectionsSheet.d.ts.map +1 -1
- package/lib/typescript/src/hooks/useStripe.d.ts +2 -2
- package/lib/typescript/src/hooks/useStripe.d.ts.map +1 -1
- package/lib/typescript/src/index.d.ts +2 -0
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/specs/NativeAddToWalletButton.d.ts +27 -0
- package/lib/typescript/src/specs/NativeAddToWalletButton.d.ts.map +1 -0
- package/lib/typescript/src/specs/NativeAddressSheet.d.ts +34 -0
- package/lib/typescript/src/specs/NativeAddressSheet.d.ts.map +1 -0
- package/lib/typescript/src/specs/NativeApplePayButton.d.ts +28 -0
- package/lib/typescript/src/specs/NativeApplePayButton.d.ts.map +1 -0
- package/lib/typescript/src/specs/NativeAuBECSDebitForm.d.ts +19 -0
- package/lib/typescript/src/specs/NativeAuBECSDebitForm.d.ts.map +1 -0
- package/lib/typescript/src/specs/NativeCardField.d.ts +33 -0
- package/lib/typescript/src/specs/NativeCardField.d.ts.map +1 -0
- package/lib/typescript/src/specs/NativeCardForm.d.ts +31 -0
- package/lib/typescript/src/specs/NativeCardForm.d.ts.map +1 -0
- package/lib/typescript/src/specs/NativeEmbeddedPaymentElement.d.ts +22 -0
- package/lib/typescript/src/specs/NativeEmbeddedPaymentElement.d.ts.map +1 -0
- package/lib/typescript/src/specs/NativeGooglePayButton.d.ts +11 -0
- package/lib/typescript/src/specs/NativeGooglePayButton.d.ts.map +1 -0
- package/lib/typescript/src/specs/NativeStripeContainer.d.ts +8 -0
- package/lib/typescript/src/specs/NativeStripeContainer.d.ts.map +1 -0
- package/lib/typescript/src/specs/NativeStripeSdkModule.d.ts +93 -0
- package/lib/typescript/src/specs/NativeStripeSdkModule.d.ts.map +1 -0
- package/lib/typescript/src/specs/utils.d.ts +20 -0
- package/lib/typescript/src/specs/utils.d.ts.map +1 -0
- package/lib/typescript/src/types/CustomerSheet.d.ts +1 -5
- package/lib/typescript/src/types/CustomerSheet.d.ts.map +1 -1
- package/lib/typescript/src/types/EmbeddedPaymentElement.d.ts +161 -0
- package/lib/typescript/src/types/EmbeddedPaymentElement.d.ts.map +1 -0
- package/lib/typescript/src/types/PaymentSheet.d.ts +97 -4
- package/lib/typescript/src/types/PaymentSheet.d.ts.map +1 -1
- package/lib/typescript/src/types/components/CardFieldInput.d.ts +3 -2
- package/lib/typescript/src/types/components/CardFieldInput.d.ts.map +1 -1
- package/lib/typescript/src/types/components/CardFormView.d.ts +3 -1
- package/lib/typescript/src/types/components/CardFormView.d.ts.map +1 -1
- package/package.json +20 -1
- package/src/components/AddToWalletButton.tsx +2 -5
- package/src/components/AddressSheet.tsx +5 -16
- package/src/components/AuBECSDebitForm.tsx +3 -12
- package/src/components/CardField.tsx +20 -30
- package/src/components/CardForm.tsx +14 -29
- package/src/components/CustomerSheet.tsx +23 -25
- package/src/components/PlatformPayButton.tsx +6 -6
- package/src/components/StripeContainer.tsx +5 -12
- package/src/components/StripeProvider.tsx +1 -1
- package/src/events.ts +49 -0
- package/src/functions.ts +13 -24
- package/src/hooks/useFinancialConnectionsSheet.tsx +2 -2
- package/src/hooks/useStripe.tsx +2 -2
- package/src/index.tsx +3 -0
- package/src/specs/NativeAddToWalletButton.ts +40 -0
- package/src/specs/NativeAddressSheet.ts +50 -0
- package/src/specs/NativeApplePayButton.ts +40 -0
- package/src/specs/NativeAuBECSDebitForm.ts +24 -0
- package/src/specs/NativeCardField.ts +51 -0
- package/src/specs/NativeCardForm.ts +43 -0
- package/src/specs/NativeEmbeddedPaymentElement.ts +37 -0
- package/src/specs/NativeGooglePayButton.ts +20 -0
- package/src/specs/NativeStripeContainer.ts +12 -0
- package/src/specs/NativeStripeSdkModule.ts +219 -0
- package/src/specs/utils.ts +22 -0
- package/src/types/CustomerSheet.ts +1 -5
- package/src/types/EmbeddedPaymentElement.tsx +467 -0
- package/src/types/PaymentSheet.ts +114 -4
- package/src/types/components/CardFieldInput.ts +1 -2
- package/src/types/components/CardFormView.ts +1 -1
- package/stripe-react-native.podspec +27 -2
- package/android/.gradle/8.11.1/checksums/checksums.lock +0 -0
- package/android/.gradle/8.11.1/checksums/md5-checksums.bin +0 -0
- package/android/.gradle/8.11.1/checksums/sha1-checksums.bin +0 -0
- package/android/.gradle/8.11.1/executionHistory/executionHistory.lock +0 -0
- package/android/.gradle/8.11.1/fileChanges/last-build.bin +0 -0
- package/android/.gradle/8.11.1/fileHashes/fileHashes.lock +0 -0
- package/android/.gradle/8.11.1/gc.properties +0 -0
- package/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock +0 -0
- package/android/.gradle/buildOutputCleanup/cache.properties +0 -2
- package/android/.gradle/vcs-1/gc.properties +0 -0
- package/android/src/main/java/com/reactnativestripesdk/CardChangedEvent.kt +0 -54
- package/ios/StripeSdk.m +0 -244
- package/lib/commonjs/NativeStripeSdk.js +0 -2
- package/lib/commonjs/NativeStripeSdk.js.map +0 -1
- package/lib/commonjs/components/ApplePayButtonNative.js +0 -2
- package/lib/commonjs/components/ApplePayButtonNative.js.map +0 -1
- package/lib/commonjs/components/GooglePayButtonNative.js +0 -2
- package/lib/commonjs/components/GooglePayButtonNative.js.map +0 -1
- package/lib/module/NativeStripeSdk.js +0 -2
- package/lib/module/NativeStripeSdk.js.map +0 -1
- package/lib/module/components/ApplePayButtonNative.js +0 -2
- package/lib/module/components/ApplePayButtonNative.js.map +0 -1
- package/lib/module/components/GooglePayButtonNative.js +0 -2
- package/lib/module/components/GooglePayButtonNative.js.map +0 -1
- package/lib/typescript/src/NativeStripeSdk.d.ts +0 -58
- package/lib/typescript/src/NativeStripeSdk.d.ts.map +0 -1
- package/lib/typescript/src/components/ApplePayButtonNative.d.ts +0 -4
- package/lib/typescript/src/components/ApplePayButtonNative.d.ts.map +0 -1
- package/lib/typescript/src/components/GooglePayButtonNative.d.ts +0 -4
- package/lib/typescript/src/components/GooglePayButtonNative.d.ts.map +0 -1
- package/src/NativeStripeSdk.tsx +0 -159
- package/src/components/ApplePayButtonNative.tsx +0 -5
- package/src/components/GooglePayButtonNative.tsx +0 -7
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
#import <Foundation/Foundation.h>
|
|
2
|
+
|
|
3
|
+
#include <folly/dynamic.h>
|
|
4
|
+
#include <vector>
|
|
5
|
+
|
|
6
|
+
NS_ASSUME_NONNULL_BEGIN
|
|
7
|
+
|
|
8
|
+
namespace stripe::react {
|
|
9
|
+
|
|
10
|
+
NSArray<NSString *> * convertStringVectorToNSArray(const std::vector<std::string> &);
|
|
11
|
+
|
|
12
|
+
NSArray<NSNumber *> * convertIntVectorToNSArray(const std::vector<int> &);
|
|
13
|
+
|
|
14
|
+
NSDictionary * _Nullable convertFollyDynamicToNSDictionaryOrNil(const folly::dynamic &dyn);
|
|
15
|
+
|
|
16
|
+
NSDictionary * convertFollyDynamicToNSDictionary(const folly::dynamic &dyn);
|
|
17
|
+
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
NS_ASSUME_NONNULL_END
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
#import <Foundation/Foundation.h>
|
|
2
|
+
#import <React/RCTConversions.h>
|
|
3
|
+
#import "RCTFollyConvert.h"
|
|
4
|
+
|
|
5
|
+
namespace stripe::react {
|
|
6
|
+
|
|
7
|
+
NSArray<NSString *> * convertStringVectorToNSArray(const std::vector<std::string> &values) {
|
|
8
|
+
NSMutableArray<NSString *> *result = [[NSMutableArray alloc] initWithCapacity:values.size()];
|
|
9
|
+
for (const auto &value : values) {
|
|
10
|
+
[result addObject:RCTNSStringFromString(value)];
|
|
11
|
+
}
|
|
12
|
+
return result;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
NSArray<NSNumber *> * convertIntVectorToNSArray(const std::vector<int> &values) {
|
|
16
|
+
NSMutableArray<NSNumber *> *result = [[NSMutableArray alloc] initWithCapacity:values.size()];
|
|
17
|
+
for (int value : values) {
|
|
18
|
+
[result addObject:@(value)];
|
|
19
|
+
}
|
|
20
|
+
return result;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
NSDictionary * _Nullable convertFollyDynamicToNSDictionaryOrNil(const folly::dynamic &dyn)
|
|
24
|
+
{
|
|
25
|
+
switch (dyn.type()) {
|
|
26
|
+
case folly::dynamic::OBJECT: {
|
|
27
|
+
NSMutableDictionary *dict = [[NSMutableDictionary alloc] initWithCapacity:dyn.size()];
|
|
28
|
+
for (const auto &elem : dyn.items()) {
|
|
29
|
+
id key = facebook::react::convertFollyDynamicToId(elem.first);
|
|
30
|
+
id value = facebook::react::convertFollyDynamicToId(elem.second);
|
|
31
|
+
if (key && value) {
|
|
32
|
+
dict[key] = value;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
return dict;
|
|
36
|
+
}
|
|
37
|
+
default:
|
|
38
|
+
return nil;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
NSDictionary * convertFollyDynamicToNSDictionary(const folly::dynamic &dyn)
|
|
43
|
+
{
|
|
44
|
+
return convertFollyDynamicToNSDictionaryOrNil(dyn) ?: [NSDictionary new];
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
// This is a compat layer for NativeStripeSdkModuleSpecBase which is generated with codegen
|
|
2
|
+
// for the new arch. This implements the same methods, but using old arch apis.
|
|
3
|
+
|
|
4
|
+
#ifndef RCT_NEW_ARCH_ENABLED
|
|
5
|
+
|
|
6
|
+
#import <React/RCTEventEmitter.h>
|
|
7
|
+
|
|
8
|
+
@interface StripeSdkEventEmitterCompat : RCTEventEmitter
|
|
9
|
+
- (void)emitOnConfirmHandlerCallback:(NSDictionary *)value;
|
|
10
|
+
- (void)emitOnFinancialConnectionsEvent:(NSDictionary *)value;
|
|
11
|
+
- (void)emitOnOrderTrackingCallback;
|
|
12
|
+
- (void)emitOnCustomerAdapterFetchPaymentMethodsCallback;
|
|
13
|
+
- (void)emitOnCustomerAdapterAttachPaymentMethodCallback:(NSDictionary *)value;
|
|
14
|
+
- (void)emitOnCustomerAdapterDetachPaymentMethodCallback:(NSDictionary *)value;
|
|
15
|
+
- (void)emitOnCustomerAdapterSetSelectedPaymentOptionCallback:(NSDictionary *)value;
|
|
16
|
+
- (void)emitOnCustomerAdapterFetchSelectedPaymentOptionCallback;
|
|
17
|
+
- (void)emitOnCustomerAdapterSetupIntentClientSecretForCustomerAttachCallback;
|
|
18
|
+
- (void)emitEmbeddedPaymentElementDidUpdateHeight:(NSDictionary *)value;
|
|
19
|
+
- (void)emitEmbeddedPaymentElementWillPresent;
|
|
20
|
+
- (void)emitEmbeddedPaymentElementDidUpdatePaymentOption:(NSDictionary *)value;
|
|
21
|
+
- (void)emitEmbeddedPaymentElementFormSheetConfirmComplete:(NSDictionary *)value;
|
|
22
|
+
- (void)emitEmbeddedPaymentElementRowSelectionImmediateAction;
|
|
23
|
+
- (void)emitEmbeddedPaymentElementLoadingFailed:(NSDictionary *)value;
|
|
24
|
+
|
|
25
|
+
@end
|
|
26
|
+
|
|
27
|
+
#endif
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
#ifndef RCT_NEW_ARCH_ENABLED
|
|
2
|
+
|
|
3
|
+
#import "StripeSdkEventEmitterCompat.h"
|
|
4
|
+
|
|
5
|
+
@implementation StripeSdkEventEmitterCompat
|
|
6
|
+
|
|
7
|
+
- (NSArray<NSString *> *)supportedEvents
|
|
8
|
+
{
|
|
9
|
+
return @[
|
|
10
|
+
@"onOrderTrackingCallback",
|
|
11
|
+
@"onConfirmHandlerCallback",
|
|
12
|
+
@"onCustomerAdapterFetchPaymentMethodsCallback",
|
|
13
|
+
@"onCustomerAdapterAttachPaymentMethodCallback",
|
|
14
|
+
@"onCustomerAdapterDetachPaymentMethodCallback",
|
|
15
|
+
@"onCustomerAdapterSetSelectedPaymentOptionCallback",
|
|
16
|
+
@"onCustomerAdapterFetchSelectedPaymentOptionCallback",
|
|
17
|
+
@"onCustomerAdapterSetupIntentClientSecretForCustomerAttachCallback",
|
|
18
|
+
@"onFinancialConnectionsEvent",
|
|
19
|
+
@"embeddedPaymentElementDidUpdateHeight",
|
|
20
|
+
@"embeddedPaymentElementWillPresent",
|
|
21
|
+
@"embeddedPaymentElementDidUpdatePaymentOption",
|
|
22
|
+
@"embeddedPaymentElementFormSheetConfirmComplete",
|
|
23
|
+
@"embeddedPaymentElementRowSelectionImmediateAction",
|
|
24
|
+
@"embeddedPaymentElementLoadingFailed"
|
|
25
|
+
];
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
- (void)emitOnConfirmHandlerCallback:(NSDictionary *)value
|
|
29
|
+
{
|
|
30
|
+
[self sendEventWithName:@"onConfirmHandlerCallback" body:value];
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
- (void)emitOnFinancialConnectionsEvent:(NSDictionary *)value
|
|
34
|
+
{
|
|
35
|
+
[self sendEventWithName:@"onFinancialConnectionsEvent" body:value];
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
- (void)emitOnOrderTrackingCallback
|
|
39
|
+
{
|
|
40
|
+
[self sendEventWithName:@"onOrderTrackingCallback" body:@{}];
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
- (void)emitOnCustomerAdapterFetchPaymentMethodsCallback
|
|
44
|
+
{
|
|
45
|
+
[self sendEventWithName:@"onCustomerAdapterFetchPaymentMethodsCallback" body:@{}];
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
- (void)emitOnCustomerAdapterAttachPaymentMethodCallback:(NSDictionary *)value
|
|
49
|
+
{
|
|
50
|
+
[self sendEventWithName:@"onCustomerAdapterAttachPaymentMethodCallback" body:value];
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
- (void)emitOnCustomerAdapterDetachPaymentMethodCallback:(NSDictionary *)value
|
|
54
|
+
{
|
|
55
|
+
[self sendEventWithName:@"onCustomerAdapterDetachPaymentMethodCallback" body:value];
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
- (void)emitOnCustomerAdapterSetSelectedPaymentOptionCallback:(NSDictionary *)value
|
|
59
|
+
{
|
|
60
|
+
[self sendEventWithName:@"onCustomerAdapterSetSelectedPaymentOptionCallback" body:value];
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
- (void)emitOnCustomerAdapterFetchSelectedPaymentOptionCallback
|
|
64
|
+
{
|
|
65
|
+
[self sendEventWithName:@"onCustomerAdapterFetchSelectedPaymentOptionCallback" body:@{}];
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
- (void)emitOnCustomerAdapterSetupIntentClientSecretForCustomerAttachCallback
|
|
69
|
+
{
|
|
70
|
+
[self sendEventWithName:@"onCustomerAdapterSetupIntentClientSecretForCustomerAttachCallback" body:@{}];
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
- (void)emitEmbeddedPaymentElementDidUpdateHeight:(NSDictionary *)value
|
|
74
|
+
{
|
|
75
|
+
[self sendEventWithName:@"embeddedPaymentElementDidUpdateHeight" body:value];
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
- (void)emitEmbeddedPaymentElementWillPresent
|
|
79
|
+
{
|
|
80
|
+
[self sendEventWithName:@"embeddedPaymentElementWillPresent" body:@{}];
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
- (void)emitEmbeddedPaymentElementDidUpdatePaymentOption:(NSDictionary *)value
|
|
84
|
+
{
|
|
85
|
+
[self sendEventWithName:@"embeddedPaymentElementDidUpdatePaymentOption" body:value];
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
- (void)emitEmbeddedPaymentElementFormSheetConfirmComplete:(NSDictionary *)value
|
|
89
|
+
{
|
|
90
|
+
[self sendEventWithName:@"embeddedPaymentElementFormSheetConfirmComplete" body:value];
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
- (void)emitEmbeddedPaymentElementRowSelectionImmediateAction
|
|
94
|
+
{
|
|
95
|
+
[self sendEventWithName:@"embeddedPaymentElementRowSelectionImmediateAction" body:@{}];
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
- (void)emitEmbeddedPaymentElementLoadingFailed:(NSDictionary *)value
|
|
99
|
+
{
|
|
100
|
+
[self sendEventWithName:@"embeddedPaymentElementLoadingFailed" body:value];
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
@end
|
|
104
|
+
|
|
105
|
+
#endif
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
//
|
|
2
|
+
// PaymentOptionDisplayData+ReactNative.swift
|
|
3
|
+
// stripe-react-native
|
|
4
|
+
//
|
|
5
|
+
// Created by Nick Porter on 4/16/25.
|
|
6
|
+
//
|
|
7
|
+
|
|
8
|
+
import Foundation
|
|
9
|
+
@_spi(EmbeddedPaymentElementPrivateBeta) import StripePaymentSheet
|
|
10
|
+
|
|
11
|
+
extension EmbeddedPaymentElement.PaymentOptionDisplayData {
|
|
12
|
+
/// Convert `PaymentOptionDisplayData` into a dictionary compatible with React Native bridge.
|
|
13
|
+
func toDictionary() -> [String: Any] {
|
|
14
|
+
// Convert UIImage to Base64
|
|
15
|
+
let imageBase64: String = {
|
|
16
|
+
guard let data = image.pngData() else { return "" }
|
|
17
|
+
return data.base64EncodedString()
|
|
18
|
+
}()
|
|
19
|
+
|
|
20
|
+
// Convert BillingDetails to a dictionary
|
|
21
|
+
let billingDetailsDict: [String: Any] = {
|
|
22
|
+
guard let billing = billingDetails else {
|
|
23
|
+
return [:]
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
// Extract address
|
|
27
|
+
let addressDict: [String: Any] = {
|
|
28
|
+
let addr = billing.address
|
|
29
|
+
return [
|
|
30
|
+
"city": addr.city ?? "",
|
|
31
|
+
"country": addr.country ?? "",
|
|
32
|
+
"line1": addr.line1 ?? "",
|
|
33
|
+
"line2": addr.line2 ?? "",
|
|
34
|
+
"postalCode": addr.postalCode ?? "",
|
|
35
|
+
"state": addr.state ?? ""
|
|
36
|
+
]
|
|
37
|
+
}()
|
|
38
|
+
|
|
39
|
+
return [
|
|
40
|
+
"name": billing.name ?? "",
|
|
41
|
+
"email": billing.email ?? "",
|
|
42
|
+
"phone": billing.phone ?? "",
|
|
43
|
+
"address": addressDict
|
|
44
|
+
]
|
|
45
|
+
}()
|
|
46
|
+
|
|
47
|
+
// Return as a dictionary
|
|
48
|
+
return [
|
|
49
|
+
"image": imageBase64,
|
|
50
|
+
"label": label,
|
|
51
|
+
"billingDetails": billingDetailsDict,
|
|
52
|
+
"paymentMethodType": paymentMethodType
|
|
53
|
+
]
|
|
54
|
+
}
|
|
55
|
+
}
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
//
|
|
5
5
|
// Created by Charles Cruzan on 5/11/22.
|
|
6
6
|
//
|
|
7
|
-
import StripePaymentSheet
|
|
7
|
+
@_spi(EmbeddedPaymentElementPrivateBeta) import StripePaymentSheet
|
|
8
8
|
|
|
9
9
|
internal class PaymentSheetAppearance {
|
|
10
10
|
class func buildAppearanceFromParams(userParams: NSDictionary?) throws -> PaymentSheet.Appearance {
|
|
@@ -27,6 +27,11 @@ internal class PaymentSheetAppearance {
|
|
|
27
27
|
if let primaryButtonParams = userParams[PaymentSheetAppearanceKeys.PRIMARY_BUTTON] as? NSDictionary {
|
|
28
28
|
appearance.primaryButton = try buildPrimaryButton(params: primaryButtonParams)
|
|
29
29
|
}
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
if let embeddedPaymentElementParams = userParams[PaymentSheetAppearanceKeys.EMBEDDED_PAYMENT_ELEMENT] as? NSDictionary {
|
|
33
|
+
appearance.embeddedPaymentElement = try buildEmbeddedPaymentElementAppearance(params: embeddedPaymentElementParams)
|
|
34
|
+
}
|
|
30
35
|
|
|
31
36
|
return appearance
|
|
32
37
|
}
|
|
@@ -151,12 +156,171 @@ internal class PaymentSheetAppearance {
|
|
|
151
156
|
return lightColor
|
|
152
157
|
}
|
|
153
158
|
}
|
|
159
|
+
|
|
160
|
+
private class func buildEmbeddedPaymentElementAppearance(params: NSDictionary) throws -> PaymentSheet.Appearance.EmbeddedPaymentElement {
|
|
161
|
+
var embeddedAppearance = PaymentSheet.Appearance.EmbeddedPaymentElement()
|
|
162
|
+
|
|
163
|
+
if let rowParams = params[PaymentSheetAppearanceKeys.ROW] as? NSDictionary {
|
|
164
|
+
embeddedAppearance.row = try buildEmbeddedRow(params: rowParams)
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
return embeddedAppearance
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
private class func buildEmbeddedRow(params: NSDictionary) throws -> PaymentSheet.Appearance.EmbeddedPaymentElement.Row {
|
|
171
|
+
var row = PaymentSheet.Appearance.default.embeddedPaymentElement.row
|
|
172
|
+
|
|
173
|
+
if let styleString = params[PaymentSheetAppearanceKeys.STYLE] as? String {
|
|
174
|
+
switch styleString {
|
|
175
|
+
case PaymentSheetAppearanceKeys.ROW_STYLE_FLAT_WITH_RADIO:
|
|
176
|
+
row.style = .flatWithRadio
|
|
177
|
+
case PaymentSheetAppearanceKeys.ROW_STYLE_FLOATING_BUTTON:
|
|
178
|
+
row.style = .floatingButton
|
|
179
|
+
case PaymentSheetAppearanceKeys.ROW_STYLE_FLAT_WITH_CHECKMARK:
|
|
180
|
+
row.style = .flatWithCheckmark
|
|
181
|
+
default:
|
|
182
|
+
throw PaymentSheetAppearanceError.invalidRowStyle(styleString)
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
if let additionalInsets = params[PaymentSheetAppearanceKeys.ADDITIONAL_INSETS] as? CGFloat {
|
|
187
|
+
row.additionalInsets = additionalInsets
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
if let flatParams = params[PaymentSheetAppearanceKeys.FLAT] as? NSDictionary {
|
|
191
|
+
row.flat = try buildEmbeddedFlat(params: flatParams)
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
if let floatingParams = params[PaymentSheetAppearanceKeys.FLOATING] as? NSDictionary {
|
|
195
|
+
row.floating = try buildEmbeddedFloating(params: floatingParams)
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
return row
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
private class func buildEmbeddedFlat(params: NSDictionary) throws -> PaymentSheet.Appearance.EmbeddedPaymentElement.Row.Flat {
|
|
202
|
+
var flat = PaymentSheet.Appearance.default.embeddedPaymentElement.row.flat
|
|
203
|
+
|
|
204
|
+
if let thickness = params[PaymentSheetAppearanceKeys.SEPARATOR_THICKNESS] as? CGFloat {
|
|
205
|
+
flat.separatorThickness = thickness
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
if let separatorColors = params[PaymentSheetAppearanceKeys.SEPARATOR_COLOR] as? [String: String] {
|
|
209
|
+
flat.separatorColor = dynamicColor(
|
|
210
|
+
from: separatorColors,
|
|
211
|
+
default: PaymentSheet.Appearance.default.colors.componentBorder
|
|
212
|
+
)
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
if let insetsParams = params[PaymentSheetAppearanceKeys.SEPARATOR_INSETS] as? NSDictionary {
|
|
216
|
+
flat.separatorInsets = try buildEdgeInsets(params: insetsParams)
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
if let topEnabled = params[PaymentSheetAppearanceKeys.TOP_SEPARATOR_ENABLED] as? Bool {
|
|
220
|
+
flat.topSeparatorEnabled = topEnabled
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
if let bottomEnabled = params[PaymentSheetAppearanceKeys.BOTTOM_SEPARATOR_ENABLED] as? Bool {
|
|
224
|
+
flat.bottomSeparatorEnabled = bottomEnabled
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
if let radioParams = params[PaymentSheetAppearanceKeys.RADIO] as? NSDictionary {
|
|
228
|
+
flat.radio = try buildEmbeddedRadio(params: radioParams)
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
if let checkmarkParams = params[PaymentSheetAppearanceKeys.CHECKMARK] as? NSDictionary {
|
|
232
|
+
flat.checkmark = try buildEmbeddedCheckmark(params: checkmarkParams)
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
return flat
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
private class func buildEmbeddedRadio(params: NSDictionary) throws -> PaymentSheet.Appearance.EmbeddedPaymentElement.Row.Flat.Radio {
|
|
239
|
+
var radio = PaymentSheet.Appearance.default.embeddedPaymentElement.row.flat.radio
|
|
240
|
+
|
|
241
|
+
// Selected‐state color
|
|
242
|
+
if let selectedHexes = params[PaymentSheetAppearanceKeys.SELECTED_COLOR] as? [String: String] {
|
|
243
|
+
radio.selectedColor = dynamicColor(
|
|
244
|
+
from: selectedHexes,
|
|
245
|
+
default: PaymentSheet.Appearance.default.colors.primary
|
|
246
|
+
)
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
// Unselected‐state color
|
|
250
|
+
if let unselectedHexes = params[PaymentSheetAppearanceKeys.UNSELECTED_COLOR] as? [String: String] {
|
|
251
|
+
radio.unselectedColor = dynamicColor(
|
|
252
|
+
from: unselectedHexes,
|
|
253
|
+
default: PaymentSheet.Appearance.default.colors.componentBorder
|
|
254
|
+
)
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
return radio
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
private class func buildEmbeddedCheckmark(params: NSDictionary) throws -> PaymentSheet.Appearance.EmbeddedPaymentElement.Row.Flat.Checkmark {
|
|
261
|
+
var checkmark = PaymentSheet.Appearance.default.embeddedPaymentElement.row.flat.checkmark
|
|
262
|
+
|
|
263
|
+
if let shadowHexes = params[PaymentSheetAppearanceKeys.COLOR] as? [String: String] {
|
|
264
|
+
checkmark.color = dynamicColor(
|
|
265
|
+
from: shadowHexes,
|
|
266
|
+
default: PaymentSheet.Appearance.default.colors.primary
|
|
267
|
+
)
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
return checkmark
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
private class func buildEmbeddedFloating(params: NSDictionary) throws -> PaymentSheet.Appearance.EmbeddedPaymentElement.Row.Floating {
|
|
274
|
+
var floating = PaymentSheet.Appearance.default.embeddedPaymentElement.row.floating
|
|
275
|
+
|
|
276
|
+
if let spacing = params[PaymentSheetAppearanceKeys.SPACING] as? CGFloat {
|
|
277
|
+
floating.spacing = spacing
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
return floating
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
private class func buildEdgeInsets(params: NSDictionary) throws -> UIEdgeInsets {
|
|
284
|
+
let top = params[PaymentSheetAppearanceKeys.TOP] as? CGFloat ?? 0
|
|
285
|
+
let left = params[PaymentSheetAppearanceKeys.LEFT] as? CGFloat ?? 0
|
|
286
|
+
let bottom = params[PaymentSheetAppearanceKeys.BOTTOM] as? CGFloat ?? 0
|
|
287
|
+
let right = params[PaymentSheetAppearanceKeys.RIGHT] as? CGFloat ?? 0
|
|
288
|
+
|
|
289
|
+
return UIEdgeInsets(
|
|
290
|
+
top: top,
|
|
291
|
+
left: left,
|
|
292
|
+
bottom: bottom,
|
|
293
|
+
right: right
|
|
294
|
+
)
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
private class func dynamicColor(
|
|
298
|
+
from hexDict: [String: String],
|
|
299
|
+
default defaultColor: UIColor
|
|
300
|
+
) -> UIColor {
|
|
301
|
+
return UIColor(
|
|
302
|
+
dynamicProvider: { traitCollection in
|
|
303
|
+
if traitCollection.userInterfaceStyle == .dark,
|
|
304
|
+
let darkHex = hexDict[PaymentSheetAppearanceKeys.DARK] {
|
|
305
|
+
return .init(
|
|
306
|
+
hexString: darkHex
|
|
307
|
+
)
|
|
308
|
+
}
|
|
309
|
+
if let lightHex = hexDict[PaymentSheetAppearanceKeys.LIGHT] {
|
|
310
|
+
return .init(
|
|
311
|
+
hexString: lightHex
|
|
312
|
+
)
|
|
313
|
+
}
|
|
314
|
+
return defaultColor
|
|
315
|
+
})
|
|
316
|
+
}
|
|
154
317
|
}
|
|
155
318
|
|
|
156
319
|
enum PaymentSheetAppearanceError : Error {
|
|
157
320
|
case missingFont(String)
|
|
158
321
|
case missingAppearanceMode
|
|
159
322
|
case unexpectedHexStringLength(String)
|
|
323
|
+
case invalidRowStyle(String)
|
|
160
324
|
}
|
|
161
325
|
|
|
162
326
|
extension PaymentSheetAppearanceError: LocalizedError {
|
|
@@ -168,6 +332,8 @@ extension PaymentSheetAppearanceError: LocalizedError {
|
|
|
168
332
|
return NSLocalizedString("Failed to set Payment Sheet appearance. When providing 'colors.light' or 'colors.dark', you must provide both.", comment: "Failed to set colors")
|
|
169
333
|
case .unexpectedHexStringLength(let hexString):
|
|
170
334
|
return NSLocalizedString("Failed to set Payment Sheet appearance. Expected hex string of length 6 or 8, but received: \(hexString)", comment: "Failed to set color")
|
|
335
|
+
case .invalidRowStyle(let styleString):
|
|
336
|
+
return NSLocalizedString("Failed to set Embedded Payment Element appearance. Invalid row style '\(styleString)'. Expected one of: 'flatWithRadio', 'floatingButton', 'flatWithCheckmark'.", comment: "Invalid row style string")
|
|
171
337
|
}
|
|
172
338
|
}
|
|
173
339
|
}
|
|
@@ -207,4 +373,31 @@ private struct PaymentSheetAppearanceKeys {
|
|
|
207
373
|
static let PRIMARY_BUTTON = "primaryButton"
|
|
208
374
|
static let TEXT = "text"
|
|
209
375
|
static let BORDER = "border"
|
|
376
|
+
|
|
377
|
+
static let EMBEDDED_PAYMENT_ELEMENT = "embeddedPaymentElement"
|
|
378
|
+
static let ROW = "row"
|
|
379
|
+
static let STYLE = "style"
|
|
380
|
+
static let ADDITIONAL_INSETS = "additionalInsets"
|
|
381
|
+
static let FLAT = "flat"
|
|
382
|
+
static let FLOATING = "floating"
|
|
383
|
+
static let SEPARATOR_THICKNESS = "separatorThickness"
|
|
384
|
+
static let SEPARATOR_COLOR = "separatorColor"
|
|
385
|
+
static let SEPARATOR_INSETS = "separatorInsets"
|
|
386
|
+
static let TOP_SEPARATOR_ENABLED = "topSeparatorEnabled"
|
|
387
|
+
static let BOTTOM_SEPARATOR_ENABLED = "bottomSeparatorEnabled"
|
|
388
|
+
static let RADIO = "radio"
|
|
389
|
+
static let SELECTED_COLOR = "selectedColor"
|
|
390
|
+
static let UNSELECTED_COLOR = "unselectedColor"
|
|
391
|
+
static let CHECKMARK = "checkmark"
|
|
392
|
+
static let SPACING = "spacing"
|
|
393
|
+
static let TOP = "top"
|
|
394
|
+
static let LEFT = "left"
|
|
395
|
+
static let BOTTOM = "bottom"
|
|
396
|
+
static let RIGHT = "right"
|
|
397
|
+
static let COLOR = "color"
|
|
398
|
+
|
|
399
|
+
// Row Style Enum Values (match TS string enum values)
|
|
400
|
+
static let ROW_STYLE_FLAT_WITH_RADIO = "flatWithRadio"
|
|
401
|
+
static let ROW_STYLE_FLOATING_BUTTON = "floatingButton"
|
|
402
|
+
static let ROW_STYLE_FLAT_WITH_CHECKMARK = "flatWithCheckmark"
|
|
210
403
|
}
|
|
@@ -9,21 +9,21 @@ import Foundation
|
|
|
9
9
|
import Stripe
|
|
10
10
|
|
|
11
11
|
@objc(AddToWalletButtonView)
|
|
12
|
-
class AddToWalletButtonView: UIView {
|
|
12
|
+
public class AddToWalletButtonView: UIView {
|
|
13
13
|
var pushProvisioningContext: STPPushProvisioningContext? = nil
|
|
14
14
|
var addToWalletButton: PKAddPassButton? = nil
|
|
15
15
|
|
|
16
|
-
@objc var testEnv: Bool = false
|
|
17
|
-
@objc var iOSButtonStyle: NSString?
|
|
18
|
-
@objc var cardDetails: NSDictionary?
|
|
19
|
-
@objc var ephemeralKey: NSDictionary?
|
|
20
|
-
@objc var onCompleteAction: RCTDirectEventBlock?
|
|
16
|
+
@objc public var testEnv: Bool = false
|
|
17
|
+
@objc public var iOSButtonStyle: NSString?
|
|
18
|
+
@objc public var cardDetails: NSDictionary?
|
|
19
|
+
@objc public var ephemeralKey: NSDictionary?
|
|
20
|
+
@objc public var onCompleteAction: RCTDirectEventBlock?
|
|
21
21
|
|
|
22
22
|
required init?(coder: NSCoder) {
|
|
23
23
|
fatalError("init(coder:) has not been implemented")
|
|
24
24
|
}
|
|
25
|
-
|
|
26
|
-
|
|
25
|
+
|
|
26
|
+
@objc public func didSetProps() {
|
|
27
27
|
if let addToWalletButton = addToWalletButton {
|
|
28
28
|
addToWalletButton.removeFromSuperview()
|
|
29
29
|
}
|
|
@@ -38,6 +38,12 @@ class AddToWalletButtonView: UIView {
|
|
|
38
38
|
}
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
+
public override func didSetProps(_ changedProps: [String]!) {
|
|
42
|
+
// This is only called on old arch, for new arch didSetProps() will be called
|
|
43
|
+
// by the view component.
|
|
44
|
+
self.didSetProps()
|
|
45
|
+
}
|
|
46
|
+
|
|
41
47
|
@objc func beginPushProvisioning() {
|
|
42
48
|
if (!PushProvisioningUtils.canAddPaymentPass(isTestMode: self.testEnv)) {
|
|
43
49
|
onCompleteAction!(
|
|
@@ -87,11 +93,11 @@ class AddToWalletButtonView: UIView {
|
|
|
87
93
|
vc.present(controller!, animated: true, completion: nil)
|
|
88
94
|
}
|
|
89
95
|
|
|
90
|
-
override init(frame: CGRect) {
|
|
96
|
+
override public init(frame: CGRect) {
|
|
91
97
|
super.init(frame: frame)
|
|
92
98
|
}
|
|
93
99
|
|
|
94
|
-
override func layoutSubviews() {
|
|
100
|
+
override public func layoutSubviews() {
|
|
95
101
|
if let addToWalletButton = self.addToWalletButton {
|
|
96
102
|
addToWalletButton.frame = self.bounds
|
|
97
103
|
}
|
|
@@ -100,13 +106,13 @@ class AddToWalletButtonView: UIView {
|
|
|
100
106
|
|
|
101
107
|
|
|
102
108
|
extension AddToWalletButtonView: PKAddPaymentPassViewControllerDelegate {
|
|
103
|
-
func addPaymentPassViewController(_ controller: PKAddPaymentPassViewController, generateRequestWithCertificateChain certificates: [Data], nonce: Data, nonceSignature: Data, completionHandler handler: @escaping (PKAddPaymentPassRequest) -> Void) {
|
|
109
|
+
public func addPaymentPassViewController(_ controller: PKAddPaymentPassViewController, generateRequestWithCertificateChain certificates: [Data], nonce: Data, nonceSignature: Data, completionHandler handler: @escaping (PKAddPaymentPassRequest) -> Void) {
|
|
104
110
|
self.pushProvisioningContext = STPPushProvisioningContext(keyProvider: self)
|
|
105
111
|
|
|
106
112
|
self.pushProvisioningContext?.addPaymentPassViewController(controller, generateRequestWithCertificateChain: certificates, nonce: nonce, nonceSignature: nonceSignature, completionHandler: handler);
|
|
107
113
|
}
|
|
108
114
|
|
|
109
|
-
func addPaymentPassViewController(_ controller: PKAddPaymentPassViewController, didFinishAdding pass: PKPaymentPass?, error: Error?) {
|
|
115
|
+
public func addPaymentPassViewController(_ controller: PKAddPaymentPassViewController, didFinishAdding pass: PKPaymentPass?, error: Error?) {
|
|
110
116
|
if let error = error as NSError? {
|
|
111
117
|
onCompleteAction!(
|
|
112
118
|
Errors.createError(
|
|
@@ -125,7 +131,7 @@ extension AddToWalletButtonView: PKAddPaymentPassViewControllerDelegate {
|
|
|
125
131
|
|
|
126
132
|
|
|
127
133
|
extension AddToWalletButtonView: STPIssuingCardEphemeralKeyProvider {
|
|
128
|
-
func createIssuingCardKey(withAPIVersion apiVersion: String, completion: @escaping STPJSONResponseCompletionBlock) {
|
|
134
|
+
public func createIssuingCardKey(withAPIVersion apiVersion: String, completion: @escaping STPJSONResponseCompletionBlock) {
|
|
129
135
|
if let ephemeralKey = self.ephemeralKey as? [AnyHashable : Any] {
|
|
130
136
|
completion(ephemeralKey, nil)
|
|
131
137
|
} else {
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import Foundation
|
|
2
2
|
import UIKit
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
@objc(StripeContainerView)
|
|
5
|
+
public class StripeContainerView: UIView {
|
|
5
6
|
var tapRecognizer: UITapGestureRecognizer? = nil
|
|
6
7
|
|
|
7
|
-
@objc var keyboardShouldPersistTaps: Bool = true {
|
|
8
|
+
@objc public var keyboardShouldPersistTaps: Bool = true {
|
|
8
9
|
didSet {
|
|
9
10
|
if (keyboardShouldPersistTaps == true) {
|
|
10
11
|
removeListener()
|
|
@@ -14,11 +15,12 @@ class StripeContainerView: UIView {
|
|
|
14
15
|
}
|
|
15
16
|
}
|
|
16
17
|
|
|
17
|
-
override init(frame: CGRect) {
|
|
18
|
+
public override init(frame: CGRect) {
|
|
18
19
|
super.init(frame: frame)
|
|
19
20
|
}
|
|
20
21
|
|
|
21
22
|
func setListener() {
|
|
23
|
+
removeListener()
|
|
22
24
|
tapRecognizer = UITapGestureRecognizer(target: self, action: #selector(endEditing(_:)))
|
|
23
25
|
|
|
24
26
|
tapRecognizer!.cancelsTouchesInView = false
|
package/ios/StripeSdk.h
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
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
|
+
@class StripeSdkImpl;
|
|
11
|
+
|
|
12
|
+
#ifdef RCT_NEW_ARCH_ENABLED
|
|
13
|
+
@interface StripeSdk : NativeStripeSdkModuleSpecBase <NativeStripeSdkModuleSpec>
|
|
14
|
+
#else
|
|
15
|
+
@interface StripeSdk : StripeSdkEventEmitterCompat <RCTBridgeModule>
|
|
16
|
+
#endif
|
|
17
|
+
|
|
18
|
+
@end
|
|
19
|
+
|
|
20
|
+
NS_ASSUME_NONNULL_END
|
|
21
|
+
|