react-native-payengine 2.0.17 → 2.0.18-alpha.1
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 +96 -65
- 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/build.gradle +2 -2
- package/android/src/main/java/com/reactnativepayengine/v2/RNPayEngineNative.kt +65 -3
- package/android/src/main/java/com/reactnativepayengine/v2/securefields/RNPEEvents.kt +1 -0
- package/android/src/main/java/com/reactnativepayengine/v2/securefields/bankaccount/RNBankAccountViewManager.kt +16 -3
- package/android/src/main/java/com/reactnativepayengine/v2/securefields/creditcard/RNPECreditCardViewManager.kt +15 -4
- package/ios/PayEngineSDK.xcframework/Info.plist +5 -5
- package/ios/PayEngineSDK.xcframework/ios-arm64/PayEngineSDK.framework/Headers/KDataCollector.h +4 -25
- package/ios/PayEngineSDK.xcframework/ios-arm64/PayEngineSDK.framework/Headers/KountAnalyticsViewController.h +0 -20
- package/ios/PayEngineSDK.xcframework/ios-arm64/PayEngineSDK.framework/Headers/KountPrivate.h +61 -0
- package/ios/PayEngineSDK.xcframework/ios-arm64/PayEngineSDK.framework/Headers/PayEngineSDK-Swift.h +430 -149
- 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 +1962 -5715
- package/ios/PayEngineSDK.xcframework/ios-arm64/PayEngineSDK.framework/Modules/PayEngineSDK.swiftmodule/arm64-apple-ios.private.swiftinterface +35 -129
- package/ios/PayEngineSDK.xcframework/ios-arm64/PayEngineSDK.framework/Modules/PayEngineSDK.swiftmodule/arm64-apple-ios.private.swiftinterface-e +35 -129
- 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 +35 -129
- package/ios/PayEngineSDK.xcframework/ios-arm64/PayEngineSDK.framework/Modules/PayEngineSDK.swiftmodule/arm64-apple-ios.swiftinterface-e +35 -129
- 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/KDataCollector.h +4 -25
- package/ios/PayEngineSDK.xcframework/ios-arm64_x86_64-simulator/PayEngineSDK.framework/Headers/KountAnalyticsViewController.h +0 -20
- package/ios/PayEngineSDK.xcframework/ios-arm64_x86_64-simulator/PayEngineSDK.framework/Headers/KountPrivate.h +61 -0
- package/ios/PayEngineSDK.xcframework/ios-arm64_x86_64-simulator/PayEngineSDK.framework/Headers/PayEngineSDK-Swift.h +860 -298
- 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 +1962 -5715
- package/ios/PayEngineSDK.xcframework/ios-arm64_x86_64-simulator/PayEngineSDK.framework/Modules/PayEngineSDK.swiftmodule/arm64-apple-ios-simulator.private.swiftinterface +35 -129
- package/ios/PayEngineSDK.xcframework/ios-arm64_x86_64-simulator/PayEngineSDK.framework/Modules/PayEngineSDK.swiftmodule/arm64-apple-ios-simulator.private.swiftinterface-e +35 -129
- 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 +35 -129
- package/ios/PayEngineSDK.xcframework/ios-arm64_x86_64-simulator/PayEngineSDK.framework/Modules/PayEngineSDK.swiftmodule/arm64-apple-ios-simulator.swiftinterface-e +35 -129
- package/ios/PayEngineSDK.xcframework/ios-arm64_x86_64-simulator/PayEngineSDK.framework/Modules/PayEngineSDK.swiftmodule/x86_64-apple-ios-simulator.abi.json +1962 -5715
- package/ios/PayEngineSDK.xcframework/ios-arm64_x86_64-simulator/PayEngineSDK.framework/Modules/PayEngineSDK.swiftmodule/x86_64-apple-ios-simulator.private.swiftinterface +35 -129
- package/ios/PayEngineSDK.xcframework/ios-arm64_x86_64-simulator/PayEngineSDK.framework/Modules/PayEngineSDK.swiftmodule/x86_64-apple-ios-simulator.private.swiftinterface-e +35 -129
- 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 +35 -129
- package/ios/PayEngineSDK.xcframework/ios-arm64_x86_64-simulator/PayEngineSDK.framework/Modules/PayEngineSDK.swiftmodule/x86_64-apple-ios-simulator.swiftinterface-e +35 -129
- 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/Info.plist +0 -0
- package/ios/Sources/Classes/RNPEEventEmitter.swift +1 -1
- package/ios/Sources/Classes/RNPayEngineNative.swift +125 -64
- package/ios/Sources/Classes/SecureFields/RNPEEvents.swift +1 -0
- package/ios/Sources/Payengine.m +6 -0
- package/lib/commonjs/components/PayEngine.js +1 -1
- package/lib/commonjs/components/PayEngine.js.map +1 -1
- package/lib/commonjs/components/v2/ApplePay/PEApplePayButton.js +124 -0
- package/lib/commonjs/components/v2/ApplePay/PEApplePayButton.js.map +1 -1
- package/lib/commonjs/components/v2/ApplePay/PEApplePayInterfaces.js +78 -0
- package/lib/commonjs/components/v2/ApplePay/PEApplePayInterfaces.js.map +1 -1
- package/lib/commonjs/components/v2/GooglePay/PEGooglePayAddress.js.map +1 -1
- package/lib/commonjs/components/v2/GooglePay/PEGooglePayButton.js +53 -0
- package/lib/commonjs/components/v2/GooglePay/PEGooglePayButton.js.map +1 -1
- package/lib/commonjs/components/v2/PEPaymentRequest.js +121 -0
- package/lib/commonjs/components/v2/PEPaymentRequest.js.map +1 -1
- package/lib/commonjs/components/v2/PayEngineNative.js +182 -4
- package/lib/commonjs/components/v2/PayEngineNative.js.map +1 -1
- package/lib/commonjs/components/v2/PayEngineProvider.js +52 -0
- package/lib/commonjs/components/v2/PayEngineProvider.js.map +1 -1
- package/lib/commonjs/components/v2/SecureFields/BankAccountView.js +71 -0
- package/lib/commonjs/components/v2/SecureFields/BankAccountView.js.map +1 -1
- package/lib/commonjs/components/v2/SecureFields/CreditCardView.js +82 -0
- package/lib/commonjs/components/v2/SecureFields/CreditCardView.js.map +1 -1
- package/lib/commonjs/components/v2/SecureFields/IPEField.js.map +1 -1
- package/lib/commonjs/components/v2/SecureFields/ITokenizationData.js.map +1 -1
- package/lib/commonjs/components/v2/SecureFields/PEBankAccount.js.map +1 -1
- package/lib/commonjs/components/v2/SecureFields/PECard.js.map +1 -1
- package/lib/commonjs/components/v2/SecureFields/PEKeyboardType.js +20 -3
- package/lib/commonjs/components/v2/SecureFields/PEKeyboardType.js.map +1 -1
- package/lib/commonjs/index.js +17 -13
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/interfaces/index.js +20 -0
- package/lib/commonjs/interfaces/index.js.map +1 -1
- package/lib/commonjs/utils/index.js +26 -0
- package/lib/commonjs/utils/index.js.map +1 -1
- package/lib/module/components/PayEngine.js +1 -1
- package/lib/module/components/PayEngine.js.map +1 -1
- package/lib/module/components/v2/ApplePay/PEApplePayButton.js +124 -0
- package/lib/module/components/v2/ApplePay/PEApplePayButton.js.map +1 -1
- package/lib/module/components/v2/ApplePay/PEApplePayInterfaces.js +75 -0
- package/lib/module/components/v2/ApplePay/PEApplePayInterfaces.js.map +1 -1
- package/lib/module/components/v2/GooglePay/PEGooglePayAddress.js.map +1 -1
- package/lib/module/components/v2/GooglePay/PEGooglePayButton.js +53 -0
- package/lib/module/components/v2/GooglePay/PEGooglePayButton.js.map +1 -1
- package/lib/module/components/v2/PEPaymentRequest.js +119 -0
- package/lib/module/components/v2/PEPaymentRequest.js.map +1 -1
- package/lib/module/components/v2/PayEngineNative.js +184 -5
- package/lib/module/components/v2/PayEngineNative.js.map +1 -1
- package/lib/module/components/v2/PayEngineProvider.js +51 -0
- package/lib/module/components/v2/PayEngineProvider.js.map +1 -1
- package/lib/module/components/v2/SecureFields/BankAccountView.js +71 -0
- package/lib/module/components/v2/SecureFields/BankAccountView.js.map +1 -1
- package/lib/module/components/v2/SecureFields/CreditCardView.js +82 -0
- package/lib/module/components/v2/SecureFields/CreditCardView.js.map +1 -1
- package/lib/module/components/v2/SecureFields/IPEField.js.map +1 -1
- package/lib/module/components/v2/SecureFields/ITokenizationData.js.map +1 -1
- package/lib/module/components/v2/SecureFields/PEBankAccount.js.map +1 -1
- package/lib/module/components/v2/SecureFields/PECard.js.map +1 -1
- package/lib/module/components/v2/SecureFields/PEKeyboardType.js +16 -1
- package/lib/module/components/v2/SecureFields/PEKeyboardType.js.map +1 -1
- package/lib/module/index.js +10 -5
- package/lib/module/index.js.map +1 -1
- package/lib/module/interfaces/index.js +19 -0
- package/lib/module/interfaces/index.js.map +1 -1
- package/lib/module/utils/index.js +27 -0
- package/lib/module/utils/index.js.map +1 -1
- package/lib/typescript/components/PayEngine.d.ts +1 -1
- package/lib/typescript/components/v2/ApplePay/PEApplePayButton.d.ts +217 -12
- package/lib/typescript/components/v2/ApplePay/PEApplePayInterfaces.d.ts +180 -1
- package/lib/typescript/components/v2/GooglePay/PEGooglePayAddress.d.ts +30 -0
- package/lib/typescript/components/v2/GooglePay/PEGooglePayButton.d.ts +99 -0
- package/lib/typescript/components/v2/PEPaymentRequest.d.ts +130 -9
- package/lib/typescript/components/v2/PayEngineNative.d.ts +165 -7
- package/lib/typescript/components/v2/PayEngineProvider.d.ts +51 -0
- package/lib/typescript/components/v2/SecureFields/BankAccountView.d.ts +103 -0
- package/lib/typescript/components/v2/SecureFields/CreditCardView.d.ts +114 -0
- package/lib/typescript/components/v2/SecureFields/IPEField.d.ts +49 -0
- package/lib/typescript/components/v2/SecureFields/ITokenizationData.d.ts +14 -0
- package/lib/typescript/components/v2/SecureFields/PEBankAccount.d.ts +36 -0
- package/lib/typescript/components/v2/SecureFields/PECard.d.ts +44 -0
- package/lib/typescript/components/v2/SecureFields/PEKeyboardType.d.ts +16 -1
- package/lib/typescript/index.d.ts +11 -5
- package/lib/typescript/interfaces/index.d.ts +35 -1
- package/lib/typescript/utils/index.d.ts +21 -0
- package/package.json +6 -3
- package/src/components/PayEngine.tsx +1 -1
- package/src/components/v2/ApplePay/PEApplePayButton.tsx +225 -12
- package/src/components/v2/ApplePay/PEApplePayInterfaces.ts +221 -8
- package/src/components/v2/GooglePay/PEGooglePayAddress.ts +39 -1
- package/src/components/v2/GooglePay/PEGooglePayButton.tsx +113 -9
- package/src/components/v2/PEPaymentRequest.ts +151 -13
- package/src/components/v2/PayEngineNative.tsx +196 -9
- package/src/components/v2/PayEngineProvider.tsx +52 -1
- package/src/components/v2/SecureFields/BankAccountView.tsx +108 -1
- package/src/components/v2/SecureFields/CreditCardView.tsx +118 -1
- package/src/components/v2/SecureFields/IPEField.ts +55 -0
- package/src/components/v2/SecureFields/ITokenizationData.ts +17 -2
- package/src/components/v2/SecureFields/PEBankAccount.ts +42 -0
- package/src/components/v2/SecureFields/PECard.ts +52 -0
- package/src/components/v2/SecureFields/PEKeyboardType.ts +18 -1
- package/src/index.tsx +23 -5
- package/src/interfaces/index.ts +40 -2
- package/src/utils/index.ts +21 -0
- package/android/.gradle/6.1.1/executionHistory/executionHistory.lock +0 -0
- package/android/.gradle/6.1.1/fileChanges/last-build.bin +0 -0
- package/android/.gradle/6.1.1/fileHashes/fileHashes.lock +0 -0
- package/android/.gradle/6.1.1/gc.properties +0 -0
- package/ios/PayEngineSDK.xcframework/ios-arm64/PayEngineSDK.framework/Headers/CustomWindow.h +0 -25
- package/ios/PayEngineSDK.xcframework/ios-arm64/PayEngineSDK.framework/Headers/UIControl+CustomControl.h +0 -33
- package/ios/PayEngineSDK.xcframework/ios-arm64/PayEngineSDK.framework/Headers/UIViewController+TouchControl.h +0 -27
- package/ios/PayEngineSDK.xcframework/ios-arm64_x86_64-simulator/PayEngineSDK.framework/Headers/CustomWindow.h +0 -25
- package/ios/PayEngineSDK.xcframework/ios-arm64_x86_64-simulator/PayEngineSDK.framework/Headers/UIControl+CustomControl.h +0 -33
- package/ios/PayEngineSDK.xcframework/ios-arm64_x86_64-simulator/PayEngineSDK.framework/Headers/UIViewController+TouchControl.h +0 -27
package/lib/module/index.js
CHANGED
|
@@ -1,10 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Main Module
|
|
3
|
+
* @module PayEngine SDK
|
|
4
|
+
*/
|
|
1
5
|
import PayEngine from './components/PayEngine';
|
|
2
6
|
import { NativeModules, Platform } from 'react-native';
|
|
3
7
|
import { PayProvider } from './interfaces/index';
|
|
4
|
-
import { PECreditCardView
|
|
5
|
-
import { PEBankAccountView
|
|
8
|
+
import { PECreditCardView } from './components/v2/SecureFields/CreditCardView';
|
|
9
|
+
import { PEBankAccountView } from './components/v2/SecureFields/BankAccountView';
|
|
6
10
|
import { PayEngineProvider } from './components/v2/PayEngineProvider';
|
|
7
11
|
import PayEngineNative from './components/v2/PayEngineNative';
|
|
12
|
+
import { FetchAccessTokenCallback, AccessToken } from './components/v2/PayEngineNative';
|
|
8
13
|
import { PEApplePayButton } from './components/v2/ApplePay/PEApplePayButton';
|
|
9
14
|
import { PEGooglePayButton } from './components/v2/GooglePay/PEGooglePayButton';
|
|
10
15
|
import * as PayEngineUtils from './utils/index';
|
|
@@ -22,10 +27,10 @@ const PayEngineStatic = NativeModules.Payengine ? NativeModules.Payengine : new
|
|
|
22
27
|
|
|
23
28
|
});
|
|
24
29
|
export { PayEngineStatic, PayEngine, PayProvider, // v2 starting here
|
|
25
|
-
PayEngineUtils, PayEngineProvider, PayEngineNative, // securefields
|
|
30
|
+
PayEngineUtils, PayEngineProvider, PayEngineNative, AccessToken, FetchAccessTokenCallback, // securefields
|
|
26
31
|
PEKeyboardType, // credit card
|
|
27
|
-
PECreditCardView,
|
|
28
|
-
PEBankAccountView,
|
|
32
|
+
PECreditCardView, // bank account
|
|
33
|
+
PEBankAccountView, // Apple Pay
|
|
29
34
|
PEApplePayButton, // RNPEGooglePayBillingAddressParameters,
|
|
30
35
|
// RNPEGooglePayShippingAddressParameters,
|
|
31
36
|
// PEPaymentRequest,
|
package/lib/module/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["PayEngine","NativeModules","Platform","PayProvider","PECreditCardView","
|
|
1
|
+
{"version":3,"names":["PayEngine","NativeModules","Platform","PayProvider","PECreditCardView","PEBankAccountView","PayEngineProvider","PayEngineNative","FetchAccessTokenCallback","AccessToken","PEApplePayButton","PEGooglePayButton","PayEngineUtils","PEKeyboardType","LINKING_ERROR","select","ios","default","PayEngineStatic","Payengine","Proxy","get","Error"],"sources":["index.tsx"],"sourcesContent":["/**\n * Main Module\n * @module PayEngine SDK\n */\n\nimport PayEngine from './components/PayEngine';\nimport { NativeModules, Platform } from 'react-native';\nimport type { IPayEngineConfig } from './interfaces/index';\nimport { PayProvider } from './interfaces/index';\nimport type ITokenizationData from './components/v2/SecureFields/ITokenizationData'\nimport {\n PECreditCardView,\n type PECreditCardViewProps,\n type PECreditCardViewMethods,\n} from './components/v2/SecureFields/CreditCardView';\nimport {\n PEBankAccountView,\n type PEBankAccountViewProps,\n type 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 { FetchAccessTokenCallback, AccessToken } from './components/v2/PayEngineNative';\nimport { PEApplePayButton, type PEApplePayButtonProps, type PEApplePayButtonMethods } from './components/v2/ApplePay/PEApplePayButton';\n\nimport { PEGooglePayButton, type PEGooglePayButtonProps, type PEGooglePayButtonMethods } 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 AccessToken,\n FetchAccessTokenCallback,\n // securefields\n PEKeyboardType,\n IPEField,\n ITokenizationData,\n // credit card\n PECreditCardView,\n PECreditCardViewProps,\n PECreditCardViewMethods,\n PECard,\n // bank account\n PEBankAccountView,\n PEBankAccountViewProps,\n PEBankAccountViewMethods,\n PEBankAccount,\n // Apple Pay\n PEApplePayButton,\n PEApplePayButtonProps,\n PEApplePayButtonMethods,\n // RNPEApplePayOptions,\n // RNPEContactField,\n PEApplePayContact,\n // RNPEGooglePayBillingAddressParameters,\n // RNPEGooglePayShippingAddressParameters,\n // PEPaymentRequest,\n PEGooglePayButton,\n PEGooglePayAddress,\n PEGooglePayButtonProps,\n PEGooglePayButtonMethods\n};\n"],"mappings":"AAAA;AACA;AACA;AACA;AAEA,OAAOA,SAAP,MAAsB,wBAAtB;AACA,SAASC,aAAT,EAAwBC,QAAxB,QAAwC,cAAxC;AAEA,SAASC,WAAT,QAA4B,oBAA5B;AAEA,SACEC,gBADF,QAIO,6CAJP;AAKA,SACEC,iBADF,QAIO,8CAJP;AAQA,SAASC,iBAAT,QAAkC,mCAAlC;AACA,OAAOC,eAAP,MAA4B,iCAA5B;AACA,SAASC,wBAAT,EAAmCC,WAAnC,QAAsD,iCAAtD;AACA,SAASC,gBAAT,QAA2F,2CAA3F;AAEA,SAASC,iBAAT,QAA8F,6CAA9F;AACA,OAAO,KAAKC,cAAZ,MAAgC,eAAhC;AACA,OAAOC,cAAP,MAA2B,6CAA3B;AAIA,cAAc,kCAAd;AACA,cAAc,+CAAd;AAGA,MAAMC,aAAa,GAChB,iFAAD,GACAZ,QAAQ,CAACa,MAAT,CAAgB;EAAEC,GAAG,EAAE,gCAAP;EAAyCC,OAAO,EAAE;AAAlD,CAAhB,CADA,GAEA,sDAFA,GAGA,6CAJF;AAMA,MAAMC,eAAe,GAAGjB,aAAa,CAACkB,SAAd,GACpBlB,aAAa,CAACkB,SADM,GAEpB,IAAIC,KAAJ,CACE,EADF,EAEE;EACEC,GAAG,GAAG;IACJ,MAAM,IAAIC,KAAJ,CAAUR,aAAV,CAAN;EACD;;AAHH,CAFF,CAFJ;AAWA,SACEI,eADF,EAEElB,SAFF,EAIEG,WAJF,EAKE;AACAS,cANF,EAOEN,iBAPF,EAQEC,eARF,EASEE,WATF,EAUED,wBAVF,EAWE;AACAK,cAZF,EAeE;AACAT,gBAhBF,EAoBE;AACAC,iBArBF,EAyBE;AACAK,gBA1BF,EAgCE;AACA;AACA;AACAC,iBAnCF"}
|
|
@@ -1,3 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Represents the configuration settings for PayEngine.
|
|
3
|
+
*
|
|
4
|
+
* The [IPayEngineConfig] interface holds essential details such as the public key,
|
|
5
|
+
* script version, and logging level. It is used to configure the PayEngine integration
|
|
6
|
+
* for API interactions.
|
|
7
|
+
*
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Enum representing supported payment providers.
|
|
12
|
+
*
|
|
13
|
+
* @remarks
|
|
14
|
+
* This enum specifies the available payment providers supported by the PayEngine SDK.
|
|
15
|
+
* It is used to check which payment method (Apple Pay or Google Pay) is available for use.
|
|
16
|
+
*
|
|
17
|
+
* @enum {string}
|
|
18
|
+
* @category PayEngine
|
|
19
|
+
*/
|
|
1
20
|
export let PayProvider;
|
|
2
21
|
|
|
3
22
|
(function (PayProvider) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["PayProvider"],"sources":["index.ts"],"sourcesContent":["
|
|
1
|
+
{"version":3,"names":["PayProvider"],"sources":["index.ts"],"sourcesContent":["/**\n * Represents the configuration settings for PayEngine.\n *\n * The [IPayEngineConfig] interface holds essential details such as the public key,\n * script version, and logging level. It is used to configure the PayEngine integration\n * for API interactions.\n *\n */\nexport interface IPayEngineConfig {\n /**\n * The public key associated with the PayEngine account.\n * This key is required for authentication when making API requests.\n */\n publicKey: string;\n\n /**\n * The version of the PayEngine integration.\n * If provided, this specifies the version of the script or API being used.\n */\n version?: string;\n\n /**\n * The script URL for loading the PayEngine JavaScript library.\n * If provided, this URL is used instead of the default script URL.\n */\n scriptURL?: string;\n\n /**\n * The log level for debugging.\n * Higher values enable more detailed logging.\n */\n logLevel?: number;\n}\n\n\n/**\n * Enum representing supported payment providers.\n *\n * @remarks\n * This enum specifies the available payment providers supported by the PayEngine SDK.\n * It is used to check which payment method (Apple Pay or Google Pay) is available for use.\n *\n * @enum {string}\n * @category PayEngine\n */\nexport enum PayProvider {\n googlePay, // Google Pay payment provider.\n applePay // Apple Pay payment provider.\n}"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AA4BA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,WAAYA,WAAZ;;WAAYA,W;EAAAA,W,CAAAA,W;EAAAA,W,CAAAA,W;GAAAA,W,KAAAA,W"}
|
|
@@ -1,15 +1,30 @@
|
|
|
1
1
|
import axios from 'axios';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Custom error thrown when an obsolete method is called.
|
|
5
|
+
*
|
|
6
|
+
* The `PEDeprecationError` indicates that the method being used is deprecated,
|
|
7
|
+
* and the user should check the package README for updated usage.
|
|
8
|
+
*/
|
|
2
9
|
export class PEDeprecationError extends Error {
|
|
3
10
|
constructor() {
|
|
4
11
|
super('This method is obsolete and can not be used anymore. Please check out the package README');
|
|
5
12
|
}
|
|
6
13
|
|
|
7
14
|
}
|
|
15
|
+
/**
|
|
16
|
+
* @private
|
|
17
|
+
*/
|
|
18
|
+
|
|
8
19
|
export const getHttpHeaders = config => {
|
|
9
20
|
return {
|
|
10
21
|
Authorization: `Signature key="${config.publicKey}",algorithm="hmac-sha256",identifier="secure-fields",signature=""`
|
|
11
22
|
};
|
|
12
23
|
};
|
|
24
|
+
/**
|
|
25
|
+
* @private
|
|
26
|
+
*/
|
|
27
|
+
|
|
13
28
|
export const getBaseURL = config => {
|
|
14
29
|
let baseUrl = config.publicKey.includes('_prod_') ? 'https://console.payengine.co' : 'https://console.payengine.dev';
|
|
15
30
|
|
|
@@ -19,12 +34,20 @@ export const getBaseURL = config => {
|
|
|
19
34
|
|
|
20
35
|
return baseUrl;
|
|
21
36
|
};
|
|
37
|
+
/**
|
|
38
|
+
* @private
|
|
39
|
+
*/
|
|
40
|
+
|
|
22
41
|
export const createHttpClient = config => {
|
|
23
42
|
return axios.create({
|
|
24
43
|
baseURL: getBaseURL(config),
|
|
25
44
|
headers: getHttpHeaders(config)
|
|
26
45
|
});
|
|
27
46
|
};
|
|
47
|
+
/**
|
|
48
|
+
* @private
|
|
49
|
+
*/
|
|
50
|
+
|
|
28
51
|
export function getScriptURL(config) {
|
|
29
52
|
if (!config.publicKey) {
|
|
30
53
|
throw new Error('PayEngine Public Key is missing');
|
|
@@ -43,6 +66,10 @@ export function getScriptURL(config) {
|
|
|
43
66
|
|
|
44
67
|
return scriptURL;
|
|
45
68
|
}
|
|
69
|
+
/**
|
|
70
|
+
* @private
|
|
71
|
+
*/
|
|
72
|
+
|
|
46
73
|
export const debuggingScript = `
|
|
47
74
|
const consoleLog = (type, ...log) => window.ReactNativeWebView.postMessage(JSON.stringify({'type': 'Console', 'data': {'type': type, 'log': log}}));
|
|
48
75
|
console = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["axios","PEDeprecationError","Error","constructor","getHttpHeaders","config","Authorization","publicKey","getBaseURL","baseUrl","includes","scriptURL","replace","createHttpClient","create","baseURL","headers","getScriptURL","logLevelStr","logLevel","version","debuggingScript"],"sources":["index.ts"],"sourcesContent":["import axios from 'axios';\nimport type { IPayEngineConfig } from '../interfaces/index';\n\nexport class PEDeprecationError extends Error {\n constructor() {\n super(\n 'This method is obsolete and can not be used anymore. Please check out the package README'\n );\n }\n}\n\nexport const getHttpHeaders = (config: IPayEngineConfig) => {\n return {\n Authorization: `Signature key=\"${config.publicKey}\",algorithm=\"hmac-sha256\",identifier=\"secure-fields\",signature=\"\"`,\n };\n};\n\nexport const getBaseURL = (config: IPayEngineConfig) => {\n let baseUrl = config.publicKey.includes('_prod_')\n ? 'https://console.payengine.co'\n : 'https://console.payengine.dev';\n\n if (config.scriptURL) {\n baseUrl = config.scriptURL.replace(/^((\\w+:)?\\/\\/[^\\/]+\\/?).*$/, '$1');\n }\n return baseUrl;\n};\n\nexport const createHttpClient = (config: IPayEngineConfig) => {\n return axios.create({\n baseURL: getBaseURL(config),\n headers: getHttpHeaders(config),\n });\n};\n\nexport function getScriptURL(config: IPayEngineConfig) {\n if (!config.publicKey) {\n throw new Error('PayEngine Public Key is missing');\n }\n let scriptURL = '';\n const logLevelStr = config.logLevel ? `&loglevel=${config.logLevel}` : '';\n if (config.scriptURL) {\n scriptURL = `${config.scriptURL}?key=${config.publicKey}${logLevelStr}`;\n } else {\n const baseURL = config.publicKey.includes('_prod_')\n ? 'https://console.payengine.co'\n : 'https://console.payengine.dev';\n const version = config.version ?? '1.0.0';\n scriptURL = `${baseURL}/js/${version}/embed.js?key=${config.publicKey}${logLevelStr}`;\n }\n\n return scriptURL;\n}\n\nexport const debuggingScript = `\nconst consoleLog = (type, ...log) => window.ReactNativeWebView.postMessage(JSON.stringify({'type': 'Console', 'data': {'type': type, 'log': log}}));\nconsole = {\n log: (...log) => consoleLog('log', ...log),\n debug: (...log) => consoleLog('debug', ...log),\n info: (...log) => consoleLog('info', ...log),\n warn: (...log) => consoleLog('warn', ...log),\n error: (...log) => consoleLog('error', ...log),\n verbose: (...log) => consoleLog('verbose', ...log),\n};\n\nconst dispatchEvent_original = EventTarget.prototype.dispatchEvent;\nfunction dispatchEvent(event) {\n if (event.type && !event.type.startsWith('react')) {\n ReactNativeWebView.postMessage(JSON.stringify({\n type: 'PayEngine',\n event: {\n type: event.type,\n detail: event.detail\n }\n }))\n }\n}\nEventTarget.prototype.dispatchEvent = dispatchEvent;\n`;\n"],"mappings":"AAAA,OAAOA,KAAP,MAAkB,OAAlB;
|
|
1
|
+
{"version":3,"names":["axios","PEDeprecationError","Error","constructor","getHttpHeaders","config","Authorization","publicKey","getBaseURL","baseUrl","includes","scriptURL","replace","createHttpClient","create","baseURL","headers","getScriptURL","logLevelStr","logLevel","version","debuggingScript"],"sources":["index.ts"],"sourcesContent":["import axios from 'axios';\nimport type { IPayEngineConfig } from '../interfaces/index';\n\n/**\n * Custom error thrown when an obsolete method is called.\n *\n * The `PEDeprecationError` indicates that the method being used is deprecated,\n * and the user should check the package README for updated usage.\n */\nexport class PEDeprecationError extends Error {\n constructor() {\n super(\n 'This method is obsolete and can not be used anymore. Please check out the package README'\n );\n }\n}\n\n/**\n * @private\n */\nexport const getHttpHeaders = (config: IPayEngineConfig) => {\n return {\n Authorization: `Signature key=\"${config.publicKey}\",algorithm=\"hmac-sha256\",identifier=\"secure-fields\",signature=\"\"`,\n };\n};\n\n/**\n * @private\n */\nexport const getBaseURL = (config: IPayEngineConfig) => {\n let baseUrl = config.publicKey.includes('_prod_')\n ? 'https://console.payengine.co'\n : 'https://console.payengine.dev';\n\n if (config.scriptURL) {\n baseUrl = config.scriptURL.replace(/^((\\w+:)?\\/\\/[^\\/]+\\/?).*$/, '$1');\n }\n return baseUrl;\n};\n\n/**\n * @private\n */\nexport const createHttpClient = (config: IPayEngineConfig) => {\n return axios.create({\n baseURL: getBaseURL(config),\n headers: getHttpHeaders(config),\n });\n};\n\n/**\n * @private\n */\nexport function getScriptURL(config: IPayEngineConfig) {\n if (!config.publicKey) {\n throw new Error('PayEngine Public Key is missing');\n }\n let scriptURL = '';\n const logLevelStr = config.logLevel ? `&loglevel=${config.logLevel}` : '';\n if (config.scriptURL) {\n scriptURL = `${config.scriptURL}?key=${config.publicKey}${logLevelStr}`;\n } else {\n const baseURL = config.publicKey.includes('_prod_')\n ? 'https://console.payengine.co'\n : 'https://console.payengine.dev';\n const version = config.version ?? '1.0.0';\n scriptURL = `${baseURL}/js/${version}/embed.js?key=${config.publicKey}${logLevelStr}`;\n }\n\n return scriptURL;\n}\n\n/**\n * @private\n */\nexport const debuggingScript = `\nconst consoleLog = (type, ...log) => window.ReactNativeWebView.postMessage(JSON.stringify({'type': 'Console', 'data': {'type': type, 'log': log}}));\nconsole = {\n log: (...log) => consoleLog('log', ...log),\n debug: (...log) => consoleLog('debug', ...log),\n info: (...log) => consoleLog('info', ...log),\n warn: (...log) => consoleLog('warn', ...log),\n error: (...log) => consoleLog('error', ...log),\n verbose: (...log) => consoleLog('verbose', ...log),\n};\n\nconst dispatchEvent_original = EventTarget.prototype.dispatchEvent;\nfunction dispatchEvent(event) {\n if (event.type && !event.type.startsWith('react')) {\n ReactNativeWebView.postMessage(JSON.stringify({\n type: 'PayEngine',\n event: {\n type: event.type,\n detail: event.detail\n }\n }))\n }\n}\nEventTarget.prototype.dispatchEvent = dispatchEvent;\n`;\n"],"mappings":"AAAA,OAAOA,KAAP,MAAkB,OAAlB;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,kBAAN,SAAiCC,KAAjC,CAAuC;EAC5CC,WAAW,GAAG;IACZ,MACE,0FADF;EAGD;;AAL2C;AAQ9C;AACA;AACA;;AACA,OAAO,MAAMC,cAAc,GAAIC,MAAD,IAA8B;EAC1D,OAAO;IACLC,aAAa,EAAG,kBAAiBD,MAAM,CAACE,SAAU;EAD7C,CAAP;AAGD,CAJM;AAMP;AACA;AACA;;AACA,OAAO,MAAMC,UAAU,GAAIH,MAAD,IAA8B;EACtD,IAAII,OAAO,GAAGJ,MAAM,CAACE,SAAP,CAAiBG,QAAjB,CAA0B,QAA1B,IACV,8BADU,GAEV,+BAFJ;;EAIA,IAAIL,MAAM,CAACM,SAAX,EAAsB;IACpBF,OAAO,GAAGJ,MAAM,CAACM,SAAP,CAAiBC,OAAjB,CAAyB,4BAAzB,EAAuD,IAAvD,CAAV;EACD;;EACD,OAAOH,OAAP;AACD,CATM;AAWP;AACA;AACA;;AACA,OAAO,MAAMI,gBAAgB,GAAIR,MAAD,IAA8B;EAC5D,OAAOL,KAAK,CAACc,MAAN,CAAa;IAClBC,OAAO,EAAEP,UAAU,CAACH,MAAD,CADD;IAElBW,OAAO,EAAEZ,cAAc,CAACC,MAAD;EAFL,CAAb,CAAP;AAID,CALM;AAOP;AACA;AACA;;AACA,OAAO,SAASY,YAAT,CAAsBZ,MAAtB,EAAgD;EACrD,IAAI,CAACA,MAAM,CAACE,SAAZ,EAAuB;IACrB,MAAM,IAAIL,KAAJ,CAAU,iCAAV,CAAN;EACD;;EACD,IAAIS,SAAS,GAAG,EAAhB;EACA,MAAMO,WAAW,GAAGb,MAAM,CAACc,QAAP,GAAmB,aAAYd,MAAM,CAACc,QAAS,EAA/C,GAAmD,EAAvE;;EACA,IAAId,MAAM,CAACM,SAAX,EAAsB;IACpBA,SAAS,GAAI,GAAEN,MAAM,CAACM,SAAU,QAAON,MAAM,CAACE,SAAU,GAAEW,WAAY,EAAtE;EACD,CAFD,MAEO;IACL,MAAMH,OAAO,GAAGV,MAAM,CAACE,SAAP,CAAiBG,QAAjB,CAA0B,QAA1B,IACZ,8BADY,GAEZ,+BAFJ;IAGA,MAAMU,OAAO,GAAGf,MAAM,CAACe,OAAP,IAAkB,OAAlC;IACAT,SAAS,GAAI,GAAEI,OAAQ,OAAMK,OAAQ,iBAAgBf,MAAM,CAACE,SAAU,GAAEW,WAAY,EAApF;EACD;;EAED,OAAOP,SAAP;AACD;AAED;AACA;AACA;;AACA,OAAO,MAAMU,eAAe,GAAI;AAChC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAxBO"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const PayEngine: () => JSX.Element;
|
|
1
|
+
declare const PayEngine: (_props: any) => JSX.Element;
|
|
2
2
|
export default PayEngine;
|
|
@@ -2,15 +2,57 @@ import * as React from 'react';
|
|
|
2
2
|
import { ViewProps } from 'react-native';
|
|
3
3
|
import type { PEPaymentRequest, PESummaryItem } from '../PEPaymentRequest';
|
|
4
4
|
import type { PEApplePayContact, PEApplePayPaymentMethod, PEApplePaySheetError, PEApplePayShippingMethod } from './PEApplePayInterfaces';
|
|
5
|
+
/**
|
|
6
|
+
* Props for the Apple Pay button component.
|
|
7
|
+
*
|
|
8
|
+
* This interface defines the properties you can pass to the Apple Pay button,
|
|
9
|
+
* including the payment request and various event callbacks triggered throughout
|
|
10
|
+
* the Apple Pay flow.
|
|
11
|
+
*
|
|
12
|
+
* @category Apple Pay
|
|
13
|
+
*/
|
|
5
14
|
export interface PEApplePayButtonProps extends ViewProps {
|
|
15
|
+
/**
|
|
16
|
+
* The payment request containing transaction details such as the total amount,
|
|
17
|
+
* currency, supported networks, and required contact fields.
|
|
18
|
+
*/
|
|
6
19
|
paymentRequest: PEPaymentRequest;
|
|
20
|
+
/**
|
|
21
|
+
* Callback triggered when the Apple Pay token is successfully generated.
|
|
22
|
+
*
|
|
23
|
+
* @param token - A string representing the Apple Pay payment token.
|
|
24
|
+
* @param metadata - Optional metadata related to the transaction.
|
|
25
|
+
* @param billingContact - The billing contact information (if available).
|
|
26
|
+
* @param shippingContact - The shipping contact information (if available).
|
|
27
|
+
*
|
|
28
|
+
* Example:
|
|
29
|
+
* ```ts
|
|
30
|
+
* onTokenDidReturn: (token, metadata, billing, shipping) => {
|
|
31
|
+
* console.log('Token:', token);
|
|
32
|
+
* console.log('Billing contact:', billing?.givenName);
|
|
33
|
+
* console.log('Shipping contact:', shipping?.givenName);
|
|
34
|
+
* }
|
|
35
|
+
* ```
|
|
36
|
+
*/
|
|
7
37
|
onTokenDidReturn?: (token: string, metadata?: any, billingContact?: PEApplePayContact, shippingContact?: PEApplePayContact) => void;
|
|
38
|
+
/**
|
|
39
|
+
* Callback triggered when the Apple Pay sheet is dismissed,
|
|
40
|
+
* either by completing the payment or canceling it.
|
|
41
|
+
*/
|
|
8
42
|
onPaymentSheetDismissed?: () => void;
|
|
43
|
+
/**
|
|
44
|
+
* Callback triggered when the Apple Pay process fails.
|
|
45
|
+
*
|
|
46
|
+
* @param error - The error that occurred during the payment flow.
|
|
47
|
+
*/
|
|
9
48
|
onPaymentFailed?: (error: Error) => void;
|
|
10
49
|
/**
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
50
|
+
* Callback triggered when the user selects or changes the payment method
|
|
51
|
+
* within the Apple Pay sheet.
|
|
52
|
+
*
|
|
53
|
+
* You MUST call `updatePaymentSheet` in response to this callback to update
|
|
54
|
+
* the Apple Pay sheet. Failing to do so will cause the sheet to hang
|
|
55
|
+
* and the transaction will automatically cancel.
|
|
14
56
|
*/
|
|
15
57
|
onPaymentMethodSelected?: (event: {
|
|
16
58
|
nativeEvent: {
|
|
@@ -18,9 +60,12 @@ export interface PEApplePayButtonProps extends ViewProps {
|
|
|
18
60
|
};
|
|
19
61
|
}) => void;
|
|
20
62
|
/**
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
63
|
+
* Callback triggered when the user selects a shipping contact
|
|
64
|
+
* (e.g., their shipping address) within the Apple Pay sheet.
|
|
65
|
+
*
|
|
66
|
+
* You MUST call `updatePaymentSheet` in response to this callback to update
|
|
67
|
+
* shipping methods, summary items, or errors. Failure to do so will hang the
|
|
68
|
+
* sheet and cancel the transaction automatically.
|
|
24
69
|
*/
|
|
25
70
|
onShippingContactSelected?: (event: {
|
|
26
71
|
nativeEvent: {
|
|
@@ -28,9 +73,12 @@ export interface PEApplePayButtonProps extends ViewProps {
|
|
|
28
73
|
};
|
|
29
74
|
}) => void;
|
|
30
75
|
/**
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
*
|
|
76
|
+
* Callback triggered when the user selects a shipping method (e.g., standard or express)
|
|
77
|
+
* in the Apple Pay sheet.
|
|
78
|
+
*
|
|
79
|
+
* You MUST call `updatePaymentSheet` in response to this callback to reflect
|
|
80
|
+
* any changes in pricing or available options. If you don't, the Apple Pay sheet
|
|
81
|
+
* will hang and the payment will be canceled.
|
|
34
82
|
*/
|
|
35
83
|
onShippingMethodSelected?: (event: {
|
|
36
84
|
nativeEvent: {
|
|
@@ -38,12 +86,169 @@ export interface PEApplePayButtonProps extends ViewProps {
|
|
|
38
86
|
};
|
|
39
87
|
}) => void;
|
|
40
88
|
}
|
|
89
|
+
/**
|
|
90
|
+
* Exposes imperative methods for controlling the Apple Pay payment sheet.
|
|
91
|
+
*
|
|
92
|
+
* This interface is typically used via a `ref` to programmatically update
|
|
93
|
+
* the state of the Apple Pay sheet after certain user interactions.
|
|
94
|
+
*
|
|
95
|
+
* Specifically, the `updatePaymentSheet` method should be called in response to
|
|
96
|
+
* any of the following events:
|
|
97
|
+
* - `onPaymentMethodSelected`
|
|
98
|
+
* - `onShippingContactSelected`
|
|
99
|
+
* - `onShippingMethodSelected`
|
|
100
|
+
*
|
|
101
|
+
* @category Apple Pay
|
|
102
|
+
*/
|
|
41
103
|
export interface PEApplePayButtonMethods {
|
|
42
104
|
/**
|
|
43
|
-
*
|
|
44
|
-
*
|
|
45
|
-
*
|
|
105
|
+
* Updates the Apple Pay payment sheet with new summary items, shipping methods, and validation errors.
|
|
106
|
+
*
|
|
107
|
+
* This method should be called in response to user selections made on the Apple Pay sheet,
|
|
108
|
+
* such as selecting a new payment method, shipping contact, or shipping method.
|
|
109
|
+
*
|
|
110
|
+
* ### Parameters:
|
|
111
|
+
* - `summaryItems`: The updated list of items summarizing the total payment amount (e.g., subtotal, tax, total).
|
|
112
|
+
* - `shippingMethods`: A list of available shipping methods based on the selected shipping contact.
|
|
113
|
+
* - Only applicable when the `onShippingContactSelected` callback is triggered.
|
|
114
|
+
* - `errors`: A list of validation errors (e.g., invalid address or unsupported shipping region).
|
|
115
|
+
* - Also only applicable for `onShippingContactSelected`.
|
|
116
|
+
*
|
|
117
|
+
* ### Returns:
|
|
118
|
+
* - A `Promise<boolean>` indicating whether the update was successful.
|
|
119
|
+
*
|
|
120
|
+
* ### Example:
|
|
121
|
+
* ```ts
|
|
122
|
+
* await ref.current?.updatePaymentSheet(
|
|
123
|
+
* updatedSummaryItems,
|
|
124
|
+
* availableShippingMethods,
|
|
125
|
+
* validationErrors
|
|
126
|
+
* );
|
|
127
|
+
* ```
|
|
46
128
|
*/
|
|
47
129
|
updatePaymentSheet: (summaryItems: PESummaryItem[], shippingMethods: PEApplePayShippingMethod[], errors: PEApplePaySheetError[]) => Promise<boolean>;
|
|
48
130
|
}
|
|
131
|
+
/**
|
|
132
|
+
* A React component for initiating an Apple Pay transaction.
|
|
133
|
+
*
|
|
134
|
+
* This button wraps the Apple Pay experience, including presenting the Apple Pay sheet,
|
|
135
|
+
* handling user interactions, processing the payment, and managing callbacks such as
|
|
136
|
+
* payment success, failure, and contact/method selection.
|
|
137
|
+
*
|
|
138
|
+
* It exposes imperative methods via `ref` to allow control over the Apple Pay sheet,
|
|
139
|
+
* such as updating summary items or shipping options in response to user input.
|
|
140
|
+
*
|
|
141
|
+
* ## Example Usage:
|
|
142
|
+
*
|
|
143
|
+
* ```tsx
|
|
144
|
+
* const paymentRequest = {
|
|
145
|
+
* merchantId: "merchant.com.example",
|
|
146
|
+
* countryCode: "US",
|
|
147
|
+
* currencyCode: "USD",
|
|
148
|
+
* paymentAmount: 10.00,
|
|
149
|
+
* paymentSummaryItems: [
|
|
150
|
+
* { label: "Test Item", amount: "10.00" }
|
|
151
|
+
* ],
|
|
152
|
+
* requiredShippingContactFields: ["name", "postalAddress"]
|
|
153
|
+
* };
|
|
154
|
+
*
|
|
155
|
+
* <PEApplePayButton
|
|
156
|
+
* paymentRequest={paymentRequest}
|
|
157
|
+
*
|
|
158
|
+
* // Triggered when payment fails
|
|
159
|
+
* onPaymentFailed={(error) => console.error("Payment failed:", error)}
|
|
160
|
+
*
|
|
161
|
+
* // Triggered when Apple Pay sheet is dismissed by the user
|
|
162
|
+
* onPaymentSheetDismissed={() => console.log("Payment sheet dismissed")}
|
|
163
|
+
*
|
|
164
|
+
* // Triggered when a valid token is generated after successful Apple Pay authorization
|
|
165
|
+
* onTokenDidReturn={(token, metadata, billingContact, shippingContact) => {
|
|
166
|
+
* console.log('Apple Pay token:', token, metadata, billingContact, shippingContact);
|
|
167
|
+
* // TODO: Send token to your server for processing
|
|
168
|
+
* purchaseWithToken(token);
|
|
169
|
+
* }}
|
|
170
|
+
*
|
|
171
|
+
* // Triggered when user selects or updates their shipping contact info
|
|
172
|
+
* onShippingContactSelected={(event) => {
|
|
173
|
+
* console.log('onShippingContactSelected', event.nativeEvent);
|
|
174
|
+
*
|
|
175
|
+
* if (!event.nativeEvent.contact.postalCode) {
|
|
176
|
+
* // Invalid postal code — update Apple Pay sheet with an error
|
|
177
|
+
* buttonRef?.current?.updatePaymentSheet([], [], [{
|
|
178
|
+
* errorType: PEApplePaySheetErrorType.InvalidShippingAddress,
|
|
179
|
+
* field: PEApplePayInvalidShippingField.PostalCode,
|
|
180
|
+
* message: 'Please update postal code to continue'
|
|
181
|
+
* }]);
|
|
182
|
+
* } else {
|
|
183
|
+
* // Provide updated shipping methods if contact is valid
|
|
184
|
+
* buttonRef?.current?.updatePaymentSheet([], [
|
|
185
|
+
* {
|
|
186
|
+
* identifier: 'new-shipping1',
|
|
187
|
+
* label: 'Updated shipping 1',
|
|
188
|
+
* amount: 3.99
|
|
189
|
+
* },
|
|
190
|
+
* {
|
|
191
|
+
* identifier: 'new-shipping2',
|
|
192
|
+
* label: 'Updated shipping 2',
|
|
193
|
+
* amount: 5.99
|
|
194
|
+
* }
|
|
195
|
+
* ], []);
|
|
196
|
+
* }
|
|
197
|
+
* }}
|
|
198
|
+
*
|
|
199
|
+
* // Triggered when user selects a shipping method
|
|
200
|
+
* onShippingMethodSelected={(event) => {
|
|
201
|
+
* console.log('onShippingMethodSelected', event.nativeEvent);
|
|
202
|
+
*
|
|
203
|
+
* const shippingFee = event.nativeEvent.shippingMethod.amount;
|
|
204
|
+
* const items = [
|
|
205
|
+
* {
|
|
206
|
+
* label: 'Product price',
|
|
207
|
+
* amount: paymentRequest.paymentAmount
|
|
208
|
+
* },
|
|
209
|
+
* ...(shippingFee > 0 ? [{
|
|
210
|
+
* label: 'Shipping Fee',
|
|
211
|
+
* amount: shippingFee
|
|
212
|
+
* }] : []),
|
|
213
|
+
* {
|
|
214
|
+
* label: 'Total',
|
|
215
|
+
* amount: paymentRequest.paymentAmount + shippingFee
|
|
216
|
+
* }
|
|
217
|
+
* ];
|
|
218
|
+
*
|
|
219
|
+
* buttonRef?.current?.updatePaymentSheet(items, [], []);
|
|
220
|
+
* }}
|
|
221
|
+
*
|
|
222
|
+
* // Triggered when user selects a payment method (e.g., credit, debit)
|
|
223
|
+
* onPaymentMethodSelected={(event) => {
|
|
224
|
+
* console.log('onPaymentMethodSelected', event.nativeEvent);
|
|
225
|
+
*
|
|
226
|
+
* const isCredit = event.nativeEvent.paymentMethod.type === PEApplePayPaymentMethodType.credit;
|
|
227
|
+
* const items = [
|
|
228
|
+
* {
|
|
229
|
+
* label: 'Product price',
|
|
230
|
+
* amount: paymentRequest.paymentAmount
|
|
231
|
+
* },
|
|
232
|
+
* ...(isCredit ? [{
|
|
233
|
+
* label: 'Credit discount',
|
|
234
|
+
* amount: 10
|
|
235
|
+
* }] : []),
|
|
236
|
+
* {
|
|
237
|
+
* label: 'Total',
|
|
238
|
+
* amount: paymentRequest.paymentAmount - (isCredit ? 1.00 : 0.00)
|
|
239
|
+
* }
|
|
240
|
+
* ];
|
|
241
|
+
*
|
|
242
|
+
* buttonRef?.current?.updatePaymentSheet(items, [], []);
|
|
243
|
+
* }}
|
|
244
|
+
*
|
|
245
|
+
* ref={applePayRef}
|
|
246
|
+
* />
|
|
247
|
+
* ```
|
|
248
|
+
*
|
|
249
|
+
* @param props - The props for configuring the Apple Pay button behavior.
|
|
250
|
+
* @param ref - A ref to access Apple Pay sheet update methods imperatively.
|
|
251
|
+
*
|
|
252
|
+
* @category Apple Pay
|
|
253
|
+
*/
|
|
49
254
|
export declare const PEApplePayButton: React.ForwardRefExoticComponent<PEApplePayButtonProps & React.RefAttributes<PEApplePayButtonMethods>>;
|