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,74 @@
1
+ import * as React from 'react';
2
+ import { Text, NativeModules } from 'react-native';
3
+ import { createHttpClient } from '../../../utils';
4
+ import type { IPayEngineConfig } from '../../../interfaces/index';
5
+
6
+ const NativeVGSCollectManager = NativeModules.VGSCollectManager;
7
+
8
+ export interface CollectManagerProps {
9
+ config: IPayEngineConfig;
10
+ children: JSX.Element | JSX.Element[];
11
+ }
12
+
13
+ export interface VGSCollectManagerMethods {
14
+ createCard: (merchantId?: string) => void;
15
+ cardBankAccount: (merchantId?: string) => void;
16
+ }
17
+
18
+ const CollectManager = React.forwardRef<
19
+ VGSCollectManagerMethods,
20
+ CollectManagerProps
21
+ >((props, ref) => {
22
+ React.useImperativeHandle(ref, () => ({
23
+ createCard: (merchantId?: string) => {
24
+ return NativeVGSCollectManager.createCard(merchantId);
25
+ },
26
+ cardBankAccount: (merchantId?: string) => {
27
+ return NativeVGSCollectManager.createBankAccount(merchantId);
28
+ },
29
+ }));
30
+
31
+ const [loading, setLoading] = React.useState(true);
32
+ const [error, setError] = React.useState('');
33
+
34
+ React.useEffect(() => {
35
+ const configure = async () => {
36
+ setLoading(true);
37
+ try {
38
+ const http = createHttpClient(props.config);
39
+ const resp = await http.get('/api/setting/secure-fields');
40
+ const { vault, environment, cname, vgs_satellite_port } =
41
+ resp.data.data;
42
+
43
+ NativeVGSCollectManager.setConfiguration(
44
+ props.config.publicKey,
45
+ vault,
46
+ environment,
47
+ cname.replace(/[^a-zA-Z\.]/g, ''),
48
+ Number(vgs_satellite_port)
49
+ );
50
+ } catch (e: any) {
51
+ console.log({ error: e });
52
+ setError(e.message);
53
+ } finally {
54
+ setLoading(false);
55
+ }
56
+ };
57
+
58
+ configure();
59
+ }, []);
60
+
61
+ return (
62
+ <React.Fragment>
63
+ {loading ? (
64
+ <Text>Loading</Text>
65
+ ) : error.length ? (
66
+ <Text>{error}</Text>
67
+ ) : (
68
+ props.children
69
+ )}
70
+ </React.Fragment>
71
+ );
72
+ });
73
+
74
+ export default CollectManager;
@@ -0,0 +1,21 @@
1
+ import React from 'react'
2
+ import { PureComponent } from 'react';
3
+ import { requireNativeComponent, StyleProp, ViewStyle } from 'react-native';
4
+
5
+
6
+
7
+ interface ExpDateFieldProps {
8
+ placeholder?: string
9
+ style?: StyleProp<ViewStyle>
10
+ }
11
+
12
+ class ExpDateField extends PureComponent<ExpDateFieldProps> {
13
+
14
+ render() {
15
+ return <RTCExpDateField {...this.props} />
16
+ }
17
+ }
18
+
19
+ const RTCExpDateField = requireNativeComponent('VGSExpDateField');
20
+
21
+ export default ExpDateField;
@@ -0,0 +1,27 @@
1
+ import React, { PureComponent } from 'react';
2
+ import { requireNativeComponent, StyleProp, ViewStyle } from 'react-native';
3
+
4
+
5
+
6
+ interface TextFieldProps {
7
+ name?: string
8
+ placeholder?: string
9
+ maxLength?: number
10
+ pattern?: string
11
+ style?: StyleProp<ViewStyle>
12
+ }
13
+
14
+ class TextField extends PureComponent<TextFieldProps> {
15
+
16
+ constructor(props: TextFieldProps) {
17
+ super(props)
18
+ }
19
+
20
+ render() {
21
+ return <RTCTextField {...this.props} />
22
+ }
23
+ }
24
+
25
+ const RTCTextField = requireNativeComponent('VGSTextField');
26
+
27
+ export default TextField;
@@ -0,0 +1,21 @@
1
+ import React from 'react'
2
+ import { PureComponent } from 'react';
3
+ import { requireNativeComponent, StyleProp, ViewStyle } from 'react-native';
4
+
5
+
6
+
7
+ interface ZipCodeFieldProps {
8
+ placeholder?: string
9
+ style?: StyleProp<ViewStyle>
10
+ }
11
+
12
+ class ZipCodeField extends PureComponent<ZipCodeFieldProps> {
13
+
14
+ render() {
15
+ return <RTCZipCodeField {...this.props} />
16
+ }
17
+ }
18
+
19
+ const RTCZipCodeField = requireNativeComponent('VGSZipCodeField');
20
+
21
+ export default ZipCodeField;
@@ -0,0 +1,17 @@
1
+ import CardNumberField from "./VGS/CardNumberField";
2
+ import CVCField from "./VGS/CVCField";
3
+ import ExpDateTextField from "./VGS/ExpDateField";
4
+ import CollectManager from "./VGS/CollectManager";
5
+ import TextField from './VGS/TextField';
6
+ import CardHolderNameField from './VGS/CardHolderNameField';
7
+ import ZipCodeField from './VGS/ZipCodeField';
8
+
9
+ export const SecureFields = {
10
+ CollectManager,
11
+ ExpDateTextField,
12
+ CardNumberField,
13
+ CVCField,
14
+ CardHolderNameField,
15
+ ZipCodeField,
16
+ TextField
17
+ }
package/src/index.tsx ADDED
@@ -0,0 +1,37 @@
1
+ import PayEngine from './components/PayEngine'
2
+ import { NativeModules, Platform } from 'react-native';
3
+ import { SecureFields } from './components/SecureFields/index';
4
+ import { CreditCardForm } from './components/CreditCardForm/index';
5
+ import CreditCardFormLegacy from './components/Legacy/CreditCardFormLegacy';
6
+ import type { IPayEngineConfig } from './interfaces/index';
7
+ import { PayEngineGooglePay } from './components/GooglePay/PayEngineGooglePay';
8
+ import { PayEngineApplePay } from './components/ApplePay/PayEngineApplePay';
9
+
10
+ const LINKING_ERROR =
11
+ `The package 'react-native-payengine' doesn't seem to be linked. Make sure: \n\n` +
12
+ Platform.select({ ios: "- You have run 'pod install'\n", default: '' }) +
13
+ '- You rebuilt the app after installing the package\n' +
14
+ '- You are not using Expo managed workflow\n';
15
+
16
+ const PayEngineStatic = NativeModules.Payengine ? NativeModules.Payengine : new Proxy(
17
+ {},
18
+ {
19
+ get() {
20
+ throw new Error(LINKING_ERROR);
21
+ },
22
+ }
23
+ );
24
+
25
+
26
+ export {
27
+ PayEngineStatic,
28
+ PayEngine,
29
+ SecureFields,
30
+ CreditCardForm,
31
+ CreditCardFormLegacy,
32
+ IPayEngineConfig,
33
+ PayEngineGooglePay,
34
+ PayEngineApplePay
35
+ }
36
+
37
+
@@ -0,0 +1,38 @@
1
+ import type { StyleProp, ViewStyle } from 'react-native';
2
+ import type { GooglePayRequestData } from '../components/GooglePay/interfaces';
3
+
4
+ export interface IPayEngineConfig {
5
+ publicKey: string;
6
+ version?: string;
7
+ scriptURL?: string;
8
+ logLevel?: number;
9
+ }
10
+
11
+ export interface CreditCardFormProps {
12
+ style?: StyleProp<ViewStyle>;
13
+ merchantId?: string;
14
+ showZipCode?: boolean;
15
+ config: IPayEngineConfig;
16
+ }
17
+
18
+ export interface CreditCardFormMethods {
19
+ createCard: (merchantId?: string) => Promise<any>;
20
+ }
21
+
22
+ export interface MobilePaymentConfig {
23
+ base_url: string;
24
+ country: string;
25
+ currency: string;
26
+ gateway: string; // nmi | converge
27
+ google_pay: GooglePayRequestData;
28
+ apple_pay: {
29
+ merchantName: string;
30
+ supportedCardNetworks: string[];
31
+ };
32
+ }
33
+
34
+ export interface PaymentRequest {
35
+ amount: number;
36
+ currencyCode?: string;
37
+ countryCode?: string;
38
+ }
@@ -0,0 +1,107 @@
1
+ import axios from 'axios';
2
+ import type { IPayEngineConfig } from '../interfaces/index';
3
+
4
+ export const getHttpHeaders = (config: IPayEngineConfig) => {
5
+ return {
6
+ Authorization: `Signature key="${config.publicKey}",algorithm="hmac-sha256",identifier="secure-fields",signature=""`,
7
+ };
8
+ };
9
+
10
+ export const getBaseURL = (config: IPayEngineConfig) => {
11
+ let baseUrl = config.publicKey.includes('_prod_')
12
+ ? 'https://console.payengine.co'
13
+ : 'https://console.payengine.dev';
14
+
15
+ if (config.scriptURL) {
16
+ baseUrl = config.scriptURL.replace(/^((\w+:)?\/\/[^\/]+\/?).*$/, '$1');
17
+ }
18
+ return baseUrl;
19
+ };
20
+
21
+ export const createHttpClient = (config: IPayEngineConfig) => {
22
+ return axios.create({
23
+ baseURL: getBaseURL(config),
24
+ headers: getHttpHeaders(config),
25
+ });
26
+ };
27
+
28
+ export function getScriptURL(config: IPayEngineConfig) {
29
+ if (!config.publicKey) {
30
+ throw new Error('PayEngine Public Key is missing');
31
+ }
32
+ let scriptURL = '';
33
+ const logLevelStr = config.logLevel ? `&loglevel=${config.logLevel}` : '';
34
+ if (config.scriptURL) {
35
+ scriptURL = `${config.scriptURL}?key=${config.publicKey}${logLevelStr}`;
36
+ } else {
37
+ const baseURL = config.publicKey.includes('_prod_')
38
+ ? 'https://console.payengine.co'
39
+ : 'https://console.payengine.dev';
40
+ const version = config.version ?? '1.0.0';
41
+ scriptURL = `${baseURL}/js/${version}/embed.js?key=${config.publicKey}${logLevelStr}`;
42
+ }
43
+
44
+ return scriptURL;
45
+ }
46
+
47
+ /**
48
+ * <script>
49
+ console.log("AAAAAAAA")
50
+ var component = document.getElementById("component");
51
+ var onEvent = function(event) {
52
+ console.log({ event })
53
+ }
54
+ console.log('component')
55
+ component.addEventListener('stepChange', function(e) {
56
+ console.log('step change')
57
+ })
58
+ function addEventListenerAll(target, listener, ...otherArguments) {
59
+
60
+ // install listeners for all natively triggered events
61
+ for (const key in target) {
62
+ if (/^on/.test(key)) {
63
+ const eventType = key.substr(2);
64
+ target.addEventListener(eventType, listener, ...otherArguments);
65
+ }
66
+ }
67
+
68
+ // dynamically install listeners for all manually triggered events, just-in-time before they're dispatched ;D
69
+ const dispatchEvent_original = EventTarget.prototype.dispatchEvent;
70
+ function dispatchEvent(event) {
71
+ console.log('event test', event.type)
72
+ target.addEventListener(event.type, listener, ...otherArguments); // multiple identical listeners are automatically discarded
73
+ dispatchEvent_original.apply(this, arguments);
74
+ }
75
+ EventTarget.prototype.dispatchEvent = dispatchEvent;
76
+ if (EventTarget.prototype.dispatchEvent !== dispatchEvent) throw new Error('Browser is smarter than you think');
77
+
78
+ }
79
+
80
+ // addEventListenerAll(component, onEvent);
81
+ </script>
82
+ */
83
+ export const debuggingScript = `
84
+ const consoleLog = (type, ...log) => window.ReactNativeWebView.postMessage(JSON.stringify({'type': 'Console', 'data': {'type': type, 'log': log}}));
85
+ console = {
86
+ log: (...log) => consoleLog('log', ...log),
87
+ debug: (...log) => consoleLog('debug', ...log),
88
+ info: (...log) => consoleLog('info', ...log),
89
+ warn: (...log) => consoleLog('warn', ...log),
90
+ error: (...log) => consoleLog('error', ...log),
91
+ verbose: (...log) => consoleLog('verbose', ...log),
92
+ };
93
+
94
+ const dispatchEvent_original = EventTarget.prototype.dispatchEvent;
95
+ function dispatchEvent(event) {
96
+ if (event.type && !event.type.startsWith('react')) {
97
+ ReactNativeWebView.postMessage(JSON.stringify({
98
+ type: 'PayEngine',
99
+ event: {
100
+ type: event.type,
101
+ detail: event.detail
102
+ }
103
+ }))
104
+ }
105
+ }
106
+ EventTarget.prototype.dispatchEvent = dispatchEvent;
107
+ `;