react-native-payengine 2.0.16 → 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/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 -133
- 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 +1848 -5121
- package/ios/PayEngineSDK.xcframework/ios-arm64/PayEngineSDK.framework/Modules/PayEngineSDK.swiftmodule/arm64-apple-ios.private.swiftinterface +35 -117
- package/ios/PayEngineSDK.xcframework/ios-arm64/PayEngineSDK.framework/Modules/PayEngineSDK.swiftmodule/arm64-apple-ios.private.swiftinterface-e +35 -117
- 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 -117
- package/ios/PayEngineSDK.xcframework/ios-arm64/PayEngineSDK.framework/Modules/PayEngineSDK.swiftmodule/arm64-apple-ios.swiftinterface-e +35 -117
- package/ios/PayEngineSDK.xcframework/ios-arm64/PayEngineSDK.framework/PayEngineSDK +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 -266
- 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 +1848 -5121
- package/ios/PayEngineSDK.xcframework/ios-arm64_x86_64-simulator/PayEngineSDK.framework/Modules/PayEngineSDK.swiftmodule/arm64-apple-ios-simulator.private.swiftinterface +35 -117
- package/ios/PayEngineSDK.xcframework/ios-arm64_x86_64-simulator/PayEngineSDK.framework/Modules/PayEngineSDK.swiftmodule/arm64-apple-ios-simulator.private.swiftinterface-e +35 -117
- 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 -117
- package/ios/PayEngineSDK.xcframework/ios-arm64_x86_64-simulator/PayEngineSDK.framework/Modules/PayEngineSDK.swiftmodule/arm64-apple-ios-simulator.swiftinterface-e +35 -117
- package/ios/PayEngineSDK.xcframework/ios-arm64_x86_64-simulator/PayEngineSDK.framework/Modules/PayEngineSDK.swiftmodule/x86_64-apple-ios-simulator.abi.json +1848 -5121
- package/ios/PayEngineSDK.xcframework/ios-arm64_x86_64-simulator/PayEngineSDK.framework/Modules/PayEngineSDK.swiftmodule/x86_64-apple-ios-simulator.private.swiftinterface +35 -117
- package/ios/PayEngineSDK.xcframework/ios-arm64_x86_64-simulator/PayEngineSDK.framework/Modules/PayEngineSDK.swiftmodule/x86_64-apple-ios-simulator.private.swiftinterface-e +35 -117
- 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 -117
- package/ios/PayEngineSDK.xcframework/ios-arm64_x86_64-simulator/PayEngineSDK.framework/Modules/PayEngineSDK.swiftmodule/x86_64-apple-ios-simulator.swiftinterface-e +35 -117
- 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/react-native-payengine.podspec +1 -1
- 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
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["React","findNodeHandle","NativeEventEmitter","NativeModules","Platform","requireNativeComponent","Text","UIManager","RNPEEventEmitter","peEventEmitter","COMPONENT_NAME","RNPEApplePayButton","RNPEApplePayButtonManager","PEApplePayButton","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","current","commandId","Commands","toString","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":"AAAA,OAAO,KAAKA,KAAZ,MAAuB,OAAvB;AACA,SACEC,cADF,EAEEC,kBAFF,EAGEC,aAHF,EAIEC,QAJF,EAKEC,sBALF,EAMEC,IANF,EAOEC,SAPF,QASO,cATP;AAkBA,MAAM;EAAEC;AAAF,IAAuBL,aAA7B;AAEA,MAAMM,cAAc,GAAG,IAAIP,kBAAJ,CAAuBM,gBAAvB,CAAvB;AAEA,MAAME,cAAc,GAAG,oBAAvB;AACA,MAAMC,kBAAkB,GACtBN,sBAAsB,CAA4BK,cAA5B,CADxB,C,CAGA;;AACA,MAAME,yBAAyB,GAAGL,SAAS,CAACG,cAAD,CAA3C;AA4FA,OAAO,MAAMG,gBAAgB,gBAAGb,KAAK,CAACc,UAAN,CAG9B,CAACC,KAAD,EAAQC,GAAR,KAAgB;EAChB,MAAMC,SAAS,GAAGjB,KAAK,CAACkB,MAAN,EAAlB;EAEAlB,KAAK,CAACmB,mBAAN,CAA0BH,GAA1B,EAA+B,OAAO;IACpCI,kBAAkB,EAAE,OAClBC,YADkB,EAElBC,eAFkB,EAGlBC,MAHkB,KAIG;MACrB,OAAO,IAAIC,OAAJ,CAAY,CAACC,OAAD,EAAUC,MAAV,KAAqB;QACtC,MAAMC,QAAQ,GAAGlB,cAAc,CAACmB,WAAf,CACf,4BADe,EAEdC,IAAD,IAAU;UACRF,QAAQ,CAACG,MAAT;UAEA,MAAM;YAAEC;UAAF,IAAYF,IAAlB;;UACA,IAAIE,KAAJ,EAAW;YACTL,MAAM,CAAC,IAAIM,KAAJ,CAAUD,KAAV,CAAD,CAAN;UACD,CAFD,MAEO;YACLN,OAAO,CAAC,IAAD,CAAP;UACD;QACF,CAX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,EAAEjD,KAAK,CAACyD,uBAVjC;IAWE,yBAAyB,EAAEzD,KAAK,CAAC0D,yBAXnC;IAYE,wBAAwB,EAAE1D,KAAK,CAAC2D;EAZlC,EADF;AAgBD,CA3H+B,CAAzB"}
|
|
1
|
+
{"version":3,"names":["React","findNodeHandle","NativeEventEmitter","NativeModules","Platform","requireNativeComponent","Text","UIManager","RNPEEventEmitter","peEventEmitter","COMPONENT_NAME","RNPEApplePayButton","RNPEApplePayButtonManager","PEApplePayButton","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","current","commandId","Commands","toString","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\n/**\n * Props for the Apple Pay button component.\n *\n * This interface defines the properties you can pass to the Apple Pay button,\n * including the payment request and various event callbacks triggered throughout\n * the Apple Pay flow.\n *\n * @category Apple Pay\n */\nexport interface PEApplePayButtonProps extends ViewProps {\n /**\n * The payment request containing transaction details such as the total amount,\n * currency, supported networks, and required contact fields.\n */\n paymentRequest: PEPaymentRequest;\n\n /**\n * Callback triggered when the Apple Pay token is successfully generated.\n *\n * @param token - A string representing the Apple Pay payment token.\n * @param metadata - Optional metadata related to the transaction.\n * @param billingContact - The billing contact information (if available).\n * @param shippingContact - The shipping contact information (if available).\n *\n * Example:\n * ```ts\n * onTokenDidReturn: (token, metadata, billing, shipping) => {\n * console.log('Token:', token);\n * console.log('Billing contact:', billing?.givenName);\n * console.log('Shipping contact:', shipping?.givenName);\n * }\n * ```\n */\n onTokenDidReturn?: (\n token: string,\n metadata?: any,\n billingContact?: PEApplePayContact,\n shippingContact?: PEApplePayContact\n ) => void;\n\n /**\n * Callback triggered when the Apple Pay sheet is dismissed,\n * either by completing the payment or canceling it.\n */\n onPaymentSheetDismissed?: () => void;\n\n /**\n * Callback triggered when the Apple Pay process fails.\n *\n * @param error - The error that occurred during the payment flow.\n */\n onPaymentFailed?: (error: Error) => void;\n\n /**\n * Callback triggered when the user selects or changes the payment method\n * within the Apple Pay sheet.\n *\n * You MUST call `updatePaymentSheet` in response to this callback to update\n * the Apple Pay sheet. Failing to do so will cause the sheet to hang\n * and the transaction will automatically cancel.\n */\n onPaymentMethodSelected?: (event: {\n nativeEvent: {\n paymentMethod: PEApplePayPaymentMethod;\n };\n }) => void;\n\n /**\n * Callback triggered when the user selects a shipping contact\n * (e.g., their shipping address) within the Apple Pay sheet.\n *\n * You MUST call `updatePaymentSheet` in response to this callback to update\n * shipping methods, summary items, or errors. Failure to do so will hang the\n * sheet and cancel the transaction automatically.\n */\n onShippingContactSelected?: (event: {\n nativeEvent: {\n contact: PEApplePayContact;\n };\n }) => void;\n\n /**\n * Callback triggered when the user selects a shipping method (e.g., standard or express)\n * in the Apple Pay sheet.\n *\n * You MUST call `updatePaymentSheet` in response to this callback to reflect\n * any changes in pricing or available options. If you don't, the Apple Pay sheet\n * will hang and the payment will be canceled.\n */\n onShippingMethodSelected?: (event: {\n nativeEvent: {\n shippingMethod: PEApplePayShippingMethod;\n };\n }) => void;\n}\n\n\n/**\n * Exposes imperative methods for controlling the Apple Pay payment sheet.\n *\n * This interface is typically used via a `ref` to programmatically update\n * the state of the Apple Pay sheet after certain user interactions.\n *\n * Specifically, the `updatePaymentSheet` method should be called in response to\n * any of the following events:\n * - `onPaymentMethodSelected`\n * - `onShippingContactSelected`\n * - `onShippingMethodSelected`\n *\n * @category Apple Pay\n */\nexport interface PEApplePayButtonMethods {\n /**\n * Updates the Apple Pay payment sheet with new summary items, shipping methods, and validation errors.\n *\n * This method should be called in response to user selections made on the Apple Pay sheet,\n * such as selecting a new payment method, shipping contact, or shipping method.\n *\n * ### Parameters:\n * - `summaryItems`: The updated list of items summarizing the total payment amount (e.g., subtotal, tax, total).\n * - `shippingMethods`: A list of available shipping methods based on the selected shipping contact.\n * - Only applicable when the `onShippingContactSelected` callback is triggered.\n * - `errors`: A list of validation errors (e.g., invalid address or unsupported shipping region).\n * - Also only applicable for `onShippingContactSelected`.\n *\n * ### Returns:\n * - A `Promise<boolean>` indicating whether the update was successful.\n *\n * ### Example:\n * ```ts\n * await ref.current?.updatePaymentSheet(\n * updatedSummaryItems,\n * availableShippingMethods,\n * validationErrors\n * );\n * ```\n */\n updatePaymentSheet: (\n summaryItems: PESummaryItem[],\n shippingMethods: PEApplePayShippingMethod[],\n errors: PEApplePaySheetError[]\n ) => Promise<boolean>;\n}\n\n\n/**\n * A React component for initiating an Apple Pay transaction.\n *\n * This button wraps the Apple Pay experience, including presenting the Apple Pay sheet,\n * handling user interactions, processing the payment, and managing callbacks such as\n * payment success, failure, and contact/method selection.\n *\n * It exposes imperative methods via `ref` to allow control over the Apple Pay sheet,\n * such as updating summary items or shipping options in response to user input.\n *\n * ## Example Usage:\n *\n * ```tsx\n * const paymentRequest = {\n * merchantId: \"merchant.com.example\",\n * countryCode: \"US\",\n * currencyCode: \"USD\",\n * paymentAmount: 10.00,\n * paymentSummaryItems: [\n * { label: \"Test Item\", amount: \"10.00\" }\n * ],\n * requiredShippingContactFields: [\"name\", \"postalAddress\"]\n * };\n *\n * <PEApplePayButton\n * paymentRequest={paymentRequest}\n *\n * // Triggered when payment fails\n * onPaymentFailed={(error) => console.error(\"Payment failed:\", error)}\n *\n * // Triggered when Apple Pay sheet is dismissed by the user\n * onPaymentSheetDismissed={() => console.log(\"Payment sheet dismissed\")}\n *\n * // Triggered when a valid token is generated after successful Apple Pay authorization\n * onTokenDidReturn={(token, metadata, billingContact, shippingContact) => {\n * console.log('Apple Pay token:', token, metadata, billingContact, shippingContact);\n * // TODO: Send token to your server for processing\n * purchaseWithToken(token);\n * }}\n *\n * // Triggered when user selects or updates their shipping contact info\n * onShippingContactSelected={(event) => {\n * console.log('onShippingContactSelected', event.nativeEvent);\n *\n * if (!event.nativeEvent.contact.postalCode) {\n * // Invalid postal code — update Apple Pay sheet with an error\n * buttonRef?.current?.updatePaymentSheet([], [], [{\n * errorType: PEApplePaySheetErrorType.InvalidShippingAddress,\n * field: PEApplePayInvalidShippingField.PostalCode,\n * message: 'Please update postal code to continue'\n * }]);\n * } else {\n * // Provide updated shipping methods if contact is valid\n * buttonRef?.current?.updatePaymentSheet([], [\n * {\n * identifier: 'new-shipping1',\n * label: 'Updated shipping 1',\n * amount: 3.99\n * },\n * {\n * identifier: 'new-shipping2',\n * label: 'Updated shipping 2',\n * amount: 5.99\n * }\n * ], []);\n * }\n * }}\n *\n * // Triggered when user selects a shipping method\n * onShippingMethodSelected={(event) => {\n * console.log('onShippingMethodSelected', event.nativeEvent);\n *\n * const shippingFee = event.nativeEvent.shippingMethod.amount;\n * const items = [\n * {\n * label: 'Product price',\n * amount: paymentRequest.paymentAmount\n * },\n * ...(shippingFee > 0 ? [{\n * label: 'Shipping Fee',\n * amount: shippingFee\n * }] : []),\n * {\n * label: 'Total',\n * amount: paymentRequest.paymentAmount + shippingFee\n * }\n * ];\n *\n * buttonRef?.current?.updatePaymentSheet(items, [], []);\n * }}\n *\n * // Triggered when user selects a payment method (e.g., credit, debit)\n * onPaymentMethodSelected={(event) => {\n * console.log('onPaymentMethodSelected', event.nativeEvent);\n *\n * const isCredit = event.nativeEvent.paymentMethod.type === PEApplePayPaymentMethodType.credit;\n * const items = [\n * {\n * label: 'Product price',\n * amount: paymentRequest.paymentAmount\n * },\n * ...(isCredit ? [{\n * label: 'Credit discount',\n * amount: 10\n * }] : []),\n * {\n * label: 'Total',\n * amount: paymentRequest.paymentAmount - (isCredit ? 1.00 : 0.00)\n * }\n * ];\n *\n * buttonRef?.current?.updatePaymentSheet(items, [], []);\n * }}\n *\n * ref={applePayRef}\n * />\n * ```\n *\n * @param props - The props for configuring the Apple Pay button behavior.\n * @param ref - A ref to access Apple Pay sheet update methods imperatively.\n *\n * @category Apple Pay\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":"AAAA,OAAO,KAAKA,KAAZ,MAAuB,OAAvB;AACA,SACEC,cADF,EAEEC,kBAFF,EAGEC,aAHF,EAIEC,QAJF,EAKEC,sBALF,EAMEC,IANF,EAOEC,SAPF,QASO,cATP;AAkBA,MAAM;EAAEC;AAAF,IAAuBL,aAA7B;AAEA,MAAMM,cAAc,GAAG,IAAIP,kBAAJ,CAAuBM,gBAAvB,CAAvB;AAEA,MAAME,cAAc,GAAG,oBAAvB;AACA,MAAMC,kBAAkB,GACtBN,sBAAsB,CAA4BK,cAA5B,CADxB,C,CAGA;;AACA,MAAME,yBAAyB,GAAGL,SAAS,CAACG,cAAD,CAA3C;;AAsLA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;A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WF,qBAAX,CADwC,GAEzC,IAFJ;MAIA7C,KAAK,CAACsC,gBAAN,CACEC,KADF,EAEEC,QAFF,EAGEE,cAAc,IAAIM,SAHpB,EAIEJ,eAAe,IAAII,SAJrB;IAMD;EACF,CA9BD;;EAgCA,MAAMC,iBAAiB,GAAG,MAAM;IAC9B,IAAIjD,KAAK,CAACkD,uBAAV,EAAmC;MACjClD,KAAK,CAACkD,uBAAN;IACD;EACF,CAJD;;EAMA,IAAI7D,QAAQ,CAACyC,EAAT,KAAgB,KAApB,EAA2B;IACzB,oBAAO,oBAAC,IAAD,sDAAP;EACD;;EAED,oBACE,oBAAC,kBAAD;IACE,GAAG,EAAE5B,SADP;IAEE,KAAK,EAAE;MAAEiD,MAAM,EAAE,EAAV;MAAcC,KAAK,EAAE,MAArB;MAA6B,GAAIpD,KAAK,CAACqD;IAAvC,CAFT;IAGE,cAAc,EAAEP,IAAI,CAACQ,SAAL,CAAe,EAC7B,GAAGtD,KAAK,CAACuD,cADoB;MAE7B,GAAGvD,KAAK,CAACuD,cAAN,CAAqBC;IAFK,CAAf,CAHlB;IAOE,SAAS,EAAEvB,OAPb;IAQE,kBAAkB,EAAEI,gBARtB;IASE,mBAAmB,EAAEY,iBATvB;IAUE,uBAAuB,EAAEjD,KAAK,CAACyD,uBAVjC;IAWE,yBAAyB,EAAEzD,KAAK,CAAC0D,yBAXnC;IAYE,wBAAwB,EAAE1D,KAAK,CAAC2D;EAZlC,EADF;AAgBD,CA3H+B,CAAzB"}
|
|
@@ -1,4 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A model representing a contact associated with Apple Pay.
|
|
3
|
+
*
|
|
4
|
+
* This interface defines the contact details that can be associated with an Apple Pay transaction,
|
|
5
|
+
* including personal and address information such as the contact's name, address, email, and phone number.
|
|
6
|
+
* The fields are optional, meaning not all fields need to be provided when creating an instance.
|
|
7
|
+
*
|
|
8
|
+
* ## Example Usage:
|
|
9
|
+
* ```ts
|
|
10
|
+
* const contact: PEApplePayContact = {
|
|
11
|
+
* givenName: 'John',
|
|
12
|
+
* familyName: 'Doe',
|
|
13
|
+
* addressLines: ['123 Main St', 'Suite 400'],
|
|
14
|
+
* locality: 'Anytown',
|
|
15
|
+
* administrativeArea: 'CA',
|
|
16
|
+
* postalCode: '12345',
|
|
17
|
+
* country: 'USA',
|
|
18
|
+
* countryCode: 'US',
|
|
19
|
+
* subAdministrativeArea: 'SubArea',
|
|
20
|
+
* subLocality: 'Locality',
|
|
21
|
+
* emailAddress: 'john.doe@example.com',
|
|
22
|
+
* phoneNumber: '+1234567890',
|
|
23
|
+
* };
|
|
24
|
+
* ```
|
|
25
|
+
*
|
|
26
|
+
* @category Apple Pay
|
|
27
|
+
*/
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* A model representing the selected Apple Pay payment method.
|
|
31
|
+
*
|
|
32
|
+
* This interface provides details about the payment method chosen by the user
|
|
33
|
+
* during an Apple Pay transaction. It includes the method's display name,
|
|
34
|
+
* payment network (e.g., Visa, MasterCard), and the type of payment method.
|
|
35
|
+
*
|
|
36
|
+
* ## Example Usage:
|
|
37
|
+
* ```ts
|
|
38
|
+
* const paymentMethod: PEApplePayPaymentMethod = {
|
|
39
|
+
* displayName: 'Visa 1234',
|
|
40
|
+
* network: 'Visa',
|
|
41
|
+
* type: 'credit', // or 'debit', depending on your enum or string literal type
|
|
42
|
+
* };
|
|
43
|
+
* ```
|
|
44
|
+
*
|
|
45
|
+
* @category Apple Pay
|
|
46
|
+
*/
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Enum representing the different types of payment methods supported by Apple Pay.
|
|
50
|
+
* Each value corresponds to a specific payment method category.
|
|
51
|
+
*
|
|
52
|
+
* @category Apple Pay
|
|
53
|
+
*/
|
|
1
54
|
export let PEApplePayPaymentMethodType;
|
|
55
|
+
/**
|
|
56
|
+
* Represents a shipping method available during Apple Pay checkout.
|
|
57
|
+
*
|
|
58
|
+
* Includes label, amount, and identifier.
|
|
59
|
+
*
|
|
60
|
+
* @category Apple Pay
|
|
61
|
+
*/
|
|
2
62
|
|
|
3
63
|
(function (PEApplePayPaymentMethodType) {
|
|
4
64
|
PEApplePayPaymentMethodType[PEApplePayPaymentMethodType["unknown"] = 0] = "unknown";
|
|
@@ -9,7 +69,22 @@ export let PEApplePayPaymentMethodType;
|
|
|
9
69
|
PEApplePayPaymentMethodType[PEApplePayPaymentMethodType["eMoney"] = 5] = "eMoney";
|
|
10
70
|
})(PEApplePayPaymentMethodType || (PEApplePayPaymentMethodType = {}));
|
|
11
71
|
|
|
72
|
+
/**
|
|
73
|
+
* Enum representing the types of errors that can occur during the Apple Pay
|
|
74
|
+
* sheet process. These errors typically relate to issues with the shipping
|
|
75
|
+
* address provided by the user.
|
|
76
|
+
*
|
|
77
|
+
* @category Apple Pay
|
|
78
|
+
*/
|
|
12
79
|
export let PEApplePaySheetErrorType;
|
|
80
|
+
/**
|
|
81
|
+
*
|
|
82
|
+
* Enum representing the fields of shipping address that may be invalid
|
|
83
|
+
* during Apple Pay transactions. These values can be used to identify
|
|
84
|
+
* which part of the shipping address is incorrect or missing.
|
|
85
|
+
*
|
|
86
|
+
* @category Apple Pay
|
|
87
|
+
*/
|
|
13
88
|
|
|
14
89
|
(function (PEApplePaySheetErrorType) {
|
|
15
90
|
PEApplePaySheetErrorType["InvalidShippingAddress"] = "InvalidShippingAddress";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["PEApplePayPaymentMethodType","PEApplePaySheetErrorType","PEApplePayInvalidShippingField"],"sources":["PEApplePayInterfaces.ts"],"sourcesContent":["
|
|
1
|
+
{"version":3,"names":["PEApplePayPaymentMethodType","PEApplePaySheetErrorType","PEApplePayInvalidShippingField"],"sources":["PEApplePayInterfaces.ts"],"sourcesContent":["/**\n * A model representing a contact associated with Apple Pay.\n *\n * This interface defines the contact details that can be associated with an Apple Pay transaction,\n * including personal and address information such as the contact's name, address, email, and phone number.\n * The fields are optional, meaning not all fields need to be provided when creating an instance.\n *\n * ## Example Usage:\n * ```ts\n * const contact: PEApplePayContact = {\n * givenName: 'John',\n * familyName: 'Doe',\n * addressLines: ['123 Main St', 'Suite 400'],\n * locality: 'Anytown',\n * administrativeArea: 'CA',\n * postalCode: '12345',\n * country: 'USA',\n * countryCode: 'US',\n * subAdministrativeArea: 'SubArea',\n * subLocality: 'Locality',\n * emailAddress: 'john.doe@example.com',\n * phoneNumber: '+1234567890',\n * };\n * ```\n *\n * @category Apple Pay\n */\nexport interface PEApplePayContact {\n /**\n * The given (first) name of the contact.\n * \n * Example: \"John\"\n */\n givenName?: string;\n\n /**\n * The family (last) name of the contact.\n * \n * Example: \"Doe\"\n */\n familyName?: string;\n\n /**\n * The contact's address lines, typically representing street addresses.\n * \n * Example: [\"123 Main St\", \"Suite 400\"]\n */\n addressLines?: string[];\n\n /**\n * The city or locality of the contact's address.\n * \n * Example: \"Anytown\"\n */\n locality?: string;\n\n /**\n * The state, province, or administrative area of the contact's address.\n * \n * Example: \"CA\"\n */\n administrativeArea?: string;\n\n /**\n * The postal code (ZIP code) of the contact's address.\n * \n * Example: \"12345\"\n */\n postalCode?: string;\n\n /**\n * The full country name of the contact's address.\n * \n * Example: \"USA\"\n */\n country?: string;\n\n /**\n * The ISO country code (e.g., \"US\" for the United States).\n * \n * Example: \"US\"\n */\n countryCode?: string;\n\n /**\n * A more specific administrative area within the main administrative area.\n * \n * Example: \"SubArea\"\n */\n subAdministrativeArea?: string;\n\n /**\n * A more specific locality within the main locality.\n * \n * Example: \"Locality\"\n */\n subLocality?: string;\n\n /**\n * The contact's email address.\n * \n * Example: \"john.doe@example.com\"\n */\n emailAddress?: string;\n\n /**\n * The contact's phone number.\n * \n * Example: \"+1234567890\"\n */\n phoneNumber?: string;\n}\n\n\n/**\n * A model representing the selected Apple Pay payment method.\n *\n * This interface provides details about the payment method chosen by the user\n * during an Apple Pay transaction. It includes the method's display name,\n * payment network (e.g., Visa, MasterCard), and the type of payment method.\n *\n * ## Example Usage:\n * ```ts\n * const paymentMethod: PEApplePayPaymentMethod = {\n * displayName: 'Visa 1234',\n * network: 'Visa',\n * type: 'credit', // or 'debit', depending on your enum or string literal type\n * };\n * ```\n *\n * @category Apple Pay\n */\nexport interface PEApplePayPaymentMethod {\n /**\n * A user-facing description of the payment method.\n * \n * This typically includes the card type and last few digits, e.g., \"Visa 1234\".\n */\n displayName?: string;\n\n /**\n * The network associated with the payment method.\n * \n * Common examples include \"Visa\", \"MasterCard\", \"Amex\", etc.\n */\n network?: string;\n\n /**\n * The type of payment method.\n * \n * This is a required field indicating whether the method is a credit card, debit card, etc.\n */\n type: PEApplePayPaymentMethodType;\n}\n\n\n/**\n * Enum representing the different types of payment methods supported by Apple Pay.\n * Each value corresponds to a specific payment method category.\n * \n * @category Apple Pay\n */\nexport enum PEApplePayPaymentMethodType {\n /** Unknown payment method type. */\n unknown = 0,\n\n /** Debit card payment method. */\n debit = 1,\n\n /** Credit card payment method. */\n credit = 2,\n\n /** Prepaid card payment method. */\n prepaid = 3,\n\n /** Store card payment method. */\n store = 4,\n\n /** Electronic money (e-money) payment method. */\n eMoney = 5\n}\n\n\n/**\n * Represents a shipping method available during Apple Pay checkout.\n *\n * Includes label, amount, and identifier.\n *\n * @category Apple Pay\n */\nexport interface PEApplePayShippingMethod {\n /** Unique identifier for the shipping method. */\n identifier: string;\n\n /** Cost associated with this shipping method. */\n amount: number;\n\n /** Display label (e.g., \"Express Delivery\"). */\n label: string;\n}\n\n/**\n * Type representing the possible errors that can occur during the Apple Pay\n * sheet process. This includes issues related to invalid or unserviceable\n * shipping addresses.\n * \n * * @category Apple Pay\n */\nexport type PEApplePaySheetError =\n | {\n /** The error occurs due to an invalid shipping address. */\n errorType: PEApplePaySheetErrorType.InvalidShippingAddress;\n\n /** The specific field in the shipping address that caused the error. */\n field: PEApplePayInvalidShippingField;\n\n /** An optional message providing more details about the error. */\n message?: string;\n }\n | {\n /** The error occurs due to an unserviceable shipping address. */\n errorType: PEApplePaySheetErrorType.UnserviceableShippingAddress;\n\n /** An optional message providing more details about the error. */\n message?: string;\n };\n\n/**\n * Enum representing the types of errors that can occur during the Apple Pay \n * sheet process. These errors typically relate to issues with the shipping \n * address provided by the user.\n * \n * @category Apple Pay\n */\nexport enum PEApplePaySheetErrorType {\n /** The shipping address provided is invalid. */\n InvalidShippingAddress = 'InvalidShippingAddress',\n\n /** The shipping address provided is unserviceable (e.g., the address cannot be delivered to). */\n UnserviceableShippingAddress = 'UnserviceableShippingAddress',\n}\n\n/**\n * \n * Enum representing the fields of shipping address that may be invalid\n * during Apple Pay transactions. These values can be used to identify \n * which part of the shipping address is incorrect or missing.\n * \n * @category Apple Pay\n */\nexport enum PEApplePayInvalidShippingField {\n /** The street address is invalid or missing. */\n Street = 'street',\n\n /** The city is invalid or missing. */\n City = 'city',\n\n /** The sub-administrative area (e.g., district) is invalid or missing. */\n SubAdministrativeArea = 'subAdministrativeArea',\n\n /** The state or province is invalid or missing. */\n State = 'state',\n\n /** The postal code is invalid or missing. */\n PostalCode = 'postalCode',\n\n /** The country is invalid or missing. */\n Country = 'country',\n\n /** The country code is invalid or missing. */\n CountryCode = 'countryCode',\n\n /** The sub-locality (e.g., neighborhood) is invalid or missing. */\n SubLocality = 'subLocality',\n}\n\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAwFA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAyBA;AACA;AACA;AACA;AACA;AACA;AACA,WAAYA,2BAAZ;AAqBA;AACA;AACA;AACA;AACA;AACA;AACA;;WA3BYA,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,KAAAA,2B;;AAiEZ;AACA;AACA;AACA;AACA;AACA;AACA;AACA,WAAYC,wBAAZ;AAQA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;WAfYA,wB;EAAAA,wB;EAAAA,wB;GAAAA,wB,KAAAA,wB;;AAgBZ,WAAYC,8BAAZ;;WAAYA,8B;EAAAA,8B;EAAAA,8B;EAAAA,8B;EAAAA,8B;EAAAA,8B;EAAAA,8B;EAAAA,8B;EAAAA,8B;GAAAA,8B,KAAAA,8B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["PEGooglePayAddress.ts"],"sourcesContent":["
|
|
1
|
+
{"version":3,"names":[],"sources":["PEGooglePayAddress.ts"],"sourcesContent":["/**\n * Represents a Google Pay address containing structured user information.\n *\n * This model holds address details returned from Google Pay, including\n * name, street address lines, locality, country code, phone number, and postal code.\n *\n * ## Example Usage:\n * ```ts\n * const address: PEGooglePayAddress = {\n * address1: \"1600 Amphitheatre Parkway\",\n * administrativeArea: \"CA\",\n * countryCode: \"US\",\n * locality: \"Mountain View\",\n * name: \"John Doe\",\n * phoneNumber: \"+1 123-456-7890\",\n * postalCode: \"94043\",\n * };\n * ```\n *\n * @category Google Pay\n */\nexport interface PEGooglePayAddress {\n /** The first line of the street address (e.g., \"123 Main St\"). */\n address1?: string;\n\n /** The second line of the street address (e.g., apartment, suite, or unit number). */\n address2?: string;\n\n /** The third line of the street address (if applicable). */\n address3?: string;\n\n /** The state, province, or region of the address. */\n administrativeArea?: string;\n\n /** The two-letter country code in ISO 3166-1 alpha-2 format (e.g., \"US\", \"CA\"). */\n countryCode?: string;\n\n /** The city or town of the address. */\n locality?: string;\n\n /** The full name of the recipient. */\n name?: string;\n\n /** The phone number associated with the address. */\n phoneNumber?: string;\n\n /** The ZIP or postal code. */\n postalCode?: string;\n}\n"],"mappings":""}
|
|
@@ -5,6 +5,59 @@ const {
|
|
|
5
5
|
} = NativeModules;
|
|
6
6
|
const RNPEGooglePayButton = requireNativeComponent('RNPEGooglePayButton');
|
|
7
7
|
const peEventEmitter = new NativeEventEmitter(RNPEEventEmitter);
|
|
8
|
+
/**
|
|
9
|
+
* Props for rendering the Google Pay payment button.
|
|
10
|
+
*
|
|
11
|
+
* This interface defines the configuration and callback handlers
|
|
12
|
+
* used when initiating a Google Pay transaction.
|
|
13
|
+
*
|
|
14
|
+
* @category Google Pay
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* A React Native component for rendering a Google Pay button.
|
|
19
|
+
*
|
|
20
|
+
* This button allows users to initiate a Google Pay transaction using the
|
|
21
|
+
* provided `paymentRequest`. The component communicates with native code
|
|
22
|
+
* and emits events through a shared event emitter (`peEventEmitter`) to
|
|
23
|
+
* notify the JavaScript layer about the payment result.
|
|
24
|
+
*
|
|
25
|
+
* ## Example Usage:
|
|
26
|
+
* ```tsx
|
|
27
|
+
* const paymentRequest = {
|
|
28
|
+
* merchantId: 'your-merchant-id',
|
|
29
|
+
* paymentAmount: 10.00,
|
|
30
|
+
* paymentItems: [
|
|
31
|
+
* { label: 'Test Item', amount: 10.00 }
|
|
32
|
+
* ],
|
|
33
|
+
* platformOptions: {
|
|
34
|
+
* billingAddressRequired: true,
|
|
35
|
+
* shippingAddressRequired: true,
|
|
36
|
+
* },
|
|
37
|
+
* };
|
|
38
|
+
*
|
|
39
|
+
* <PEGooglePayButton
|
|
40
|
+
* paymentRequest={paymentRequest}
|
|
41
|
+
* onPaymentFailed={(error) => {
|
|
42
|
+
* console.log("Payment failed", error);
|
|
43
|
+
* }}
|
|
44
|
+
* onPaymentSheetDismissed={() => {
|
|
45
|
+
* console.log("Payment sheet dismissed");
|
|
46
|
+
* }}
|
|
47
|
+
* onTokenDidReturn={(token, metadata, billingAddress, shippingAddress) => {
|
|
48
|
+
* console.log("Payment successful", token, metadata, billingAddress, shippingAddress);
|
|
49
|
+
* }}
|
|
50
|
+
* />
|
|
51
|
+
* ```
|
|
52
|
+
*
|
|
53
|
+
* ## Platform Support:
|
|
54
|
+
* - **Android only**: On iOS, this component renders a fallback message.
|
|
55
|
+
*
|
|
56
|
+
* @param props - See {@link PEGooglePayButtonProps}
|
|
57
|
+
* @returns A Google Pay button on Android or a fallback message on iOS.
|
|
58
|
+
*
|
|
59
|
+
* @category Google Pay
|
|
60
|
+
*/
|
|
8
61
|
export const PEGooglePayButton = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
9
62
|
React.useImperativeHandle(ref, () => ({}));
|
|
10
63
|
React.useEffect(() => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["React","NativeEventEmitter","NativeModules","Platform","requireNativeComponent","Text","RNPEEventEmitter","RNPEGooglePayButton","peEventEmitter","PEGooglePayButton","forwardRef","props","ref","useImperativeHandle","useEffect","listener1","addListener","args","token","metadata","metadataString","billingAddress","billingAddressString","shippingAddress","shippingAddressString","console","log","JSON","parse","onTokenDidReturn","undefined","listener2","error","onPaymentFailed","Error","listener3","onPaymentSheetDismissed","remove","OS","height","width","style","stringify","paymentRequest","platformOptions"],"sources":["PEGooglePayButton.tsx"],"sourcesContent":["\nimport * as React from 'react';\nimport { NativeEventEmitter, NativeModules, Platform, requireNativeComponent, Text, ViewProps } from 'react-native';\nimport type { PEPaymentRequest } from '../PEPaymentRequest';\nimport type { PEGooglePayAddress } from './PEGooglePayAddress';\n\nconst { RNPEEventEmitter } = NativeModules;\n\nconst RNPEGooglePayButton = requireNativeComponent<NativePEGooglePayViewProps>('RNPEGooglePayButton');\n\ninterface NativePEGooglePayViewProps extends ViewProps {\n // amount: number;\n // merchantId: string;\n paymentRequest: string;\n}\n\nconst peEventEmitter = new NativeEventEmitter(RNPEEventEmitter);\n\nexport interface PEGooglePayButtonProps extends ViewProps {\n paymentRequest: PEPaymentRequest;\n onTokenDidReturn?: (token: string
|
|
1
|
+
{"version":3,"names":["React","NativeEventEmitter","NativeModules","Platform","requireNativeComponent","Text","RNPEEventEmitter","RNPEGooglePayButton","peEventEmitter","PEGooglePayButton","forwardRef","props","ref","useImperativeHandle","useEffect","listener1","addListener","args","token","metadata","metadataString","billingAddress","billingAddressString","shippingAddress","shippingAddressString","console","log","JSON","parse","onTokenDidReturn","undefined","listener2","error","onPaymentFailed","Error","listener3","onPaymentSheetDismissed","remove","OS","height","width","style","stringify","paymentRequest","platformOptions"],"sources":["PEGooglePayButton.tsx"],"sourcesContent":["\nimport * as React from 'react';\nimport { NativeEventEmitter, NativeModules, Platform, requireNativeComponent, Text, ViewProps } from 'react-native';\nimport type { PEPaymentRequest } from '../PEPaymentRequest';\nimport type { PEGooglePayAddress } from './PEGooglePayAddress';\n\nconst { RNPEEventEmitter } = NativeModules;\n\nconst RNPEGooglePayButton = requireNativeComponent<NativePEGooglePayViewProps>('RNPEGooglePayButton');\n\ninterface NativePEGooglePayViewProps extends ViewProps {\n // amount: number;\n // merchantId: string;\n paymentRequest: string;\n}\n\nconst peEventEmitter = new NativeEventEmitter(RNPEEventEmitter);\n\n/**\n * Props for rendering the Google Pay payment button.\n *\n * This interface defines the configuration and callback handlers\n * used when initiating a Google Pay transaction.\n *\n * @category Google Pay\n */\nexport interface PEGooglePayButtonProps extends ViewProps {\n /**\n * The payment request containing merchant details, amount, currency,\n * and optional payment item breakdown.\n *\n * This object defines the core transaction that will be processed.\n */\n paymentRequest: PEPaymentRequest;\n\n /**\n * Callback triggered when a Google Pay token is successfully returned.\n *\n * @param token - The Google Pay payment token as a string.\n * @param metadata - Additional transaction metadata (if available).\n * @param billingAddress - The billing address provided by Google Pay (optional).\n * @param shippingAddress - The shipping address provided by Google Pay (optional).\n *\n * Example usage:\n * ```ts\n * onTokenDidReturn: (token, metadata, billingAddress, shippingAddress) => {\n * console.log(\"Token:\", token);\n * }\n * ```\n */\n onTokenDidReturn?: (\n token: string,\n metadata?: any,\n billingAddress?: PEGooglePayAddress,\n shippingAddress?: PEGooglePayAddress\n ) => void;\n\n /**\n * Callback triggered when the Google Pay sheet is dismissed\n * without completing the payment.\n *\n * Useful for UI updates or restoring state.\n */\n onPaymentSheetDismissed?: () => void;\n\n /**\n * Callback triggered when a payment fails during processing.\n *\n * @param error - An error object describing the cause of the failure.\n *\n * Example:\n * ```ts\n * onPaymentFailed: (error) => {\n * console.error(\"Payment failed:\", error.message);\n * }\n * ```\n */\n onPaymentFailed?: (error: Error) => void;\n}\n\n/**\n * Interface for defining methods related to the Google Pay button.\n *\n * Currently empty, this interface serves as a placeholder for any\n * platform-specific Google Pay button methods that may be added in the future.\n *\n * @category Google Pay\n */\nexport interface PEGooglePayButtonMethods { }\n\n/**\n * A React Native component for rendering a Google Pay button.\n *\n * This button allows users to initiate a Google Pay transaction using the\n * provided `paymentRequest`. The component communicates with native code\n * and emits events through a shared event emitter (`peEventEmitter`) to\n * notify the JavaScript layer about the payment result.\n *\n * ## Example Usage:\n * ```tsx\n * const paymentRequest = {\n * merchantId: 'your-merchant-id',\n * paymentAmount: 10.00,\n * paymentItems: [\n * { label: 'Test Item', amount: 10.00 }\n * ],\n * platformOptions: {\n * billingAddressRequired: true,\n * shippingAddressRequired: true,\n * },\n * };\n * \n * <PEGooglePayButton\n * paymentRequest={paymentRequest}\n * onPaymentFailed={(error) => {\n * console.log(\"Payment failed\", error);\n * }}\n * onPaymentSheetDismissed={() => {\n * console.log(\"Payment sheet dismissed\");\n * }}\n * onTokenDidReturn={(token, metadata, billingAddress, shippingAddress) => {\n * console.log(\"Payment successful\", token, metadata, billingAddress, shippingAddress);\n * }}\n * />\n * ```\n *\n * ## Platform Support:\n * - **Android only**: On iOS, this component renders a fallback message.\n *\n * @param props - See {@link PEGooglePayButtonProps}\n * @returns A Google Pay button on Android or a fallback message on iOS.\n *\n * @category Google Pay\n */\nexport const PEGooglePayButton = React.forwardRef<\n PEGooglePayButtonMethods,\n PEGooglePayButtonProps\n>((props, ref) => {\n\n React.useImperativeHandle(ref, () => ({\n }));\n\n React.useEffect(() => {\n const listener1 = peEventEmitter.addListener('onGooglePayRespond', args => {\n const { token, metadata: metadataString, billingAddress: billingAddressString, shippingAddress: shippingAddressString } = args;\n console.log('ON token', token, metadataString, billingAddressString, shippingAddressString)\n const metadata = metadataString ? JSON.parse(metadataString) : null;\n const billingAddress = billingAddressString ? JSON.parse(billingAddressString) as PEGooglePayAddress : null;\n const shippingAddress = shippingAddressString ? JSON.parse(shippingAddressString) as PEGooglePayAddress : null;\n\n props.onTokenDidReturn?.(token, metadata, billingAddress ?? undefined, shippingAddress ?? undefined)\n });\n\n const listener2 = peEventEmitter.addListener('onGooglePayError', args => {\n const { error } = args;\n console.log('ON error', error)\n props.onPaymentFailed?.(new Error(error))\n });\n\n const listener3 = peEventEmitter.addListener('onGooglePayDismiss', () => {\n console.log('ON dismiss')\n props.onPaymentSheetDismissed?.()\n });\n\n return () => {\n listener1.remove();\n listener2.remove();\n listener3.remove();\n }\n }, []);\n\n if (Platform.OS !== 'android') {\n return <Text>Google Pay is not supported on this platform</Text>\n }\n\n return (\n <RNPEGooglePayButton\n style={{ height: 32, width: '100%', ...(props.style as object) }}\n // amount={props.paymentRequest.paymentAmount}\n // merchantId={props.paymentRequest.merchantId} \n paymentRequest={JSON.stringify({\n ...props.paymentRequest,\n ...props.paymentRequest.platformOptions\n })}\n />\n );\n});\n"],"mappings":"AACA,OAAO,KAAKA,KAAZ,MAAuB,OAAvB;AACA,SAASC,kBAAT,EAA6BC,aAA7B,EAA4CC,QAA5C,EAAsDC,sBAAtD,EAA8EC,IAA9E,QAAqG,cAArG;AAIA,MAAM;EAAEC;AAAF,IAAuBJ,aAA7B;AAEA,MAAMK,mBAAmB,GAAGH,sBAAsB,CAA6B,qBAA7B,CAAlD;AAQA,MAAMI,cAAc,GAAG,IAAIP,kBAAJ,CAAuBK,gBAAvB,CAAvB;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAiEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA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A,yBAAArB,KAAK,CAACsB,eAAN,qFAAAtB,KAAK,EAAmB,IAAIuB,KAAJ,CAAUF,KAAV,CAAnB,CAAL;IACD,CAJiB,CAAlB;IAMA,MAAMG,SAAS,GAAG3B,cAAc,CAACQ,WAAf,CAA2B,oBAA3B,EAAiD,MAAM;MAAA;;MACvES,OAAO,CAACC,GAAR,CAAY,YAAZ;MACA,yBAAAf,KAAK,CAACyB,uBAAN,qFAAAzB,KAAK;IACN,CAHiB,CAAlB;IAKA,OAAO,MAAM;MACXI,SAAS,CAACsB,MAAV;MACAN,SAAS,CAACM,MAAV;MACAF,SAAS,CAACE,MAAV;IACD,CAJD;EAKD,CA3BD,EA2BG,EA3BH;;EA6BA,IAAIlC,QAAQ,CAACmC,EAAT,KAAgB,SAApB,EAA+B;IAC7B,oBAAO,oBAAC,IAAD,uDAAP;EACD;;EAED,oBACE,oBAAC,mBAAD;IACE,KAAK,EAAE;MAAEC,MAAM,EAAE,EAAV;MAAcC,KAAK,EAAE,MAArB;MAA6B,GAAI7B,KAAK,CAAC8B;IAAvC,CADT,CAEE;IACA;IAHF;IAIE,cAAc,EAAEd,IAAI,CAACe,SAAL,CAAe,EAC7B,GAAG/B,KAAK,CAACgC,cADoB;MAE7B,GAAGhC,KAAK,CAACgC,cAAN,CAAqBC;IAFK,CAAf;EAJlB,EADF;AAWD,CApDgC,CAA1B"}
|
|
@@ -1,6 +1,51 @@
|
|
|
1
1
|
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
2
2
|
|
|
3
|
+
/**
|
|
4
|
+
* A union type that represents platform-specific payment options.
|
|
5
|
+
*
|
|
6
|
+
* This can either be `RNPEGooglePayOptions` or `RNPEApplePayOptions`, depending
|
|
7
|
+
* on the platform.
|
|
8
|
+
*
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* A class representing a payment request containing all necessary transaction details.
|
|
13
|
+
*
|
|
14
|
+
* This includes merchant identifier, total payment amount, currency code,
|
|
15
|
+
* individual payment items, and optional platform-specific configurations
|
|
16
|
+
* such as Apple Pay or Google Pay options.
|
|
17
|
+
*/
|
|
3
18
|
export class PEPaymentRequest {
|
|
19
|
+
/**
|
|
20
|
+
* The unique identifier for the merchant initiating the transaction.
|
|
21
|
+
*/
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* The total amount to be charged for the transaction.
|
|
25
|
+
*/
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* The currency code used for the transaction. Defaults to `'USD'`.
|
|
29
|
+
*/
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* List of items representing the breakdown of the transaction.
|
|
33
|
+
*/
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Platform-specific options for customizing the payment experience
|
|
37
|
+
* (e.g., Apple Pay or Google Pay settings).
|
|
38
|
+
*/
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Constructs a new instance of [PEPaymentRequest].
|
|
42
|
+
*
|
|
43
|
+
* @param merchantId - The merchant's unique identifier.
|
|
44
|
+
* @param paymentAmount - The total transaction amount.
|
|
45
|
+
* @param currencyCode - The currency code (either `'USD'` or `'CAD'`).
|
|
46
|
+
* @param paymentItems - An array of individual summary items.
|
|
47
|
+
* @param platformOptions - Optional platform-specific payment configuration.
|
|
48
|
+
*/
|
|
4
49
|
constructor(merchantId, paymentAmount) {
|
|
5
50
|
let currencyCode = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'USD';
|
|
6
51
|
let paymentItems = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : [];
|
|
@@ -24,7 +69,29 @@ export class PEPaymentRequest {
|
|
|
24
69
|
}
|
|
25
70
|
|
|
26
71
|
}
|
|
72
|
+
/**
|
|
73
|
+
* Represents an individual item in a payment transaction.
|
|
74
|
+
*
|
|
75
|
+
* Each item includes a label and an associated amount.
|
|
76
|
+
*
|
|
77
|
+
*/
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Contact fields that can be requested from the user during Apple Pay transactions.
|
|
81
|
+
*
|
|
82
|
+
* These fields specify what customer information (e.g., name, email, address) is required.
|
|
83
|
+
*
|
|
84
|
+
* @category Apple Pay
|
|
85
|
+
*/
|
|
27
86
|
export let RNPEContactField;
|
|
87
|
+
/**
|
|
88
|
+
* Options specific to Apple Pay payment flow.
|
|
89
|
+
*
|
|
90
|
+
* Includes configuration for required billing and shipping contact fields,
|
|
91
|
+
* as well as available shipping methods.
|
|
92
|
+
*
|
|
93
|
+
* @category Apple Pay
|
|
94
|
+
*/
|
|
28
95
|
|
|
29
96
|
(function (RNPEContactField) {
|
|
30
97
|
RNPEContactField["name"] = "name";
|
|
@@ -35,6 +102,17 @@ export let RNPEContactField;
|
|
|
35
102
|
})(RNPEContactField || (RNPEContactField = {}));
|
|
36
103
|
|
|
37
104
|
export class RNPEApplePayOptions {
|
|
105
|
+
/**
|
|
106
|
+
* Contact fields required for billing (e.g., name, address).
|
|
107
|
+
*/
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* Contact fields required for shipping (e.g., phone number, address).
|
|
111
|
+
*/
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* List of available shipping methods shown to the user.
|
|
115
|
+
*/
|
|
38
116
|
constructor(params) {
|
|
39
117
|
_defineProperty(this, "requiredBillingContactFields", []);
|
|
40
118
|
|
|
@@ -48,6 +126,14 @@ export class RNPEApplePayOptions {
|
|
|
48
126
|
}
|
|
49
127
|
|
|
50
128
|
}
|
|
129
|
+
/**
|
|
130
|
+
* Represents the billing address parameters for Google Pay in React Native.
|
|
131
|
+
*
|
|
132
|
+
* Specifies the address format and whether a phone number is required.
|
|
133
|
+
*
|
|
134
|
+
* @category Google Pay
|
|
135
|
+
*/
|
|
136
|
+
|
|
51
137
|
export class RNPEGooglePayBillingAddressParameters {
|
|
52
138
|
constructor() {
|
|
53
139
|
_defineProperty(this, "format", 'FULL');
|
|
@@ -56,6 +142,14 @@ export class RNPEGooglePayBillingAddressParameters {
|
|
|
56
142
|
}
|
|
57
143
|
|
|
58
144
|
}
|
|
145
|
+
/**
|
|
146
|
+
* Represents the shipping address parameters for Google Pay in React Native.
|
|
147
|
+
*
|
|
148
|
+
* Specifies the allowed countries and whether a phone number is required.
|
|
149
|
+
*
|
|
150
|
+
* @category Google Pay
|
|
151
|
+
*/
|
|
152
|
+
|
|
59
153
|
export class RNPEGooglePayShippingAddressParameters {
|
|
60
154
|
constructor() {
|
|
61
155
|
_defineProperty(this, "allowedCountryCodes", undefined);
|
|
@@ -64,7 +158,32 @@ export class RNPEGooglePayShippingAddressParameters {
|
|
|
64
158
|
}
|
|
65
159
|
|
|
66
160
|
}
|
|
161
|
+
/**
|
|
162
|
+
* A class representing Google Pay-specific payment options for React Native.
|
|
163
|
+
*
|
|
164
|
+
* This includes flags and parameters for requiring billing and shipping addresses.
|
|
165
|
+
*
|
|
166
|
+
* @category Google Pay
|
|
167
|
+
*/
|
|
168
|
+
|
|
67
169
|
export class RNPEGooglePayOptions {
|
|
170
|
+
/** Whether a billing address is required for the transaction. */
|
|
171
|
+
|
|
172
|
+
/** Additional parameters for billing address collection (platform-specific). */
|
|
173
|
+
|
|
174
|
+
/** Whether a shipping address is required for the transaction. */
|
|
175
|
+
|
|
176
|
+
/** Additional parameters for shipping address collection (platform-specific). */
|
|
177
|
+
|
|
178
|
+
/**
|
|
179
|
+
* Creates a new instance of `RNPEGooglePayOptions`.
|
|
180
|
+
*
|
|
181
|
+
* @param params - The configuration object for Google Pay options.
|
|
182
|
+
* @param params.billingAddressRequired - Whether billing address is required.
|
|
183
|
+
* @param params.shippingAddressRequired - Whether shipping address is required.
|
|
184
|
+
* @param params.billingAddressParameters - Optional parameters for billing address.
|
|
185
|
+
* @param params.shippingAddressParameters - Optional parameters for shipping address.
|
|
186
|
+
*/
|
|
68
187
|
constructor(params) {
|
|
69
188
|
_defineProperty(this, "billingAddressRequired", void 0);
|
|
70
189
|
|
|
@@ -1 +1 @@
|
|
|
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\
|
|
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\n/**\n * A union type that represents platform-specific payment options.\n * \n * This can either be `RNPEGooglePayOptions` or `RNPEApplePayOptions`, depending\n * on the platform.\n * \n */\nexport type RNPEPaymentOptions = RNPEGooglePayOptions | RNPEApplePayOptions;\n\n/**\n * A class representing a payment request containing all necessary transaction details.\n *\n * This includes merchant identifier, total payment amount, currency code,\n * individual payment items, and optional platform-specific configurations\n * such as Apple Pay or Google Pay options.\n */\nexport class PEPaymentRequest {\n /**\n * The unique identifier for the merchant initiating the transaction.\n */\n merchantId: string;\n\n /**\n * The total amount to be charged for the transaction.\n */\n paymentAmount: number;\n\n /**\n * The currency code used for the transaction. Defaults to `'USD'`.\n */\n currencyCode?: 'USD' | 'CAD' = 'USD';\n\n /**\n * List of items representing the breakdown of the transaction.\n */\n paymentItems?: PESummaryItem[] = [];\n\n /**\n * Platform-specific options for customizing the payment experience\n * (e.g., Apple Pay or Google Pay settings).\n */\n platformOptions?: RNPEPaymentOptions;\n\n /**\n * Constructs a new instance of [PEPaymentRequest].\n *\n * @param merchantId - The merchant's unique identifier.\n * @param paymentAmount - The total transaction amount.\n * @param currencyCode - The currency code (either `'USD'` or `'CAD'`).\n * @param paymentItems - An array of individual summary items.\n * @param platformOptions - Optional platform-specific payment configuration.\n */\n constructor(\n merchantId: string,\n paymentAmount: number,\n currencyCode: 'USD' | 'CAD' = 'USD',\n paymentItems: PESummaryItem[] = [],\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\n/**\n * Represents an individual item in a payment transaction.\n *\n * Each item includes a label and an associated amount.\n *\n */\nexport interface PESummaryItem {\n /** A descriptive label for the payment item (e.g., \"Item 1\"). */\n label: string;\n\n /** The monetary amount for this item. */\n amount: number;\n}\n\n/**\n * Contact fields that can be requested from the user during Apple Pay transactions.\n *\n * These fields specify what customer information (e.g., name, email, address) is required.\n *\n * @category Apple Pay\n */\nexport enum RNPEContactField {\n /** The customer's full name. */\n name = 'name',\n\n /** The customer's postal address. */\n postalAddress = 'postalAddress',\n\n /** The customer's email address. */\n emailAddress = 'emailAddress',\n\n /** The customer's phone number. */\n phoneNumber = 'phoneNumber',\n\n /** The phonetic spelling of the customer's name. */\n phoneticName = 'phoneticName',\n}\n\n\n/**\n * Options specific to Apple Pay payment flow.\n *\n * Includes configuration for required billing and shipping contact fields,\n * as well as available shipping methods.\n *\n * @category Apple Pay\n */\nexport class RNPEApplePayOptions {\n /**\n * Contact fields required for billing (e.g., name, address).\n */\n requiredBillingContactFields?: RNPEContactField[] = [];\n\n /**\n * Contact fields required for shipping (e.g., phone number, address).\n */\n requiredShippingContactFields?: RNPEContactField[] = [];\n\n /**\n * List of available shipping methods shown to the user.\n */\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\n/**\n * Represents the billing address parameters for Google Pay in React Native.\n *\n * Specifies the address format and whether a phone number is required.\n *\n * @category Google Pay\n */\nexport class RNPEGooglePayBillingAddressParameters {\n /**\n * The format of the billing address.\n * \n * - `'FULL'`: Includes street, city, state, and postal code.\n * - `'MIN'`: Minimal format with limited address details.\n */\n format: 'FULL' | 'MIN' = 'FULL';\n\n /**\n * Whether a phone number is required in the billing address.\n */\n phoneNumberRequired: boolean = false;\n}\n\n/**\n * Represents the shipping address parameters for Google Pay in React Native.\n *\n * Specifies the allowed countries and whether a phone number is required.\n *\n * @category Google Pay\n */\nexport class RNPEGooglePayShippingAddressParameters {\n /**\n * A list of allowed country codes for shipping (e.g., `[\"US\", \"CA\"]`).\n */\n allowedCountryCodes?: string[] = undefined;\n\n /**\n * Whether a phone number is required in the shipping address.\n */\n phoneNumberRequired: boolean = false;\n}\n\n/**\n * A class representing Google Pay-specific payment options for React Native.\n * \n * This includes flags and parameters for requiring billing and shipping addresses.\n * \n * @category Google Pay\n */\nexport class RNPEGooglePayOptions {\n /** Whether a billing address is required for the transaction. */\n billingAddressRequired: boolean;\n\n /** Additional parameters for billing address collection (platform-specific). */\n billingAddressParameters?: RNPEGooglePayBillingAddressParameters;\n\n /** Whether a shipping address is required for the transaction. */\n shippingAddressRequired: boolean;\n\n /** Additional parameters for shipping address collection (platform-specific). */\n shippingAddressParameters?: RNPEGooglePayShippingAddressParameters;\n\n /**\n * Creates a new instance of `RNPEGooglePayOptions`.\n * \n * @param params - The configuration object for Google Pay options.\n * @param params.billingAddressRequired - Whether billing address is required.\n * @param params.shippingAddressRequired - Whether shipping address is required.\n * @param params.billingAddressParameters - Optional parameters for billing address.\n * @param params.shippingAddressParameters - Optional parameters for shipping address.\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":";;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMA,gBAAN,CAAuB;EAC5B;AACF;AACA;;EAGE;AACF;AACA;;EAGE;AACF;AACA;;EAGE;AACF;AACA;;EAGE;AACF;AACA;AACA;;EAGE;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;EACEC,WAAW,CACTC,UADS,EAETC,aAFS,EAMT;IAAA,IAHAC,YAGA,uEAH8B,KAG9B;IAAA,IAFAC,YAEA,uEAFgC,EAEhC;IAAA,IADAC,eACA;;IAAA;;IAAA;;IAAA,sCA5B6B,KA4B7B;;IAAA,sCAvB+B,EAuB/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;;AAhD2B;AAmD9B;AACA;AACA;AACA;AACA;AACA;;AASA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,WAAYC,gBAAZ;AAkBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;WAzBYA,gB;EAAAA,gB;EAAAA,gB;EAAAA,gB;EAAAA,gB;EAAAA,gB;GAAAA,gB,KAAAA,gB;;AA0BZ,OAAO,MAAMC,mBAAN,CAA0B;EAC/B;AACF;AACA;;EAGE;AACF;AACA;;EAG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