react-native-payengine 1.0.5 → 1.0.6
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/android/.gradle/5.6.4/executionHistory/executionHistory.bin +0 -0
- package/android/.gradle/5.6.4/executionHistory/executionHistory.lock +0 -0
- package/android/.gradle/5.6.4/fileContent/fileContent.lock +0 -0
- package/android/.gradle/5.6.4/fileHashes/fileHashes.bin +0 -0
- package/android/.gradle/5.6.4/fileHashes/fileHashes.lock +0 -0
- package/android/.gradle/5.6.4/fileHashes/resourceHashesCache.bin +0 -0
- package/android/.gradle/5.6.4/javaCompile/classAnalysis.bin +0 -0
- package/android/.gradle/5.6.4/javaCompile/jarAnalysis.bin +0 -0
- package/android/.gradle/5.6.4/javaCompile/javaCompile.lock +0 -0
- package/android/.gradle/5.6.4/javaCompile/taskHistory.bin +0 -0
- package/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock +0 -0
- package/android/.gradle/buildOutputCleanup/outputFiles.bin +0 -0
- package/android/.idea/compiler.xml +1 -1
- package/android/.idea/gradle.xml +1 -0
- package/android/.idea/misc.xml +1 -1
- package/android/build.gradle +24 -9
- package/android/src/legacy/AndroidManifest.xml +4 -0
- package/android/src/main/java/com/reactnativepayengine/GooglePayModule.java +196 -0
- package/android/src/main/java/com/reactnativepayengine/PayenginePackage.java +1 -0
- package/android/src/main/java/com/reactnativepayengine/collect/VGSCollectModule.java +22 -17
- package/android/src/main/java/com/reactnativepayengine/util/PaymentsUtil.java +113 -0
- package/ios/Payengine.m +18 -1
- package/ios/Payengine.swift +85 -2
- package/ios/Payengine.xcodeproj/project.pbxproj +16 -5
- package/ios/Payengine.xcodeproj/project.xcworkspace/xcuserdata/tringuyen.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
- package/ios/Payengine.xcodeproj/xcuserdata/tringuyen.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist +4 -4
- package/ios/Payengine.xcworkspace/xcuserdata/tringuyen.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
- package/lib/commonjs/components/ApplePay/PayEngineApplePay.js +71 -0
- package/lib/commonjs/components/ApplePay/PayEngineApplePay.js.map +1 -0
- package/lib/commonjs/components/ApplePay/index.js +46 -0
- package/lib/commonjs/components/ApplePay/index.js.map +1 -0
- package/lib/commonjs/components/ApplePay/interfaces.js +2 -0
- package/lib/commonjs/components/ApplePay/interfaces.js.map +1 -0
- package/lib/commonjs/components/CreditCardForm/index.js +76 -0
- package/lib/commonjs/components/CreditCardForm/index.js.map +1 -0
- package/lib/commonjs/components/GooglePay/PayEngineGooglePay.js +65 -0
- package/lib/commonjs/components/GooglePay/PayEngineGooglePay.js.map +1 -0
- package/lib/commonjs/components/GooglePay/index.js +40 -0
- package/lib/commonjs/components/GooglePay/index.js.map +1 -0
- package/lib/commonjs/components/GooglePay/interfaces.js +2 -0
- package/lib/commonjs/components/GooglePay/interfaces.js.map +1 -0
- package/lib/commonjs/components/Legacy/CreditCardFormLegacy.js +323 -0
- package/lib/commonjs/components/Legacy/CreditCardFormLegacy.js.map +1 -0
- package/lib/commonjs/components/PayEngine.js.map +1 -1
- package/lib/commonjs/components/SecureFields/VGS/CollectManager.js +3 -8
- package/lib/commonjs/components/SecureFields/VGS/CollectManager.js.map +1 -1
- package/lib/commonjs/index.js +33 -4
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/interfaces/index.js +6 -0
- package/lib/commonjs/interfaces/index.js.map +1 -0
- package/lib/commonjs/utils/index.js +20 -8
- package/lib/commonjs/utils/index.js.map +1 -1
- package/lib/module/components/ApplePay/PayEngineApplePay.js +58 -0
- package/lib/module/components/ApplePay/PayEngineApplePay.js.map +1 -0
- package/lib/module/components/ApplePay/index.js +35 -0
- package/lib/module/components/ApplePay/index.js.map +1 -0
- package/lib/module/components/ApplePay/interfaces.js +2 -0
- package/lib/module/components/ApplePay/interfaces.js.map +1 -0
- package/lib/module/components/CreditCardForm/index.js +60 -0
- package/lib/module/components/CreditCardForm/index.js.map +1 -0
- package/lib/module/components/GooglePay/PayEngineGooglePay.js +52 -0
- package/lib/module/components/GooglePay/PayEngineGooglePay.js.map +1 -0
- package/lib/module/components/GooglePay/index.js +29 -0
- package/lib/module/components/GooglePay/index.js.map +1 -0
- package/lib/module/components/GooglePay/interfaces.js +2 -0
- package/lib/module/components/GooglePay/interfaces.js.map +1 -0
- package/lib/module/components/Legacy/CreditCardFormLegacy.js +302 -0
- package/lib/module/components/Legacy/CreditCardFormLegacy.js.map +1 -0
- package/lib/module/components/PayEngine.js.map +1 -1
- package/lib/module/components/SecureFields/VGS/CollectManager.js +3 -8
- package/lib/module/components/SecureFields/VGS/CollectManager.js.map +1 -1
- package/lib/module/index.js +6 -5
- package/lib/module/index.js.map +1 -1
- package/lib/module/interfaces/index.js +2 -0
- package/lib/module/interfaces/index.js.map +1 -0
- package/lib/module/utils/index.js +14 -8
- package/lib/module/utils/index.js.map +1 -1
- package/lib/typescript/components/ApplePay/PayEngineApplePay.d.ts +12 -0
- package/lib/typescript/components/ApplePay/index.d.ts +7 -0
- package/lib/typescript/components/ApplePay/interfaces.d.ts +20 -0
- package/lib/typescript/components/CreditCardForm/index.d.ts +3 -0
- package/lib/typescript/components/GooglePay/PayEngineGooglePay.d.ts +10 -0
- package/lib/typescript/components/GooglePay/index.d.ts +7 -0
- package/lib/typescript/components/GooglePay/interfaces.d.ts +38 -0
- package/lib/typescript/components/Legacy/CreditCardFormLegacy.d.ts +4 -0
- package/lib/typescript/components/PayEngine.d.ts +1 -1
- package/lib/typescript/components/SecureFields/VGS/CollectManager.d.ts +1 -1
- package/lib/typescript/index.d.ts +6 -2
- package/lib/typescript/interfaces/index.d.ts +33 -0
- package/lib/typescript/utils/index.d.ts +5 -6
- package/package.json +6 -5
- package/react-native-payengine.podspec +2 -2
- package/src/components/ApplePay/PayEngineApplePay.ts +61 -0
- package/src/components/ApplePay/index.ts +32 -0
- package/src/components/ApplePay/interfaces.ts +25 -0
- package/src/components/CreditCardForm/index.tsx +43 -0
- package/src/components/GooglePay/PayEngineGooglePay.ts +48 -0
- package/src/components/GooglePay/index.ts +39 -0
- package/src/components/GooglePay/interfaces.ts +42 -0
- package/src/components/Legacy/CreditCardFormLegacy.tsx +292 -0
- package/src/components/LoadingIndicator.tsx +28 -0
- package/src/components/PayEngine.tsx +121 -0
- package/src/components/SecureFields/VGS/CVCField.tsx +21 -0
- package/src/components/SecureFields/VGS/CardHolderNameField.tsx +21 -0
- package/src/components/SecureFields/VGS/CardNumberField.tsx +21 -0
- package/src/components/SecureFields/VGS/CollectManager.tsx +74 -0
- package/src/components/SecureFields/VGS/ExpDateField.tsx +21 -0
- package/src/components/SecureFields/VGS/TextField.tsx +27 -0
- package/src/components/SecureFields/VGS/ZipCodeField.tsx +21 -0
- package/src/components/SecureFields/index.ts +17 -0
- package/src/index.tsx +37 -0
- package/src/interfaces/index.ts +38 -0
- package/src/utils/index.ts +107 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["React","Platform","StyleSheet","Text","View","WebView","getScriptURL","debuggingScript","LoadingIndicator","getHtmlTag","props","allowedProps","Object","keys","filter","x","includes","map","propName","join","generateHTML","scriptURL","PayEngine","useState","config","height","setHeight","html","onMessage","payload","isDebug","logLevel","dataPayload","JSON","parse","nativeEvent","data","e","type","console","info","stringify","detail","event","events","log","flex","style","styles","yellowBox","baseUrl","OS","create","marginVertical","marginHorizontal","padding","backgroundColor","borderWidth","borderColor"],"sources":["PayEngine.tsx"],"sourcesContent":["import React from 'react';\nimport { Platform, StyleProp, StyleSheet, Text, View, ViewStyle } from 'react-native';\nimport { WebView } from 'react-native-webview';\nimport { getScriptURL,
|
|
1
|
+
{"version":3,"names":["React","Platform","StyleSheet","Text","View","WebView","getScriptURL","debuggingScript","LoadingIndicator","getHtmlTag","props","allowedProps","Object","keys","filter","x","includes","map","propName","join","generateHTML","scriptURL","PayEngine","useState","config","height","setHeight","html","onMessage","payload","isDebug","logLevel","dataPayload","JSON","parse","nativeEvent","data","e","type","console","info","stringify","detail","event","events","log","flex","style","styles","yellowBox","baseUrl","OS","create","marginVertical","marginHorizontal","padding","backgroundColor","borderWidth","borderColor"],"sources":["PayEngine.tsx"],"sourcesContent":["import React from 'react';\nimport { Platform, StyleProp, StyleSheet, Text, View, ViewStyle } from 'react-native';\nimport { WebView } from 'react-native-webview';\nimport { getScriptURL, debuggingScript } from '../utils';\nimport LoadingIndicator from './LoadingIndicator';\nimport type { IPayEngineConfig } from '../interfaces/index';\n\ninterface IProps {\n config: IPayEngineConfig\n type: string\n merchantId?: string\n hash?: string\n events: {\n [key: string]: (eventData: any) => void\n }\n style?: StyleProp<ViewStyle>\n [key: string]: any\n}\n\nconst getHtmlTag = (props: IProps) => {\n const allowedProps = Object.keys(props).filter(x => !['config', 'events', 'style'].includes(x))\n return `<pay-engine id=\"component\"\n style=\"z-index: 100\"\n ${allowedProps.map((propName: string) => `${propName}=\"${props[propName]}\"`).join(' ')}\n ></pay-engine>`\n}\n\nconst generateHTML = (scriptURL: string, props: IProps) => {\n return `<!DOCTYPE html>\n <html>\n <head>\n <title>PayEngine Elements</title>\n <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">\n <script src=\"${scriptURL}\" async defer type=\"text/javascript\"></script>\n </head>\n <body>\n ${getHtmlTag(props)}\n <script>\n setInterval(function() {\n window.ReactNativeWebView.postMessage(JSON.stringify({\n type: 'PayEngine-height',\n height: document.body.scrollHeight\n }))\n }, 500);\n </script>\n </body>\n </html>`\n}\n\nconst PayEngine = (props: IProps) => {\n\n const [scriptURL] = React.useState(getScriptURL(props.config))\n const [height, setHeight] = React.useState(30)\n\n const html = generateHTML(scriptURL, props)\n\n const onMessage = (payload: any) => {\n const isDebug = props.config.logLevel! > 0\n let dataPayload;\n try {\n dataPayload = JSON.parse(payload.nativeEvent.data);\n } catch (e) { }\n\n if (dataPayload) {\n switch (dataPayload.type) {\n case 'Console':\n if (isDebug) {\n console.info(`[Console] ${JSON.stringify(dataPayload.data)}`);\n }\n break;\n case 'PayEngine':\n const { type, detail } = dataPayload.event\n if (props.events?.[type]) {\n props.events?.[type]?.(detail)\n }\n break;\n case 'PayEngine-height':\n setHeight(dataPayload.height)\n break;\n default:\n if (isDebug) {\n console.log(dataPayload)\n }\n break;\n }\n }\n };\n\n return <View style={[{ flex: 1, height: height }, props.style]}>\n <View style={styles.yellowBox}>\n <Text>Script URL: {scriptURL}</Text>\n </View>\n <View style={styles.yellowBox}>\n <Text>{getHtmlTag(props)}</Text>\n </View>\n <WebView\n originWhitelist={['*']}\n source={{ html: html, baseUrl: '' }}\n // source={{ uri: 'https://google.com' }}\n applicationNameForUserAgent={`PayEngine-RN/${Platform.OS}`}\n injectedJavaScript={debuggingScript}\n renderLoading={LoadingIndicator}\n startInLoadingState={true}\n onMessage={onMessage}\n />\n </View>\n}\n\nconst styles = StyleSheet.create({\n yellowBox: {\n marginVertical: 5,\n marginHorizontal: 10,\n padding: 10,\n backgroundColor: 'yellow',\n borderWidth: 1,\n borderColor: 'yellow'\n }\n})\n\n\nexport default PayEngine\n"],"mappings":"AAAA,OAAOA,KAAP,MAAkB,OAAlB;AACA,SAASC,QAAT,EAA8BC,UAA9B,EAA0CC,IAA1C,EAAgDC,IAAhD,QAAuE,cAAvE;AACA,SAASC,OAAT,QAAwB,sBAAxB;AACA,SAASC,YAAT,EAAuBC,eAAvB,QAA8C,UAA9C;AACA,OAAOC,gBAAP,MAA6B,oBAA7B;;AAeA,MAAMC,UAAU,GAAIC,KAAD,IAAmB;EACpC,MAAMC,YAAY,GAAGC,MAAM,CAACC,IAAP,CAAYH,KAAZ,EAAmBI,MAAnB,CAA0BC,CAAC,IAAI,CAAC,CAAC,QAAD,EAAW,QAAX,EAAqB,OAArB,EAA8BC,QAA9B,CAAuCD,CAAvC,CAAhC,CAArB;EACA,OAAQ;AACV;AACA,MAAMJ,YAAY,CAACM,GAAb,CAAkBC,QAAD,IAAuB,GAAEA,QAAS,KAAIR,KAAK,CAACQ,QAAD,CAAW,GAAvE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SAAf"}
|
|
@@ -12,7 +12,7 @@ const CollectManager = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
|
12
12
|
}
|
|
13
13
|
}));
|
|
14
14
|
const [loading, setLoading] = React.useState(true);
|
|
15
|
-
const [error, setError] = React.useState(
|
|
15
|
+
const [error, setError] = React.useState('');
|
|
16
16
|
React.useEffect(() => {
|
|
17
17
|
const configure = async () => {
|
|
18
18
|
setLoading(true);
|
|
@@ -26,17 +26,12 @@ const CollectManager = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
|
26
26
|
cname,
|
|
27
27
|
vgs_satellite_port
|
|
28
28
|
} = resp.data.data;
|
|
29
|
-
|
|
30
|
-
resp
|
|
31
|
-
});
|
|
32
|
-
console.log('Starting collect');
|
|
33
|
-
NativeVGSCollectManager.setConfiguration(vault, environment, cname.replace(/[^a-zA-Z\.]/g, ''), Number(vgs_satellite_port));
|
|
34
|
-
console.log('Set configuration successfully');
|
|
29
|
+
NativeVGSCollectManager.setConfiguration(props.config.publicKey, vault, environment, cname.replace(/[^a-zA-Z\.]/g, ''), Number(vgs_satellite_port));
|
|
35
30
|
} catch (e) {
|
|
36
31
|
console.log({
|
|
37
32
|
error: e
|
|
38
33
|
});
|
|
39
|
-
setError(
|
|
34
|
+
setError(e.message);
|
|
40
35
|
} finally {
|
|
41
36
|
setLoading(false);
|
|
42
37
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["React","Text","NativeModules","createHttpClient","NativeVGSCollectManager","VGSCollectManager","CollectManager","forwardRef","props","ref","useImperativeHandle","createCard","merchantId","cardBankAccount","createBankAccount","loading","setLoading","useState","error","setError","useEffect","configure","http","config","resp","get","vault","environment","cname","vgs_satellite_port","data","
|
|
1
|
+
{"version":3,"names":["React","Text","NativeModules","createHttpClient","NativeVGSCollectManager","VGSCollectManager","CollectManager","forwardRef","props","ref","useImperativeHandle","createCard","merchantId","cardBankAccount","createBankAccount","loading","setLoading","useState","error","setError","useEffect","configure","http","config","resp","get","vault","environment","cname","vgs_satellite_port","data","setConfiguration","publicKey","replace","Number","e","console","log","message","length","children"],"sources":["CollectManager.tsx"],"sourcesContent":["import * as React from 'react';\nimport { Text, NativeModules } from 'react-native';\nimport { createHttpClient } from '../../../utils';\nimport type { IPayEngineConfig } from '../../../interfaces/index';\n\nconst NativeVGSCollectManager = NativeModules.VGSCollectManager;\n\nexport interface CollectManagerProps {\n config: IPayEngineConfig;\n children: JSX.Element | JSX.Element[];\n}\n\nexport interface VGSCollectManagerMethods {\n createCard: (merchantId?: string) => void;\n cardBankAccount: (merchantId?: string) => void;\n}\n\nconst CollectManager = React.forwardRef<\n VGSCollectManagerMethods,\n CollectManagerProps\n>((props, ref) => {\n React.useImperativeHandle(ref, () => ({\n createCard: (merchantId?: string) => {\n return NativeVGSCollectManager.createCard(merchantId);\n },\n cardBankAccount: (merchantId?: string) => {\n return NativeVGSCollectManager.createBankAccount(merchantId);\n },\n }));\n\n const [loading, setLoading] = React.useState(true);\n const [error, setError] = React.useState('');\n\n React.useEffect(() => {\n const configure = async () => {\n setLoading(true);\n try {\n const http = createHttpClient(props.config);\n const resp = await http.get('/api/setting/secure-fields');\n const { vault, environment, cname, vgs_satellite_port } =\n resp.data.data;\n\n NativeVGSCollectManager.setConfiguration(\n props.config.publicKey,\n vault,\n environment,\n cname.replace(/[^a-zA-Z\\.]/g, ''),\n Number(vgs_satellite_port)\n );\n } catch (e: any) {\n console.log({ error: e });\n setError(e.message);\n } finally {\n setLoading(false);\n }\n };\n\n configure();\n }, []);\n\n return (\n <React.Fragment>\n {loading ? (\n <Text>Loading</Text>\n ) : error.length ? (\n <Text>{error}</Text>\n ) : (\n props.children\n )}\n </React.Fragment>\n );\n});\n\nexport default CollectManager;\n"],"mappings":"AAAA,OAAO,KAAKA,KAAZ,MAAuB,OAAvB;AACA,SAASC,IAAT,EAAeC,aAAf,QAAoC,cAApC;AACA,SAASC,gBAAT,QAAiC,gBAAjC;AAGA,MAAMC,uBAAuB,GAAGF,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AH,CAAR;MACD,CAhBD,SAgBU;QACRtB,UAAU,CAAC,KAAD,CAAV;MACD;IACF,CArBD;;IAuBAK,SAAS;EACV,CAzBD,EAyBG,EAzBH;EA2BA,oBACE,oBAAC,KAAD,CAAO,QAAP,QACGN,OAAO,gBACN,oBAAC,IAAD,kBADM,GAEJG,KAAK,CAACqB,MAAN,gBACF,oBAAC,IAAD,QAAOrB,KAAP,CADE,GAGFV,KAAK,CAACgC,QANV,CADF;AAWD,CAtDsB,CAAvB;AAwDA,eAAelC,cAAf"}
|
package/lib/module/index.js
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import PayEngine from './components/PayEngine';
|
|
2
2
|
import { NativeModules, Platform } from 'react-native';
|
|
3
3
|
import { SecureFields } from './components/SecureFields/index';
|
|
4
|
+
import { CreditCardForm } from './components/CreditCardForm/index';
|
|
5
|
+
import CreditCardFormLegacy from './components/Legacy/CreditCardFormLegacy';
|
|
6
|
+
import { PayEngineGooglePay } from './components/GooglePay/PayEngineGooglePay';
|
|
7
|
+
import { PayEngineApplePay } from './components/ApplePay/PayEngineApplePay';
|
|
4
8
|
const LINKING_ERROR = `The package 'react-native-payengine' doesn't seem to be linked. Make sure: \n\n` + Platform.select({
|
|
5
9
|
ios: "- You have run 'pod install'\n",
|
|
6
10
|
default: ''
|
|
@@ -10,9 +14,6 @@ const PayEngineStatic = NativeModules.Payengine ? NativeModules.Payengine : new
|
|
|
10
14
|
throw new Error(LINKING_ERROR);
|
|
11
15
|
}
|
|
12
16
|
|
|
13
|
-
});
|
|
14
|
-
|
|
15
|
-
// }
|
|
16
|
-
|
|
17
|
-
export { PayEngineStatic, PayEngine, SecureFields };
|
|
17
|
+
});
|
|
18
|
+
export { PayEngineStatic, PayEngine, SecureFields, CreditCardForm, CreditCardFormLegacy, PayEngineGooglePay, PayEngineApplePay };
|
|
18
19
|
//# sourceMappingURL=index.js.map
|
package/lib/module/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["PayEngine","NativeModules","Platform","SecureFields","LINKING_ERROR","select","ios","default","PayEngineStatic","Payengine","Proxy","get","Error"],"sources":["index.tsx"],"sourcesContent":["import PayEngine from './components/PayEngine'\nimport { NativeModules, Platform } from 'react-native';\nimport { SecureFields } from './components/SecureFields/index';\nimport type { IPayEngineConfig } from './
|
|
1
|
+
{"version":3,"names":["PayEngine","NativeModules","Platform","SecureFields","CreditCardForm","CreditCardFormLegacy","PayEngineGooglePay","PayEngineApplePay","LINKING_ERROR","select","ios","default","PayEngineStatic","Payengine","Proxy","get","Error"],"sources":["index.tsx"],"sourcesContent":["import PayEngine from './components/PayEngine'\nimport { NativeModules, Platform } from 'react-native';\nimport { SecureFields } from './components/SecureFields/index';\nimport { CreditCardForm } from './components/CreditCardForm/index';\nimport CreditCardFormLegacy from './components/Legacy/CreditCardFormLegacy';\nimport type { IPayEngineConfig } from './interfaces/index';\nimport { PayEngineGooglePay } from './components/GooglePay/PayEngineGooglePay';\nimport { PayEngineApplePay } from './components/ApplePay/PayEngineApplePay';\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 ? NativeModules.Payengine : new Proxy(\n {},\n {\n get() {\n throw new Error(LINKING_ERROR);\n },\n }\n);\n\n\nexport {\n PayEngineStatic,\n PayEngine,\n SecureFields,\n CreditCardForm,\n CreditCardFormLegacy,\n IPayEngineConfig,\n PayEngineGooglePay,\n PayEngineApplePay\n}\n\n\n"],"mappings":"AAAA,OAAOA,SAAP,MAAsB,wBAAtB;AACA,SAASC,aAAT,EAAwBC,QAAxB,QAAwC,cAAxC;AACA,SAASC,YAAT,QAA6B,iCAA7B;AACA,SAASC,cAAT,QAA+B,mCAA/B;AACA,OAAOC,oBAAP,MAAiC,0CAAjC;AAEA,SAASC,kBAAT,QAAmC,2CAAnC;AACA,SAASC,iBAAT,QAAkC,yCAAlC;AAEA,MAAMC,aAAa,GAChB,iFAAD,GACAN,QAAQ,CAACO,MAAT,CAAgB;EAAEC,GAAG,EAAE,gCAAP;EAAyCC,OAAO,EAAE;AAAlD,CAAhB,CADA,GAEA,sDAFA,GAGA,6CAJF;AAMA,MAAMC,eAAe,GAAGX,aAAa,CAACY,SAAd,GAA0BZ,aAAa,CAACY,SAAxC,GAAoD,IAAIC,KAAJ,CAC1E,EAD0E,EAE1E;EACEC,GAAG,GAAG;IACJ,MAAM,IAAIC,KAAJ,CAAUR,aAAV,CAAN;EACD;;AAHH,CAF0E,CAA5E;AAUA,SACEI,eADF,EAEEZ,SAFF,EAGEG,YAHF,EAIEC,cAJF,EAKEC,oBALF,EAOEC,kBAPF,EAQEC,iBARF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["import type { StyleProp, ViewStyle } from 'react-native';\nimport type { GooglePayRequestData } from '../components/GooglePay/interfaces';\n\nexport interface IPayEngineConfig {\n publicKey: string;\n version?: string;\n scriptURL?: string;\n logLevel?: number;\n}\n\nexport interface CreditCardFormProps {\n style?: StyleProp<ViewStyle>;\n merchantId?: string;\n showZipCode?: boolean;\n config: IPayEngineConfig;\n}\n\nexport interface CreditCardFormMethods {\n createCard: (merchantId?: string) => Promise<any>;\n}\n\nexport interface MobilePaymentConfig {\n base_url: string;\n country: string;\n currency: string;\n gateway: string; // nmi | converge\n google_pay: GooglePayRequestData;\n apple_pay: {\n merchantName: string;\n supportedCardNetworks: string[];\n };\n}\n\nexport interface PaymentRequest {\n amount: number;\n currencyCode?: string;\n countryCode?: string;\n}\n"],"mappings":""}
|
|
@@ -1,16 +1,22 @@
|
|
|
1
|
-
import axios from
|
|
2
|
-
export const
|
|
3
|
-
|
|
1
|
+
import axios from 'axios';
|
|
2
|
+
export const getHttpHeaders = config => {
|
|
3
|
+
return {
|
|
4
|
+
Authorization: `Signature key="${config.publicKey}",algorithm="hmac-sha256",identifier="secure-fields",signature=""`
|
|
5
|
+
};
|
|
6
|
+
};
|
|
7
|
+
export const getBaseURL = config => {
|
|
8
|
+
let baseUrl = config.publicKey.includes('_prod_') ? 'https://console.payengine.co' : 'https://console.payengine.dev';
|
|
4
9
|
|
|
5
10
|
if (config.scriptURL) {
|
|
6
11
|
baseUrl = config.scriptURL.replace(/^((\w+:)?\/\/[^\/]+\/?).*$/, '$1');
|
|
7
12
|
}
|
|
8
13
|
|
|
14
|
+
return baseUrl;
|
|
15
|
+
};
|
|
16
|
+
export const createHttpClient = config => {
|
|
9
17
|
return axios.create({
|
|
10
|
-
baseURL:
|
|
11
|
-
headers:
|
|
12
|
-
Authorization: `Signature key="${config.publicKey}",algorithm="hmac-sha256",identifier="secure-fields",signature=""`
|
|
13
|
-
}
|
|
18
|
+
baseURL: getBaseURL(config),
|
|
19
|
+
headers: getHttpHeaders(config)
|
|
14
20
|
});
|
|
15
21
|
};
|
|
16
22
|
export function getScriptURL(config) {
|
|
@@ -24,7 +30,7 @@ export function getScriptURL(config) {
|
|
|
24
30
|
if (config.scriptURL) {
|
|
25
31
|
scriptURL = `${config.scriptURL}?key=${config.publicKey}${logLevelStr}`;
|
|
26
32
|
} else {
|
|
27
|
-
const baseURL = config.publicKey.includes('_prod_') ?
|
|
33
|
+
const baseURL = config.publicKey.includes('_prod_') ? 'https://console.payengine.co' : 'https://console.payengine.dev';
|
|
28
34
|
const version = config.version ?? '1.0.0';
|
|
29
35
|
scriptURL = `${baseURL}/js/${version}/embed.js?key=${config.publicKey}${logLevelStr}`;
|
|
30
36
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["axios","
|
|
1
|
+
{"version":3,"names":["axios","getHttpHeaders","config","Authorization","publicKey","getBaseURL","baseUrl","includes","scriptURL","replace","createHttpClient","create","baseURL","headers","getScriptURL","Error","logLevelStr","logLevel","version","debuggingScript"],"sources":["index.ts"],"sourcesContent":["import axios from 'axios';\nimport type { IPayEngineConfig } from '../interfaces/index';\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\n/**\n * <script>\n console.log(\"AAAAAAAA\")\n var component = document.getElementById(\"component\");\n var onEvent = function(event) {\n console.log({ event })\n }\n console.log('component')\n component.addEventListener('stepChange', function(e) {\n console.log('step change')\n })\n function addEventListenerAll(target, listener, ...otherArguments) {\n\n // install listeners for all natively triggered events\n for (const key in target) {\n if (/^on/.test(key)) {\n const eventType = key.substr(2);\n target.addEventListener(eventType, listener, ...otherArguments);\n }\n }\n\n // dynamically install listeners for all manually triggered events, just-in-time before they're dispatched ;D\n const dispatchEvent_original = EventTarget.prototype.dispatchEvent;\n function dispatchEvent(event) {\n console.log('event test', event.type)\n target.addEventListener(event.type, listener, ...otherArguments); // multiple identical listeners are automatically discarded\n dispatchEvent_original.apply(this, arguments);\n }\n EventTarget.prototype.dispatchEvent = dispatchEvent;\n if (EventTarget.prototype.dispatchEvent !== dispatchEvent) throw new Error('Browser is smarter than you think');\n\n }\n\n // addEventListenerAll(component, onEvent);\n </script>\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,OAAO,MAAMC,cAAc,GAAIC,MAAD,IAA8B;EAC1D,OAAO;IACLC,aAAa,EAAG,kBAAiBD,MAAM,CAACE,SAAU;EAD7C,CAAP;AAGD,CAJM;AAMP,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,OAAO,MAAMI,gBAAgB,GAAIR,MAAD,IAA8B;EAC5D,OAAOF,KAAK,CAACW,MAAN,CAAa;IAClBC,OAAO,EAAEP,UAAU,CAACH,MAAD,CADD;IAElBW,OAAO,EAAEZ,cAAc,CAACC,MAAD;EAFL,CAAb,CAAP;AAID,CALM;AAOP,OAAO,SAASY,YAAT,CAAsBZ,MAAtB,EAAgD;EACrD,IAAI,CAACA,MAAM,CAACE,SAAZ,EAAuB;IACrB,MAAM,IAAIW,KAAJ,CAAU,iCAAV,CAAN;EACD;;EACD,IAAIP,SAAS,GAAG,EAAhB;EACA,MAAMQ,WAAW,GAAGd,MAAM,CAACe,QAAP,GAAmB,aAAYf,MAAM,CAACe,QAAS,EAA/C,GAAmD,EAAvE;;EACA,IAAIf,MAAM,CAACM,SAAX,EAAsB;IACpBA,SAAS,GAAI,GAAEN,MAAM,CAACM,SAAU,QAAON,MAAM,CAACE,SAAU,GAAEY,WAAY,EAAtE;EACD,CAFD,MAEO;IACL,MAAMJ,OAAO,GAAGV,MAAM,CAACE,SAAP,CAAiBG,QAAjB,CAA0B,QAA1B,IACZ,8BADY,GAEZ,+BAFJ;IAGA,MAAMW,OAAO,GAAGhB,MAAM,CAACgB,OAAP,IAAkB,OAAlC;IACAV,SAAS,GAAI,GAAEI,OAAQ,OAAMM,OAAQ,iBAAgBhB,MAAM,CAACE,SAAU,GAAEY,WAAY,EAApF;EACD;;EAED,OAAOR,SAAP;AACD;AAED;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,OAAO,MAAMW,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"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { IPayEngineConfig, PaymentRequest } from '../../interfaces';
|
|
2
|
+
import type { IApplePay } from './interfaces';
|
|
3
|
+
export declare class PayEngineApplePay implements IApplePay {
|
|
4
|
+
private applePay;
|
|
5
|
+
private payEngineConfig;
|
|
6
|
+
private config?;
|
|
7
|
+
private method?;
|
|
8
|
+
private details?;
|
|
9
|
+
constructor(payEngineConfig: IPayEngineConfig);
|
|
10
|
+
canMakePayments(merchantId: string, paymentConfig: PaymentRequest): Promise<boolean>;
|
|
11
|
+
start(): Promise<any>;
|
|
12
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { ApplePayDetailsData, ApplePayMethodData, IApplePay } from './interfaces';
|
|
2
|
+
export default class ApplePay implements IApplePay {
|
|
3
|
+
private isReady;
|
|
4
|
+
constructor();
|
|
5
|
+
start(): Promise<any>;
|
|
6
|
+
canMakePayments(method: ApplePayMethodData, details: ApplePayDetailsData): Promise<boolean>;
|
|
7
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export interface IApplePay {
|
|
2
|
+
canMakePayments: (...args: any) => Promise<boolean>;
|
|
3
|
+
start: (...args: any) => Promise<any>;
|
|
4
|
+
}
|
|
5
|
+
declare type Network = 'Visa' | 'MasterCard' | 'AmEx';
|
|
6
|
+
export interface ApplePayMethodData {
|
|
7
|
+
countryCode: string;
|
|
8
|
+
currencyCode: string;
|
|
9
|
+
supportedNetworks: Network[];
|
|
10
|
+
merchantIdentifier: string;
|
|
11
|
+
}
|
|
12
|
+
export interface ApplePayDetail {
|
|
13
|
+
label: string;
|
|
14
|
+
amount: number;
|
|
15
|
+
}
|
|
16
|
+
export interface ApplePayDetailsData {
|
|
17
|
+
total: ApplePayDetail;
|
|
18
|
+
}
|
|
19
|
+
export declare type ApplePayTransactionIdentifier = string;
|
|
20
|
+
export {};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { IPayEngineConfig, PaymentRequest } from '../../interfaces';
|
|
2
|
+
import type { IGooglePay } from './interfaces';
|
|
3
|
+
export declare class PayEngineGooglePay implements IGooglePay {
|
|
4
|
+
private googlePay;
|
|
5
|
+
private payEngineConfig;
|
|
6
|
+
private config?;
|
|
7
|
+
constructor(payEngineConfig: IPayEngineConfig);
|
|
8
|
+
canMakePayments(merchantId: string): Promise<any>;
|
|
9
|
+
start(paymentConfig: PaymentRequest): Promise<any>;
|
|
10
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { GooglePayAllowedCardAuthMethods, GooglePayAllowedCardNetworks, GooglePayRequestData, IGooglePay } from './interfaces';
|
|
2
|
+
export default class GooglePay implements IGooglePay {
|
|
3
|
+
constructor();
|
|
4
|
+
setProduction(isProduction: boolean): Promise<any>;
|
|
5
|
+
canMakePayments(allowedCardNetworks: GooglePayAllowedCardNetworks, allowedCardAuthMethods: GooglePayAllowedCardAuthMethods): Promise<any>;
|
|
6
|
+
start(requestData: GooglePayRequestData): Promise<any>;
|
|
7
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
export interface IGooglePay {
|
|
2
|
+
canMakePayments: (...args: any) => Promise<boolean>;
|
|
3
|
+
start: (...args: any) => Promise<any>;
|
|
4
|
+
}
|
|
5
|
+
declare type NetworkType = 'AMEX' | 'DISCOVER' | 'JCB' | 'MASTERCARD' | 'VISA';
|
|
6
|
+
declare type MethodType = 'PAN_ONLY' | 'CRYPTOGRAM_3DS';
|
|
7
|
+
export declare type GooglePayAllowedCardNetworks = NetworkType[];
|
|
8
|
+
export declare type GooglePayAllowedCardAuthMethods = MethodType[];
|
|
9
|
+
export declare type TokenizationSpecificationType = 'PAYMENT_GATEWAY' | 'DIRECT';
|
|
10
|
+
export interface GooglePayRequestData {
|
|
11
|
+
production?: boolean;
|
|
12
|
+
cardPaymentMethod: {
|
|
13
|
+
tokenizationSpecification: {
|
|
14
|
+
type: TokenizationSpecificationType;
|
|
15
|
+
/** only with type: PAYMENT_GATEWAY */
|
|
16
|
+
gateway?: string;
|
|
17
|
+
/** only with type: PAYMENT_GATEWAY */
|
|
18
|
+
gatewayMerchantId?: string;
|
|
19
|
+
/** only with gateway: stripe */
|
|
20
|
+
stripe?: {
|
|
21
|
+
publishableKey: string;
|
|
22
|
+
version: string;
|
|
23
|
+
};
|
|
24
|
+
/** only with type: DIRECT */
|
|
25
|
+
publicKey?: string;
|
|
26
|
+
};
|
|
27
|
+
allowedCardNetworks: GooglePayAllowedCardNetworks;
|
|
28
|
+
allowedCardAuthMethods: GooglePayAllowedCardAuthMethods;
|
|
29
|
+
};
|
|
30
|
+
transaction: {
|
|
31
|
+
totalPrice: string;
|
|
32
|
+
totalPriceStatus: string;
|
|
33
|
+
currencyCode: string;
|
|
34
|
+
countryCode: string;
|
|
35
|
+
};
|
|
36
|
+
merchantName: string;
|
|
37
|
+
}
|
|
38
|
+
export {};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import type { CreditCardFormMethods, CreditCardFormProps } from '../../interfaces/index';
|
|
3
|
+
declare const CreditCardFormLegacy: React.ForwardRefExoticComponent<CreditCardFormProps & React.RefAttributes<CreditCardFormMethods>>;
|
|
4
|
+
export default CreditCardFormLegacy;
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import PayEngine from './components/PayEngine';
|
|
2
2
|
import { SecureFields } from './components/SecureFields/index';
|
|
3
|
-
import
|
|
3
|
+
import { CreditCardForm } from './components/CreditCardForm/index';
|
|
4
|
+
import CreditCardFormLegacy from './components/Legacy/CreditCardFormLegacy';
|
|
5
|
+
import type { IPayEngineConfig } from './interfaces/index';
|
|
6
|
+
import { PayEngineGooglePay } from './components/GooglePay/PayEngineGooglePay';
|
|
7
|
+
import { PayEngineApplePay } from './components/ApplePay/PayEngineApplePay';
|
|
4
8
|
declare const PayEngineStatic: any;
|
|
5
|
-
export { PayEngineStatic, PayEngine, SecureFields, IPayEngineConfig };
|
|
9
|
+
export { PayEngineStatic, PayEngine, SecureFields, CreditCardForm, CreditCardFormLegacy, IPayEngineConfig, PayEngineGooglePay, PayEngineApplePay };
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { StyleProp, ViewStyle } from 'react-native';
|
|
2
|
+
import type { GooglePayRequestData } from '../components/GooglePay/interfaces';
|
|
3
|
+
export interface IPayEngineConfig {
|
|
4
|
+
publicKey: string;
|
|
5
|
+
version?: string;
|
|
6
|
+
scriptURL?: string;
|
|
7
|
+
logLevel?: number;
|
|
8
|
+
}
|
|
9
|
+
export interface CreditCardFormProps {
|
|
10
|
+
style?: StyleProp<ViewStyle>;
|
|
11
|
+
merchantId?: string;
|
|
12
|
+
showZipCode?: boolean;
|
|
13
|
+
config: IPayEngineConfig;
|
|
14
|
+
}
|
|
15
|
+
export interface CreditCardFormMethods {
|
|
16
|
+
createCard: (merchantId?: string) => Promise<any>;
|
|
17
|
+
}
|
|
18
|
+
export interface MobilePaymentConfig {
|
|
19
|
+
base_url: string;
|
|
20
|
+
country: string;
|
|
21
|
+
currency: string;
|
|
22
|
+
gateway: string;
|
|
23
|
+
google_pay: GooglePayRequestData;
|
|
24
|
+
apple_pay: {
|
|
25
|
+
merchantName: string;
|
|
26
|
+
supportedCardNetworks: string[];
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
export interface PaymentRequest {
|
|
30
|
+
amount: number;
|
|
31
|
+
currencyCode?: string;
|
|
32
|
+
countryCode?: string;
|
|
33
|
+
}
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
}
|
|
1
|
+
import type { IPayEngineConfig } from '../interfaces/index';
|
|
2
|
+
export declare const getHttpHeaders: (config: IPayEngineConfig) => {
|
|
3
|
+
Authorization: string;
|
|
4
|
+
};
|
|
5
|
+
export declare const getBaseURL: (config: IPayEngineConfig) => string;
|
|
7
6
|
export declare const createHttpClient: (config: IPayEngineConfig) => import("axios").AxiosInstance;
|
|
8
7
|
export declare function getScriptURL(config: IPayEngineConfig): string;
|
|
9
8
|
/**
|
package/package.json
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-payengine",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.6",
|
|
4
4
|
"description": "PayEngine SDK for React Native",
|
|
5
5
|
"main": "lib/commonjs/index",
|
|
6
6
|
"module": "lib/module/index",
|
|
7
7
|
"types": "lib/typescript/index.d.ts",
|
|
8
|
-
"react-native": "
|
|
9
|
-
"source": "
|
|
8
|
+
"react-native": "src",
|
|
9
|
+
"source": "src",
|
|
10
10
|
"files": [
|
|
11
|
+
"src",
|
|
11
12
|
"lib",
|
|
12
13
|
"android",
|
|
13
14
|
"ios",
|
|
14
15
|
"cpp",
|
|
15
16
|
"android/src",
|
|
16
17
|
"react-native-payengine.podspec",
|
|
17
|
-
"!./src",
|
|
18
18
|
"!lib/typescript/example",
|
|
19
19
|
"!android/build",
|
|
20
20
|
"!ios/build",
|
|
@@ -149,6 +149,7 @@
|
|
|
149
149
|
]
|
|
150
150
|
},
|
|
151
151
|
"dependencies": {
|
|
152
|
-
"axios": "^0.27.2"
|
|
152
|
+
"axios": "^0.27.2",
|
|
153
|
+
"events": "^3.3.0"
|
|
153
154
|
}
|
|
154
155
|
}
|
|
@@ -11,7 +11,7 @@ Pod::Spec.new do |s|
|
|
|
11
11
|
s.license = package["license"]
|
|
12
12
|
s.authors = package["author"]
|
|
13
13
|
|
|
14
|
-
s.platforms = { :ios => "
|
|
14
|
+
s.platforms = { :ios => "12.0" }
|
|
15
15
|
s.source = { :git => "https://bitbucket.org/payfac0/pf-react-native-payengine", :tag => "#{s.version}" }
|
|
16
16
|
|
|
17
17
|
s.source_files = "ios/**/*.{h,m,mm,swift}"
|
|
@@ -19,7 +19,7 @@ Pod::Spec.new do |s|
|
|
|
19
19
|
s.dependency "React-Core"
|
|
20
20
|
|
|
21
21
|
# VGS collect
|
|
22
|
-
s.dependency 'VGSCollectSDK'
|
|
22
|
+
s.dependency 'VGSCollectSDK', "~> 1.9.8"
|
|
23
23
|
|
|
24
24
|
# Don't install the dependencies when we run `pod install` in the old architecture.
|
|
25
25
|
if ENV['RCT_NEW_ARCH_ENABLED'] == '1' then
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import ApplePay from '.';
|
|
2
|
+
import type {
|
|
3
|
+
IPayEngineConfig,
|
|
4
|
+
MobilePaymentConfig,
|
|
5
|
+
PaymentRequest,
|
|
6
|
+
} from '../../interfaces';
|
|
7
|
+
import { createHttpClient } from '../../utils';
|
|
8
|
+
import type {
|
|
9
|
+
ApplePayDetailsData,
|
|
10
|
+
ApplePayMethodData,
|
|
11
|
+
IApplePay,
|
|
12
|
+
} from './interfaces';
|
|
13
|
+
|
|
14
|
+
export class PayEngineApplePay implements IApplePay {
|
|
15
|
+
private applePay: ApplePay;
|
|
16
|
+
private payEngineConfig: IPayEngineConfig;
|
|
17
|
+
private config?: MobilePaymentConfig;
|
|
18
|
+
private method?: ApplePayMethodData;
|
|
19
|
+
private details?: ApplePayDetailsData;
|
|
20
|
+
|
|
21
|
+
constructor(payEngineConfig: IPayEngineConfig) {
|
|
22
|
+
this.payEngineConfig = payEngineConfig;
|
|
23
|
+
this.applePay = new ApplePay();
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
public async canMakePayments(merchantId: string, paymentConfig: PaymentRequest) {
|
|
27
|
+
const client = createHttpClient(this.payEngineConfig);
|
|
28
|
+
const { data } = await client.get(
|
|
29
|
+
`/api/mobile-payment/config?merchant_id=${merchantId}`
|
|
30
|
+
);
|
|
31
|
+
this.config = data.data;
|
|
32
|
+
console.log('config', this.config);
|
|
33
|
+
this.method = {
|
|
34
|
+
countryCode: paymentConfig.countryCode ?? this.config!.country,
|
|
35
|
+
currencyCode: paymentConfig.currencyCode ?? this.config!.currency,
|
|
36
|
+
merchantIdentifier: 'merchant.payengine.tunnel3000cc',
|
|
37
|
+
supportedNetworks: ['Visa', 'MasterCard', 'AmEx'],
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
this.details = {
|
|
41
|
+
total: {
|
|
42
|
+
label: this.config!.apple_pay.merchantName,
|
|
43
|
+
amount: 1.00,
|
|
44
|
+
},
|
|
45
|
+
};
|
|
46
|
+
return await this.applePay.canMakePayments(this.method, this.details);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
public async start() {
|
|
50
|
+
if (!this.config) {
|
|
51
|
+
throw new Error('You must call `canMakePayments` first');
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
const result = await this.applePay.start();
|
|
55
|
+
try {
|
|
56
|
+
return JSON.parse(result);
|
|
57
|
+
} catch {
|
|
58
|
+
return result;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { NativeModules, Platform } from 'react-native';
|
|
2
|
+
import type { ApplePayDetailsData, ApplePayMethodData, IApplePay } from './interfaces';
|
|
3
|
+
|
|
4
|
+
const { ApplePay: RNApplePay } = NativeModules;
|
|
5
|
+
|
|
6
|
+
export default class ApplePay implements IApplePay {
|
|
7
|
+
private isReady = false;
|
|
8
|
+
|
|
9
|
+
constructor() {
|
|
10
|
+
if (Platform.OS === 'ios') {
|
|
11
|
+
if (!RNApplePay) {
|
|
12
|
+
throw new Error('ApplePay is not defined');
|
|
13
|
+
}
|
|
14
|
+
} else {
|
|
15
|
+
throw new Error('Apple Pay is supported (iOS only)');
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
public async start() {
|
|
20
|
+
if (!this.isReady) {
|
|
21
|
+
throw new Error('Apple Pay is not ready')
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
return await RNApplePay.initApplePay();
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
public async canMakePayments(method: ApplePayMethodData, details: ApplePayDetailsData) {
|
|
28
|
+
RNApplePay.invokeApplePay(method, details);
|
|
29
|
+
this.isReady = await RNApplePay.canMakePayments();
|
|
30
|
+
return this.isReady
|
|
31
|
+
}
|
|
32
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export interface IApplePay {
|
|
2
|
+
canMakePayments: (...args: any) => Promise<boolean>
|
|
3
|
+
start: (...args: any) => Promise<any>
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
type Network = 'Visa' | 'MasterCard' | 'AmEx';
|
|
8
|
+
|
|
9
|
+
export interface ApplePayMethodData {
|
|
10
|
+
countryCode: string;
|
|
11
|
+
currencyCode: string;
|
|
12
|
+
supportedNetworks: Network[];
|
|
13
|
+
merchantIdentifier: string;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export interface ApplePayDetail {
|
|
17
|
+
label: string;
|
|
18
|
+
amount: number;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export interface ApplePayDetailsData {
|
|
22
|
+
total: ApplePayDetail;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export type ApplePayTransactionIdentifier = string;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { View, StyleSheet } from 'react-native';
|
|
3
|
+
import { SecureFields } from '../SecureFields';
|
|
4
|
+
import type { CreditCardFormMethods, CreditCardFormProps } from '../../interfaces/index';
|
|
5
|
+
|
|
6
|
+
export const CreditCardForm = React.forwardRef<CreditCardFormMethods, CreditCardFormProps>((props, ref) => {
|
|
7
|
+
|
|
8
|
+
React.useImperativeHandle(ref, () => ({
|
|
9
|
+
createCard: async (merchantId?: string) => {
|
|
10
|
+
return await secureFieldRef.current?.createCard(props.merchantId ?? merchantId)
|
|
11
|
+
},
|
|
12
|
+
}));
|
|
13
|
+
|
|
14
|
+
const secureFieldRef = React.createRef<any>()
|
|
15
|
+
|
|
16
|
+
return (
|
|
17
|
+
<View style={[styles.container, props.style]}>
|
|
18
|
+
<SecureFields.CollectManager ref={secureFieldRef} config={props.config}>
|
|
19
|
+
<SecureFields.CardHolderNameField placeholder="Card holder name" style={styles.field} />
|
|
20
|
+
<SecureFields.CardNumberField placeholder="Card number" style={styles.field} />
|
|
21
|
+
<View style={{ display: 'flex', flexDirection: "row", width: '100%', height: 50, margin: 8 }}>
|
|
22
|
+
<SecureFields.ExpDateTextField style={[styles.field, { flex: 1, margin: 0, marginRight: 10 }]} />
|
|
23
|
+
<SecureFields.CVCField style={[styles.field, { flex: 1, margin: 0 }]} />
|
|
24
|
+
</View>
|
|
25
|
+
{props.showZipCode ? <SecureFields.ZipCodeField placeholder="Zip code" style={styles.field} /> : <></>}
|
|
26
|
+
</SecureFields.CollectManager>
|
|
27
|
+
</View>
|
|
28
|
+
);
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
const styles = StyleSheet.create({
|
|
32
|
+
container: {
|
|
33
|
+
width: '100%',
|
|
34
|
+
padding: 20,
|
|
35
|
+
},
|
|
36
|
+
field: {
|
|
37
|
+
width: '100%',
|
|
38
|
+
height: 50,
|
|
39
|
+
margin: 8,
|
|
40
|
+
padding: 5
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
|