react-native-payengine 2.0.11 → 2.0.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +137 -0
- package/android/.gradle/6.1.1/executionHistory/executionHistory.lock +0 -0
- package/android/.gradle/6.1.1/fileHashes/fileHashes.lock +0 -0
- package/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock +0 -0
- package/android/.gradle/buildOutputCleanup/cache.properties +1 -1
- package/android/.gradle/checksums/checksums.lock +0 -0
- package/android/.gradle/checksums/md5-checksums.bin +0 -0
- package/android/.gradle/checksums/sha1-checksums.bin +0 -0
- package/android/.idea/gradle.xml +2 -2
- package/android/.idea/jarRepositories.xml +0 -5
- package/android/.idea/libraries/Gradle__android_arch_core_common_1_0_0.xml +11 -0
- package/android/.idea/libraries/Gradle__android_arch_lifecycle_common_1_0_0.xml +11 -0
- package/android/.idea/libraries/Gradle__android_arch_lifecycle_runtime_1_0_0_aar.xml +13 -0
- package/android/.idea/libraries/Gradle__androidx_annotation_annotation_1_1_0.xml +13 -0
- package/android/.idea/libraries/Gradle__androidx_appcompat_appcompat_1_0_2_aar.xml +16 -0
- package/android/.idea/libraries/Gradle__androidx_arch_core_core_common_2_0_0.xml +11 -0
- package/android/.idea/libraries/Gradle__androidx_arch_core_core_runtime_2_0_0_aar.xml +13 -0
- package/android/.idea/libraries/Gradle__androidx_asynclayoutinflater_asynclayoutinflater_1_0_0_aar.xml +13 -0
- package/android/.idea/libraries/Gradle__androidx_autofill_autofill_1_1_0_aar.xml +16 -0
- package/android/.idea/libraries/Gradle__androidx_collection_collection_1_0_0.xml +11 -0
- package/android/.idea/libraries/Gradle__androidx_coordinatorlayout_coordinatorlayout_1_0_0_aar.xml +16 -0
- package/android/.idea/libraries/Gradle__androidx_core_core_1_1_0_aar.xml +16 -0
- package/android/.idea/libraries/Gradle__androidx_cursoradapter_cursoradapter_1_0_0_aar.xml +13 -0
- package/android/.idea/libraries/Gradle__androidx_customview_customview_1_0_0_aar.xml +13 -0
- package/android/.idea/libraries/Gradle__androidx_documentfile_documentfile_1_0_0_aar.xml +13 -0
- package/android/.idea/libraries/Gradle__androidx_drawerlayout_drawerlayout_1_0_0_aar.xml +16 -0
- package/android/.idea/libraries/Gradle__androidx_fragment_fragment_1_0_0_aar.xml +16 -0
- package/android/.idea/libraries/Gradle__androidx_interpolator_interpolator_1_0_0_aar.xml +13 -0
- package/android/.idea/libraries/Gradle__androidx_legacy_legacy_support_core_ui_1_0_0_aar.xml +13 -0
- package/android/.idea/libraries/Gradle__androidx_legacy_legacy_support_core_utils_1_0_0_aar.xml +13 -0
- package/android/.idea/libraries/Gradle__androidx_lifecycle_lifecycle_common_2_0_0.xml +11 -0
- package/android/.idea/libraries/Gradle__androidx_lifecycle_lifecycle_livedata_2_0_0_aar.xml +13 -0
- package/android/.idea/libraries/Gradle__androidx_lifecycle_lifecycle_livedata_core_2_0_0_aar.xml +13 -0
- package/android/.idea/libraries/Gradle__androidx_lifecycle_lifecycle_runtime_2_0_0_aar.xml +13 -0
- package/android/.idea/libraries/Gradle__androidx_lifecycle_lifecycle_viewmodel_2_0_0_aar.xml +13 -0
- package/android/.idea/libraries/Gradle__androidx_loader_loader_1_0_0_aar.xml +13 -0
- package/android/.idea/libraries/Gradle__androidx_localbroadcastmanager_localbroadcastmanager_1_0_0_aar.xml +13 -0
- package/android/.idea/libraries/Gradle__androidx_print_print_1_0_0_aar.xml +16 -0
- package/android/.idea/libraries/Gradle__androidx_slidingpanelayout_slidingpanelayout_1_0_0_aar.xml +13 -0
- package/android/.idea/libraries/Gradle__androidx_swiperefreshlayout_swiperefreshlayout_1_0_0_aar.xml +16 -0
- package/android/.idea/libraries/Gradle__androidx_vectordrawable_vectordrawable_1_0_1_aar.xml +13 -0
- package/android/.idea/libraries/Gradle__androidx_vectordrawable_vectordrawable_animated_1_0_0_aar.xml +13 -0
- package/android/.idea/libraries/Gradle__androidx_versionedparcelable_versionedparcelable_1_1_0_aar.xml +13 -0
- package/android/.idea/libraries/Gradle__androidx_viewpager_viewpager_1_0_0_aar.xml +13 -0
- package/android/.idea/libraries/Gradle__com_android_support_support_annotations_26_1_0.xml +13 -0
- package/android/.idea/libraries/Gradle__com_android_support_support_compat_26_1_0_aar.xml +13 -0
- package/android/.idea/libraries/Gradle__com_android_support_support_core_ui_26_1_0_aar.xml +13 -0
- package/android/.idea/libraries/Gradle__com_android_support_support_core_utils_26_1_0_aar.xml +13 -0
- package/android/.idea/libraries/Gradle__com_android_support_support_fragment_26_1_0_aar.xml +13 -0
- package/android/.idea/libraries/Gradle__com_android_support_support_media_compat_26_1_0_aar.xml +13 -0
- package/android/.idea/libraries/Gradle__com_android_support_support_v4_26_1_0_aar.xml +13 -0
- package/android/.idea/libraries/Gradle__com_facebook_fbjni_fbjni_java_only_0_2_2.xml +13 -0
- package/android/.idea/libraries/Gradle__com_facebook_fresco_drawee_2_5_0_aar.xml +15 -0
- package/android/.idea/libraries/Gradle__com_facebook_fresco_fbcore_2_5_0_aar.xml +18 -0
- package/android/.idea/libraries/Gradle__com_facebook_fresco_fresco_2_5_0_aar.xml +18 -0
- package/android/.idea/libraries/Gradle__com_facebook_fresco_imagepipeline_2_5_0_aar.xml +18 -0
- package/android/.idea/libraries/Gradle__com_facebook_fresco_imagepipeline_base_2_5_0_aar.xml +18 -0
- package/android/.idea/libraries/Gradle__com_facebook_fresco_imagepipeline_native_2_5_0_aar.xml +15 -0
- package/android/.idea/libraries/Gradle__com_facebook_fresco_imagepipeline_okhttp3_2_5_0_aar.xml +15 -0
- package/android/.idea/libraries/Gradle__com_facebook_fresco_memory_type_ashmem_2_5_0_aar.xml +15 -0
- package/android/.idea/libraries/Gradle__com_facebook_fresco_memory_type_java_2_5_0_aar.xml +15 -0
- package/android/.idea/libraries/Gradle__com_facebook_fresco_memory_type_native_2_5_0_aar.xml +15 -0
- package/android/.idea/libraries/Gradle__com_facebook_fresco_nativeimagefilters_2_5_0_aar.xml +15 -0
- package/android/.idea/libraries/Gradle__com_facebook_fresco_nativeimagetranscoder_2_5_0_aar.xml +15 -0
- package/android/.idea/libraries/Gradle__com_facebook_fresco_ui_common_2_5_0_aar.xml +15 -0
- package/android/.idea/libraries/Gradle__com_facebook_infer_annotation_infer_annotation_0_18_0.xml +13 -0
- package/android/.idea/libraries/Gradle__com_facebook_react_react_native_0_68_2_aar.xml +16 -0
- package/android/.idea/libraries/Gradle__com_facebook_soloader_annotation_0_10_3.xml +13 -0
- package/android/.idea/libraries/Gradle__com_facebook_soloader_nativeloader_0_10_3.xml +13 -0
- package/android/.idea/libraries/Gradle__com_facebook_soloader_soloader_0_10_3_aar.xml +15 -0
- package/android/.idea/libraries/Gradle__com_facebook_yoga_proguard_annotations_1_19_0.xml +13 -0
- package/android/.idea/libraries/Gradle__com_google_android_gms_play_services_base_15_0_1_aar.xml +11 -0
- package/android/.idea/libraries/Gradle__com_google_android_gms_play_services_basement_15_0_1_aar.xml +11 -0
- package/android/.idea/libraries/Gradle__com_google_android_gms_play_services_identity_15_0_1_aar.xml +11 -0
- package/android/.idea/libraries/Gradle__com_google_android_gms_play_services_maps_15_0_1_aar.xml +11 -0
- package/android/.idea/libraries/Gradle__com_google_android_gms_play_services_tasks_15_0_1_aar.xml +11 -0
- package/android/.idea/libraries/Gradle__com_google_android_gms_play_services_wallet_16_0_0_aar.xml +11 -0
- package/android/.idea/libraries/Gradle__com_google_code_findbugs_jsr305_3_0_2.xml +13 -0
- package/android/.idea/libraries/Gradle__com_squareup_okhttp3_okhttp_4_9_2.xml +13 -0
- package/android/.idea/libraries/Gradle__com_squareup_okhttp3_okhttp_urlconnection_4_9_2.xml +13 -0
- package/android/.idea/libraries/Gradle__com_squareup_okio_okio_2_9_0.xml +13 -0
- package/android/.idea/libraries/Gradle__javax_inject_javax_inject_1.xml +13 -0
- package/android/.idea/libraries/Gradle__org_jetbrains_annotations_13_0.xml +13 -0
- package/android/.idea/libraries/Gradle__org_jetbrains_kotlin_kotlin_annotations_jvm_1_3_72.xml +13 -0
- package/android/.idea/libraries/Gradle__org_jetbrains_kotlin_kotlin_stdlib_1_4_10.xml +13 -0
- package/android/.idea/libraries/Gradle__org_jetbrains_kotlin_kotlin_stdlib_common_1_4_10.xml +13 -0
- package/android/.idea/libraries/Gradle__org_jetbrains_kotlin_kotlin_stdlib_jdk7_1_4_10.xml +13 -0
- package/android/.idea/libraries/Gradle__org_jetbrains_kotlin_kotlin_stdlib_jdk8_1_4_10.xml +13 -0
- package/android/.idea/misc.xml +1 -2
- package/android/.idea/modules/android.androidTest.iml +114 -0
- package/android/.idea/modules/android.iml +40 -0
- package/android/.idea/modules/android.main.iml +122 -0
- package/android/.idea/modules/android.unitTest.iml +109 -0
- package/android/.idea/modules.xml +11 -0
- package/android/build.gradle +16 -12
- package/android/local.properties +2 -2
- package/android/src/main/java/com/reactnativepayengine/v2/features/googlepay/RNPEGooglePayButton.kt +2 -3
- package/android/src/main/java/com/reactnativepayengine/v2/features/googlepay/RNPEPaymentRequest.kt +1 -1
- package/android/src/main/java/com/reactnativepayengine/v2/securefields/bankaccount/RNPEBankAccountView.kt +1 -1
- package/android/src/main/java/com/reactnativepayengine/v2/securefields/creditcard/RNPECreditCardView.kt +1 -1
- package/ios/PayEngineSDK.xcframework/ios-arm64/PayEngineSDK.framework/Headers/PayEngineSDK-Swift.h +19 -3
- package/ios/PayEngineSDK.xcframework/ios-arm64/PayEngineSDK.framework/Info.plist +0 -0
- package/ios/PayEngineSDK.xcframework/ios-arm64/PayEngineSDK.framework/Modules/PayEngineSDK.swiftmodule/arm64-apple-ios.abi.json +1367 -3704
- package/ios/PayEngineSDK.xcframework/ios-arm64/PayEngineSDK.framework/Modules/PayEngineSDK.swiftmodule/arm64-apple-ios.private.swiftinterface +68 -59
- package/ios/PayEngineSDK.xcframework/ios-arm64/PayEngineSDK.framework/Modules/PayEngineSDK.swiftmodule/arm64-apple-ios.private.swiftinterface-e +68 -59
- package/ios/PayEngineSDK.xcframework/ios-arm64/PayEngineSDK.framework/Modules/PayEngineSDK.swiftmodule/arm64-apple-ios.swiftdoc +0 -0
- package/ios/PayEngineSDK.xcframework/ios-arm64/PayEngineSDK.framework/Modules/PayEngineSDK.swiftmodule/arm64-apple-ios.swiftinterface +68 -59
- package/ios/PayEngineSDK.xcframework/ios-arm64/PayEngineSDK.framework/Modules/PayEngineSDK.swiftmodule/arm64-apple-ios.swiftinterface-e +68 -59
- package/ios/PayEngineSDK.xcframework/ios-arm64/PayEngineSDK.framework/PayEngineSDK +0 -0
- package/ios/PayEngineSDK.xcframework/ios-arm64/PayEngineSDK.framework/VGSCollectSDK_VGSCollectSDK.bundle/Assets.car +0 -0
- package/ios/PayEngineSDK.xcframework/ios-arm64/PayEngineSDK.framework/VGSCollectSDK_VGSCollectSDK.bundle/Info.plist +0 -0
- package/ios/PayEngineSDK.xcframework/ios-arm64_x86_64-simulator/PayEngineSDK.framework/Headers/PayEngineSDK-Swift.h +38 -6
- package/ios/PayEngineSDK.xcframework/ios-arm64_x86_64-simulator/PayEngineSDK.framework/Info.plist +0 -0
- package/ios/PayEngineSDK.xcframework/ios-arm64_x86_64-simulator/PayEngineSDK.framework/Modules/PayEngineSDK.swiftmodule/arm64-apple-ios-simulator.abi.json +1367 -3704
- package/ios/PayEngineSDK.xcframework/ios-arm64_x86_64-simulator/PayEngineSDK.framework/Modules/PayEngineSDK.swiftmodule/arm64-apple-ios-simulator.private.swiftinterface +68 -59
- package/ios/PayEngineSDK.xcframework/ios-arm64_x86_64-simulator/PayEngineSDK.framework/Modules/PayEngineSDK.swiftmodule/arm64-apple-ios-simulator.private.swiftinterface-e +68 -59
- package/ios/PayEngineSDK.xcframework/ios-arm64_x86_64-simulator/PayEngineSDK.framework/Modules/PayEngineSDK.swiftmodule/arm64-apple-ios-simulator.swiftdoc +0 -0
- package/ios/PayEngineSDK.xcframework/ios-arm64_x86_64-simulator/PayEngineSDK.framework/Modules/PayEngineSDK.swiftmodule/arm64-apple-ios-simulator.swiftinterface +68 -59
- package/ios/PayEngineSDK.xcframework/ios-arm64_x86_64-simulator/PayEngineSDK.framework/Modules/PayEngineSDK.swiftmodule/arm64-apple-ios-simulator.swiftinterface-e +68 -59
- package/ios/PayEngineSDK.xcframework/ios-arm64_x86_64-simulator/PayEngineSDK.framework/Modules/PayEngineSDK.swiftmodule/x86_64-apple-ios-simulator.abi.json +1367 -3704
- package/ios/PayEngineSDK.xcframework/ios-arm64_x86_64-simulator/PayEngineSDK.framework/Modules/PayEngineSDK.swiftmodule/x86_64-apple-ios-simulator.private.swiftinterface +68 -59
- package/ios/PayEngineSDK.xcframework/ios-arm64_x86_64-simulator/PayEngineSDK.framework/Modules/PayEngineSDK.swiftmodule/x86_64-apple-ios-simulator.private.swiftinterface-e +68 -59
- package/ios/PayEngineSDK.xcframework/ios-arm64_x86_64-simulator/PayEngineSDK.framework/Modules/PayEngineSDK.swiftmodule/x86_64-apple-ios-simulator.swiftdoc +0 -0
- package/ios/PayEngineSDK.xcframework/ios-arm64_x86_64-simulator/PayEngineSDK.framework/Modules/PayEngineSDK.swiftmodule/x86_64-apple-ios-simulator.swiftinterface +68 -59
- package/ios/PayEngineSDK.xcframework/ios-arm64_x86_64-simulator/PayEngineSDK.framework/Modules/PayEngineSDK.swiftmodule/x86_64-apple-ios-simulator.swiftinterface-e +68 -59
- package/ios/PayEngineSDK.xcframework/ios-arm64_x86_64-simulator/PayEngineSDK.framework/PayEngineSDK +0 -0
- package/ios/PayEngineSDK.xcframework/ios-arm64_x86_64-simulator/PayEngineSDK.framework/VGSCollectSDK_VGSCollectSDK.bundle/Assets.car +0 -0
- package/ios/PayEngineSDK.xcframework/ios-arm64_x86_64-simulator/PayEngineSDK.framework/VGSCollectSDK_VGSCollectSDK.bundle/Info.plist +0 -0
- package/ios/Payengine.xcodeproj/project.xcworkspace/xcuserdata/trinvh.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
- package/ios/Payengine.xcworkspace/xcuserdata/trinvh.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
- package/ios/Sources/Classes/ApplePay/ApplePayUtils.swift +220 -0
- package/ios/Sources/Classes/ApplePay/RNPEApplePayButton.swift +232 -139
- package/ios/Sources/Classes/ApplePay/RNPEApplePayPaymentRequest.swift +83 -61
- package/ios/Sources/Classes/RNPEEventEmitter.swift +1 -1
- package/ios/Sources/Payengine.m +8 -1
- package/lib/commonjs/components/v2/ApplePay/PEApplePayButton.js +52 -3
- package/lib/commonjs/components/v2/ApplePay/PEApplePayButton.js.map +1 -1
- package/lib/commonjs/components/v2/ApplePay/PEApplePayInterfaces.js +40 -0
- package/lib/commonjs/components/v2/ApplePay/PEApplePayInterfaces.js.map +1 -0
- package/lib/commonjs/components/v2/PEPaymentRequest.js +3 -0
- package/lib/commonjs/components/v2/PEPaymentRequest.js.map +1 -1
- package/lib/commonjs/index.js +43 -32
- package/lib/commonjs/index.js.map +1 -1
- package/lib/module/components/v2/ApplePay/PEApplePayButton.js +53 -4
- package/lib/module/components/v2/ApplePay/PEApplePayButton.js.map +1 -1
- package/lib/module/components/v2/ApplePay/PEApplePayInterfaces.js +31 -0
- package/lib/module/components/v2/ApplePay/PEApplePayInterfaces.js.map +1 -0
- package/lib/module/components/v2/PEPaymentRequest.js +3 -0
- package/lib/module/components/v2/PEPaymentRequest.js.map +1 -1
- package/lib/module/index.js +6 -2
- package/lib/module/index.js.map +1 -1
- package/lib/typescript/components/v2/ApplePay/PEApplePayButton.d.ts +38 -2
- package/lib/typescript/components/v2/ApplePay/PEApplePayInterfaces.d.ts +54 -0
- package/lib/typescript/components/v2/PEPaymentRequest.d.ts +8 -4
- package/lib/typescript/index.d.ts +4 -3
- package/package.json +1 -1
- package/src/components/v2/ApplePay/PEApplePayButton.tsx +181 -24
- package/src/components/v2/ApplePay/PEApplePayInterfaces.ts +63 -0
- package/src/components/v2/PEPaymentRequest.ts +12 -4
- package/src/index.tsx +11 -7
- package/android/.gradle/6.1.1/fileHashes/fileHashes.bin +0 -0
- package/android/.gradle/buildOutputCleanup/outputFiles.bin +0 -0
- package/android/.gradle/config.properties +0 -2
- package/android/.idea/caches/deviceStreaming.xml +0 -329
- package/android/.idea/kotlinc.xml +0 -6
- package/android/.idea/migrations.xml +0 -10
- package/android/payment-sdk-debug-1.0.4.aar +0 -0
- package/android/payment-sdk-release-1.0.4.aar +0 -0
- package/android/securefields-1.7.2-debug.aar +0 -0
- package/ios/Payengine.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved +0 -34
- package/ios/Payengine.xcodeproj/project.xcworkspace/xcuserdata/tringuyen.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
- package/ios/Payengine.xcodeproj/xcuserdata/tringuyen.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist +0 -24
- package/ios/Payengine.xcworkspace/xcuserdata/tringuyen.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
- package/ios/Pods/Pods.xcodeproj/xcuserdata/tringuyen.xcuserdatad/xcschemes/Pods-Payengine.xcscheme +0 -58
- package/ios/Pods/Pods.xcodeproj/xcuserdata/tringuyen.xcuserdatad/xcschemes/VGSCollectSDK-CardIcon.xcscheme +0 -58
- package/ios/Pods/Pods.xcodeproj/xcuserdata/tringuyen.xcuserdatad/xcschemes/VGSCollectSDK.xcscheme +0 -58
- package/ios/Pods/Pods.xcodeproj/xcuserdata/tringuyen.xcuserdatad/xcschemes/xcschememanagement.plist +0 -32
- package/lib/commonjs/components/v2/ApplePay/PEApplePayContact.js +0 -2
- package/lib/commonjs/components/v2/ApplePay/PEApplePayContact.js.map +0 -1
- package/lib/module/components/v2/ApplePay/PEApplePayContact.js +0 -2
- package/lib/module/components/v2/ApplePay/PEApplePayContact.js.map +0 -1
- package/lib/typescript/components/v2/ApplePay/PEApplePayContact.d.ts +0 -14
- package/src/components/v2/ApplePay/PEApplePayContact.ts +0 -14
- /package/ios/Payengine.xcodeproj/xcuserdata/{tringuyen.xcuserdatad → trinvh.xcuserdatad}/xcschemes/xcschememanagement.plist +0 -0
|
@@ -10,73 +10,95 @@ import PassKit
|
|
|
10
10
|
import PayEngineSDK
|
|
11
11
|
|
|
12
12
|
public struct RNPEApplePayPaymentRequest: Codable {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
13
|
+
var paymentAmount: Double
|
|
14
|
+
var currencyCode: String?
|
|
15
|
+
var paymentItems: [RNPEApplePayPaymentSummaryItem]
|
|
16
|
+
var requiredBillingContactFields: Set<RNPEContactField>? = []
|
|
17
|
+
var requiredShippingContactFields: Set<RNPEContactField>? = []
|
|
18
|
+
var shippingMethods: [RNPEApplePayShippingMethod]? = []
|
|
19
|
+
|
|
20
|
+
init(
|
|
21
|
+
paymentAmount: Double,
|
|
22
|
+
currencyCode: String? = "USD",
|
|
23
|
+
paymentItems: [RNPEApplePayPaymentSummaryItem],
|
|
24
|
+
requiredBillingContactFields: Set<RNPEContactField> = [],
|
|
25
|
+
requiredShippingContactFields: Set<RNPEContactField> = [],
|
|
26
|
+
shippingMethods: [RNPEApplePayShippingMethod] = []
|
|
27
|
+
) {
|
|
28
|
+
self.paymentAmount = paymentAmount
|
|
29
|
+
self.currencyCode = currencyCode ?? "USD"
|
|
30
|
+
self.paymentItems = paymentItems
|
|
31
|
+
self.requiredBillingContactFields = requiredBillingContactFields
|
|
32
|
+
self.requiredShippingContactFields = requiredShippingContactFields
|
|
33
|
+
self.shippingMethods = shippingMethods
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
func toNative() -> ApplePayPaymentRequest {
|
|
37
|
+
let request = ApplePayPaymentRequest()
|
|
38
|
+
request.build(
|
|
39
|
+
paymentItems: self.paymentItems.map { $0.toNative() },
|
|
40
|
+
paymentAmount: self.paymentAmount,
|
|
41
|
+
currencyCode: self.currencyCode ?? "USD",
|
|
42
|
+
requiredBillingContactFields: Set(self.requiredBillingContactFields?.map { $0.toNative() } ?? []),
|
|
43
|
+
requiredShippingContactFields: Set(self.requiredShippingContactFields?.map { $0.toNative() } ?? []),
|
|
44
|
+
shippingMethods: self.shippingMethods?.map { $0.toNative() } ?? []
|
|
45
|
+
)
|
|
46
|
+
return request
|
|
47
|
+
}
|
|
44
48
|
}
|
|
45
49
|
|
|
46
50
|
public enum RNPEContactField: String, Codable {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
}
|
|
51
|
+
case postalAddress = "postalAddress"
|
|
52
|
+
case emailAddress = "emailAddress"
|
|
53
|
+
case phoneNumber = "phoneNumber"
|
|
54
|
+
case name = "name"
|
|
55
|
+
case phoneticName = "phoneticName"
|
|
56
|
+
|
|
57
|
+
func toNative() -> PKContactField {
|
|
58
|
+
switch (self) {
|
|
59
|
+
case .postalAddress:
|
|
60
|
+
return PKContactField.postalAddress;
|
|
61
|
+
case .emailAddress:
|
|
62
|
+
return PKContactField.emailAddress;
|
|
63
|
+
case .phoneNumber:
|
|
64
|
+
return PKContactField.phoneNumber;
|
|
65
|
+
case .name:
|
|
66
|
+
return PKContactField.name;
|
|
67
|
+
case .phoneticName:
|
|
68
|
+
return PKContactField.phoneticName;
|
|
66
69
|
}
|
|
70
|
+
}
|
|
67
71
|
}
|
|
68
72
|
|
|
69
73
|
public struct RNPEApplePayPaymentSummaryItem: Codable {
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
74
|
+
var amount: Double
|
|
75
|
+
var label: String
|
|
76
|
+
|
|
77
|
+
init(amount: Double, label: String) {
|
|
78
|
+
self.amount = amount
|
|
79
|
+
self.label = label
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
func toNative() -> PKPaymentSummaryItem {
|
|
83
|
+
return PKPaymentSummaryItem(label: self.label, amount: NSDecimalNumber(value: self.amount))
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
public struct RNPEApplePayShippingMethod: Codable {
|
|
88
|
+
var identifier: String
|
|
89
|
+
var amount: Double
|
|
90
|
+
var label: String
|
|
91
|
+
|
|
92
|
+
init(identifier: String, amount: Double, label: String) {
|
|
93
|
+
self.identifier = identifier
|
|
94
|
+
self.amount = amount
|
|
95
|
+
self.label = label
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
func toNative() -> PKShippingMethod {
|
|
99
|
+
let shippingMethod = PKShippingMethod(label: self.label, amount: NSDecimalNumber(value: self.amount))
|
|
100
|
+
shippingMethod.identifier = self.identifier
|
|
101
|
+
return shippingMethod
|
|
102
|
+
}
|
|
81
103
|
}
|
|
82
104
|
|
|
@@ -20,7 +20,7 @@ open class RNPEEventEmitter:RCTEventEmitter{
|
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
open override func supportedEvents() -> [String] {
|
|
23
|
-
["onReady", "onSizeChanges", "onCardRespond", "onBankAccountRespond"]
|
|
23
|
+
["onReady", "onSizeChanges", "onCardRespond", "onBankAccountRespond", "onUpdatePaymentSheetResult"]
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
@objc public override static func requiresMainQueueSetup() -> Bool {
|
package/ios/Sources/Payengine.m
CHANGED
|
@@ -50,7 +50,14 @@ RCT_EXPORT_VIEW_PROPERTY(onPmSheetDidDismiss, RCTBubblingEventBlock)
|
|
|
50
50
|
RCT_EXPORT_VIEW_PROPERTY(onPmTokenDidReturn, RCTBubblingEventBlock)
|
|
51
51
|
RCT_EXPORT_VIEW_PROPERTY(onPmTokenNotAvailable, RCTBubblingEventBlock)
|
|
52
52
|
RCT_EXPORT_VIEW_PROPERTY(onPmError, RCTBubblingEventBlock)
|
|
53
|
-
|
|
53
|
+
RCT_EXPORT_VIEW_PROPERTY(onPaymentMethodSelected, RCTBubblingEventBlock)
|
|
54
|
+
RCT_EXPORT_VIEW_PROPERTY(onShippingContactSelected, RCTBubblingEventBlock)
|
|
55
|
+
RCT_EXPORT_VIEW_PROPERTY(onShippingMethodSelected, RCTBubblingEventBlock)
|
|
56
|
+
|
|
57
|
+
RCT_EXTERN_METHOD(updatePaymentSheet:(nonnull NSNumber *)node
|
|
58
|
+
summaryItems:(NSArray *)summaryItems
|
|
59
|
+
shippingMethods:(NSArray *)shippingMethods
|
|
60
|
+
errors:(NSArray *)errors)
|
|
54
61
|
@end
|
|
55
62
|
|
|
56
63
|
@interface RCT_EXTERN_MODULE(RNPEEventEmitter, RCTEventEmitter)
|
|
@@ -13,9 +13,54 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
|
|
|
13
13
|
|
|
14
14
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
15
15
|
|
|
16
|
-
const
|
|
16
|
+
const {
|
|
17
|
+
RNPEEventEmitter
|
|
18
|
+
} = _reactNative.NativeModules;
|
|
19
|
+
const peEventEmitter = new _reactNative.NativeEventEmitter(RNPEEventEmitter);
|
|
20
|
+
const COMPONENT_NAME = 'RNPEApplePayButton';
|
|
21
|
+
const RNPEApplePayButton = (0, _reactNative.requireNativeComponent)(COMPONENT_NAME); // @ts-ignore
|
|
22
|
+
|
|
23
|
+
const RNPEApplePayButtonManager = _reactNative.UIManager[COMPONENT_NAME];
|
|
17
24
|
const PEApplePayButton = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
18
|
-
|
|
25
|
+
const buttonRef = React.useRef();
|
|
26
|
+
React.useImperativeHandle(ref, () => ({
|
|
27
|
+
updatePaymentSheet: async (summaryItems, shippingMethods, errors) => {
|
|
28
|
+
return new Promise((resolve, reject) => {
|
|
29
|
+
const listener = peEventEmitter.addListener('onUpdatePaymentSheetResult', args => {
|
|
30
|
+
listener.remove();
|
|
31
|
+
const {
|
|
32
|
+
error
|
|
33
|
+
} = args;
|
|
34
|
+
|
|
35
|
+
if (error) {
|
|
36
|
+
reject(new Error(error));
|
|
37
|
+
} else {
|
|
38
|
+
resolve(true);
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
callNativeMethod('updatePaymentSheet', [summaryItems, shippingMethods, errors]);
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
}));
|
|
45
|
+
React.useEffect(() => {
|
|
46
|
+
const listener = peEventEmitter.addListener('onUpdatePaymentSheetResult', args => {
|
|
47
|
+
console.log('Received event onUpdatePaymentSheetResult', args);
|
|
48
|
+
});
|
|
49
|
+
return () => {
|
|
50
|
+
listener.remove();
|
|
51
|
+
};
|
|
52
|
+
}, []);
|
|
53
|
+
const callNativeMethod = React.useCallback(function (methodName) {
|
|
54
|
+
let params = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
|
|
55
|
+
const viewId = (0, _reactNative.findNodeHandle)(buttonRef.current);
|
|
56
|
+
let commandId = RNPEApplePayButtonManager.Commands[methodName].toString();
|
|
57
|
+
|
|
58
|
+
if (_reactNative.Platform.OS === 'ios') {
|
|
59
|
+
commandId = Number(commandId);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
_reactNative.UIManager.dispatchViewManagerCommand(viewId, commandId, params);
|
|
63
|
+
}, [buttonRef.current]);
|
|
19
64
|
|
|
20
65
|
const pmError = event => {
|
|
21
66
|
if (props.onPaymentFailed) {
|
|
@@ -50,6 +95,7 @@ const PEApplePayButton = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
|
50
95
|
}
|
|
51
96
|
|
|
52
97
|
return /*#__PURE__*/React.createElement(RNPEApplePayButton, {
|
|
98
|
+
ref: buttonRef,
|
|
53
99
|
style: {
|
|
54
100
|
height: 32,
|
|
55
101
|
width: '100%',
|
|
@@ -60,7 +106,10 @@ const PEApplePayButton = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
|
60
106
|
}),
|
|
61
107
|
onPmError: pmError,
|
|
62
108
|
onPmTokenDidReturn: pmTokenDidReturn,
|
|
63
|
-
onPmSheetDidDismiss: pmSheetDidDismiss
|
|
109
|
+
onPmSheetDidDismiss: pmSheetDidDismiss,
|
|
110
|
+
onPaymentMethodSelected: props.onPaymentMethodSelected,
|
|
111
|
+
onShippingContactSelected: props.onShippingContactSelected,
|
|
112
|
+
onShippingMethodSelected: props.onShippingMethodSelected
|
|
64
113
|
});
|
|
65
114
|
});
|
|
66
115
|
exports.PEApplePayButton = PEApplePayButton;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["RNPEApplePayButton","requireNativeComponent","PEApplePayButton","React","forwardRef","props","ref","useImperativeHandle","pmError","event","onPaymentFailed","Error","nativeEvent","error","pmTokenDidReturn","onTokenDidReturn","token","metadata","metadataString","billingContact","billingContactString","shippingContact","shippingContactString","console","log","JSON","parse","undefined","pmSheetDidDismiss","onPaymentSheetDismissed","Platform","OS","height","width","style","stringify","paymentRequest","platformOptions"],"sources":["PEApplePayButton.tsx"],"sourcesContent":["\nimport * as React from 'react';\nimport { Platform, requireNativeComponent, Text, ViewProps } from 'react-native';\nimport type { PEPaymentRequest } from '../PEPaymentRequest';\nimport type { PEApplePayContact } from './PEApplePayContact';\n\n\nconst RNPEApplePayButton = requireNativeComponent<NativePEApplePayViewProps>('RNPEApplePayButton');\n\ntype NativePEApplePayEvent = {\n nativeEvent: {\n error?: string;\n token?: string;\n metadata?: any;\n billingContact?: string;\n shippingContact?: string;\n };\n};\n\ninterface NativePEApplePayViewProps extends ViewProps {\n paymentRequest: string;\n onPmSheetDidDismiss: (event: NativePEApplePayEvent) => void;\n onPmTokenDidReturn: (event: NativePEApplePayEvent) => void;\n onPmError: (event: NativePEApplePayEvent) => void;\n}\n\nexport interface PEApplePayButtonProps extends ViewProps {\n paymentRequest: PEPaymentRequest;\n onTokenDidReturn?: (token: string, metadata?: any, billingContact?: PEApplePayContact, shippingContact?: PEApplePayContact) => void;\n onPaymentSheetDismissed?: () => void;\n onPaymentFailed?: (error: Error) => void;\n}\n\nexport interface PEApplePayButtonMethods {\n \n}\n\n\nexport const PEApplePayButton = React.forwardRef<\nPEApplePayButtonMethods,\n PEApplePayButtonProps\n>((props, ref) => {\n\n React.useImperativeHandle(ref, () => ({\n }));\n\n const pmError = (event: NativePEApplePayEvent) => {\n if (props.onPaymentFailed) {\n props.onPaymentFailed(new Error(event.nativeEvent.error));\n }\n };\n\n const pmTokenDidReturn = (event: NativePEApplePayEvent) => {\n if (props.onTokenDidReturn) {\n const { token, metadata: metadataString, billingContact: billingContactString, shippingContact: shippingContactString } = event.nativeEvent;\n console.log('ON token', token, metadataString, billingContactString, shippingContactString)\n const metadata = metadataString ? JSON.parse(metadataString) : null;\n const billingContact = billingContactString ? JSON.parse(billingContactString) as PEApplePayContact : null;\n const shippingContact = shippingContactString ? JSON.parse(shippingContactString) as PEApplePayContact : null;\n\n props.onTokenDidReturn(token!, metadata, billingContact ?? undefined, shippingContact ?? undefined);\n }\n };\n\n const pmSheetDidDismiss = () => {\n if (props.onPaymentSheetDismissed) {\n props.onPaymentSheetDismissed();\n }\n }\n\n if (Platform.OS !== 'ios') {\n return <Text>Apple Pay is not supported on this platform</Text>\n }\n \n return (\n <RNPEApplePayButton \n style={{ height: 32, width: '100%', ...(props.style as object) }} \n paymentRequest={JSON.stringify({\n ...props.paymentRequest,\n ...props.paymentRequest.platformOptions\n })} \n onPmError={pmError} \n onPmTokenDidReturn={pmTokenDidReturn} \n onPmSheetDidDismiss={pmSheetDidDismiss} \n />\n );\n});\n"],"mappings":";;;;;;;AACA;;AACA;;;;;;AAKA,MAAMA,kBAAkB,GAAG,IAAAC,mCAAA,EAAkD,oBAAlD,CAA3B;AA+BO,MAAMC,gBAAgB,gBAAGC,KAAK,CAACC,UAAN,CAG9B,CAACC,KAAD,EAAQC,GAAR,KAAgB;EAEhBH,KAAK,CAACI,mBAAN,CAA0BD,GAA1B,EAA+B,OAAO,EAAP,CAA/B;;EAGA,MAAME,OAAO,GAAIC,KAAD,IAAkC;IAChD,IAAIJ,KAAK,CAACK,eAAV,EAA2B;MACzBL,KAAK,CAACK,eAAN,CAAsB,IAAIC,KAAJ,CAAUF,KAAK,CAACG,WAAN,CAAkBC,KAA5B,CAAtB;IACD;EACF,CAJD;;EAMA,MAAMC,gBAAgB,GAAIL,KAAD,IAAkC;IACzD,IAAIJ,KAAK,CAACU,gBAAV,EAA4B;MAC1B,MAAM;QAAEC,KAAF;QAASC,QAAQ,EAAEC,cAAnB;QAAmCC,cAAc,EAAEC,oBAAnD;QAAyEC,eAAe,EAAEC;MAA1F,IAAoHb,KAAK,CAACG,WAAhI;MACAW,OAAO,CAACC,GAAR,CAAY,UAAZ,EAAwBR,KAAxB,EAA+BE,cAA/B,EAA+CE,oBAA/C,EAAqEE,qBAArE;MACA,MAAML,QAAQ,GAAGC,cAAc,GAAGO,IAAI,CAACC,KAAL,CAAWR,cAAX,CAAH,GAAgC,IAA/D;MACA,MAAMC,cAAc,GAAGC,oBAAoB,GAAGK,IAAI,CAACC,KAAL,CAAWN,oBAAX,CAAH,GAA2D,IAAtG;MACA,MAAMC,eAAe,GAAGC,qBAAqB,GAAGG,IAAI,CAACC,KAAL,CAAWJ,qBAAX,CAAH,GAA4D,IAAzG;MAEAjB,KAAK,CAACU,gBAAN,CAAuBC,KAAvB,EAA+BC,QAA/B,EAAyCE,cAAc,IAAIQ,SAA3D,EAAsEN,eAAe,IAAIM,SAAzF;IACD;EACF,CAVD;;EAYA,MAAMC,iBAAiB,GAAG,MAAM;IAC9B,IAAIvB,KAAK,CAACwB,uBAAV,EAAmC;MACjCxB,KAAK,CAACwB,uBAAN;IACD;EACF,CAJD;;EAMA,IAAIC,qBAAA,CAASC,EAAT,KAAgB,KAApB,EAA2B;IACzB,oBAAO,oBAAC,iBAAD,sDAAP;EACD;;EAED,oBACE,oBAAC,kBAAD;IACE,KAAK,EAAE;MAAEC,MAAM,EAAE,EAAV;MAAcC,KAAK,EAAE,MAArB;MAA6B,GAAI5B,KAAK,CAAC6B;IAAvC,CADT;IAEE,cAAc,EAAET,IAAI,CAACU,SAAL,CAAe,EAC7B,GAAG9B,KAAK,CAAC+B,cADoB;MAE7B,GAAG/B,KAAK,CAAC+B,cAAN,CAAqBC;IAFK,CAAf,CAFlB;IAME,SAAS,EAAE7B,OANb;IAOE,kBAAkB,EAAEM,gBAPtB;IAQE,mBAAmB,EAAEc;EARvB,EADF;AAYD,CAhD+B,CAAzB"}
|
|
1
|
+
{"version":3,"names":["RNPEEventEmitter","NativeModules","peEventEmitter","NativeEventEmitter","COMPONENT_NAME","RNPEApplePayButton","requireNativeComponent","RNPEApplePayButtonManager","UIManager","PEApplePayButton","React","forwardRef","props","ref","buttonRef","useRef","useImperativeHandle","updatePaymentSheet","summaryItems","shippingMethods","errors","Promise","resolve","reject","listener","addListener","args","remove","error","Error","callNativeMethod","useEffect","console","log","useCallback","methodName","params","viewId","findNodeHandle","current","commandId","Commands","toString","Platform","OS","Number","dispatchViewManagerCommand","pmError","event","onPaymentFailed","nativeEvent","pmTokenDidReturn","onTokenDidReturn","token","metadata","metadataString","billingContact","billingContactString","shippingContact","shippingContactString","JSON","parse","undefined","pmSheetDidDismiss","onPaymentSheetDismissed","height","width","style","stringify","paymentRequest","platformOptions","onPaymentMethodSelected","onShippingContactSelected","onShippingMethodSelected"],"sources":["PEApplePayButton.tsx"],"sourcesContent":["import * as React from 'react';\nimport {\n findNodeHandle,\n NativeEventEmitter,\n NativeModules,\n Platform,\n requireNativeComponent,\n Text,\n UIManager,\n ViewProps,\n} from 'react-native';\nimport type { PEPaymentRequest, PESummaryItem } from '../PEPaymentRequest';\nimport type {\n PEApplePayContact,\n PEApplePayPaymentMethod,\n PEApplePaySheetError,\n PEApplePayShippingMethod,\n} from './PEApplePayInterfaces';\n\nconst { RNPEEventEmitter } = NativeModules;\n\nconst peEventEmitter = new NativeEventEmitter(RNPEEventEmitter);\n\nconst COMPONENT_NAME = 'RNPEApplePayButton';\nconst RNPEApplePayButton =\n requireNativeComponent<NativePEApplePayViewProps>(COMPONENT_NAME);\n\n// @ts-ignore\nconst RNPEApplePayButtonManager = UIManager[COMPONENT_NAME];\n\ntype NativePEApplePayEvent = {\n nativeEvent: {\n error?: string;\n token?: string;\n metadata?: any;\n billingContact?: string;\n shippingContact?: string;\n paymentMethod?: string;\n contact?: string;\n shippingMethod?: string;\n };\n};\n\ninterface NativePEApplePayViewProps extends ViewProps {\n paymentRequest: string;\n onPmSheetDidDismiss: (event: NativePEApplePayEvent) => void;\n onPmTokenDidReturn: (event: NativePEApplePayEvent) => void;\n onPmError: (event: NativePEApplePayEvent) => void;\n onPaymentMethodSelected?: (event: {\n nativeEvent: {\n paymentMethod: PEApplePayPaymentMethod;\n };\n }) => void;\n onShippingContactSelected?: (event: {\n nativeEvent: {\n contact: PEApplePayContact;\n };\n }) => void;\n onShippingMethodSelected?: (event: {\n nativeEvent: {\n shippingMethod: PEApplePayShippingMethod;\n };\n }) => void;\n}\n\nexport interface PEApplePayButtonProps extends ViewProps {\n paymentRequest: PEPaymentRequest;\n onTokenDidReturn?: (\n token: string,\n metadata?: any,\n billingContact?: PEApplePayContact,\n shippingContact?: PEApplePayContact\n ) => void;\n onPaymentSheetDismissed?: () => void;\n onPaymentFailed?: (error: Error) => void;\n /**\n * This callback is triggered whenever the payment method changes in the Apple Pay sheet.\n * You MUST update the Apple Pay sheet in your callback using the updatePaymentSheet function,\n * otherwise the Apple Pay sheet will hang and the payment flow will automatically cancel.\n */\n onPaymentMethodSelected?: (event: {\n nativeEvent: {\n paymentMethod: PEApplePayPaymentMethod;\n };\n }) => void;\n /**\n * This callback is triggered whenever the user selects a shipping method in the Apple Pay sheet.\n * You MUST update the Apple Pay sheet in your callback using the updatePaymentSheet function,\n * otherwise the Apple Pay sheet will hang and the payment flow will automatically cancel.\n */\n onShippingContactSelected?: (event: {\n nativeEvent: {\n contact: PEApplePayContact;\n };\n }) => void;\n /**\n * This callback is triggered whenever the user selects a shipping contact in the Apple Pay sheet.\n * You MUST update the Apple Pay sheet in your callback using the updatePaymentSheet function,\n * otherwise the Apple Pay sheet will hang and the payment flow will automatically cancel.\n */\n onShippingMethodSelected?: (event: {\n nativeEvent: {\n shippingMethod: PEApplePayShippingMethod;\n };\n }) => void;\n}\n\nexport interface PEApplePayButtonMethods {\n /**\n * This method must be called after either onPaymentMethodSelected, onShippingContactSelected or\n * onShippingMethodSelected callbacks are triggered.\n * `shippingMethods` and `errors` are only applicable for onShippingContactSelected callback\n */\n updatePaymentSheet: (\n summaryItems: PESummaryItem[],\n shippingMethods: PEApplePayShippingMethod[],\n errors: PEApplePaySheetError[]\n ) => Promise<boolean>;\n}\n\nexport const PEApplePayButton = React.forwardRef<\n PEApplePayButtonMethods,\n PEApplePayButtonProps\n>((props, ref) => {\n const buttonRef = React.useRef<any>();\n\n React.useImperativeHandle(ref, () => ({\n updatePaymentSheet: async (\n summaryItems: PESummaryItem[],\n shippingMethods: PEApplePayShippingMethod[],\n errors: PEApplePaySheetError[]\n ): Promise<boolean> => {\n return new Promise((resolve, reject) => {\n const listener = peEventEmitter.addListener(\n 'onUpdatePaymentSheetResult',\n (args) => {\n listener.remove();\n\n const { error } = args;\n if (error) {\n reject(new Error(error));\n } else {\n resolve(true);\n }\n }\n );\n callNativeMethod('updatePaymentSheet', [\n summaryItems,\n shippingMethods,\n errors,\n ]);\n });\n },\n }));\n\n React.useEffect(() => {\n const listener = peEventEmitter.addListener(\n 'onUpdatePaymentSheetResult',\n (args) => {\n console.log('Received event onUpdatePaymentSheetResult', args);\n }\n );\n return () => {\n listener.remove();\n };\n }, []);\n\n const callNativeMethod = React.useCallback(\n (methodName: string, params: any[] = []) => {\n const viewId = findNodeHandle(buttonRef.current);\n let commandId = RNPEApplePayButtonManager.Commands[methodName].toString();\n if (Platform.OS === 'ios') {\n commandId = Number(commandId);\n }\n UIManager.dispatchViewManagerCommand(viewId, commandId, params);\n },\n [buttonRef.current]\n );\n\n const pmError = (event: NativePEApplePayEvent) => {\n if (props.onPaymentFailed) {\n props.onPaymentFailed(new Error(event.nativeEvent.error));\n }\n };\n\n const pmTokenDidReturn = (event: NativePEApplePayEvent) => {\n if (props.onTokenDidReturn) {\n const {\n token,\n metadata: metadataString,\n billingContact: billingContactString,\n shippingContact: shippingContactString,\n } = event.nativeEvent;\n console.log(\n 'ON token',\n token,\n metadataString,\n billingContactString,\n shippingContactString\n );\n const metadata = metadataString ? JSON.parse(metadataString) : null;\n const billingContact = billingContactString\n ? (JSON.parse(billingContactString) as PEApplePayContact)\n : null;\n const shippingContact = shippingContactString\n ? (JSON.parse(shippingContactString) as PEApplePayContact)\n : null;\n\n props.onTokenDidReturn(\n token!,\n metadata,\n billingContact ?? undefined,\n shippingContact ?? undefined\n );\n }\n };\n\n const pmSheetDidDismiss = () => {\n if (props.onPaymentSheetDismissed) {\n props.onPaymentSheetDismissed();\n }\n };\n\n if (Platform.OS !== 'ios') {\n return <Text>Apple Pay is not supported on this platform</Text>;\n }\n\n return (\n <RNPEApplePayButton\n ref={buttonRef}\n style={{ height: 32, width: '100%', ...(props.style as object) }}\n paymentRequest={JSON.stringify({\n ...props.paymentRequest,\n ...props.paymentRequest.platformOptions,\n })}\n onPmError={pmError}\n onPmTokenDidReturn={pmTokenDidReturn}\n onPmSheetDidDismiss={pmSheetDidDismiss}\n onPaymentMethodSelected={props.onPaymentMethodSelected}\n onShippingContactSelected={props.onShippingContactSelected}\n onShippingMethodSelected={props.onShippingMethodSelected}\n />\n );\n});\n"],"mappings":"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"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.PEApplePaySheetErrorType = exports.PEApplePayPaymentMethodType = exports.PEApplePayInvalidShippingField = void 0;
|
|
7
|
+
let PEApplePayPaymentMethodType;
|
|
8
|
+
exports.PEApplePayPaymentMethodType = PEApplePayPaymentMethodType;
|
|
9
|
+
|
|
10
|
+
(function (PEApplePayPaymentMethodType) {
|
|
11
|
+
PEApplePayPaymentMethodType[PEApplePayPaymentMethodType["unknown"] = 0] = "unknown";
|
|
12
|
+
PEApplePayPaymentMethodType[PEApplePayPaymentMethodType["debit"] = 1] = "debit";
|
|
13
|
+
PEApplePayPaymentMethodType[PEApplePayPaymentMethodType["credit"] = 2] = "credit";
|
|
14
|
+
PEApplePayPaymentMethodType[PEApplePayPaymentMethodType["prepaid"] = 3] = "prepaid";
|
|
15
|
+
PEApplePayPaymentMethodType[PEApplePayPaymentMethodType["store"] = 4] = "store";
|
|
16
|
+
PEApplePayPaymentMethodType[PEApplePayPaymentMethodType["eMoney"] = 5] = "eMoney";
|
|
17
|
+
})(PEApplePayPaymentMethodType || (exports.PEApplePayPaymentMethodType = PEApplePayPaymentMethodType = {}));
|
|
18
|
+
|
|
19
|
+
let PEApplePaySheetErrorType;
|
|
20
|
+
exports.PEApplePaySheetErrorType = PEApplePaySheetErrorType;
|
|
21
|
+
|
|
22
|
+
(function (PEApplePaySheetErrorType) {
|
|
23
|
+
PEApplePaySheetErrorType["InvalidShippingAddress"] = "InvalidShippingAddress";
|
|
24
|
+
PEApplePaySheetErrorType["UnserviceableShippingAddress"] = "UnserviceableShippingAddress";
|
|
25
|
+
})(PEApplePaySheetErrorType || (exports.PEApplePaySheetErrorType = PEApplePaySheetErrorType = {}));
|
|
26
|
+
|
|
27
|
+
let PEApplePayInvalidShippingField;
|
|
28
|
+
exports.PEApplePayInvalidShippingField = PEApplePayInvalidShippingField;
|
|
29
|
+
|
|
30
|
+
(function (PEApplePayInvalidShippingField) {
|
|
31
|
+
PEApplePayInvalidShippingField["Street"] = "street";
|
|
32
|
+
PEApplePayInvalidShippingField["City"] = "city";
|
|
33
|
+
PEApplePayInvalidShippingField["SubAdministrativeArea"] = "subAdministrativeArea";
|
|
34
|
+
PEApplePayInvalidShippingField["State"] = "state";
|
|
35
|
+
PEApplePayInvalidShippingField["PostalCode"] = "postalCode";
|
|
36
|
+
PEApplePayInvalidShippingField["Country"] = "country";
|
|
37
|
+
PEApplePayInvalidShippingField["CountryCode"] = "countryCode";
|
|
38
|
+
PEApplePayInvalidShippingField["SubLocality"] = "subLocality";
|
|
39
|
+
})(PEApplePayInvalidShippingField || (exports.PEApplePayInvalidShippingField = PEApplePayInvalidShippingField = {}));
|
|
40
|
+
//# sourceMappingURL=PEApplePayInterfaces.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["PEApplePayPaymentMethodType","PEApplePaySheetErrorType","PEApplePayInvalidShippingField"],"sources":["PEApplePayInterfaces.ts"],"sourcesContent":["export interface PEApplePayContact {\n givenName?: string;\n familyName?: string;\n addressLines?: string[];\n locality?: string;\n administrativeArea?: string;\n postalCode?: string;\n country?: string;\n countryCode?: string;\n subAdministrativeArea?: string;\n subLocality?: string;\n emailAddress?: string;\n phoneNumber?: string;\n}\n\nexport interface PEApplePayPaymentMethod {\n displayName?: string;\n network?: string;\n type: PEApplePayPaymentMethodType;\n}\n\nexport enum PEApplePayPaymentMethodType {\n unknown = 0,\n debit = 1,\n credit = 2,\n prepaid = 3,\n store = 4,\n eMoney = 5\n}\n\nexport interface PEApplePayShippingMethod {\n identifier: string;\n amount: number;\n label: string;\n}\n\nexport type PEApplePaySheetError =\n | {\n errorType: PEApplePaySheetErrorType.InvalidShippingAddress;\n field: PEApplePayInvalidShippingField;\n message?: string;\n }\n | {\n errorType:\n | PEApplePaySheetErrorType.UnserviceableShippingAddress\n message?: string;\n };\n\nexport enum PEApplePaySheetErrorType {\n InvalidShippingAddress = 'InvalidShippingAddress',\n UnserviceableShippingAddress = 'UnserviceableShippingAddress',\n}\n\nexport enum PEApplePayInvalidShippingField {\n Street = 'street',\n City = 'city',\n SubAdministrativeArea = 'subAdministrativeArea',\n State = 'state',\n PostalCode = 'postalCode',\n Country = 'country',\n CountryCode = 'countryCode',\n SubLocality = 'subLocality',\n}\n"],"mappings":";;;;;;IAqBYA,2B;;;WAAAA,2B;EAAAA,2B,CAAAA,2B;EAAAA,2B,CAAAA,2B;EAAAA,2B,CAAAA,2B;EAAAA,2B,CAAAA,2B;EAAAA,2B,CAAAA,2B;EAAAA,2B,CAAAA,2B;GAAAA,2B,2CAAAA,2B;;IA2BAC,wB;;;WAAAA,wB;EAAAA,wB;EAAAA,wB;GAAAA,wB,wCAAAA,wB;;IAKAC,8B;;;WAAAA,8B;EAAAA,8B;EAAAA,8B;EAAAA,8B;EAAAA,8B;EAAAA,8B;EAAAA,8B;EAAAA,8B;EAAAA,8B;GAAAA,8B,8CAAAA,8B"}
|
|
@@ -50,8 +50,11 @@ class RNPEApplePayOptions {
|
|
|
50
50
|
|
|
51
51
|
_defineProperty(this, "requiredShippingContactFields", []);
|
|
52
52
|
|
|
53
|
+
_defineProperty(this, "shippingMethods", []);
|
|
54
|
+
|
|
53
55
|
this.requiredBillingContactFields = params.requiredBillingContactFields;
|
|
54
56
|
this.requiredShippingContactFields = params.requiredShippingContactFields;
|
|
57
|
+
this.shippingMethods = params.shippingMethods;
|
|
55
58
|
}
|
|
56
59
|
|
|
57
60
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["PEPaymentRequest","constructor","merchantId","paymentAmount","currencyCode","paymentItems","platformOptions","RNPEContactField","RNPEApplePayOptions","params","requiredBillingContactFields","requiredShippingContactFields","RNPEGooglePayBillingAddressParameters","RNPEGooglePayShippingAddressParameters","undefined","RNPEGooglePayOptions","billingAddressRequired","billingAddressParameters","shippingAddressRequired","shippingAddressParameters"],"sources":["PEPaymentRequest.ts"],"sourcesContent":["type RNPEPaymentOptions = RNPEGooglePayOptions | RNPEApplePayOptions;\n\nexport class PEPaymentRequest {\n merchantId: string;\n paymentAmount: number;\n currencyCode?: 'USD' | 'CAD' = 'USD';\n paymentItems?:
|
|
1
|
+
{"version":3,"names":["PEPaymentRequest","constructor","merchantId","paymentAmount","currencyCode","paymentItems","platformOptions","RNPEContactField","RNPEApplePayOptions","params","requiredBillingContactFields","requiredShippingContactFields","shippingMethods","RNPEGooglePayBillingAddressParameters","RNPEGooglePayShippingAddressParameters","undefined","RNPEGooglePayOptions","billingAddressRequired","billingAddressParameters","shippingAddressRequired","shippingAddressParameters"],"sources":["PEPaymentRequest.ts"],"sourcesContent":["import type { PEApplePayShippingMethod } from \"./ApplePay/PEApplePayInterfaces\";\n\ntype RNPEPaymentOptions = RNPEGooglePayOptions | RNPEApplePayOptions;\n\nexport class PEPaymentRequest {\n merchantId: string;\n paymentAmount: number;\n currencyCode?: 'USD' | 'CAD' = 'USD';\n paymentItems?: PESummaryItem[] = [];\n platformOptions?: RNPEPaymentOptions;\n\n constructor(\n merchantId: string,\n paymentAmount: number,\n currencyCode: 'USD' | 'CAD' = 'USD',\n paymentItems: {\n amount: number;\n label: string;\n }[] = [],\n platformOptions?: RNPEPaymentOptions\n ) {\n this.merchantId = merchantId;\n this.paymentAmount = paymentAmount;\n this.currencyCode = currencyCode;\n this.paymentItems = paymentItems;\n this.platformOptions = platformOptions;\n }\n}\n\nexport interface PESummaryItem {\n amount: number;\n label: string;\n}\n\nexport enum RNPEContactField {\n name = 'name',\n postalAddress = 'postalAddress',\n emailAddress = 'emailAddress',\n phoneNumber = 'phoneNumber',\n phoneticName = 'phoneticName',\n}\n\n\nexport class RNPEApplePayOptions {\n requiredBillingContactFields?: RNPEContactField[] = [];\n requiredShippingContactFields?: RNPEContactField[] = [];\n shippingMethods?: PEApplePayShippingMethod[] = [];\n\n constructor(params: {\n requiredBillingContactFields: RNPEContactField[];\n requiredShippingContactFields: RNPEContactField[];\n shippingMethods: PEApplePayShippingMethod[];\n }) {\n this.requiredBillingContactFields = params.requiredBillingContactFields;\n this.requiredShippingContactFields = params.requiredShippingContactFields;\n this.shippingMethods = params.shippingMethods\n }\n}\n\nexport class RNPEGooglePayBillingAddressParameters {\n format: 'FULL' | 'MIN' = 'FULL'\n phoneNumberRequired: boolean = false\n}\n\nexport class RNPEGooglePayShippingAddressParameters {\n allowedCountryCodes?: string[] = undefined\n phoneNumberRequired: boolean = false\n}\n\nexport class RNPEGooglePayOptions {\n billingAddressRequired: boolean;\n billingAddressParameters?: any;\n shippingAddressRequired: boolean;\n shippingAddressParameters?: any;\n\n constructor(params: {\n billingAddressRequired: boolean;\n shippingAddressRequired: boolean;\n billingAddressParameters?: RNPEGooglePayBillingAddressParameters;\n shippingAddressParameters?: RNPEGooglePayShippingAddressParameters;\n }) {\n this.billingAddressRequired = params.billingAddressRequired;\n this.billingAddressParameters = params.billingAddressParameters;\n this.shippingAddressRequired = params.shippingAddressRequired;\n this.shippingAddressParameters = params.shippingAddressParameters;\n }\n}\n"],"mappings":";;;;;;;;;AAIO,MAAMA,gBAAN,CAAuB;EAO5BC,WAAW,CACTC,UADS,EAETC,aAFS,EAST;IAAA,IANAC,YAMA,uEAN8B,KAM9B;IAAA,IALAC,YAKA,uEAFM,EAEN;IAAA,IADAC,eACA;;IAAA;;IAAA;;IAAA,sCAb6B,KAa7B;;IAAA,sCAZ+B,EAY/B;;IAAA;;IACA,KAAKJ,UAAL,GAAkBA,UAAlB;IACA,KAAKC,aAAL,GAAqBA,aAArB;IACA,KAAKC,YAAL,GAAoBA,YAApB;IACA,KAAKC,YAAL,GAAoBA,YAApB;IACA,KAAKC,eAAL,GAAuBA,eAAvB;EACD;;AAtB2B;;;IA8BlBC,gB;;;WAAAA,gB;EAAAA,gB;EAAAA,gB;EAAAA,gB;EAAAA,gB;EAAAA,gB;GAAAA,gB,gCAAAA,gB;;AASL,MAAMC,mBAAN,CAA0B;EAK/BP,WAAW,CAACQ,MAAD,EAIR;IAAA,sDARiD,EAQjD;;IAAA,uDAPkD,EAOlD;;IAAA,yCAN4C,EAM5C;;IACD,KAAKC,4BAAL,GAAoCD,MAAM,CAACC,4BAA3C;IACA,KAAKC,6BAAL,GAAqCF,MAAM,CAACE,6BAA5C;IACA,KAAKC,eAAL,GAAuBH,MAAM,CAACG,eAA9B;EACD;;AAb8B;;;;AAgB1B,MAAMC,qCAAN,CAA4C;EAAA;IAAA,gCACxB,MADwB;;IAAA,6CAElB,KAFkB;EAAA;;AAAA;;;;AAK5C,MAAMC,sCAAN,CAA6C;EAAA;IAAA,6CACjBC,SADiB;;IAAA,6CAEnB,KAFmB;EAAA;;AAAA;;;;AAK7C,MAAMC,oBAAN,CAA2B;EAMhCf,WAAW,CAACQ,MAAD,EAKR;IAAA;;IAAA;;IAAA;;IAAA;;IACD,KAAKQ,sBAAL,GAA8BR,MAAM,CAACQ,sBAArC;IACA,KAAKC,wBAAL,GAAgCT,MAAM,CAACS,wBAAvC;IACA,KAAKC,uBAAL,GAA+BV,MAAM,CAACU,uBAAtC;IACA,KAAKC,yBAAL,GAAiCX,MAAM,CAACW,yBAAxC;EACD;;AAhB+B"}
|
package/lib/commonjs/index.js
CHANGED
|
@@ -3,6 +3,21 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
+
var _exportNames = {
|
|
7
|
+
PayEngineStatic: true,
|
|
8
|
+
PayEngine: true,
|
|
9
|
+
PayProvider: true,
|
|
10
|
+
PECreditCardView: true,
|
|
11
|
+
PECreditCardViewMethods: true,
|
|
12
|
+
PEBankAccountView: true,
|
|
13
|
+
PEBankAccountViewMethods: true,
|
|
14
|
+
PayEngineProvider: true,
|
|
15
|
+
PayEngineNative: true,
|
|
16
|
+
PEApplePayButton: true,
|
|
17
|
+
PEGooglePayButton: true,
|
|
18
|
+
PayEngineUtils: true,
|
|
19
|
+
PEKeyboardType: true
|
|
20
|
+
};
|
|
6
21
|
Object.defineProperty(exports, "PEApplePayButton", {
|
|
7
22
|
enumerable: true,
|
|
8
23
|
get: function () {
|
|
@@ -45,12 +60,6 @@ Object.defineProperty(exports, "PEKeyboardType", {
|
|
|
45
60
|
return _PEKeyboardType.default;
|
|
46
61
|
}
|
|
47
62
|
});
|
|
48
|
-
Object.defineProperty(exports, "PEPaymentRequest", {
|
|
49
|
-
enumerable: true,
|
|
50
|
-
get: function () {
|
|
51
|
-
return _PEPaymentRequest.PEPaymentRequest;
|
|
52
|
-
}
|
|
53
|
-
});
|
|
54
63
|
Object.defineProperty(exports, "PayEngine", {
|
|
55
64
|
enumerable: true,
|
|
56
65
|
get: function () {
|
|
@@ -76,30 +85,6 @@ Object.defineProperty(exports, "PayProvider", {
|
|
|
76
85
|
return _index.PayProvider;
|
|
77
86
|
}
|
|
78
87
|
});
|
|
79
|
-
Object.defineProperty(exports, "RNPEApplePayOptions", {
|
|
80
|
-
enumerable: true,
|
|
81
|
-
get: function () {
|
|
82
|
-
return _PEPaymentRequest.RNPEApplePayOptions;
|
|
83
|
-
}
|
|
84
|
-
});
|
|
85
|
-
Object.defineProperty(exports, "RNPEContactField", {
|
|
86
|
-
enumerable: true,
|
|
87
|
-
get: function () {
|
|
88
|
-
return _PEPaymentRequest.RNPEContactField;
|
|
89
|
-
}
|
|
90
|
-
});
|
|
91
|
-
Object.defineProperty(exports, "RNPEGooglePayBillingAddressParameters", {
|
|
92
|
-
enumerable: true,
|
|
93
|
-
get: function () {
|
|
94
|
-
return _PEPaymentRequest.RNPEGooglePayBillingAddressParameters;
|
|
95
|
-
}
|
|
96
|
-
});
|
|
97
|
-
Object.defineProperty(exports, "RNPEGooglePayShippingAddressParameters", {
|
|
98
|
-
enumerable: true,
|
|
99
|
-
get: function () {
|
|
100
|
-
return _PEPaymentRequest.RNPEGooglePayShippingAddressParameters;
|
|
101
|
-
}
|
|
102
|
-
});
|
|
103
88
|
|
|
104
89
|
var _PayEngine = _interopRequireDefault(require("./components/PayEngine"));
|
|
105
90
|
|
|
@@ -117,8 +102,6 @@ var _PayEngineNative = _interopRequireDefault(require("./components/v2/PayEngine
|
|
|
117
102
|
|
|
118
103
|
var _PEApplePayButton = require("./components/v2/ApplePay/PEApplePayButton");
|
|
119
104
|
|
|
120
|
-
var _PEPaymentRequest = require("./components/v2/PEPaymentRequest");
|
|
121
|
-
|
|
122
105
|
var _PEGooglePayButton = require("./components/v2/GooglePay/PEGooglePayButton");
|
|
123
106
|
|
|
124
107
|
var PayEngineUtils = _interopRequireWildcard(require("./utils/index"));
|
|
@@ -127,6 +110,34 @@ exports.PayEngineUtils = PayEngineUtils;
|
|
|
127
110
|
|
|
128
111
|
var _PEKeyboardType = _interopRequireDefault(require("./components/v2/SecureFields/PEKeyboardType"));
|
|
129
112
|
|
|
113
|
+
var _PEPaymentRequest = require("./components/v2/PEPaymentRequest");
|
|
114
|
+
|
|
115
|
+
Object.keys(_PEPaymentRequest).forEach(function (key) {
|
|
116
|
+
if (key === "default" || key === "__esModule") return;
|
|
117
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
118
|
+
if (key in exports && exports[key] === _PEPaymentRequest[key]) return;
|
|
119
|
+
Object.defineProperty(exports, key, {
|
|
120
|
+
enumerable: true,
|
|
121
|
+
get: function () {
|
|
122
|
+
return _PEPaymentRequest[key];
|
|
123
|
+
}
|
|
124
|
+
});
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
var _PEApplePayInterfaces = require("./components/v2/ApplePay/PEApplePayInterfaces");
|
|
128
|
+
|
|
129
|
+
Object.keys(_PEApplePayInterfaces).forEach(function (key) {
|
|
130
|
+
if (key === "default" || key === "__esModule") return;
|
|
131
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
132
|
+
if (key in exports && exports[key] === _PEApplePayInterfaces[key]) return;
|
|
133
|
+
Object.defineProperty(exports, key, {
|
|
134
|
+
enumerable: true,
|
|
135
|
+
get: function () {
|
|
136
|
+
return _PEApplePayInterfaces[key];
|
|
137
|
+
}
|
|
138
|
+
});
|
|
139
|
+
});
|
|
140
|
+
|
|
130
141
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
131
142
|
|
|
132
143
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["LINKING_ERROR","Platform","select","ios","default","PayEngineStatic","NativeModules","Payengine","Proxy","get","Error"],"sources":["index.tsx"],"sourcesContent":["import PayEngine from './components/PayEngine';\nimport { NativeModules, Platform } from 'react-native';\nimport type { IPayEngineConfig } from './interfaces/index';\nimport { PayProvider } from './interfaces/index';\nimport {\n PECreditCardView,\n PECreditCardViewMethods,\n} from './components/v2/SecureFields/CreditCardView';\nimport {\n PEBankAccountView,\n PEBankAccountViewMethods,\n} from './components/v2/SecureFields/BankAccountView';\nimport type IPEField from './components/v2/SecureFields/IPEField';\nimport type PECard from './components/v2/SecureFields/PECard';\nimport type PEBankAccount from './components/v2/SecureFields/PEBankAccount';\nimport { PayEngineProvider } from './components/v2/PayEngineProvider';\nimport PayEngineNative from './components/v2/PayEngineNative';\nimport { PEApplePayButton } from './components/v2/ApplePay/PEApplePayButton';\nimport {
|
|
1
|
+
{"version":3,"names":["LINKING_ERROR","Platform","select","ios","default","PayEngineStatic","NativeModules","Payengine","Proxy","get","Error"],"sources":["index.tsx"],"sourcesContent":["import PayEngine from './components/PayEngine';\nimport { NativeModules, Platform } from 'react-native';\nimport type { IPayEngineConfig } from './interfaces/index';\nimport { PayProvider } from './interfaces/index';\nimport {\n PECreditCardView,\n PECreditCardViewMethods,\n} from './components/v2/SecureFields/CreditCardView';\nimport {\n PEBankAccountView,\n PEBankAccountViewMethods,\n} from './components/v2/SecureFields/BankAccountView';\nimport type IPEField from './components/v2/SecureFields/IPEField';\nimport type PECard from './components/v2/SecureFields/PECard';\nimport type PEBankAccount from './components/v2/SecureFields/PEBankAccount';\nimport { PayEngineProvider } from './components/v2/PayEngineProvider';\nimport PayEngineNative from './components/v2/PayEngineNative';\nimport { PEApplePayButton } from './components/v2/ApplePay/PEApplePayButton';\n\nimport { PEGooglePayButton } from './components/v2/GooglePay/PEGooglePayButton';\nimport * as PayEngineUtils from './utils/index';\nimport PEKeyboardType from './components/v2/SecureFields/PEKeyboardType';\nimport type { PEGooglePayAddress } from './components/v2/GooglePay/PEGooglePayAddress';\nimport type { PEApplePayContact } from './components/v2/ApplePay/PEApplePayInterfaces';\n\nexport * from './components/v2/PEPaymentRequest';\nexport * from './components/v2/ApplePay/PEApplePayInterfaces';\n\n\nconst LINKING_ERROR =\n `The package 'react-native-payengine' doesn't seem to be linked. Make sure: \\n\\n` +\n Platform.select({ ios: \"- You have run 'pod install'\\n\", default: '' }) +\n '- You rebuilt the app after installing the package\\n' +\n '- You are not using Expo managed workflow\\n';\n\nconst PayEngineStatic = NativeModules.Payengine\n ? NativeModules.Payengine\n : new Proxy(\n {},\n {\n get() {\n throw new Error(LINKING_ERROR);\n },\n }\n );\n\nexport {\n PayEngineStatic,\n PayEngine,\n IPayEngineConfig,\n PayProvider,\n // v2 starting here\n PayEngineUtils,\n PayEngineProvider,\n PayEngineNative,\n // securefields\n PEKeyboardType,\n IPEField,\n // credit card\n PECreditCardView,\n PECreditCardViewMethods,\n PECard,\n // bank account\n PEBankAccountView,\n PEBankAccountViewMethods,\n PEBankAccount,\n // Apple Pay\n PEApplePayButton,\n // RNPEApplePayOptions,\n // RNPEContactField,\n PEApplePayContact,\n // RNPEGooglePayBillingAddressParameters,\n // RNPEGooglePayShippingAddressParameters,\n // PEPaymentRequest,\n PEGooglePayButton,\n PEGooglePayAddress\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AAEA;;AACA;;AAIA;;AAOA;;AACA;;AACA;;AAEA;;AACA;;;;AACA;;AAIA;;AAAA;EAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AACA;;AAAA;EAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;;;;;;;AAGA,MAAMA,aAAa,GAChB,iFAAD,GACAC,qBAAA,CAASC,MAAT,CAAgB;EAAEC,GAAG,EAAE,gCAAP;EAAyCC,OAAO,EAAE;AAAlD,CAAhB,CADA,GAEA,sDAFA,GAGA,6CAJF;AAMA,MAAMC,eAAe,GAAGC,0BAAA,CAAcC,SAAd,GACpBD,0BAAA,CAAcC,SADM,GAEpB,IAAIC,KAAJ,CACE,EADF,EAEE;EACEC,GAAG,GAAG;IACJ,MAAM,IAAIC,KAAJ,CAAUV,aAAV,CAAN;EACD;;AAHH,CAFF,CAFJ"}
|
|
@@ -1,8 +1,53 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import { Platform, requireNativeComponent, Text } from 'react-native';
|
|
3
|
-
const
|
|
2
|
+
import { findNodeHandle, NativeEventEmitter, NativeModules, Platform, requireNativeComponent, Text, UIManager } from 'react-native';
|
|
3
|
+
const {
|
|
4
|
+
RNPEEventEmitter
|
|
5
|
+
} = NativeModules;
|
|
6
|
+
const peEventEmitter = new NativeEventEmitter(RNPEEventEmitter);
|
|
7
|
+
const COMPONENT_NAME = 'RNPEApplePayButton';
|
|
8
|
+
const RNPEApplePayButton = requireNativeComponent(COMPONENT_NAME); // @ts-ignore
|
|
9
|
+
|
|
10
|
+
const RNPEApplePayButtonManager = UIManager[COMPONENT_NAME];
|
|
4
11
|
export const PEApplePayButton = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
5
|
-
|
|
12
|
+
const buttonRef = React.useRef();
|
|
13
|
+
React.useImperativeHandle(ref, () => ({
|
|
14
|
+
updatePaymentSheet: async (summaryItems, shippingMethods, errors) => {
|
|
15
|
+
return new Promise((resolve, reject) => {
|
|
16
|
+
const listener = peEventEmitter.addListener('onUpdatePaymentSheetResult', args => {
|
|
17
|
+
listener.remove();
|
|
18
|
+
const {
|
|
19
|
+
error
|
|
20
|
+
} = args;
|
|
21
|
+
|
|
22
|
+
if (error) {
|
|
23
|
+
reject(new Error(error));
|
|
24
|
+
} else {
|
|
25
|
+
resolve(true);
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
callNativeMethod('updatePaymentSheet', [summaryItems, shippingMethods, errors]);
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
}));
|
|
32
|
+
React.useEffect(() => {
|
|
33
|
+
const listener = peEventEmitter.addListener('onUpdatePaymentSheetResult', args => {
|
|
34
|
+
console.log('Received event onUpdatePaymentSheetResult', args);
|
|
35
|
+
});
|
|
36
|
+
return () => {
|
|
37
|
+
listener.remove();
|
|
38
|
+
};
|
|
39
|
+
}, []);
|
|
40
|
+
const callNativeMethod = React.useCallback(function (methodName) {
|
|
41
|
+
let params = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
|
|
42
|
+
const viewId = findNodeHandle(buttonRef.current);
|
|
43
|
+
let commandId = RNPEApplePayButtonManager.Commands[methodName].toString();
|
|
44
|
+
|
|
45
|
+
if (Platform.OS === 'ios') {
|
|
46
|
+
commandId = Number(commandId);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
UIManager.dispatchViewManagerCommand(viewId, commandId, params);
|
|
50
|
+
}, [buttonRef.current]);
|
|
6
51
|
|
|
7
52
|
const pmError = event => {
|
|
8
53
|
if (props.onPaymentFailed) {
|
|
@@ -37,6 +82,7 @@ export const PEApplePayButton = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
|
37
82
|
}
|
|
38
83
|
|
|
39
84
|
return /*#__PURE__*/React.createElement(RNPEApplePayButton, {
|
|
85
|
+
ref: buttonRef,
|
|
40
86
|
style: {
|
|
41
87
|
height: 32,
|
|
42
88
|
width: '100%',
|
|
@@ -47,7 +93,10 @@ export const PEApplePayButton = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
|
47
93
|
}),
|
|
48
94
|
onPmError: pmError,
|
|
49
95
|
onPmTokenDidReturn: pmTokenDidReturn,
|
|
50
|
-
onPmSheetDidDismiss: pmSheetDidDismiss
|
|
96
|
+
onPmSheetDidDismiss: pmSheetDidDismiss,
|
|
97
|
+
onPaymentMethodSelected: props.onPaymentMethodSelected,
|
|
98
|
+
onShippingContactSelected: props.onShippingContactSelected,
|
|
99
|
+
onShippingMethodSelected: props.onShippingMethodSelected
|
|
51
100
|
});
|
|
52
101
|
});
|
|
53
102
|
//# sourceMappingURL=PEApplePayButton.js.map
|