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,323 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+
8
+ var React = _interopRequireWildcard(require("react"));
9
+
10
+ var _reactNative = require("react-native");
11
+
12
+ var _events = _interopRequireDefault(require("events"));
13
+
14
+ var _reactNativeWebview = require("react-native-webview");
15
+
16
+ var _index = require("../../utils/index");
17
+
18
+ var _LoadingIndicator = _interopRequireDefault(require("../LoadingIndicator"));
19
+
20
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
21
+
22
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
23
+
24
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
25
+
26
+ 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; }
27
+
28
+ const emitter = new _events.default();
29
+
30
+ class CardError extends Error {
31
+ constructor(data) {
32
+ super('Failed to create card');
33
+
34
+ _defineProperty(this, "data", null);
35
+
36
+ this.data = data;
37
+ }
38
+
39
+ }
40
+
41
+ const CreditCardFormLegacy = /*#__PURE__*/React.forwardRef((props, ref) => {
42
+ const webviewRef = /*#__PURE__*/React.createRef();
43
+ const [loading, setLoading] = React.useState(true);
44
+ const [error, setError] = React.useState("");
45
+ const [html, setHtml] = React.useState("");
46
+ const [webviewResponse, setWebviewResponse] = React.useState();
47
+ React.useImperativeHandle(ref, () => ({
48
+ createCard: async merchantId => {
49
+ setWebviewResponse(null);
50
+ const headers = (0, _index.getHttpHeaders)(props.config);
51
+ const script = `
52
+ submit(${merchantId ? '"' + merchantId + '"' : 'null'}, '${headers.Authorization}');
53
+ `;
54
+ return new Promise((resolve, reject) => {
55
+ var _webviewRef$current;
56
+
57
+ console.log({
58
+ emitter
59
+ });
60
+ emitter.once('pe.card_response', (data, isError) => {
61
+ if (isError) {
62
+ reject(new CardError(data));
63
+ } else {
64
+ resolve(data);
65
+ }
66
+ });
67
+ (_webviewRef$current = webviewRef.current) === null || _webviewRef$current === void 0 ? void 0 : _webviewRef$current.injectJavaScript(script);
68
+ });
69
+ }
70
+ }), [props.config, webviewRef, webviewResponse]);
71
+ React.useEffect(() => {
72
+ const configure = async () => {
73
+ setLoading(true);
74
+
75
+ try {
76
+ const http = (0, _index.createHttpClient)(props.config);
77
+ const resp = await http.get('/api/setting/secure-fields');
78
+ const {
79
+ vault,
80
+ environment,
81
+ cname,
82
+ vgs_satellite_port
83
+ } = resp.data.data;
84
+ setHtml(createVGSCollectFormHTML(Boolean(props.showZipCode), vault, environment, cname, vgs_satellite_port));
85
+ } catch (e) {
86
+ console.log({
87
+ error: e
88
+ });
89
+ setError(e.message);
90
+ } finally {
91
+ setLoading(false);
92
+ }
93
+ };
94
+
95
+ configure();
96
+ }, []);
97
+
98
+ const onMessage = payload => {
99
+ let dataPayload;
100
+
101
+ try {
102
+ dataPayload = JSON.parse(payload.nativeEvent.data);
103
+ } catch (e) {}
104
+
105
+ if (dataPayload) {
106
+ console.log({
107
+ dataPayload
108
+ });
109
+
110
+ switch (dataPayload.type) {
111
+ case 'PayEngineCardResponse':
112
+ emitter.emit('pe.card_response', dataPayload.data, dataPayload.isError);
113
+ break;
114
+
115
+ default:
116
+ break;
117
+ }
118
+ }
119
+ };
120
+
121
+ if (loading || !html) {
122
+ return /*#__PURE__*/React.createElement(_reactNative.ActivityIndicator, null);
123
+ }
124
+
125
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(_reactNative.View, {
126
+ style: [styles.container, {
127
+ height: props.showZipCode ? 270 : 215
128
+ }]
129
+ }, /*#__PURE__*/React.createElement(_reactNativeWebview.WebView, {
130
+ ref: webviewRef,
131
+ originWhitelist: ['*'],
132
+ source: {
133
+ html: html
134
+ },
135
+ scalesPageToFit: false,
136
+ style: {
137
+ backgroundColor: 'transparent'
138
+ },
139
+ bounces: false,
140
+ scrollEnabled: false,
141
+ renderLoading: _LoadingIndicator.default,
142
+ startInLoadingState: true,
143
+ onMessage: onMessage
144
+ })), error.length ? /*#__PURE__*/React.createElement(_reactNative.Text, null, error) : /*#__PURE__*/React.createElement(React.Fragment, null));
145
+ });
146
+ var _default = CreditCardFormLegacy;
147
+ exports.default = _default;
148
+
149
+ const styles = _reactNative.StyleSheet.create({
150
+ container: {
151
+ width: '100%',
152
+ padding: 20
153
+ }
154
+ });
155
+
156
+ const createVGSCollectFormHTML = (showZipCode, vault, environment, cname, vgs_satellite_port) => `
157
+ <!DOCTYPE html>
158
+ <html lang="en">
159
+ <head>
160
+ <meta charset="UTF-8">
161
+ <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
162
+ <title>Credit Card Form</title>
163
+ <script type="text/javascript" src="https://js.verygoodvault.com/vgs-collect/2.16.0/vgs-collect.js"></script>
164
+
165
+ <style>
166
+ html, body {
167
+ margin: 0;
168
+ padding: 0;
169
+ background: transparent;
170
+ }
171
+ .row {
172
+ display: flex;
173
+ gap: 10px;
174
+ }
175
+ .col {
176
+ flex: 1;
177
+ }
178
+ .form-group {
179
+ margin-bottom: 10px;
180
+ }
181
+ .form-field {
182
+ display: block;
183
+ width: 100%;
184
+ height: 50px;
185
+ }
186
+
187
+ .form-field iframe {
188
+ border: 0 none transparent;
189
+ height: 100%;
190
+ vertical-align: middle;
191
+ width: 100%;
192
+ }
193
+ </style>
194
+ </head>
195
+ <body>
196
+ <form id="cc-form">
197
+ <div class="form-group">
198
+ <span id="card_holder" class="form-field">
199
+ </span>
200
+ </div>
201
+ <div class="form-group">
202
+ <span id="card_number" class="form-field"></span>
203
+ </div>
204
+ <div class="row">
205
+ <div class="form-group">
206
+ <span id="card_exp" class="form-field"></span>
207
+ </div>
208
+ <div class="form-group">
209
+ <span id="card_cvc" class="form-field"></span>
210
+ </div>
211
+ </div>
212
+ ${showZipCode ? `<div class="form-group">
213
+ <span id="address_zip" class="form-field"></span>
214
+ </div>` : ''}
215
+ </form>
216
+
217
+ <script>
218
+ const css = {
219
+ color: '#000',
220
+ border: '#CCC 1px solid',
221
+ 'border-radius': '5px',
222
+ 'text-transform': 'uppercase',
223
+ padding: '5px 10px',
224
+ 'box-sizing': 'border-box',
225
+ 'font-size': '1em',
226
+ 'caret-color': 'transparent',
227
+ '&:focus': {
228
+ 'border-color': '#999',
229
+ },
230
+ '&.invalid.touched': {
231
+ 'border-color': 'red',
232
+ },
233
+ '&.valid': {
234
+ 'border-color': '#CCC',
235
+ },
236
+ }
237
+ const form = VGSCollect.create('${vault}', '${environment}', function(state) {});
238
+ alert('${cname}')
239
+ form.useCname('${cname}')
240
+ // form.connectSatellite(parseInt(${vgs_satellite_port}) ?? 9098)
241
+ form.field('#card_holder', {
242
+ type: 'text',
243
+ name: 'card_holder',
244
+ placeholder: 'Card holder name',
245
+ validations: ['required'],
246
+ css
247
+ });
248
+
249
+ const cardElement = form.field('#card_number', {
250
+ type: 'card-number',
251
+ name: 'card_number',
252
+ placeholder: 'Card number',
253
+ validations: ['required', 'validCardNumber'],
254
+ showCardIcon: true,
255
+ css
256
+ });
257
+
258
+ const cvcElement = form.field('#card_cvc', {
259
+ type: 'card-security-code',
260
+ name: 'card_cvc',
261
+ placeholder: 'CVC',
262
+ validations: ['required', 'validCardSecurityCode'],
263
+ showCardIcon: true,
264
+ css
265
+ });
266
+
267
+ cardElement.setCVCDependency(cvcElement);
268
+
269
+ form.field('#card_exp', {
270
+ type: 'card-expiration-date',
271
+ name: 'card_exp',
272
+ placeholder: 'Exp date',
273
+ validations: ['required', 'validCardExpirationDate'],
274
+ css
275
+ });
276
+
277
+ ${showZipCode ? `
278
+ form.field('#address_zip', {
279
+ type: 'text',
280
+ name: 'address_zip',
281
+ placeholder: 'Zip code',
282
+ maxLength: 7,
283
+ validations: ['required', 'postal_code/us,ca'],
284
+ css
285
+ });
286
+ ` : ''}
287
+
288
+ const sendNative = (data, isError) => {
289
+ window.ReactNativeWebView.postMessage(JSON.stringify({
290
+ type: 'PayEngineCardResponse',
291
+ data: data,
292
+ isError: isError
293
+ }))
294
+ }
295
+
296
+ function submit(merchantId, authHeader) {
297
+ form.submit('/api/cards', {
298
+ method: 'POST',
299
+ data: {
300
+ brand: form.state.card_number.cardType,
301
+ last_4: form.state.card_number.last4,
302
+ bin: form.state.card_number.bin,
303
+ pci_vault_provider: 'vgs',
304
+ merchant_id: merchantId,
305
+ },
306
+ headers: {
307
+ Authorization: authHeader
308
+ }
309
+ }, (status, data) => {
310
+ if (status === 200) {
311
+ sendNative(data, false)
312
+ } else {
313
+ sendNative({ data, status }, true)
314
+ }
315
+ }, error => {
316
+ sendNative(error, true)
317
+ })
318
+ return true
319
+ }
320
+ </script>
321
+ </body>
322
+ </html>`;
323
+ //# sourceMappingURL=CreditCardFormLegacy.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["emitter","eventEmitter","CardError","Error","constructor","data","CreditCardFormLegacy","React","forwardRef","props","ref","webviewRef","createRef","loading","setLoading","useState","error","setError","html","setHtml","webviewResponse","setWebviewResponse","useImperativeHandle","createCard","merchantId","headers","getHttpHeaders","config","script","Authorization","Promise","resolve","reject","console","log","once","isError","current","injectJavaScript","useEffect","configure","http","createHttpClient","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","LoadingIndicator","length","StyleSheet","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(error, true)\n })\n return true\n }\n </script>\n </body>\n </html>`;\n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,OAAO,EAAE;EAFA;AADoB,CAAlB,CAAf;;AAOA,MAAMtB,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"}
@@ -1 +1 @@
1
- {"version":3,"names":["getHtmlTag","props","allowedProps","Object","keys","filter","x","includes","map","propName","join","generateHTML","scriptURL","PayEngine","React","useState","getScriptURL","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","Platform","OS","debuggingScript","LoadingIndicator","StyleSheet","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, IPayEngineConfig, debuggingScript } from '../utils';\nimport LoadingIndicator from './LoadingIndicator';\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;;AACA;;AACA;;AACA;;AACA;;;;AAcA,MAAMA,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,EAA2EC,IAA3E,CAAgF,GAAhF,CAAqF;AAC3F,iBAHE;AAID,CAND;;AAQA,MAAMC,YAAY,GAAG,CAACC,SAAD,EAAoBX,KAApB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;UACEhB,SAAS,CAACM,WAAW,CAACP,MAAb,CAAT;UACA;;QACF;UACE,IAAIK,OAAJ,EAAa;YACXS,OAAO,CAACM,GAAR,CAAYb,WAAZ;UACD;;UACD;MAnBJ;IAqBD;EACF,CA9BD;;EAgCA,oBAAO,6BAAC,iBAAD;IAAM,KAAK,EAAE,CAAC;MAAEc,IAAI,EAAE,CAAR;MAAWrB,MAAM,EAAEA;IAAnB,CAAD,EAA8BjB,KAAK,CAACuC,KAApC;EAAb,gBACL,6BAAC,iBAAD;IAAM,KAAK,EAAEC,MAAM,CAACC;EAApB,gBACE,6BAAC,iBAAD,wBAAmB9B,SAAnB,CADF,CADK,eAIL,6BAAC,iBAAD;IAAM,KAAK,EAAE6B,MAAM,CAACC;EAApB,gBACE,6BAAC,iBAAD,QAAO1C,UAAU,CAACC,KAAD,CAAjB,CADF,CAJK,eAOL,6BAAC,2BAAD;IACE,eAAe,EAAE,CAAC,GAAD,CADnB;IAEE,MAAM,EAAE;MAAEmB,IAAI,EAAEA,IAAR;MAAcuB,OAAO,EAAE;IAAvB,CAFV,CAGE;IAHF;IAIE,2BAA2B,EAAG,gBAAeC,qBAAA,CAASC,EAAG,EAJ3D;IAKE,kBAAkB,EAAEC,sBALtB;IAME,aAAa,EAAEC,yBANjB;IAOE,mBAAmB,EAAE,IAPvB;IAQE,SAAS,EAAE1B;EARb,EAPK,CAAP;AAkBD,CAzDD;;AA2DA,MAAMoB,MAAM,GAAGO,uBAAA,CAAWC,MAAX,CAAkB;EAC/BP,SAAS,EAAE;IACTQ,cAAc,EAAE,CADP;IAETC,gBAAgB,EAAE,EAFT;IAGTC,OAAO,EAAE,EAHA;IAITC,eAAe,EAAE,QAJR;IAKTC,WAAW,EAAE,CALJ;IAMTC,WAAW,EAAE;EANJ;AADoB,CAAlB,CAAf;;eAYe1C,S"}
1
+ {"version":3,"names":["getHtmlTag","props","allowedProps","Object","keys","filter","x","includes","map","propName","join","generateHTML","scriptURL","PayEngine","React","useState","getScriptURL","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","Platform","OS","debuggingScript","LoadingIndicator","StyleSheet","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;;AACA;;AACA;;AACA;;AACA;;;;AAeA,MAAMA,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,EAA2EC,IAA3E,CAAgF,GAAhF,CAAqF;AAC3F,iBAHE;AAID,CAND;;AAQA,MAAMC,YAAY,GAAG,CAACC,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28
28
  const [loading, setLoading] = React.useState(true);
29
- const [error, setError] = React.useState("");
29
+ const [error, setError] = React.useState('');
30
30
  React.useEffect(() => {
31
31
  const configure = async () => {
32
32
  setLoading(true);
@@ -40,17 +40,12 @@ const CollectManager = /*#__PURE__*/React.forwardRef((props, ref) => {
40
40
  cname,
41
41
  vgs_satellite_port
42
42
  } = resp.data.data;
43
- console.log({
44
- resp
45
- });
46
- console.log('Starting collect');
47
- NativeVGSCollectManager.setConfiguration(vault, environment, cname.replace(/[^a-zA-Z\.]/g, ''), Number(vgs_satellite_port));
48
- console.log('Set configuration successfully');
43
+ NativeVGSCollectManager.setConfiguration(props.config.publicKey, vault, environment, cname.replace(/[^a-zA-Z\.]/g, ''), Number(vgs_satellite_port));
49
44
  } catch (e) {
50
45
  console.log({
51
46
  error: e
52
47
  });
53
- setError("Unexpected error: " + e.message);
48
+ setError(e.message);
54
49
  } finally {
55
50
  setLoading(false);
56
51
  }
@@ -1 +1 @@
1
- {"version":3,"names":["NativeVGSCollectManager","NativeModules","VGSCollectManager","CollectManager","React","forwardRef","props","ref","useImperativeHandle","createCard","merchantId","cardBankAccount","createBankAccount","loading","setLoading","useState","error","setError","useEffect","configure","http","createHttpClient","config","resp","get","vault","environment","cname","vgs_satellite_port","data","console","log","setConfiguration","replace","Number","e","message","length","children"],"sources":["CollectManager.tsx"],"sourcesContent":["import * as React from 'react';\nimport { Text, NativeModules } from 'react-native';\nimport { createHttpClient, IPayEngineConfig } from '../../../utils';\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<VGSCollectManagerMethods, CollectManagerProps>((props, ref) => {\n\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\n const { vault, environment, cname, vgs_satellite_port } = resp.data.data\n console.log({ resp })\n console.log('Starting collect')\n\n NativeVGSCollectManager.setConfiguration(vault, environment, cname.replace(/[^a-zA-Z\\.]/g, ''), Number(vgs_satellite_port))\n console.log('Set configuration successfully')\n } catch (e: any) {\n console.log({ error: e })\n setError(\"Unexpected error: \" + e.message)\n } finally {\n setLoading(false)\n }\n }\n\n configure()\n }, [])\n\n return (\n <React.Fragment>\n {loading ? <Text>Loading</Text> : (error.length ? <Text>{error}</Text> : props.children)}\n </React.Fragment>\n );\n});\n\nexport default CollectManager;\n\n"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;;;;;AAEA,MAAMA,uBAAuB,GAAGC,0BAAA,CAAcC,iBAA9C;AAYA,MAAMC,cAAc,gBAAGC,KAAK,CAACC,UAAN,CAAgE,CAACC,KAAD,EAAQC,GAAR,KAAgB;EAErGH,KAAK,CAACI,mBAAN,CAA0BD,GAA1B,EAA+B,OAAO;IACpCE,UAAU,EAAGC,UAAD,IAAyB;MACnC,OAAOV,uBAAuB,CAACS,UAAxB,CAAmCC,UAAnC,CAAP;IACD,CAHmC;IAIpCC,eAAe,EAAGD,UAAD,IAAyB;MACxC,OAAOV,uBAAuB,CAACY,iBAAxB,CAA0CF,UAA1C,CAAP;IACD;EANmC,CAAP,CAA/B;EASA,MAAM,CAACG,OAAD,EAAUC,UAAV,IAAwBV,KAAK,CAACW,QAAN,CAAe,IAAf,CAA9B;EACA,MAAM,CAACC,KAAD,EAAQC,QAAR,IAAoBb,KAAK,CAACW,QAAN,CAAe,EAAf,CAA1B;EAEAX,KAAK,CAACc,SAAN,CAAgB,MAAM;IACpB,MAAMC,SAAS,GAAG,YAAY;MAC5BL,UAAU,CAAC,IAAD,CAAV;;MACA,IAAI;QACF,MAAMM,IAAI,GAAG,IAAAC,uBAAA,EAAiBf,KAAK,CAACgB,MAAvB,CAAb;QACA,MAAMC,IAAI,GAAG,MAAMH,IAAI,CAACI,GAAL,CAAS,4BAAT,CAAnB;QAEA,MAAM;UAAEC,KAAF;UAASC,WAAT;UAAsBC,KAAtB;UAA6BC;QAA7B,IAAoDL,IAAI,CAACM,IAAL,CAAUA,IAApE;QACAC,OAAO,CAACC,GAAR,CAAY;UAAER;QAAF,CAAZ;QACAO,OAAO,CAACC,GAAR,CAAY,kBAAZ;QAEA/B,uBAAuB,CAACgC,gBAAxB,CAAyCP,KAAzC,EAAgDC,WAAhD,EAA6DC,KAAK,CAACM,OAAN,CAAc,cAAd,EAA8B,EAA9B,CAA7D,EAAgGC,MAAM,CAACN,kBAAD,CAAtG;QACAE,OAAO,CAACC,GAAR,CAAY,gCAAZ;MACD,CAVD,CAUE,OAAOI,CAAP,EAAe;QACfL,OAAO,CAACC,GAAR,CAAY;UAAEf,KAAK,EAAEmB;QAAT,CAAZ;QACAlB,QAAQ,CAAC,uBAAuBkB,CAAC,CAACC,OAA1B,CAAR;MACD,CAbD,SAaU;QACRtB,UAAU,CAAC,KAAD,CAAV;MACD;IACF,CAlBD;;IAoBAK,SAAS;EACV,CAtBD,EAsBG,EAtBH;EAwBA,oBACE,oBAAC,KAAD,CAAO,QAAP,QACGN,OAAO,gBAAG,oBAAC,iBAAD,kBAAH,GAA2BG,KAAK,CAACqB,MAAN,gBAAe,oBAAC,iBAAD,QAAOrB,KAAP,CAAf,GAAsCV,KAAK,CAACgC,QADjF,CADF;AAKD,CA3CsB,CAAvB;eA6CenC,c"}
1
+ {"version":3,"names":["NativeVGSCollectManager","NativeModules","VGSCollectManager","CollectManager","React","forwardRef","props","ref","useImperativeHandle","createCard","merchantId","cardBankAccount","createBankAccount","loading","setLoading","useState","error","setError","useEffect","configure","http","createHttpClient","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;;AACA;;AACA;;;;;;AAGA,MAAMA,uBAAuB,GAAGC,0BAAA,CAAcC,iBAA9C;AAYA,MAAMC,cAAc,gBAAGC,KAAK,CAACC,UAAN,CAG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CArBD;;IAuBAK,SAAS;EACV,CAzBD,EAyBG,EAzBH;EA2BA,oBACE,oBAAC,KAAD,CAAO,QAAP,QACGN,OAAO,gBACN,oBAAC,iBAAD,kBADM,GAEJG,KAAK,CAACsB,MAAN,gBACF,oBAAC,iBAAD,QAAOtB,KAAP,CADE,GAGFV,KAAK,CAACiC,QANV,CADF;AAWD,CAtDsB,CAAvB;eAwDepC,c"}
@@ -3,12 +3,36 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
+ Object.defineProperty(exports, "CreditCardForm", {
7
+ enumerable: true,
8
+ get: function () {
9
+ return _index2.CreditCardForm;
10
+ }
11
+ });
12
+ Object.defineProperty(exports, "CreditCardFormLegacy", {
13
+ enumerable: true,
14
+ get: function () {
15
+ return _CreditCardFormLegacy.default;
16
+ }
17
+ });
6
18
  Object.defineProperty(exports, "PayEngine", {
7
19
  enumerable: true,
8
20
  get: function () {
9
21
  return _PayEngine.default;
10
22
  }
11
23
  });
24
+ Object.defineProperty(exports, "PayEngineApplePay", {
25
+ enumerable: true,
26
+ get: function () {
27
+ return _PayEngineApplePay.PayEngineApplePay;
28
+ }
29
+ });
30
+ Object.defineProperty(exports, "PayEngineGooglePay", {
31
+ enumerable: true,
32
+ get: function () {
33
+ return _PayEngineGooglePay.PayEngineGooglePay;
34
+ }
35
+ });
12
36
  exports.PayEngineStatic = void 0;
13
37
  Object.defineProperty(exports, "SecureFields", {
14
38
  enumerable: true,
@@ -23,6 +47,14 @@ var _reactNative = require("react-native");
23
47
 
24
48
  var _index = require("./components/SecureFields/index");
25
49
 
50
+ var _index2 = require("./components/CreditCardForm/index");
51
+
52
+ var _CreditCardFormLegacy = _interopRequireDefault(require("./components/Legacy/CreditCardFormLegacy"));
53
+
54
+ var _PayEngineGooglePay = require("./components/GooglePay/PayEngineGooglePay");
55
+
56
+ var _PayEngineApplePay = require("./components/ApplePay/PayEngineApplePay");
57
+
26
58
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
27
59
 
28
60
  const LINKING_ERROR = `The package 'react-native-payengine' doesn't seem to be linked. Make sure: \n\n` + _reactNative.Platform.select({
@@ -34,9 +66,6 @@ const PayEngineStatic = _reactNative.NativeModules.Payengine ? _reactNative.Nati
34
66
  throw new Error(LINKING_ERROR);
35
67
  }
36
68
 
37
- }); // function multiply(a: number, b: number): Promise<number> {
38
- // return PayEngineStatic.multiply(a, b);
39
- // }
40
-
69
+ });
41
70
  exports.PayEngineStatic = PayEngineStatic;
42
71
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["LINKING_ERROR","Platform","select","ios","default","PayEngineStatic","NativeModules","Payengine","Proxy","get","Error"],"sources":["index.tsx"],"sourcesContent":["import PayEngine from './components/PayEngine'\nimport { NativeModules, Platform } from 'react-native';\nimport { SecureFields } from './components/SecureFields/index';\nimport type { IPayEngineConfig } from './utils';\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// function multiply(a: number, b: number): Promise<number> {\n// return PayEngineStatic.multiply(a, b);\n// }\n\nexport {\n PayEngineStatic,\n PayEngine,\n SecureFields,\n IPayEngineConfig\n}\n\n\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;;;AAGA,MAAMA,aAAa,GAChB,iFAAD,GACAC,qBAAA,CAASC,MAAT,CAAgB;EAAEC,GAAG,EAAE,gCAAP;EAAyCC,OAAO,EAAE;AAAlD,CAAhB,CADA,GAEA,sDAFA,GAGA,6CAJF;AAMA,MAAMC,eAAe,GAAGC,0BAAA,CAAcC,SAAd,GAA0BD,0BAAA,CAAcC,SAAxC,GAAoD,IAAIC,KAAJ,CAC1E,EAD0E,EAE1E;EACEC,GAAG,GAAG;IACJ,MAAM,IAAIC,KAAJ,CAAUV,aAAV,CAAN;EACD;;AAHH,CAF0E,CAA5E,C,CASA;AACA;AACA"}
1
+ {"version":3,"names":["LINKING_ERROR","Platform","select","ios","default","PayEngineStatic","NativeModules","Payengine","Proxy","get","Error"],"sources":["index.tsx"],"sourcesContent":["import PayEngine from './components/PayEngine'\nimport { NativeModules, Platform } from 'react-native';\nimport { 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;;AACA;;AACA;;AACA;;AACA;;AAEA;;AACA;;;;AAEA,MAAMA,aAAa,GAChB,iFAAD,GACAC,qBAAA,CAASC,MAAT,CAAgB;EAAEC,GAAG,EAAE,gCAAP;EAAyCC,OAAO,EAAE;AAAlD,CAAhB,CADA,GAEA,sDAFA,GAGA,6CAJF;AAMA,MAAMC,eAAe,GAAGC,0BAAA,CAAcC,SAAd,GAA0BD,0BAAA,CAAcC,SAAxC,GAAoD,IAAIC,KAAJ,CAC1E,EAD0E,EAE1E;EACEC,GAAG,GAAG;IACJ,MAAM,IAAIC,KAAJ,CAAUV,aAAV,CAAN;EACD;;AAHH,CAF0E,CAA5E"}
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ //# sourceMappingURL=index.js.map
@@ -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":""}
@@ -3,25 +3,37 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.debuggingScript = exports.createHttpClient = void 0;
6
+ exports.getHttpHeaders = exports.getBaseURL = exports.debuggingScript = exports.createHttpClient = void 0;
7
7
  exports.getScriptURL = getScriptURL;
8
8
 
9
9
  var _axios = _interopRequireDefault(require("axios"));
10
10
 
11
11
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
12
12
 
13
- const createHttpClient = config => {
14
- let baseUrl = config.publicKey.includes('_prod_') ? "https://console.payengine.co" : "https://console.payengine.dev";
13
+ const getHttpHeaders = config => {
14
+ return {
15
+ Authorization: `Signature key="${config.publicKey}",algorithm="hmac-sha256",identifier="secure-fields",signature=""`
16
+ };
17
+ };
18
+
19
+ exports.getHttpHeaders = getHttpHeaders;
20
+
21
+ const getBaseURL = config => {
22
+ let baseUrl = config.publicKey.includes('_prod_') ? 'https://console.payengine.co' : 'https://console.payengine.dev';
15
23
 
16
24
  if (config.scriptURL) {
17
25
  baseUrl = config.scriptURL.replace(/^((\w+:)?\/\/[^\/]+\/?).*$/, '$1');
18
26
  }
19
27
 
28
+ return baseUrl;
29
+ };
30
+
31
+ exports.getBaseURL = getBaseURL;
32
+
33
+ const createHttpClient = config => {
20
34
  return _axios.default.create({
21
- baseURL: baseUrl,
22
- headers: {
23
- Authorization: `Signature key="${config.publicKey}",algorithm="hmac-sha256",identifier="secure-fields",signature=""`
24
- }
35
+ baseURL: getBaseURL(config),
36
+ headers: getHttpHeaders(config)
25
37
  });
26
38
  };
27
39
 
@@ -38,7 +50,7 @@ function getScriptURL(config) {
38
50
  if (config.scriptURL) {
39
51
  scriptURL = `${config.scriptURL}?key=${config.publicKey}${logLevelStr}`;
40
52
  } else {
41
- const baseURL = config.publicKey.includes('_prod_') ? "https://console.payengine.co" : "https://console.payengine.dev";
53
+ const baseURL = config.publicKey.includes('_prod_') ? 'https://console.payengine.co' : 'https://console.payengine.dev';
42
54
  const version = config.version ?? '1.0.0';
43
55
  scriptURL = `${baseURL}/js/${version}/embed.js?key=${config.publicKey}${logLevelStr}`;
44
56
  }
@@ -1 +1 @@
1
- {"version":3,"names":["createHttpClient","config","baseUrl","publicKey","includes","scriptURL","replace","axios","create","baseURL","headers","Authorization","getScriptURL","Error","logLevelStr","logLevel","version","debuggingScript"],"sources":["index.ts"],"sourcesContent":["import axios from \"axios\"\n\nexport interface IPayEngineConfig {\n publicKey: string\n version?: string\n scriptURL?: string\n logLevel?: number\n}\n\nexport const createHttpClient = (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 axios.create({\n baseURL: baseUrl,\n headers: {\n Authorization: `Signature key=\"${config.publicKey}\",algorithm=\"hmac-sha256\",identifier=\"secure-fields\",signature=\"\"`\n }\n })\n}\n\nexport function getScriptURL(config: IPayEngineConfig) {\n\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;;;;AASO,MAAMA,gBAAgB,GAAIC,MAAD,IAA8B;EAC5D,IAAIC,OAAO,GAAGD,MAAM,CAACE,SAAP,CAAiBC,QAAjB,CAA0B,QAA1B,IACR,8BADQ,GAEV,+BAFJ;;EAIA,IAAIH,MAAM,CAACI,SAAX,EAAsB;IACpBH,OAAO,GAAGD,MAAM,CAACI,SAAP,CAAiBC,OAAjB,CAAyB,4BAAzB,EAAsD,IAAtD,CAAV;EACD;;EACD,OAAOC,cAAA,CAAMC,MAAN,CAAa;IAClBC,OAAO,EAAEP,OADS;IAElBQ,OAAO,EAAE;MACPC,aAAa,EAAG,kBAAiBV,MAAM,CAACE,SAAU;IAD3C;EAFS,CAAb,CAAP;AAMD,CAdM;;;;AAgBA,SAASS,YAAT,CAAsBX,MAAtB,EAAgD;EAErD,IAAI,CAACA,MAAM,CAACE,SAAZ,EAAuB;IACrB,MAAM,IAAIU,KAAJ,CAAU,iCAAV,CAAN;EACD;;EACD,IAAIR,SAAS,GAAG,EAAhB;EACA,MAAMS,WAAW,GAAGb,MAAM,CAACc,QAAP,GAAmB,aAAYd,MAAM,CAACc,QAAS,EAA/C,GAAmD,EAAvE;;EACA,IAAId,MAAM,CAACI,SAAX,EAAsB;IACpBA,SAAS,GAAI,GAAEJ,MAAM,CAACI,SAAU,QAAOJ,MAAM,CAACE,SAAU,GAAEW,WAAY,EAAtE;EACD,CAFD,MAEO;IACL,MAAML,OAAO,GAAGR,MAAM,CAACE,SAAP,CAAiBC,QAAjB,CAA0B,QAA1B,IACZ,8BADY,GAEZ,+BAFJ;IAGA,MAAMY,OAAO,GAAGf,MAAM,CAACe,OAAP,IAAkB,OAAlC;IACAX,SAAS,GAAI,GAAEI,OAAQ,OAAMO,OAAQ,iBAAgBf,MAAM,CAACE,SAAU,GAAEW,WAAY,EAApF;EACD;;EAED,OAAOT,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;;;AACO,MAAMY,eAAe,GAAI;AAChC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAxBO"}
1
+ {"version":3,"names":["getHttpHeaders","config","Authorization","publicKey","getBaseURL","baseUrl","includes","scriptURL","replace","createHttpClient","axios","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;;;;AAGO,MAAMA,cAAc,GAAIC,MAAD,IAA8B;EAC1D,OAAO;IACLC,aAAa,EAAG,kBAAiBD,MAAM,CAACE,SAAU;EAD7C,CAAP;AAGD,CAJM;;;;AAMA,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;;;;AAWA,MAAMI,gBAAgB,GAAIR,MAAD,IAA8B;EAC5D,OAAOS,cAAA,CAAMC,MAAN,CAAa;IAClBC,OAAO,EAAER,UAAU,CAACH,MAAD,CADD;IAElBY,OAAO,EAAEb,cAAc,CAACC,MAAD;EAFL,CAAb,CAAP;AAID,CALM;;;;AAOA,SAASa,YAAT,CAAsBb,MAAtB,EAAgD;EACrD,IAAI,CAACA,MAAM,CAACE,SAAZ,EAAuB;IACrB,MAAM,IAAIY,KAAJ,CAAU,iCAAV,CAAN;EACD;;EACD,IAAIR,SAAS,GAAG,EAAhB;EACA,MAAMS,WAAW,GAAGf,MAAM,CAACgB,QAAP,GAAmB,aAAYhB,MAAM,CAACgB,QAAS,EAA/C,GAAmD,EAAvE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