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.
Files changed (113) hide show
  1. package/android/.gradle/5.6.4/executionHistory/executionHistory.bin +0 -0
  2. package/android/.gradle/5.6.4/executionHistory/executionHistory.lock +0 -0
  3. package/android/.gradle/5.6.4/fileContent/fileContent.lock +0 -0
  4. package/android/.gradle/5.6.4/fileHashes/fileHashes.bin +0 -0
  5. package/android/.gradle/5.6.4/fileHashes/fileHashes.lock +0 -0
  6. package/android/.gradle/5.6.4/fileHashes/resourceHashesCache.bin +0 -0
  7. package/android/.gradle/5.6.4/javaCompile/classAnalysis.bin +0 -0
  8. package/android/.gradle/5.6.4/javaCompile/jarAnalysis.bin +0 -0
  9. package/android/.gradle/5.6.4/javaCompile/javaCompile.lock +0 -0
  10. package/android/.gradle/5.6.4/javaCompile/taskHistory.bin +0 -0
  11. package/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock +0 -0
  12. package/android/.gradle/buildOutputCleanup/outputFiles.bin +0 -0
  13. package/android/.idea/compiler.xml +1 -1
  14. package/android/.idea/gradle.xml +1 -0
  15. package/android/.idea/misc.xml +1 -1
  16. package/android/build.gradle +24 -9
  17. package/android/src/legacy/AndroidManifest.xml +4 -0
  18. package/android/src/main/java/com/reactnativepayengine/GooglePayModule.java +196 -0
  19. package/android/src/main/java/com/reactnativepayengine/PayenginePackage.java +1 -0
  20. package/android/src/main/java/com/reactnativepayengine/collect/VGSCollectModule.java +22 -17
  21. package/android/src/main/java/com/reactnativepayengine/util/PaymentsUtil.java +113 -0
  22. package/ios/Payengine.m +18 -1
  23. package/ios/Payengine.swift +85 -2
  24. package/ios/Payengine.xcodeproj/project.pbxproj +16 -5
  25. package/ios/Payengine.xcodeproj/project.xcworkspace/xcuserdata/tringuyen.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
  26. package/ios/Payengine.xcodeproj/xcuserdata/tringuyen.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist +4 -4
  27. package/ios/Payengine.xcworkspace/xcuserdata/tringuyen.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
  28. package/lib/commonjs/components/ApplePay/PayEngineApplePay.js +71 -0
  29. package/lib/commonjs/components/ApplePay/PayEngineApplePay.js.map +1 -0
  30. package/lib/commonjs/components/ApplePay/index.js +46 -0
  31. package/lib/commonjs/components/ApplePay/index.js.map +1 -0
  32. package/lib/commonjs/components/ApplePay/interfaces.js +2 -0
  33. package/lib/commonjs/components/ApplePay/interfaces.js.map +1 -0
  34. package/lib/commonjs/components/CreditCardForm/index.js +76 -0
  35. package/lib/commonjs/components/CreditCardForm/index.js.map +1 -0
  36. package/lib/commonjs/components/GooglePay/PayEngineGooglePay.js +65 -0
  37. package/lib/commonjs/components/GooglePay/PayEngineGooglePay.js.map +1 -0
  38. package/lib/commonjs/components/GooglePay/index.js +40 -0
  39. package/lib/commonjs/components/GooglePay/index.js.map +1 -0
  40. package/lib/commonjs/components/GooglePay/interfaces.js +2 -0
  41. package/lib/commonjs/components/GooglePay/interfaces.js.map +1 -0
  42. package/lib/commonjs/components/Legacy/CreditCardFormLegacy.js +323 -0
  43. package/lib/commonjs/components/Legacy/CreditCardFormLegacy.js.map +1 -0
  44. package/lib/commonjs/components/PayEngine.js.map +1 -1
  45. package/lib/commonjs/components/SecureFields/VGS/CollectManager.js +3 -8
  46. package/lib/commonjs/components/SecureFields/VGS/CollectManager.js.map +1 -1
  47. package/lib/commonjs/index.js +33 -4
  48. package/lib/commonjs/index.js.map +1 -1
  49. package/lib/commonjs/interfaces/index.js +6 -0
  50. package/lib/commonjs/interfaces/index.js.map +1 -0
  51. package/lib/commonjs/utils/index.js +20 -8
  52. package/lib/commonjs/utils/index.js.map +1 -1
  53. package/lib/module/components/ApplePay/PayEngineApplePay.js +58 -0
  54. package/lib/module/components/ApplePay/PayEngineApplePay.js.map +1 -0
  55. package/lib/module/components/ApplePay/index.js +35 -0
  56. package/lib/module/components/ApplePay/index.js.map +1 -0
  57. package/lib/module/components/ApplePay/interfaces.js +2 -0
  58. package/lib/module/components/ApplePay/interfaces.js.map +1 -0
  59. package/lib/module/components/CreditCardForm/index.js +60 -0
  60. package/lib/module/components/CreditCardForm/index.js.map +1 -0
  61. package/lib/module/components/GooglePay/PayEngineGooglePay.js +52 -0
  62. package/lib/module/components/GooglePay/PayEngineGooglePay.js.map +1 -0
  63. package/lib/module/components/GooglePay/index.js +29 -0
  64. package/lib/module/components/GooglePay/index.js.map +1 -0
  65. package/lib/module/components/GooglePay/interfaces.js +2 -0
  66. package/lib/module/components/GooglePay/interfaces.js.map +1 -0
  67. package/lib/module/components/Legacy/CreditCardFormLegacy.js +302 -0
  68. package/lib/module/components/Legacy/CreditCardFormLegacy.js.map +1 -0
  69. package/lib/module/components/PayEngine.js.map +1 -1
  70. package/lib/module/components/SecureFields/VGS/CollectManager.js +3 -8
  71. package/lib/module/components/SecureFields/VGS/CollectManager.js.map +1 -1
  72. package/lib/module/index.js +6 -5
  73. package/lib/module/index.js.map +1 -1
  74. package/lib/module/interfaces/index.js +2 -0
  75. package/lib/module/interfaces/index.js.map +1 -0
  76. package/lib/module/utils/index.js +14 -8
  77. package/lib/module/utils/index.js.map +1 -1
  78. package/lib/typescript/components/ApplePay/PayEngineApplePay.d.ts +12 -0
  79. package/lib/typescript/components/ApplePay/index.d.ts +7 -0
  80. package/lib/typescript/components/ApplePay/interfaces.d.ts +20 -0
  81. package/lib/typescript/components/CreditCardForm/index.d.ts +3 -0
  82. package/lib/typescript/components/GooglePay/PayEngineGooglePay.d.ts +10 -0
  83. package/lib/typescript/components/GooglePay/index.d.ts +7 -0
  84. package/lib/typescript/components/GooglePay/interfaces.d.ts +38 -0
  85. package/lib/typescript/components/Legacy/CreditCardFormLegacy.d.ts +4 -0
  86. package/lib/typescript/components/PayEngine.d.ts +1 -1
  87. package/lib/typescript/components/SecureFields/VGS/CollectManager.d.ts +1 -1
  88. package/lib/typescript/index.d.ts +6 -2
  89. package/lib/typescript/interfaces/index.d.ts +33 -0
  90. package/lib/typescript/utils/index.d.ts +5 -6
  91. package/package.json +6 -5
  92. package/react-native-payengine.podspec +2 -2
  93. package/src/components/ApplePay/PayEngineApplePay.ts +61 -0
  94. package/src/components/ApplePay/index.ts +32 -0
  95. package/src/components/ApplePay/interfaces.ts +25 -0
  96. package/src/components/CreditCardForm/index.tsx +43 -0
  97. package/src/components/GooglePay/PayEngineGooglePay.ts +48 -0
  98. package/src/components/GooglePay/index.ts +39 -0
  99. package/src/components/GooglePay/interfaces.ts +42 -0
  100. package/src/components/Legacy/CreditCardFormLegacy.tsx +292 -0
  101. package/src/components/LoadingIndicator.tsx +28 -0
  102. package/src/components/PayEngine.tsx +121 -0
  103. package/src/components/SecureFields/VGS/CVCField.tsx +21 -0
  104. package/src/components/SecureFields/VGS/CardHolderNameField.tsx +21 -0
  105. package/src/components/SecureFields/VGS/CardNumberField.tsx +21 -0
  106. package/src/components/SecureFields/VGS/CollectManager.tsx +74 -0
  107. package/src/components/SecureFields/VGS/ExpDateField.tsx +21 -0
  108. package/src/components/SecureFields/VGS/TextField.tsx +27 -0
  109. package/src/components/SecureFields/VGS/ZipCodeField.tsx +21 -0
  110. package/src/components/SecureFields/index.ts +17 -0
  111. package/src/index.tsx +37 -0
  112. package/src/interfaces/index.ts +38 -0
  113. package/src/utils/index.ts +107 -0
@@ -0,0 +1,58 @@
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
+
3
+ import ApplePay from '.';
4
+ import { createHttpClient } from '../../utils';
5
+ export class PayEngineApplePay {
6
+ constructor(payEngineConfig) {
7
+ _defineProperty(this, "applePay", void 0);
8
+
9
+ _defineProperty(this, "payEngineConfig", void 0);
10
+
11
+ _defineProperty(this, "config", void 0);
12
+
13
+ _defineProperty(this, "method", void 0);
14
+
15
+ _defineProperty(this, "details", void 0);
16
+
17
+ this.payEngineConfig = payEngineConfig;
18
+ this.applePay = new ApplePay();
19
+ }
20
+
21
+ async canMakePayments(merchantId, paymentConfig) {
22
+ const client = createHttpClient(this.payEngineConfig);
23
+ const {
24
+ data
25
+ } = await client.get(`/api/mobile-payment/config?merchant_id=${merchantId}`);
26
+ this.config = data.data;
27
+ console.log('config', this.config);
28
+ this.method = {
29
+ countryCode: paymentConfig.countryCode ?? this.config.country,
30
+ currencyCode: paymentConfig.currencyCode ?? this.config.currency,
31
+ merchantIdentifier: 'merchant.payengine.tunnel3000cc',
32
+ supportedNetworks: ['Visa', 'MasterCard', 'AmEx']
33
+ };
34
+ this.details = {
35
+ total: {
36
+ label: this.config.apple_pay.merchantName,
37
+ amount: 1.00
38
+ }
39
+ };
40
+ return await this.applePay.canMakePayments(this.method, this.details);
41
+ }
42
+
43
+ async start() {
44
+ if (!this.config) {
45
+ throw new Error('You must call `canMakePayments` first');
46
+ }
47
+
48
+ const result = await this.applePay.start();
49
+
50
+ try {
51
+ return JSON.parse(result);
52
+ } catch {
53
+ return result;
54
+ }
55
+ }
56
+
57
+ }
58
+ //# sourceMappingURL=PayEngineApplePay.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["ApplePay","createHttpClient","PayEngineApplePay","constructor","payEngineConfig","applePay","canMakePayments","merchantId","paymentConfig","client","data","get","config","console","log","method","countryCode","country","currencyCode","currency","merchantIdentifier","supportedNetworks","details","total","label","apple_pay","merchantName","amount","start","Error","result","JSON","parse"],"sources":["PayEngineApplePay.ts"],"sourcesContent":["import ApplePay from '.';\nimport type {\n IPayEngineConfig,\n MobilePaymentConfig,\n PaymentRequest,\n} from '../../interfaces';\nimport { createHttpClient } from '../../utils';\nimport type {\n ApplePayDetailsData,\n ApplePayMethodData,\n IApplePay,\n} from './interfaces';\n\nexport class PayEngineApplePay implements IApplePay {\n private applePay: ApplePay;\n private payEngineConfig: IPayEngineConfig;\n private config?: MobilePaymentConfig;\n private method?: ApplePayMethodData;\n private details?: ApplePayDetailsData;\n\n constructor(payEngineConfig: IPayEngineConfig) {\n this.payEngineConfig = payEngineConfig;\n this.applePay = new ApplePay();\n }\n\n public async canMakePayments(merchantId: string, paymentConfig: PaymentRequest) {\n const client = createHttpClient(this.payEngineConfig);\n const { data } = await client.get(\n `/api/mobile-payment/config?merchant_id=${merchantId}`\n );\n this.config = data.data;\n console.log('config', this.config);\n this.method = {\n countryCode: paymentConfig.countryCode ?? this.config!.country,\n currencyCode: paymentConfig.currencyCode ?? this.config!.currency,\n merchantIdentifier: 'merchant.payengine.tunnel3000cc',\n supportedNetworks: ['Visa', 'MasterCard', 'AmEx'],\n };\n\n this.details = {\n total: {\n label: this.config!.apple_pay.merchantName,\n amount: 1.00,\n },\n };\n return await this.applePay.canMakePayments(this.method, this.details);\n }\n\n public async start() {\n if (!this.config) {\n throw new Error('You must call `canMakePayments` first');\n }\n\n const result = await this.applePay.start();\n try {\n return JSON.parse(result);\n } catch {\n return result;\n }\n }\n}\n"],"mappings":";;AAAA,OAAOA,QAAP,MAAqB,GAArB;AAMA,SAASC,gBAAT,QAAiC,aAAjC;AAOA,OAAO,MAAMC,iBAAN,CAA6C;EAOlDC,WAAW,CAACC,eAAD,EAAoC;IAAA;;IAAA;;IAAA;;IAAA;;IAAA;;IAC7C,KAAKA,eAAL,GAAuBA,eAAvB;IACA,KAAKC,QAAL,GAAgB,IAAIL,QAAJ,EAAhB;EACD;;EAE2B,MAAfM,eAAe,CAACC,UAAD,EAAqBC,aAArB,EAAoD;IAC9E,MAAMC,MAAM,GAAGR,gBAAgB,CAAC,KAAKG,eAAN,CAA/B;IACA,MAAM;MAAEM;IAAF,IAAW,MAAMD,MAAM,CAACE,GAAP,CACpB,0CAAyCJ,UAAW,EADhC,CAAvB;IAGA,KAAKK,MAAL,GAAcF,IAAI,CAACA,IAAnB;IACAG,OAAO,CAACC,GAAR,CAAY,QAAZ,EAAsB,KAAKF,MAA3B;IACA,KAAKG,MAAL,GAAc;MACZC,WAAW,EAAER,aAAa,CAACQ,WAAd,IAA6B,KAAKJ,MAAL,CAAaK,OAD3C;MAEZC,YAAY,EAAEV,aAAa,CAACU,YAAd,IAA8B,KAAKN,MAAL,CAAaO,QAF7C;MAGZC,kBAAkB,EAAE,iCAHR;MAIZC,iBAAiB,EAAE,CAAC,MAAD,EAAS,YAAT,EAAuB,MAAvB;IAJP,CAAd;IAOA,KAAKC,OAAL,GAAe;MACbC,KAAK,EAAE;QACLC,KAAK,EAAE,KAAKZ,MAAL,CAAaa,SAAb,CAAuBC,YADzB;QAELC,MAAM,EAAE;MAFH;IADM,CAAf;IAMA,OAAO,MAAM,KAAKtB,QAAL,CAAcC,eAAd,CAA8B,KAAKS,MAAnC,EAA2C,KAAKO,OAAhD,CAAb;EACD;;EAEiB,MAALM,KAAK,GAAG;IACnB,IAAI,CAAC,KAAKhB,MAAV,EAAkB;MAChB,MAAM,IAAIiB,KAAJ,CAAU,uCAAV,CAAN;IACD;;IAED,MAAMC,MAAM,GAAG,MAAM,KAAKzB,QAAL,CAAcuB,KAAd,EAArB;;IACA,IAAI;MACF,OAAOG,IAAI,CAACC,KAAL,CAAWF,MAAX,CAAP;IACD,CAFD,CAEE,MAAM;MACN,OAAOA,MAAP;IACD;EACF;;AA9CiD"}
@@ -0,0 +1,35 @@
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
+
3
+ import { NativeModules, Platform } from 'react-native';
4
+ const {
5
+ ApplePay: RNApplePay
6
+ } = NativeModules;
7
+ export default class ApplePay {
8
+ constructor() {
9
+ _defineProperty(this, "isReady", false);
10
+
11
+ if (Platform.OS === 'ios') {
12
+ if (!RNApplePay) {
13
+ throw new Error('ApplePay is not defined');
14
+ }
15
+ } else {
16
+ throw new Error('Apple Pay is supported (iOS only)');
17
+ }
18
+ }
19
+
20
+ async start() {
21
+ if (!this.isReady) {
22
+ throw new Error('Apple Pay is not ready');
23
+ }
24
+
25
+ return await RNApplePay.initApplePay();
26
+ }
27
+
28
+ async canMakePayments(method, details) {
29
+ RNApplePay.invokeApplePay(method, details);
30
+ this.isReady = await RNApplePay.canMakePayments();
31
+ return this.isReady;
32
+ }
33
+
34
+ }
35
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["NativeModules","Platform","ApplePay","RNApplePay","constructor","OS","Error","start","isReady","initApplePay","canMakePayments","method","details","invokeApplePay"],"sources":["index.ts"],"sourcesContent":["import { NativeModules, Platform } from 'react-native';\nimport type { ApplePayDetailsData, ApplePayMethodData, IApplePay } from './interfaces';\n\nconst { ApplePay: RNApplePay } = NativeModules;\n\nexport default class ApplePay implements IApplePay {\n private isReady = false;\n\n constructor() {\n if (Platform.OS === 'ios') {\n if (!RNApplePay) {\n throw new Error('ApplePay is not defined');\n }\n } else {\n throw new Error('Apple Pay is supported (iOS only)');\n }\n }\n\n public async start() {\n if (!this.isReady) {\n throw new Error('Apple Pay is not ready')\n }\n\n return await RNApplePay.initApplePay();\n }\n\n public async canMakePayments(method: ApplePayMethodData, details: ApplePayDetailsData) {\n RNApplePay.invokeApplePay(method, details);\n this.isReady = await RNApplePay.canMakePayments();\n return this.isReady\n }\n}\n"],"mappings":";;AAAA,SAASA,aAAT,EAAwBC,QAAxB,QAAwC,cAAxC;AAGA,MAAM;EAAEC,QAAQ,EAAEC;AAAZ,IAA2BH,aAAjC;AAEA,eAAe,MAAME,QAAN,CAAoC;EAGjDE,WAAW,GAAG;IAAA,iCAFI,KAEJ;;IACZ,IAAIH,QAAQ,CAACI,EAAT,KAAgB,KAApB,EAA2B;MACzB,IAAI,CAACF,UAAL,EAAiB;QACf,MAAM,IAAIG,KAAJ,CAAU,yBAAV,CAAN;MACD;IACF,CAJD,MAIO;MACL,MAAM,IAAIA,KAAJ,CAAU,mCAAV,CAAN;IACD;EACF;;EAEiB,MAALC,KAAK,GAAG;IACnB,IAAI,CAAC,KAAKC,OAAV,EAAmB;MACjB,MAAM,IAAIF,KAAJ,CAAU,wBAAV,CAAN;IACD;;IAED,OAAO,MAAMH,UAAU,CAACM,YAAX,EAAb;EACD;;EAE2B,MAAfC,eAAe,CAACC,MAAD,EAA6BC,OAA7B,EAA2D;IACrFT,UAAU,CAACU,cAAX,CAA0BF,MAA1B,EAAkCC,OAAlC;IACA,KAAKJ,OAAL,GAAe,MAAML,UAAU,CAACO,eAAX,EAArB;IACA,OAAO,KAAKF,OAAZ;EACD;;AAzBgD"}
@@ -0,0 +1,2 @@
1
+
2
+ //# sourceMappingURL=interfaces.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":[],"sources":["interfaces.ts"],"sourcesContent":["export interface IApplePay {\n canMakePayments: (...args: any) => Promise<boolean>\n start: (...args: any) => Promise<any>\n}\n\n\ntype Network = 'Visa' | 'MasterCard' | 'AmEx';\n\nexport interface ApplePayMethodData {\n countryCode: string;\n currencyCode: string;\n supportedNetworks: Network[];\n merchantIdentifier: string;\n}\n\nexport interface ApplePayDetail {\n label: string;\n amount: number;\n}\n\nexport interface ApplePayDetailsData {\n total: ApplePayDetail;\n}\n\nexport type ApplePayTransactionIdentifier = string;\n"],"mappings":""}
@@ -0,0 +1,60 @@
1
+ import * as React from 'react';
2
+ import { View, StyleSheet } from 'react-native';
3
+ import { SecureFields } from '../SecureFields';
4
+ export const CreditCardForm = /*#__PURE__*/React.forwardRef((props, ref) => {
5
+ React.useImperativeHandle(ref, () => ({
6
+ createCard: async merchantId => {
7
+ var _secureFieldRef$curre;
8
+
9
+ return await ((_secureFieldRef$curre = secureFieldRef.current) === null || _secureFieldRef$curre === void 0 ? void 0 : _secureFieldRef$curre.createCard(props.merchantId ?? merchantId));
10
+ }
11
+ }));
12
+ const secureFieldRef = /*#__PURE__*/React.createRef();
13
+ return /*#__PURE__*/React.createElement(View, {
14
+ style: [styles.container, props.style]
15
+ }, /*#__PURE__*/React.createElement(SecureFields.CollectManager, {
16
+ ref: secureFieldRef,
17
+ config: props.config
18
+ }, /*#__PURE__*/React.createElement(SecureFields.CardHolderNameField, {
19
+ placeholder: "Card holder name",
20
+ style: styles.field
21
+ }), /*#__PURE__*/React.createElement(SecureFields.CardNumberField, {
22
+ placeholder: "Card number",
23
+ style: styles.field
24
+ }), /*#__PURE__*/React.createElement(View, {
25
+ style: {
26
+ display: 'flex',
27
+ flexDirection: "row",
28
+ width: '100%',
29
+ height: 50,
30
+ margin: 8
31
+ }
32
+ }, /*#__PURE__*/React.createElement(SecureFields.ExpDateTextField, {
33
+ style: [styles.field, {
34
+ flex: 1,
35
+ margin: 0,
36
+ marginRight: 10
37
+ }]
38
+ }), /*#__PURE__*/React.createElement(SecureFields.CVCField, {
39
+ style: [styles.field, {
40
+ flex: 1,
41
+ margin: 0
42
+ }]
43
+ })), props.showZipCode ? /*#__PURE__*/React.createElement(SecureFields.ZipCodeField, {
44
+ placeholder: "Zip code",
45
+ style: styles.field
46
+ }) : /*#__PURE__*/React.createElement(React.Fragment, null)));
47
+ });
48
+ const styles = StyleSheet.create({
49
+ container: {
50
+ width: '100%',
51
+ padding: 20
52
+ },
53
+ field: {
54
+ width: '100%',
55
+ height: 50,
56
+ margin: 8,
57
+ padding: 5
58
+ }
59
+ });
60
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["React","View","StyleSheet","SecureFields","CreditCardForm","forwardRef","props","ref","useImperativeHandle","createCard","merchantId","secureFieldRef","current","createRef","styles","container","style","config","field","display","flexDirection","width","height","margin","flex","marginRight","showZipCode","create","padding"],"sources":["index.tsx"],"sourcesContent":["import * as React from 'react';\nimport { View, StyleSheet } from 'react-native';\nimport { SecureFields } from '../SecureFields';\nimport type { CreditCardFormMethods, CreditCardFormProps } from '../../interfaces/index';\n\nexport const CreditCardForm = React.forwardRef<CreditCardFormMethods, CreditCardFormProps>((props, ref) => {\n\n React.useImperativeHandle(ref, () => ({\n createCard: async (merchantId?: string) => {\n return await secureFieldRef.current?.createCard(props.merchantId ?? merchantId)\n },\n }));\n\n const secureFieldRef = React.createRef<any>()\n\n return (\n <View style={[styles.container, props.style]}>\n <SecureFields.CollectManager ref={secureFieldRef} config={props.config}>\n <SecureFields.CardHolderNameField placeholder=\"Card holder name\" style={styles.field} />\n <SecureFields.CardNumberField placeholder=\"Card number\" style={styles.field} />\n <View style={{ display: 'flex', flexDirection: \"row\", width: '100%', height: 50, margin: 8 }}>\n <SecureFields.ExpDateTextField style={[styles.field, { flex: 1, margin: 0, marginRight: 10 }]} />\n <SecureFields.CVCField style={[styles.field, { flex: 1, margin: 0 }]} />\n </View>\n {props.showZipCode ? <SecureFields.ZipCodeField placeholder=\"Zip code\" style={styles.field} /> : <></>}\n </SecureFields.CollectManager>\n </View>\n );\n});\n\nconst styles = StyleSheet.create({\n container: {\n width: '100%',\n padding: 20,\n },\n field: {\n width: '100%',\n height: 50,\n margin: 8,\n padding: 5\n }\n});\n\n"],"mappings":"AAAA,OAAO,KAAKA,KAAZ,MAAuB,OAAvB;AACA,SAASC,IAAT,EAAeC,UAAf,QAAiC,cAAjC;AACA,SAASC,YAAT,QAA6B,iBAA7B;AAGA,OAAO,MAAMC,cAAc,gBAAGJ,KAAK,CAACK,UAAN,CAA6D,CAACC,KAAD,EAAQC,GAAR,KAAgB;EAEzGP,KAAK,CAACQ,mBAAN,CAA0BD,GAA1B,EAA+B,OAAO;IACpCE,UAAU,EAAE,MAAOC,UAAP,IAA+B;MAAA;;MACzC,OAAO,gCAAMC,cAAc,CAACC,OAArB,0DAAM,sBAAwBH,UAAxB,CAAmCH,KAAK,CAACI,UAAN,IAAoBA,UAAvD,CAAN,CAAP;IACD;EAHmC,CAAP,CAA/B;EAMA,MAAMC,cAAc,gBAAGX,KAAK,CAACa,SAAN,EAAvB;EAEA,oBACE,oBAAC,IAAD;IAAM,KAAK,EAAE,CAACC,MAAM,CAACC,SAAR,EAAmBT,KAAK,CAACU,KAAzB;EAAb,gBACE,oBAAC,YAAD,CAAc,cAAd;IAA6B,GAAG,EAAEL,cAAlC;IAAkD,M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+ 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
+
3
+ import GooglePay from '.';
4
+ import { createHttpClient } from '../../utils';
5
+ export class PayEngineGooglePay {
6
+ constructor(payEngineConfig) {
7
+ _defineProperty(this, "googlePay", void 0);
8
+
9
+ _defineProperty(this, "payEngineConfig", void 0);
10
+
11
+ _defineProperty(this, "config", void 0);
12
+
13
+ this.payEngineConfig = payEngineConfig;
14
+ this.googlePay = new GooglePay();
15
+ }
16
+
17
+ async canMakePayments(merchantId) {
18
+ const client = createHttpClient(this.payEngineConfig);
19
+ const {
20
+ data
21
+ } = await client.get(`/api/mobile-payment/config?merchant_id=${merchantId}`);
22
+ this.config = data.data;
23
+ await this.googlePay.setProduction(Boolean(this.config.google_pay.production));
24
+ return await this.googlePay.canMakePayments(this.config.google_pay.cardPaymentMethod.allowedCardNetworks, this.config.google_pay.cardPaymentMethod.allowedCardAuthMethods);
25
+ }
26
+
27
+ async start(paymentConfig) {
28
+ if (!this.config) {
29
+ throw new Error('You must call `canMakePayments` first');
30
+ }
31
+
32
+ const payload = {
33
+ cardPaymentMethod: this.config.google_pay.cardPaymentMethod,
34
+ transaction: {
35
+ totalPrice: String(paymentConfig.amount),
36
+ totalPriceStatus: 'FINAL',
37
+ currencyCode: paymentConfig.currencyCode ?? this.config.currency,
38
+ countryCode: paymentConfig.countryCode ?? this.config.country
39
+ },
40
+ merchantName: this.config.google_pay.merchantName
41
+ };
42
+ const result = await this.googlePay.start(payload);
43
+
44
+ try {
45
+ return JSON.parse(result);
46
+ } catch {
47
+ return result;
48
+ }
49
+ }
50
+
51
+ }
52
+ //# sourceMappingURL=PayEngineGooglePay.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["GooglePay","createHttpClient","PayEngineGooglePay","constructor","payEngineConfig","googlePay","canMakePayments","merchantId","client","data","get","config","setProduction","Boolean","google_pay","production","cardPaymentMethod","allowedCardNetworks","allowedCardAuthMethods","start","paymentConfig","Error","payload","transaction","totalPrice","String","amount","totalPriceStatus","currencyCode","currency","countryCode","country","merchantName","result","JSON","parse"],"sources":["PayEngineGooglePay.ts"],"sourcesContent":["import GooglePay from '.';\nimport type { IPayEngineConfig, MobilePaymentConfig, PaymentRequest } from '../../interfaces';\nimport { createHttpClient } from '../../utils';\nimport type { GooglePayRequestData, IGooglePay } from './interfaces';\n\nexport class PayEngineGooglePay implements IGooglePay {\n\n private googlePay: GooglePay;\n private payEngineConfig: IPayEngineConfig;\n private config?: MobilePaymentConfig;\n\n constructor(payEngineConfig: IPayEngineConfig) {\n this.payEngineConfig = payEngineConfig;\n this.googlePay = new GooglePay()\n }\n\n public async canMakePayments(merchantId: string) {\n const client = createHttpClient(this.payEngineConfig);\n const { data } = await client.get(`/api/mobile-payment/config?merchant_id=${merchantId}`)\n this.config = data.data\n await this.googlePay.setProduction(Boolean(this.config!.google_pay.production))\n return await this.googlePay.canMakePayments(this.config!.google_pay.cardPaymentMethod.allowedCardNetworks, this.config!.google_pay.cardPaymentMethod.allowedCardAuthMethods)\n }\n\n public async start(paymentConfig: PaymentRequest) {\n if (!this.config) {\n throw new Error('You must call `canMakePayments` first')\n }\n\n const payload: GooglePayRequestData = {\n cardPaymentMethod: this.config!.google_pay.cardPaymentMethod,\n transaction: {\n totalPrice: String(paymentConfig.amount),\n totalPriceStatus: 'FINAL',\n currencyCode: paymentConfig.currencyCode ?? this.config!.currency,\n countryCode: paymentConfig.countryCode ?? this.config!.country\n },\n merchantName: this.config!.google_pay.merchantName\n }\n\n const result = await this.googlePay.start(payload);\n try {\n return JSON.parse(result)\n } catch {\n return result;\n }\n }\n}\n"],"mappings":";;AAAA,OAAOA,SAAP,MAAsB,GAAtB;AAEA,SAASC,gBAAT,QAAiC,aAAjC;AAGA,OAAO,MAAMC,kBAAN,CAA+C;EAMpDC,WAAW,CAACC,eAAD,EAAoC;IAAA;;IAAA;;IAAA;;IAC7C,KAAKA,eAAL,G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B;;IACA,IAAI;MACF,OAAOY,IAAI,CAACC,KAAL,CAAWF,MAAX,CAAP;IACD,CAFD,CAEE,MAAM;MACN,OAAOA,MAAP;IACD;EACF;;AAzCmD"}
@@ -0,0 +1,29 @@
1
+ import { NativeModules, Platform } from 'react-native';
2
+ const {
3
+ GooglePay: RNGooglePay
4
+ } = NativeModules;
5
+ export default class GooglePay {
6
+ constructor() {
7
+ if (Platform.OS === 'android') {
8
+ if (!RNGooglePay) {
9
+ throw new Error('GooglePay is not defined');
10
+ }
11
+ } else {
12
+ throw new Error('Google Pay is not supported (Android only)');
13
+ }
14
+ }
15
+
16
+ async setProduction(isProduction) {
17
+ return RNGooglePay.setEnvironment(isProduction ? 1 : 3);
18
+ }
19
+
20
+ async canMakePayments(allowedCardNetworks, allowedCardAuthMethods) {
21
+ return await RNGooglePay.isReadyToPay(allowedCardNetworks, allowedCardAuthMethods);
22
+ }
23
+
24
+ async start(requestData) {
25
+ return await RNGooglePay.requestPayment(requestData);
26
+ }
27
+
28
+ }
29
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["NativeModules","Platform","GooglePay","RNGooglePay","constructor","OS","Error","setProduction","isProduction","setEnvironment","canMakePayments","allowedCardNetworks","allowedCardAuthMethods","isReadyToPay","start","requestData","requestPayment"],"sources":["index.ts"],"sourcesContent":["import { NativeModules, Platform } from 'react-native';\nimport type {\n GooglePayAllowedCardAuthMethods,\n GooglePayAllowedCardNetworks,\n GooglePayRequestData,\n IGooglePay,\n} from './interfaces';\n\nconst { GooglePay: RNGooglePay } = NativeModules;\n\nexport default class GooglePay implements IGooglePay {\n constructor() {\n if (Platform.OS === 'android') {\n if (!RNGooglePay) {\n throw new Error('GooglePay is not defined');\n }\n } else {\n throw new Error('Google Pay is not supported (Android only)');\n }\n }\n\n public async setProduction(isProduction: boolean) {\n return RNGooglePay.setEnvironment(isProduction ? 1 : 3);\n }\n\n public async canMakePayments(\n allowedCardNetworks: GooglePayAllowedCardNetworks,\n allowedCardAuthMethods: GooglePayAllowedCardAuthMethods\n ) {\n return await RNGooglePay.isReadyToPay(\n allowedCardNetworks,\n allowedCardAuthMethods\n );\n }\n\n public async start(requestData: GooglePayRequestData) {\n return await RNGooglePay.requestPayment(requestData);\n }\n}\n"],"mappings":"AAAA,SAASA,aAAT,EAAwBC,QAAxB,QAAwC,cAAxC;AAQA,MAAM;EAAEC,SAAS,EAAEC;AAAb,IAA6BH,aAAnC;AAEA,eAAe,MAAME,SAAN,CAAsC;EACnDE,WAAW,GAAG;IACZ,IAAIH,QAAQ,CAACI,EAAT,KAAgB,SAApB,EAA+B;MAC7B,IAAI,CAACF,WAAL,EAAkB;QAChB,MAAM,IAAIG,KAAJ,CAAU,0BAAV,CAAN;MACD;IACF,CAJD,MAIO;MACL,MAAM,IAAIA,KAAJ,CAAU,4CAAV,CAAN;IACD;EACF;;EAEyB,MAAbC,aAAa,CAACC,YAAD,EAAwB;IAChD,OAAOL,WAAW,CAACM,cAAZ,CAA2BD,YAAY,GAAG,CAAH,GAAO,CAA9C,CAAP;EACD;;EAE2B,MAAfE,eAAe,CAC1BC,mBAD0B,EAE1BC,sBAF0B,EAG1B;IACA,OAAO,MAAMT,WAAW,CAACU,YAAZ,CACXF,mBADW,EAEXC,sBAFW,CAAb;EAID;;EAEiB,MAALE,KAAK,CAACC,WAAD,EAAoC;IACpD,OAAO,MAAMZ,WAAW,CAACa,cAAZ,CAA2BD,WAA3B,CAAb;EACD;;AA3BkD"}
@@ -0,0 +1,2 @@
1
+
2
+ //# sourceMappingURL=interfaces.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":[],"sources":["interfaces.ts"],"sourcesContent":["export interface IGooglePay {\n canMakePayments: (...args: any) => Promise<boolean>\n start: (...args: any) => Promise<any>\n}\n\ntype NetworkType = 'AMEX' | 'DISCOVER' | 'JCB' | 'MASTERCARD' | 'VISA';\ntype MethodType = 'PAN_ONLY' | 'CRYPTOGRAM_3DS';\n\nexport type GooglePayAllowedCardNetworks = NetworkType[];\n\nexport type GooglePayAllowedCardAuthMethods = MethodType[];\n\nexport type TokenizationSpecificationType = 'PAYMENT_GATEWAY' | 'DIRECT';\n\nexport interface GooglePayRequestData {\n production?: boolean,\n cardPaymentMethod: {\n tokenizationSpecification: {\n type: TokenizationSpecificationType;\n /** only with type: PAYMENT_GATEWAY */\n gateway?: string;\n /** only with type: PAYMENT_GATEWAY */\n gatewayMerchantId?: string;\n /** only with gateway: stripe */\n stripe?: {\n publishableKey: string;\n version: string;\n };\n /** only with type: DIRECT */\n publicKey?: string;\n };\n allowedCardNetworks: GooglePayAllowedCardNetworks;\n allowedCardAuthMethods: GooglePayAllowedCardAuthMethods;\n };\n transaction: {\n totalPrice: string;\n totalPriceStatus: string;\n currencyCode: string;\n countryCode: string;\n };\n merchantName: string;\n}\n"],"mappings":""}
@@ -0,0 +1,302 @@
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
+
3
+ import * as React from 'react';
4
+ import { Text, View, StyleSheet, ActivityIndicator } from 'react-native';
5
+ import eventEmitter from 'events';
6
+ import { WebView } from 'react-native-webview';
7
+ import { createHttpClient, getHttpHeaders } from '../../utils/index';
8
+ import LoadingIndicator from '../LoadingIndicator';
9
+ const emitter = new eventEmitter();
10
+
11
+ class CardError extends Error {
12
+ constructor(data) {
13
+ super('Failed to create card');
14
+
15
+ _defineProperty(this, "data", null);
16
+
17
+ this.data = data;
18
+ }
19
+
20
+ }
21
+
22
+ const CreditCardFormLegacy = /*#__PURE__*/React.forwardRef((props, ref) => {
23
+ const webviewRef = /*#__PURE__*/React.createRef();
24
+ const [loading, setLoading] = React.useState(true);
25
+ const [error, setError] = React.useState("");
26
+ const [html, setHtml] = React.useState("");
27
+ const [webviewResponse, setWebviewResponse] = React.useState();
28
+ React.useImperativeHandle(ref, () => ({
29
+ createCard: async merchantId => {
30
+ setWebviewResponse(null);
31
+ const headers = getHttpHeaders(props.config);
32
+ const script = `
33
+ submit(${merchantId ? '"' + merchantId + '"' : 'null'}, '${headers.Authorization}');
34
+ `;
35
+ return new Promise((resolve, reject) => {
36
+ var _webviewRef$current;
37
+
38
+ console.log({
39
+ emitter
40
+ });
41
+ emitter.once('pe.card_response', (data, isError) => {
42
+ if (isError) {
43
+ reject(new CardError(data));
44
+ } else {
45
+ resolve(data);
46
+ }
47
+ });
48
+ (_webviewRef$current = webviewRef.current) === null || _webviewRef$current === void 0 ? void 0 : _webviewRef$current.injectJavaScript(script);
49
+ });
50
+ }
51
+ }), [props.config, webviewRef, webviewResponse]);
52
+ React.useEffect(() => {
53
+ const configure = async () => {
54
+ setLoading(true);
55
+
56
+ try {
57
+ const http = createHttpClient(props.config);
58
+ const resp = await http.get('/api/setting/secure-fields');
59
+ const {
60
+ vault,
61
+ environment,
62
+ cname,
63
+ vgs_satellite_port
64
+ } = resp.data.data;
65
+ setHtml(createVGSCollectFormHTML(Boolean(props.showZipCode), vault, environment, cname, vgs_satellite_port));
66
+ } catch (e) {
67
+ console.log({
68
+ error: e
69
+ });
70
+ setError(e.message);
71
+ } finally {
72
+ setLoading(false);
73
+ }
74
+ };
75
+
76
+ configure();
77
+ }, []);
78
+
79
+ const onMessage = payload => {
80
+ let dataPayload;
81
+
82
+ try {
83
+ dataPayload = JSON.parse(payload.nativeEvent.data);
84
+ } catch (e) {}
85
+
86
+ if (dataPayload) {
87
+ console.log({
88
+ dataPayload
89
+ });
90
+
91
+ switch (dataPayload.type) {
92
+ case 'PayEngineCardResponse':
93
+ emitter.emit('pe.card_response', dataPayload.data, dataPayload.isError);
94
+ break;
95
+
96
+ default:
97
+ break;
98
+ }
99
+ }
100
+ };
101
+
102
+ if (loading || !html) {
103
+ return /*#__PURE__*/React.createElement(ActivityIndicator, null);
104
+ }
105
+
106
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(View, {
107
+ style: [styles.container, {
108
+ height: props.showZipCode ? 270 : 215
109
+ }]
110
+ }, /*#__PURE__*/React.createElement(WebView, {
111
+ ref: webviewRef,
112
+ originWhitelist: ['*'],
113
+ source: {
114
+ html: html
115
+ },
116
+ scalesPageToFit: false,
117
+ style: {
118
+ backgroundColor: 'transparent'
119
+ },
120
+ bounces: false,
121
+ scrollEnabled: false,
122
+ renderLoading: LoadingIndicator,
123
+ startInLoadingState: true,
124
+ onMessage: onMessage
125
+ })), error.length ? /*#__PURE__*/React.createElement(Text, null, error) : /*#__PURE__*/React.createElement(React.Fragment, null));
126
+ });
127
+ export default CreditCardFormLegacy;
128
+ const styles = StyleSheet.create({
129
+ container: {
130
+ width: '100%',
131
+ padding: 20
132
+ }
133
+ });
134
+
135
+ const createVGSCollectFormHTML = (showZipCode, vault, environment, cname, vgs_satellite_port) => `
136
+ <!DOCTYPE html>
137
+ <html lang="en">
138
+ <head>
139
+ <meta charset="UTF-8">
140
+ <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
141
+ <title>Credit Card Form</title>
142
+ <script type="text/javascript" src="https://js.verygoodvault.com/vgs-collect/2.16.0/vgs-collect.js"></script>
143
+
144
+ <style>
145
+ html, body {
146
+ margin: 0;
147
+ padding: 0;
148
+ background: transparent;
149
+ }
150
+ .row {
151
+ display: flex;
152
+ gap: 10px;
153
+ }
154
+ .col {
155
+ flex: 1;
156
+ }
157
+ .form-group {
158
+ margin-bottom: 10px;
159
+ }
160
+ .form-field {
161
+ display: block;
162
+ width: 100%;
163
+ height: 50px;
164
+ }
165
+
166
+ .form-field iframe {
167
+ border: 0 none transparent;
168
+ height: 100%;
169
+ vertical-align: middle;
170
+ width: 100%;
171
+ }
172
+ </style>
173
+ </head>
174
+ <body>
175
+ <form id="cc-form">
176
+ <div class="form-group">
177
+ <span id="card_holder" class="form-field">
178
+ </span>
179
+ </div>
180
+ <div class="form-group">
181
+ <span id="card_number" class="form-field"></span>
182
+ </div>
183
+ <div class="row">
184
+ <div class="form-group">
185
+ <span id="card_exp" class="form-field"></span>
186
+ </div>
187
+ <div class="form-group">
188
+ <span id="card_cvc" class="form-field"></span>
189
+ </div>
190
+ </div>
191
+ ${showZipCode ? `<div class="form-group">
192
+ <span id="address_zip" class="form-field"></span>
193
+ </div>` : ''}
194
+ </form>
195
+
196
+ <script>
197
+ const css = {
198
+ color: '#000',
199
+ border: '#CCC 1px solid',
200
+ 'border-radius': '5px',
201
+ 'text-transform': 'uppercase',
202
+ padding: '5px 10px',
203
+ 'box-sizing': 'border-box',
204
+ 'font-size': '1em',
205
+ 'caret-color': 'transparent',
206
+ '&:focus': {
207
+ 'border-color': '#999',
208
+ },
209
+ '&.invalid.touched': {
210
+ 'border-color': 'red',
211
+ },
212
+ '&.valid': {
213
+ 'border-color': '#CCC',
214
+ },
215
+ }
216
+ const form = VGSCollect.create('${vault}', '${environment}', function(state) {});
217
+ alert('${cname}')
218
+ form.useCname('${cname}')
219
+ // form.connectSatellite(parseInt(${vgs_satellite_port}) ?? 9098)
220
+ form.field('#card_holder', {
221
+ type: 'text',
222
+ name: 'card_holder',
223
+ placeholder: 'Card holder name',
224
+ validations: ['required'],
225
+ css
226
+ });
227
+
228
+ const cardElement = form.field('#card_number', {
229
+ type: 'card-number',
230
+ name: 'card_number',
231
+ placeholder: 'Card number',
232
+ validations: ['required', 'validCardNumber'],
233
+ showCardIcon: true,
234
+ css
235
+ });
236
+
237
+ const cvcElement = form.field('#card_cvc', {
238
+ type: 'card-security-code',
239
+ name: 'card_cvc',
240
+ placeholder: 'CVC',
241
+ validations: ['required', 'validCardSecurityCode'],
242
+ showCardIcon: true,
243
+ css
244
+ });
245
+
246
+ cardElement.setCVCDependency(cvcElement);
247
+
248
+ form.field('#card_exp', {
249
+ type: 'card-expiration-date',
250
+ name: 'card_exp',
251
+ placeholder: 'Exp date',
252
+ validations: ['required', 'validCardExpirationDate'],
253
+ css
254
+ });
255
+
256
+ ${showZipCode ? `
257
+ form.field('#address_zip', {
258
+ type: 'text',
259
+ name: 'address_zip',
260
+ placeholder: 'Zip code',
261
+ maxLength: 7,
262
+ validations: ['required', 'postal_code/us,ca'],
263
+ css
264
+ });
265
+ ` : ''}
266
+
267
+ const sendNative = (data, isError) => {
268
+ window.ReactNativeWebView.postMessage(JSON.stringify({
269
+ type: 'PayEngineCardResponse',
270
+ data: data,
271
+ isError: isError
272
+ }))
273
+ }
274
+
275
+ function submit(merchantId, authHeader) {
276
+ form.submit('/api/cards', {
277
+ method: 'POST',
278
+ data: {
279
+ brand: form.state.card_number.cardType,
280
+ last_4: form.state.card_number.last4,
281
+ bin: form.state.card_number.bin,
282
+ pci_vault_provider: 'vgs',
283
+ merchant_id: merchantId,
284
+ },
285
+ headers: {
286
+ Authorization: authHeader
287
+ }
288
+ }, (status, data) => {
289
+ if (status === 200) {
290
+ sendNative(data, false)
291
+ } else {
292
+ sendNative({ data, status }, true)
293
+ }
294
+ }, error => {
295
+ sendNative(error, true)
296
+ })
297
+ return true
298
+ }
299
+ </script>
300
+ </body>
301
+ </html>`;
302
+ //# sourceMappingURL=CreditCardFormLegacy.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["React","Text","View","StyleSheet","ActivityIndicator","eventEmitter","WebView","createHttpClient","getHttpHeaders","LoadingIndicator","emitter","CardError","Error","constructor","data","CreditCardFormLegacy","forwardRef","props","ref","webviewRef","createRef","loading","setLoading","useState","error","setError","html","setHtml","webviewResponse","setWebviewResponse","useImperativeHandle","createCard","merchantId","headers","config","script","Authorization","Promise","resolve","reject","console","log","once","isError","current","injectJavaScript","useEffect","configure","http","resp","get","vault","environment","cname","vgs_satellite_port","createVGSCollectFormHTML","Boolean","showZipCode","e","message","onMessage","payload","dataPayload","JSON","parse","nativeEvent","type","emit","styles","container","height","backgroundColor","length","create","width","padding"],"sources":["CreditCardFormLegacy.tsx"],"sourcesContent":["import * as React from 'react';\nimport { Text, View, StyleSheet, ActivityIndicator } from 'react-native';\nimport eventEmitter from 'events';\nimport { WebView } from 'react-native-webview';\nimport { createHttpClient, getHttpHeaders } from '../../utils/index';\nimport type { CreditCardFormMethods, CreditCardFormProps } from '../../interfaces/index';\nimport LoadingIndicator from '../LoadingIndicator';\n\nconst emitter = new eventEmitter();\n\nclass CardError extends Error {\n public data: any = null;\n\n constructor(data: any) {\n super('Failed to create card')\n this.data = data\n }\n}\n\nconst CreditCardFormLegacy = React.forwardRef<CreditCardFormMethods, CreditCardFormProps>((props, ref) => {\n const webviewRef = React.createRef<WebView>()\n\n const [loading, setLoading] = React.useState(true)\n const [error, setError] = React.useState(\"\")\n const [html, setHtml] = React.useState(\"\")\n const [webviewResponse, setWebviewResponse] = React.useState<any>()\n\n React.useImperativeHandle(ref, () => ({\n createCard: async (merchantId?: string) => {\n setWebviewResponse(null)\n const headers = getHttpHeaders(props.config)\n const script = `\n submit(${merchantId ? '\"' + merchantId + '\"' : 'null'}, '${headers.Authorization}');\n `\n return new Promise((resolve, reject) => {\n console.log({ emitter })\n emitter.once('pe.card_response', (data, isError) => {\n if (isError) {\n reject(new CardError(data))\n } else {\n resolve(data)\n }\n })\n webviewRef.current?.injectJavaScript(script)\n })\n\n },\n }), [props.config, webviewRef, webviewResponse]);\n\n\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 } = resp.data.data\n\n setHtml(createVGSCollectFormHTML(Boolean(props.showZipCode), vault, environment, cname, vgs_satellite_port))\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 const onMessage = (payload: any) => {\n let dataPayload;\n try {\n dataPayload = JSON.parse(payload.nativeEvent.data);\n } catch (e) { }\n\n if (dataPayload) {\n console.log({ dataPayload })\n switch (dataPayload.type) {\n case 'PayEngineCardResponse':\n emitter.emit('pe.card_response', dataPayload.data, dataPayload.isError)\n break\n default:\n break\n }\n }\n };\n\n if (loading || !html) {\n return <ActivityIndicator />\n }\n\n return (\n <>\n <View style={[styles.container, { height: props.showZipCode ? 270 : 215 }]}>\n <WebView\n ref={webviewRef}\n originWhitelist={['*']}\n source={{\n html: html,\n }}\n scalesPageToFit={false}\n style={{ backgroundColor: 'transparent' }}\n bounces={false}\n scrollEnabled={false}\n renderLoading={LoadingIndicator}\n startInLoadingState={true}\n onMessage={onMessage}\n />\n </View>\n {error.length ? <Text>{error}</Text> : <></>}\n </>\n );\n});\n\nexport default CreditCardFormLegacy;\n\nconst styles = StyleSheet.create({\n container: {\n width: '100%',\n padding: 20,\n }\n});\n\nconst createVGSCollectFormHTML = (showZipCode: boolean, vault: string, environment: string, cname: string, vgs_satellite_port: string) => `\n <!DOCTYPE html>\n <html lang=\"en\">\n <head>\n <meta charset=\"UTF-8\">\n <meta name=\"viewport\" content=\"width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no\">\n <title>Credit Card Form</title>\n <script type=\"text/javascript\" src=\"https://js.verygoodvault.com/vgs-collect/2.16.0/vgs-collect.js\"></script>\n\n <style>\n html, body {\n margin: 0;\n padding: 0;\n background: transparent;\n }\n .row {\n display: flex;\n gap: 10px;\n }\n .col {\n flex: 1;\n }\n .form-group {\n margin-bottom: 10px;\n }\n .form-field {\n display: block;\n width: 100%;\n height: 50px;\n }\n\n .form-field iframe {\n border: 0 none transparent;\n height: 100%;\n vertical-align: middle;\n width: 100%;\n }\n </style>\n </head>\n <body>\n <form id=\"cc-form\">\n <div class=\"form-group\">\n <span id=\"card_holder\" class=\"form-field\">\n </span>\n </div>\n <div class=\"form-group\">\n <span id=\"card_number\" class=\"form-field\"></span>\n </div>\n <div class=\"row\">\n <div class=\"form-group\">\n <span id=\"card_exp\" class=\"form-field\"></span>\n </div>\n <div class=\"form-group\">\n <span id=\"card_cvc\" class=\"form-field\"></span>\n </div>\n </div>\n ${showZipCode ? `<div class=\"form-group\">\n <span id=\"address_zip\" class=\"form-field\"></span>\n </div>` : ''}\n </form>\n\n <script>\n const css = {\n color: '#000',\n border: '#CCC 1px solid',\n 'border-radius': '5px',\n 'text-transform': 'uppercase',\n padding: '5px 10px',\n 'box-sizing': 'border-box',\n 'font-size': '1em',\n 'caret-color': 'transparent',\n '&:focus': {\n 'border-color': '#999',\n },\n '&.invalid.touched': {\n 'border-color': 'red',\n },\n '&.valid': {\n 'border-color': '#CCC',\n },\n }\n const form = VGSCollect.create('${vault}', '${environment}', function(state) {});\n alert('${cname}')\n form.useCname('${cname}')\n // form.connectSatellite(parseInt(${vgs_satellite_port}) ?? 9098)\n form.field('#card_holder', {\n type: 'text',\n name: 'card_holder',\n placeholder: 'Card holder name',\n validations: ['required'],\n css\n });\n\n const cardElement = form.field('#card_number', {\n type: 'card-number',\n name: 'card_number',\n placeholder: 'Card number',\n validations: ['required', 'validCardNumber'],\n showCardIcon: true,\n css\n });\n\n const cvcElement = form.field('#card_cvc', {\n type: 'card-security-code',\n name: 'card_cvc',\n placeholder: 'CVC',\n validations: ['required', 'validCardSecurityCode'],\n showCardIcon: true,\n css\n });\n\n cardElement.setCVCDependency(cvcElement);\n\n form.field('#card_exp', {\n type: 'card-expiration-date',\n name: 'card_exp',\n placeholder: 'Exp date',\n validations: ['required', 'validCardExpirationDate'],\n css\n });\n\n ${showZipCode ? `\n form.field('#address_zip', {\n type: 'text',\n name: 'address_zip',\n placeholder: 'Zip code',\n maxLength: 7,\n validations: ['required', 'postal_code/us,ca'],\n css\n });\n ` : ''}\n\n const sendNative = (data, isError) => {\n window.ReactNativeWebView.postMessage(JSON.stringify({\n type: 'PayEngineCardResponse',\n data: data,\n isError: isError\n }))\n }\n\n function submit(merchantId, authHeader) {\n form.submit('/api/cards', {\n method: 'POST',\n data: {\n brand: form.state.card_number.cardType,\n last_4: form.state.card_number.last4,\n bin: form.state.card_number.bin,\n pci_vault_provider: 'vgs',\n merchant_id: merchantId,\n },\n headers: {\n Authorization: authHeader\n }\n }, (status, data) => {\n if (status === 200) {\n sendNative(data, false)\n } else {\n sendNative({ data, status }, true)\n }\n }, error => {\n sendNative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ADF,EAiBGpC,KAAK,CAACgD,MAAN,gBAAe,oBAAC,IAAD,QAAOhD,KAAP,CAAf,gBAAsC,yCAjBzC,CADF;AAqBD,CA/F4B,CAA7B;AAiGA,eAAeT,oBAAf;AAEA,MAAMqD,MAAM,GAAGjE,UAAU,CAACsE,MAAX,CAAkB;EAC/BJ,SAAS,EAAE;IACTK,KAAK,EAAE,MADE;IAETC,OAAO,EAAE;EAFA;AADoB,CAAlB,CAAf;;AAOA,MAAMpB,wBAAwB,GAAG,CAACE,WAAD,EAAuBN,KAAvB,EAAsCC,WAAtC,EAA2DC,KAA3D,EAA0EC,kBAA1E,KAA0G;AAC3I;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,QAAQG,WAAW,GAAI;AACvB;AACA,eAFmB,GAED,EAAG;AACrB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,wCAAwCN,KAAM,OAAMC,WAAY;AAChE,eAAeC,KAAM;AACrB,uBAAuBA,KAAM;AAC7B,0CAA0CC,kBAAmB;AAC7D;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,QAAQG,WAAW,GAAI;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OATmB,GAST,EAAG;AACb;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,UAtKA"}