@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
|
@@ -3,13 +3,13 @@ import UIKit
|
|
|
3
3
|
import Stripe
|
|
4
4
|
|
|
5
5
|
@objc(AuBECSDebitFormView)
|
|
6
|
-
class AuBECSDebitFormView: UIView, STPAUBECSDebitFormViewDelegate {
|
|
6
|
+
public class AuBECSDebitFormView: UIView, STPAUBECSDebitFormViewDelegate {
|
|
7
7
|
|
|
8
8
|
var auBecsFormView: STPAUBECSDebitFormView?
|
|
9
|
-
@objc var onCompleteAction: RCTDirectEventBlock?
|
|
10
|
-
@objc var companyName: NSString?
|
|
9
|
+
@objc public var onCompleteAction: RCTDirectEventBlock?
|
|
10
|
+
@objc public var companyName: NSString?
|
|
11
11
|
|
|
12
|
-
|
|
12
|
+
@objc public func didSetProps() {
|
|
13
13
|
if let auBecsFormView = self.auBecsFormView {
|
|
14
14
|
auBecsFormView.removeFromSuperview()
|
|
15
15
|
}
|
|
@@ -24,8 +24,14 @@ class AuBECSDebitFormView: UIView, STPAUBECSDebitFormViewDelegate {
|
|
|
24
24
|
setStyles()
|
|
25
25
|
}
|
|
26
26
|
}
|
|
27
|
+
|
|
28
|
+
override public func didSetProps(_ changedProps: [String]!) {
|
|
29
|
+
// This is only called on old arch, for new arch didSetProps() will be called
|
|
30
|
+
// by the view component.
|
|
31
|
+
self.didSetProps();
|
|
32
|
+
}
|
|
27
33
|
|
|
28
|
-
@objc var formStyle: NSDictionary = NSDictionary() {
|
|
34
|
+
@objc public var formStyle: NSDictionary = NSDictionary() {
|
|
29
35
|
didSet {
|
|
30
36
|
setStyles()
|
|
31
37
|
}
|
|
@@ -60,7 +66,7 @@ class AuBECSDebitFormView: UIView, STPAUBECSDebitFormViewDelegate {
|
|
|
60
66
|
}
|
|
61
67
|
}
|
|
62
68
|
|
|
63
|
-
func auBECSDebitForm(_ form: STPAUBECSDebitFormView, didChangeToStateComplete complete: Bool) {
|
|
69
|
+
public func auBECSDebitForm(_ form: STPAUBECSDebitFormView, didChangeToStateComplete complete: Bool) {
|
|
64
70
|
onCompleteAction!([
|
|
65
71
|
"accountNumber": form.paymentMethodParams?.auBECSDebit?.accountNumber ?? "",
|
|
66
72
|
"bsbNumber": form.paymentMethodParams?.auBECSDebit?.bsbNumber ?? "",
|
|
@@ -69,11 +75,11 @@ class AuBECSDebitFormView: UIView, STPAUBECSDebitFormViewDelegate {
|
|
|
69
75
|
])
|
|
70
76
|
}
|
|
71
77
|
|
|
72
|
-
override init(frame: CGRect) {
|
|
78
|
+
override public init(frame: CGRect) {
|
|
73
79
|
super.init(frame: frame)
|
|
74
80
|
}
|
|
75
81
|
|
|
76
|
-
override func layoutSubviews() {
|
|
82
|
+
override public func layoutSubviews() {
|
|
77
83
|
if let auBecsFormView = self.auBecsFormView {
|
|
78
84
|
auBecsFormView.frame = self.bounds
|
|
79
85
|
}
|
|
@@ -3,10 +3,7 @@ import Foundation
|
|
|
3
3
|
@objc(CardFieldManager)
|
|
4
4
|
class CardFieldManager: RCTViewManager {
|
|
5
5
|
override func view() -> UIView! {
|
|
6
|
-
|
|
7
|
-
let stripeSdk = bridge.module(forName: "StripeSdk") as? StripeSdk
|
|
8
|
-
stripeSdk?.cardFieldView = cardField;
|
|
9
|
-
return cardField
|
|
6
|
+
return CardFieldView()
|
|
10
7
|
}
|
|
11
8
|
|
|
12
9
|
@objc func focus(_ reactTag: NSNumber) {
|
package/ios/CardFieldView.swift
CHANGED
|
@@ -2,41 +2,42 @@ import Foundation
|
|
|
2
2
|
import UIKit
|
|
3
3
|
import Stripe
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
@objc var
|
|
8
|
-
@objc var
|
|
5
|
+
@objc(CardFieldView)
|
|
6
|
+
public class CardFieldView: UIView, STPPaymentCardTextFieldDelegate {
|
|
7
|
+
@objc public var onCardChange: RCTDirectEventBlock?
|
|
8
|
+
@objc public var onFocusChange: RCTDirectEventBlock?
|
|
9
|
+
@objc public var dangerouslyGetFullCardDetails: Bool = false
|
|
9
10
|
|
|
10
11
|
private var cardField = STPPaymentCardTextField()
|
|
11
12
|
|
|
12
13
|
public var cardParams: STPPaymentMethodParams? = nil
|
|
13
14
|
public var cardPostalCode: String? = nil
|
|
14
15
|
|
|
15
|
-
@objc var disabled: Bool = false {
|
|
16
|
+
@objc public var disabled: Bool = false {
|
|
16
17
|
didSet {
|
|
17
18
|
cardField.isUserInteractionEnabled = !disabled
|
|
18
19
|
}
|
|
19
20
|
}
|
|
20
21
|
|
|
21
|
-
@objc var postalCodeEnabled: Bool = true {
|
|
22
|
+
@objc public var postalCodeEnabled: Bool = true {
|
|
22
23
|
didSet {
|
|
23
24
|
cardField.postalCodeEntryEnabled = postalCodeEnabled
|
|
24
25
|
}
|
|
25
26
|
}
|
|
26
27
|
|
|
27
|
-
@objc var countryCode: String? {
|
|
28
|
+
@objc public var countryCode: String? {
|
|
28
29
|
didSet {
|
|
29
30
|
cardField.countryCode = countryCode
|
|
30
31
|
}
|
|
31
32
|
}
|
|
32
33
|
|
|
33
|
-
@objc var onBehalfOf: String? {
|
|
34
|
+
@objc public var onBehalfOf: String? {
|
|
34
35
|
didSet {
|
|
35
36
|
cardField.onBehalfOf = onBehalfOf
|
|
36
37
|
}
|
|
37
38
|
}
|
|
38
39
|
|
|
39
|
-
@objc var preferredNetworks: Array<Int>? {
|
|
40
|
+
@objc public var preferredNetworks: Array<Int>? {
|
|
40
41
|
didSet {
|
|
41
42
|
if let preferredNetworks = preferredNetworks {
|
|
42
43
|
cardField.preferredNetworks = preferredNetworks.map(Mappers.intToCardBrand).compactMap { $0 }
|
|
@@ -44,7 +45,7 @@ class CardFieldView: UIView, STPPaymentCardTextFieldDelegate {
|
|
|
44
45
|
}
|
|
45
46
|
}
|
|
46
47
|
|
|
47
|
-
@objc var placeholders: NSDictionary = NSDictionary() {
|
|
48
|
+
@objc public var placeholders: NSDictionary = NSDictionary() {
|
|
48
49
|
didSet {
|
|
49
50
|
if let numberPlaceholder = placeholders["number"] as? String {
|
|
50
51
|
cardField.numberPlaceholder = numberPlaceholder
|
|
@@ -63,7 +64,7 @@ class CardFieldView: UIView, STPPaymentCardTextFieldDelegate {
|
|
|
63
64
|
}
|
|
64
65
|
}
|
|
65
66
|
|
|
66
|
-
@objc var autofocus: Bool = false {
|
|
67
|
+
@objc public var autofocus: Bool = false {
|
|
67
68
|
didSet {
|
|
68
69
|
if autofocus == true {
|
|
69
70
|
cardField.reactFocus()
|
|
@@ -71,7 +72,7 @@ class CardFieldView: UIView, STPPaymentCardTextFieldDelegate {
|
|
|
71
72
|
}
|
|
72
73
|
}
|
|
73
74
|
|
|
74
|
-
@objc var cardStyle: NSDictionary = NSDictionary() {
|
|
75
|
+
@objc public var cardStyle: NSDictionary = NSDictionary() {
|
|
75
76
|
didSet {
|
|
76
77
|
if let borderWidth = cardStyle["borderWidth"] as? Int {
|
|
77
78
|
cardField.borderWidth = CGFloat(borderWidth)
|
|
@@ -111,46 +112,48 @@ class CardFieldView: UIView, STPPaymentCardTextFieldDelegate {
|
|
|
111
112
|
}
|
|
112
113
|
}
|
|
113
114
|
|
|
114
|
-
override init(frame: CGRect) {
|
|
115
|
+
override public init(frame: CGRect) {
|
|
115
116
|
super.init(frame: frame)
|
|
116
117
|
cardField.delegate = self
|
|
117
118
|
|
|
118
119
|
self.addSubview(cardField)
|
|
120
|
+
|
|
121
|
+
StripeSdkImpl.shared.cardFieldView = self
|
|
119
122
|
}
|
|
120
123
|
|
|
121
|
-
func focus() {
|
|
124
|
+
@objc public func focus() {
|
|
122
125
|
cardField.becomeFirstResponder()
|
|
123
126
|
}
|
|
124
127
|
|
|
125
|
-
func blur() {
|
|
128
|
+
@objc public func blur() {
|
|
126
129
|
cardField.resignFirstResponder()
|
|
127
130
|
}
|
|
128
131
|
|
|
129
|
-
func clear() {
|
|
132
|
+
@objc public func clear() {
|
|
130
133
|
cardField.clear()
|
|
131
134
|
}
|
|
132
135
|
|
|
133
|
-
func paymentCardTextFieldDidEndEditing(_ textField: STPPaymentCardTextField) {
|
|
134
|
-
onFocusChange?(["focusedField":
|
|
136
|
+
public func paymentCardTextFieldDidEndEditing(_ textField: STPPaymentCardTextField) {
|
|
137
|
+
onFocusChange?(["focusedField": ""])
|
|
135
138
|
}
|
|
136
139
|
|
|
137
|
-
func paymentCardTextFieldDidBeginEditingNumber(_ textField: STPPaymentCardTextField) {
|
|
140
|
+
public func paymentCardTextFieldDidBeginEditingNumber(_ textField: STPPaymentCardTextField) {
|
|
138
141
|
onFocusChange?(["focusedField": "CardNumber"])
|
|
139
142
|
}
|
|
140
143
|
|
|
141
|
-
func paymentCardTextFieldDidBeginEditingCVC(_ textField: STPPaymentCardTextField) {
|
|
144
|
+
public func paymentCardTextFieldDidBeginEditingCVC(_ textField: STPPaymentCardTextField) {
|
|
142
145
|
onFocusChange?(["focusedField": "Cvc"])
|
|
143
146
|
}
|
|
144
147
|
|
|
145
|
-
func paymentCardTextFieldDidBeginEditingExpiration(_ textField: STPPaymentCardTextField) {
|
|
148
|
+
public func paymentCardTextFieldDidBeginEditingExpiration(_ textField: STPPaymentCardTextField) {
|
|
146
149
|
onFocusChange?(["focusedField": "ExpiryDate"])
|
|
147
150
|
}
|
|
148
151
|
|
|
149
|
-
func paymentCardTextFieldDidBeginEditingPostalCode(_ textField: STPPaymentCardTextField) {
|
|
152
|
+
public func paymentCardTextFieldDidBeginEditingPostalCode(_ textField: STPPaymentCardTextField) {
|
|
150
153
|
onFocusChange?(["focusedField": "PostalCode"])
|
|
151
154
|
}
|
|
152
155
|
|
|
153
|
-
func paymentCardTextFieldDidChange(_ textField: STPPaymentCardTextField) {
|
|
156
|
+
public func paymentCardTextFieldDidChange(_ textField: STPPaymentCardTextField) {
|
|
154
157
|
if onCardChange != nil {
|
|
155
158
|
let brand = STPCardValidator.brand(forNumber: textField.cardNumber ?? "")
|
|
156
159
|
let validExpiryDate = STPCardValidator.validationState(
|
|
@@ -176,7 +179,7 @@ class CardFieldView: UIView, STPPaymentCardTextFieldDelegate {
|
|
|
176
179
|
cardData["number"] = textField.cardNumber ?? ""
|
|
177
180
|
cardData["cvc"] = textField.cvc ?? ""
|
|
178
181
|
}
|
|
179
|
-
onCardChange!(cardData as [AnyHashable : Any])
|
|
182
|
+
onCardChange!(["card": cardData as [AnyHashable : Any]])
|
|
180
183
|
}
|
|
181
184
|
if (textField.isValid) {
|
|
182
185
|
self.cardParams = textField.paymentMethodParams
|
|
@@ -187,7 +190,7 @@ class CardFieldView: UIView, STPPaymentCardTextFieldDelegate {
|
|
|
187
190
|
}
|
|
188
191
|
}
|
|
189
192
|
|
|
190
|
-
override func layoutSubviews() {
|
|
193
|
+
override public func layoutSubviews() {
|
|
191
194
|
cardField.frame = self.bounds
|
|
192
195
|
}
|
|
193
196
|
|
|
@@ -3,10 +3,7 @@ import Foundation
|
|
|
3
3
|
@objc(CardFormManager)
|
|
4
4
|
class CardFormManager: RCTViewManager {
|
|
5
5
|
override func view() -> UIView! {
|
|
6
|
-
|
|
7
|
-
let stripeSdk = bridge.module(forName: "StripeSdk") as? StripeSdk
|
|
8
|
-
stripeSdk?.cardFormView = cardForm;
|
|
9
|
-
return cardForm
|
|
6
|
+
return CardFormView()
|
|
10
7
|
}
|
|
11
8
|
|
|
12
9
|
override class func requiresMainQueueSetup() -> Bool {
|
package/ios/CardFormView.swift
CHANGED
|
@@ -2,22 +2,23 @@ import Foundation
|
|
|
2
2
|
import UIKit
|
|
3
3
|
import Stripe
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
@objc(CardFormView)
|
|
6
|
+
public class CardFormView: UIView, STPCardFormViewDelegate {
|
|
6
7
|
public var cardForm: STPCardFormView?
|
|
7
8
|
|
|
8
9
|
public var cardParams: STPPaymentMethodCardParams? = nil
|
|
9
10
|
|
|
10
|
-
@objc var dangerouslyGetFullCardDetails: Bool = false
|
|
11
|
-
@objc var onFormComplete: RCTDirectEventBlock?
|
|
12
|
-
@objc var autofocus: Bool = false
|
|
13
|
-
@objc var disabled: Bool = false
|
|
14
|
-
@objc var preferredNetworks: Array<Int>? {
|
|
11
|
+
@objc public var dangerouslyGetFullCardDetails: Bool = false
|
|
12
|
+
@objc public var onFormComplete: RCTDirectEventBlock?
|
|
13
|
+
@objc public var autofocus: Bool = false
|
|
14
|
+
@objc public var disabled: Bool = false
|
|
15
|
+
@objc public var preferredNetworks: Array<Int>? {
|
|
15
16
|
didSet {
|
|
16
17
|
setPreferredNetworks()
|
|
17
18
|
}
|
|
18
19
|
}
|
|
19
|
-
|
|
20
|
-
|
|
20
|
+
|
|
21
|
+
@objc public func didSetProps() {
|
|
21
22
|
if let cardForm = self.cardForm {
|
|
22
23
|
cardForm.removeFromSuperview()
|
|
23
24
|
}
|
|
@@ -37,13 +38,19 @@ class CardFormView: UIView, STPCardFormViewDelegate {
|
|
|
37
38
|
setPreferredNetworks()
|
|
38
39
|
}
|
|
39
40
|
|
|
40
|
-
|
|
41
|
+
override public 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
|
+
|
|
47
|
+
@objc public var cardStyle: NSDictionary = NSDictionary() {
|
|
41
48
|
didSet {
|
|
42
49
|
setStyles()
|
|
43
50
|
}
|
|
44
51
|
}
|
|
45
52
|
|
|
46
|
-
func cardFormView(_ form: STPCardFormView, didChangeToStateComplete complete: Bool) {
|
|
53
|
+
public func cardFormView(_ form: STPCardFormView, didChangeToStateComplete complete: Bool) {
|
|
47
54
|
if onFormComplete != nil {
|
|
48
55
|
let brand = STPCardValidator.brand(forNumber: cardForm?.cardParams?.card?.number ?? "")
|
|
49
56
|
var cardData: [String: Any?] = [
|
|
@@ -65,15 +72,15 @@ class CardFormView: UIView, STPCardFormViewDelegate {
|
|
|
65
72
|
} else {
|
|
66
73
|
self.cardParams = nil
|
|
67
74
|
}
|
|
68
|
-
onFormComplete!(cardData as [AnyHashable : Any])
|
|
75
|
+
onFormComplete!(["card": cardData as [AnyHashable : Any]])
|
|
69
76
|
}
|
|
70
77
|
}
|
|
71
78
|
|
|
72
|
-
func focus() {
|
|
79
|
+
@objc public func focus() {
|
|
73
80
|
let _ = cardForm?.becomeFirstResponder()
|
|
74
81
|
}
|
|
75
82
|
|
|
76
|
-
func blur() {
|
|
83
|
+
@objc public func blur() {
|
|
77
84
|
let _ = cardForm?.resignFirstResponder()
|
|
78
85
|
}
|
|
79
86
|
|
|
@@ -112,11 +119,13 @@ class CardFormView: UIView, STPCardFormViewDelegate {
|
|
|
112
119
|
}
|
|
113
120
|
}
|
|
114
121
|
|
|
115
|
-
override init(frame: CGRect) {
|
|
122
|
+
override public init(frame: CGRect) {
|
|
116
123
|
super.init(frame: frame)
|
|
124
|
+
|
|
125
|
+
StripeSdkImpl.shared.cardFormView = self
|
|
117
126
|
}
|
|
118
|
-
|
|
119
|
-
override func layoutSubviews() {
|
|
127
|
+
|
|
128
|
+
override public func layoutSubviews() {
|
|
120
129
|
cardForm?.frame = self.bounds
|
|
121
130
|
}
|
|
122
131
|
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
//
|
|
7
7
|
|
|
8
8
|
import Foundation
|
|
9
|
-
@_spi(PrivateBetaCustomerSheet) @_spi(STP)
|
|
9
|
+
@_spi(PrivateBetaCustomerSheet) @_spi(STP) import StripePaymentSheet
|
|
10
10
|
|
|
11
11
|
class CustomerSheetUtils {
|
|
12
12
|
internal class func buildCustomerSheetConfiguration(
|
|
@@ -21,7 +21,6 @@ class CustomerSheetUtils {
|
|
|
21
21
|
defaultBillingDetails: NSDictionary?,
|
|
22
22
|
preferredNetworks: Array<Int>?,
|
|
23
23
|
allowsRemovalOfLastSavedPaymentMethod: Bool?,
|
|
24
|
-
updatePaymentMethodEnabled: Bool?,
|
|
25
24
|
cardBrandAcceptance: PaymentSheet.CardBrandAcceptance
|
|
26
25
|
) -> CustomerSheet.Configuration {
|
|
27
26
|
var config = CustomerSheet.Configuration()
|
|
@@ -38,10 +37,10 @@ class CustomerSheetUtils {
|
|
|
38
37
|
config.preferredNetworks = preferredNetworks.map(Mappers.intToCardBrand).compactMap { $0 }
|
|
39
38
|
}
|
|
40
39
|
if let billingConfigParams = billingDetailsCollectionConfiguration {
|
|
41
|
-
config.billingDetailsCollectionConfiguration.name =
|
|
42
|
-
config.billingDetailsCollectionConfiguration.phone =
|
|
43
|
-
config.billingDetailsCollectionConfiguration.email =
|
|
44
|
-
config.billingDetailsCollectionConfiguration.address =
|
|
40
|
+
config.billingDetailsCollectionConfiguration.name = StripeSdkImpl.mapToCollectionMode(str: billingConfigParams["name"] as? String)
|
|
41
|
+
config.billingDetailsCollectionConfiguration.phone = StripeSdkImpl.mapToCollectionMode(str: billingConfigParams["phone"] as? String)
|
|
42
|
+
config.billingDetailsCollectionConfiguration.email = StripeSdkImpl.mapToCollectionMode(str: billingConfigParams["email"] as? String)
|
|
43
|
+
config.billingDetailsCollectionConfiguration.address = StripeSdkImpl.mapToAddressCollectionMode(str: billingConfigParams["address"] as? String)
|
|
45
44
|
config.billingDetailsCollectionConfiguration.attachDefaultsToPaymentMethod = billingConfigParams["attachDefaultsToPaymentMethod"] as? Bool == true
|
|
46
45
|
}
|
|
47
46
|
if let defaultBillingDetails = defaultBillingDetails {
|
|
@@ -60,19 +59,16 @@ class CustomerSheetUtils {
|
|
|
60
59
|
if let allowsRemovalOfLastSavedPaymentMethod = allowsRemovalOfLastSavedPaymentMethod {
|
|
61
60
|
config.allowsRemovalOfLastSavedPaymentMethod = allowsRemovalOfLastSavedPaymentMethod
|
|
62
61
|
}
|
|
63
|
-
if let updatePaymentMethodEnabled = updatePaymentMethodEnabled {
|
|
64
|
-
config.updatePaymentMethodEnabled = updatePaymentMethodEnabled
|
|
65
|
-
}
|
|
66
62
|
config.cardBrandAcceptance = cardBrandAcceptance
|
|
67
63
|
return config
|
|
68
64
|
}
|
|
69
|
-
|
|
65
|
+
|
|
70
66
|
internal class func buildStripeCustomerAdapter(
|
|
71
67
|
customerId: String,
|
|
72
68
|
ephemeralKeySecret: String,
|
|
73
69
|
setupIntentClientSecret: String?,
|
|
74
70
|
customerAdapter: NSDictionary,
|
|
75
|
-
stripeSdk:
|
|
71
|
+
stripeSdk: StripeSdkImpl
|
|
76
72
|
) -> StripeCustomerAdapter {
|
|
77
73
|
if (customerAdapter.count > 0) {
|
|
78
74
|
return buildCustomerAdapterOverride(
|
|
@@ -83,7 +79,7 @@ class CustomerSheetUtils {
|
|
|
83
79
|
stripeSdk: stripeSdk
|
|
84
80
|
)
|
|
85
81
|
}
|
|
86
|
-
|
|
82
|
+
|
|
87
83
|
if let setupIntentClientSecret = setupIntentClientSecret {
|
|
88
84
|
return StripeCustomerAdapter(
|
|
89
85
|
customerEphemeralKeyProvider: {
|
|
@@ -101,13 +97,13 @@ class CustomerSheetUtils {
|
|
|
101
97
|
}
|
|
102
98
|
)
|
|
103
99
|
}
|
|
104
|
-
|
|
100
|
+
|
|
105
101
|
internal class func buildCustomerAdapterOverride(
|
|
106
102
|
customerAdapter: NSDictionary,
|
|
107
103
|
customerId: String,
|
|
108
104
|
ephemeralKeySecret: String,
|
|
109
105
|
setupIntentClientSecret: String?,
|
|
110
|
-
stripeSdk:
|
|
106
|
+
stripeSdk: StripeSdkImpl
|
|
111
107
|
) -> StripeCustomerAdapter {
|
|
112
108
|
return ReactNativeCustomerAdapter(
|
|
113
109
|
fetchPaymentMethods: customerAdapter["fetchPaymentMethods"] as? Bool ?? false,
|
|
@@ -157,7 +153,7 @@ class CustomerSheetUtils {
|
|
|
157
153
|
}
|
|
158
154
|
}
|
|
159
155
|
|
|
160
|
-
|
|
156
|
+
|
|
161
157
|
internal class func buildPaymentOptionResult(label: String, imageData: String?, paymentMethod: STPPaymentMethod?) -> NSMutableDictionary {
|
|
162
158
|
let result: NSMutableDictionary = [:]
|
|
163
159
|
let paymentOption: NSMutableDictionary = [:]
|
|
@@ -171,7 +167,7 @@ class CustomerSheetUtils {
|
|
|
171
167
|
}
|
|
172
168
|
return result
|
|
173
169
|
}
|
|
174
|
-
|
|
170
|
+
|
|
175
171
|
internal class func interpretResult(result: CustomerSheet.CustomerSheetResult) -> NSDictionary {
|
|
176
172
|
var payload: NSMutableDictionary = [:]
|
|
177
173
|
switch result {
|
|
@@ -15,7 +15,7 @@ class ReactNativeCustomerAdapter: StripeCustomerAdapter {
|
|
|
15
15
|
var overridesSetSelectedPaymentOption: Bool
|
|
16
16
|
var overridesFetchSelectedPaymentOption: Bool
|
|
17
17
|
var overridesSetupIntentClientSecretForCustomerAttach: Bool
|
|
18
|
-
var stripeSdk:
|
|
18
|
+
var stripeSdk: StripeSdkImpl
|
|
19
19
|
|
|
20
20
|
init(
|
|
21
21
|
fetchPaymentMethods: Bool,
|
|
@@ -27,7 +27,7 @@ class ReactNativeCustomerAdapter: StripeCustomerAdapter {
|
|
|
27
27
|
customerId: String,
|
|
28
28
|
ephemeralKeySecret: String,
|
|
29
29
|
setupIntentClientSecret: String?,
|
|
30
|
-
stripeSdk:
|
|
30
|
+
stripeSdk: StripeSdkImpl
|
|
31
31
|
) {
|
|
32
32
|
self.overridesFetchPaymentMethods = fetchPaymentMethods
|
|
33
33
|
self.overridesAttachPaymentMethod = attachPaymentMethod
|
|
@@ -132,42 +132,42 @@ extension ReactNativeCustomerAdapter {
|
|
|
132
132
|
func fetchPaymentMethods(completion: @escaping ([STPPaymentMethod]) -> Void) {
|
|
133
133
|
DispatchQueue.main.async {
|
|
134
134
|
self.stripeSdk.fetchPaymentMethodsCallback = completion
|
|
135
|
-
self.stripeSdk.
|
|
135
|
+
self.stripeSdk.emitter?.emitOnCustomerAdapterFetchPaymentMethodsCallback()
|
|
136
136
|
}
|
|
137
137
|
}
|
|
138
138
|
|
|
139
139
|
func attachPaymentMethod(_ paymentMethodId: String, completion: @escaping () -> Void) {
|
|
140
140
|
DispatchQueue.main.async {
|
|
141
141
|
self.stripeSdk.attachPaymentMethodCallback = completion
|
|
142
|
-
self.stripeSdk.
|
|
142
|
+
self.stripeSdk.emitter?.emitOnCustomerAdapterAttachPaymentMethodCallback(["paymentMethodId": paymentMethodId])
|
|
143
143
|
}
|
|
144
144
|
}
|
|
145
145
|
|
|
146
146
|
func detachPaymentMethod(_ paymentMethodId: String, completion: @escaping () -> Void) {
|
|
147
147
|
DispatchQueue.main.async {
|
|
148
148
|
self.stripeSdk.detachPaymentMethodCallback = completion
|
|
149
|
-
self.stripeSdk.
|
|
149
|
+
self.stripeSdk.emitter?.emitOnCustomerAdapterDetachPaymentMethodCallback(["paymentMethodId": paymentMethodId])
|
|
150
150
|
}
|
|
151
151
|
}
|
|
152
152
|
|
|
153
153
|
func setSelectedPaymentOption(_ paymentOption: CustomerPaymentOption?, completion: @escaping () -> Void) {
|
|
154
154
|
DispatchQueue.main.async {
|
|
155
155
|
self.stripeSdk.setSelectedPaymentOptionCallback = completion
|
|
156
|
-
self.stripeSdk.
|
|
156
|
+
self.stripeSdk.emitter?.emitOnCustomerAdapterSetSelectedPaymentOptionCallback(["paymentOption": paymentOption?.value])
|
|
157
157
|
}
|
|
158
158
|
}
|
|
159
159
|
|
|
160
160
|
func fetchSelectedPaymentOption(completion: @escaping (CustomerPaymentOption?) -> Void) {
|
|
161
161
|
DispatchQueue.main.async {
|
|
162
162
|
self.stripeSdk.fetchSelectedPaymentOptionCallback = completion
|
|
163
|
-
self.stripeSdk.
|
|
163
|
+
self.stripeSdk.emitter?.emitOnCustomerAdapterFetchSelectedPaymentOptionCallback()
|
|
164
164
|
}
|
|
165
165
|
}
|
|
166
166
|
|
|
167
167
|
func setupIntentClientSecretForCustomerAttach(completion: @escaping (String) -> Void) {
|
|
168
168
|
DispatchQueue.main.async {
|
|
169
169
|
self.stripeSdk.setupIntentClientSecretForCustomerAttachCallback = completion
|
|
170
|
-
self.stripeSdk.
|
|
170
|
+
self.stripeSdk.emitter?.emitOnCustomerAdapterSetupIntentClientSecretForCustomerAttachCallback()
|
|
171
171
|
}
|
|
172
172
|
}
|
|
173
173
|
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
//
|
|
2
|
+
// EmbeddedPaymentElementView.swift
|
|
3
|
+
// stripe-react-native
|
|
4
|
+
//
|
|
5
|
+
// Created by Nick Porter on 4/16/25.
|
|
6
|
+
//
|
|
7
|
+
|
|
8
|
+
import Foundation
|
|
9
|
+
import UIKit
|
|
10
|
+
@_spi(EmbeddedPaymentElementPrivateBeta) import StripePaymentSheet
|
|
11
|
+
|
|
12
|
+
@objc(EmbeddedPaymentElementView)
|
|
13
|
+
class EmbeddedPaymentElementView: RCTViewManager {
|
|
14
|
+
|
|
15
|
+
override static func requiresMainQueueSetup() -> Bool {
|
|
16
|
+
return true
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
override func view() -> UIView! {
|
|
20
|
+
return EmbeddedPaymentElementContainerView(frame: .zero)
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
class EmbeddedPaymentElementContainerView: UIView, UIGestureRecognizerDelegate {
|
|
25
|
+
override init(frame: CGRect) {
|
|
26
|
+
super.init(frame: frame)
|
|
27
|
+
backgroundColor = .clear
|
|
28
|
+
attachPaymentElementIfAvailable()
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
required init?(coder: NSCoder) {
|
|
32
|
+
fatalError()
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
private func attachPaymentElementIfAvailable() {
|
|
36
|
+
guard let embeddedElement = StripeSdkImpl.shared.embeddedInstance else { return }
|
|
37
|
+
let paymentElementView = embeddedElement.view
|
|
38
|
+
addSubview(paymentElementView)
|
|
39
|
+
paymentElementView.translatesAutoresizingMaskIntoConstraints = false
|
|
40
|
+
|
|
41
|
+
NSLayoutConstraint.activate([
|
|
42
|
+
paymentElementView.topAnchor.constraint(equalTo: topAnchor),
|
|
43
|
+
paymentElementView.leadingAnchor.constraint(equalTo: leadingAnchor),
|
|
44
|
+
paymentElementView.trailingAnchor.constraint(equalTo: trailingAnchor),
|
|
45
|
+
paymentElementView.bottomAnchor.constraint(equalTo: bottomAnchor),
|
|
46
|
+
])
|
|
47
|
+
}
|
|
48
|
+
}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
#import "AddToWalletButtonComponentView.h"
|
|
2
|
+
|
|
3
|
+
#import <react/renderer/components/rnstripe/ComponentDescriptors.h>
|
|
4
|
+
#import <react/renderer/components/rnstripe/EventEmitters.h>
|
|
5
|
+
#import <react/renderer/components/rnstripe/Props.h>
|
|
6
|
+
#import <react/renderer/components/rnstripe/RCTComponentViewHelpers.h>
|
|
7
|
+
|
|
8
|
+
#import <React/RCTConversions.h>
|
|
9
|
+
#import <React/RCTFabricComponentsPlugins.h>
|
|
10
|
+
|
|
11
|
+
#import "RCTFollyConvert.h"
|
|
12
|
+
#import "StripeNewArchConversions.h"
|
|
13
|
+
#import "StripeSwiftInterop.h"
|
|
14
|
+
|
|
15
|
+
using namespace facebook::react;
|
|
16
|
+
using namespace stripe::react;
|
|
17
|
+
|
|
18
|
+
@interface AddToWalletButtonComponentView () <RCTAddToWalletButtonViewProtocol>
|
|
19
|
+
@end
|
|
20
|
+
|
|
21
|
+
@implementation AddToWalletButtonComponentView {
|
|
22
|
+
AddToWalletButtonView *_view;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
// Needed because of this: https://github.com/facebook/react-native/pull/37274
|
|
26
|
+
+ (void)load
|
|
27
|
+
{
|
|
28
|
+
[super load];
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
- (instancetype)initWithFrame:(CGRect)frame
|
|
32
|
+
{
|
|
33
|
+
if (self = [super initWithFrame:frame]) {
|
|
34
|
+
static const auto defaultProps = std::make_shared<const AddToWalletButtonProps>();
|
|
35
|
+
_props = defaultProps;
|
|
36
|
+
[self prepareView];
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
return self;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
- (void)prepareView
|
|
43
|
+
{
|
|
44
|
+
_view = [[AddToWalletButtonView alloc] initWithFrame:self.frame];
|
|
45
|
+
self.contentView = _view;
|
|
46
|
+
|
|
47
|
+
__weak __typeof(self) weakSelf = self;
|
|
48
|
+
|
|
49
|
+
_view.onCompleteAction = ^(NSDictionary *event) {
|
|
50
|
+
__typeof(self) strongSelf = weakSelf;
|
|
51
|
+
if (!strongSelf || !strongSelf->_eventEmitter) {
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
AddToWalletButtonEventEmitter::OnCompleteAction emitterEvent = {.error = convertIdToFollyDynamic(event[@"error"])};
|
|
55
|
+
std::static_pointer_cast<const AddToWalletButtonEventEmitter>(strongSelf->_eventEmitter)
|
|
56
|
+
->onCompleteAction(std::move(emitterEvent));
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
- (void)updateProps:(const facebook::react::Props::Shared &)props
|
|
61
|
+
oldProps:(const facebook::react::Props::Shared &)oldProps
|
|
62
|
+
{
|
|
63
|
+
const auto &newViewProps = *std::static_pointer_cast<const AddToWalletButtonProps>(props);
|
|
64
|
+
|
|
65
|
+
_view.iOSButtonStyle = RCTNSStringFromStringNilIfEmpty(newViewProps.iOSButtonStyle);
|
|
66
|
+
_view.testEnv = newViewProps.testEnv;
|
|
67
|
+
_view.cardDetails = convertFollyDynamicToNSDictionaryOrNil(newViewProps.cardDetails);
|
|
68
|
+
_view.ephemeralKey = convertFollyDynamicToNSDictionaryOrNil(newViewProps.ephemeralKey);
|
|
69
|
+
|
|
70
|
+
[super updateProps:props oldProps:oldProps];
|
|
71
|
+
|
|
72
|
+
[_view didSetProps];
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
#pragma mark - RCTComponentViewProtocol
|
|
76
|
+
|
|
77
|
+
+ (ComponentDescriptorProvider)componentDescriptorProvider
|
|
78
|
+
{
|
|
79
|
+
return concreteComponentDescriptorProvider<AddToWalletButtonComponentDescriptor>();
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
- (void)prepareForRecycle
|
|
83
|
+
{
|
|
84
|
+
[super prepareForRecycle];
|
|
85
|
+
[self prepareView];
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
@end
|
|
89
|
+
|
|
90
|
+
Class<RCTComponentViewProtocol> AddToWalletButtonCls(void)
|
|
91
|
+
{
|
|
92
|
+
return AddToWalletButtonComponentView.class;
|
|
93
|
+
}
|