react-amwal-pay 0.1.7 → 0.1.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,173 +1,173 @@
1
- {
2
- "name": "react-amwal-pay",
3
- "version": "0.1.7",
4
- "description": "amwal pay",
5
- "main": "./lib/module/index.js",
6
- "types": "./lib/typescript/src/index.d.ts",
7
- "exports": {
8
- ".": {
9
- "source": "./src/index.tsx",
10
- "types": "./lib/typescript/src/index.d.ts",
11
- "default": "./lib/module/index.js"
12
- },
13
- "./package.json": "./package.json"
14
- },
15
- "files": [
16
- "src",
17
- "android",
18
- "ios",
19
- "lib",
20
- "cpp",
21
- "*.podspec",
22
- "react-native.config.js",
23
- "!ios/build",
24
- "!android/build",
25
- "!android/gradle",
26
- "!android/gradlew",
27
- "!android/gradlew.bat",
28
- "!android/local.properties",
29
- "!**/__tests__",
30
- "!**/__fixtures__",
31
- "!**/__mocks__",
32
- "!**/.*"
33
- ],
34
- "scripts": {
35
- "example": "yarn workspace react-amwal-pay-example",
36
- "test": "jest",
37
- "typecheck": "tsc",
38
- "lint": "eslint \"**/*.{js,ts,tsx}\"",
39
- "clean": "del-cli android/build example/android/build example/android/app/build example/ios/build lib",
40
- "prepare": "bob build",
41
- "release": "release-it --only-version",
42
- "android": "expo run:android",
43
- "ios": "expo run:ios"
44
- },
45
- "keywords": [
46
- "react-native",
47
- "ios",
48
- "android"
49
- ],
50
- "repository": {
51
- "type": "git",
52
- "url": "git+https://https://github.com/amwal-pay/AnwalPaySDKReactNative.git"
53
- },
54
- "author": "amr saied <amr.elskaan@amwal-pay.com> (https://)",
55
- "license": "MIT",
56
- "bugs": {
57
- "url": "https:///issues"
58
- },
59
- "homepage": "https://#readme",
60
- "publishConfig": {
61
- "registry": "https://registry.npmjs.org/"
62
- },
63
- "devDependencies": {
64
- "@commitlint/config-conventional": "^19.6.0",
65
- "@eslint/compat": "^1.2.7",
66
- "@eslint/eslintrc": "^3.3.0",
67
- "@eslint/js": "^9.22.0",
68
- "@evilmartians/lefthook": "^1.5.0",
69
- "@react-native-community/cli": "15.0.0-alpha.2",
70
- "@react-native/babel-preset": "0.79.2",
71
- "@react-native/eslint-config": "^0.78.0",
72
- "@release-it/conventional-changelog": "^9.0.2",
73
- "@types/crypto-js": "^4.2.2",
74
- "@types/jest": "^29.5.5",
75
- "@types/react": "^19.0.0",
76
- "commitlint": "^19.6.1",
77
- "del-cli": "^5.1.0",
78
- "eslint": "^9.22.0",
79
- "eslint-config-prettier": "^10.1.1",
80
- "eslint-plugin-prettier": "^5.2.3",
81
- "jest": "^29.7.0",
82
- "prettier": "^3.0.3",
83
- "react": "19.0.0",
84
- "react-native": "0.79.2",
85
- "react-native-builder-bob": "^0.40.11",
86
- "release-it": "^17.10.0",
87
- "turbo": "^1.10.7",
88
- "typescript": "^5.8.3"
89
- },
90
- "peerDependencies": {
91
- "react": "*",
92
- "react-native": "*"
93
- },
94
- "workspaces": [
95
- "example"
96
- ],
97
- "packageManager": "yarn@3.6.1",
98
- "jest": {
99
- "preset": "react-native",
100
- "modulePathIgnorePatterns": [
101
- "<rootDir>/example/node_modules",
102
- "<rootDir>/lib/"
103
- ]
104
- },
105
- "commitlint": {
106
- "extends": [
107
- "@commitlint/config-conventional"
108
- ]
109
- },
110
- "release-it": {
111
- "git": {
112
- "commitMessage": "chore: release ${version}",
113
- "tagName": "v${version}"
114
- },
115
- "npm": {
116
- "publish": true
117
- },
118
- "github": {
119
- "release": true
120
- },
121
- "plugins": {
122
- "@release-it/conventional-changelog": {
123
- "preset": {
124
- "name": "angular"
125
- }
126
- }
127
- }
128
- },
129
- "prettier": {
130
- "quoteProps": "consistent",
131
- "singleQuote": true,
132
- "tabWidth": 2,
133
- "trailingComma": "es5",
134
- "useTabs": false
135
- },
136
- "react-native-builder-bob": {
137
- "source": "src",
138
- "output": "lib",
139
- "targets": [
140
- [
141
- "module",
142
- {
143
- "esm": true
144
- }
145
- ],
146
- [
147
- "typescript",
148
- {
149
- "project": "tsconfig.build.json"
150
- }
151
- ]
152
- ]
153
- },
154
- "codegenConfig": {
155
- "name": "ReactAmwalPaySpec",
156
- "type": "modules",
157
- "jsSrcsDir": "src",
158
- "android": {
159
- "javaPackageName": "com.reactamwalpay"
160
- }
161
- },
162
- "create-react-native-library": {
163
- "languages": "kotlin-objc",
164
- "type": "turbo-module",
165
- "version": "0.50.3"
166
- },
167
- "dependencies": {
168
- "crypto-js": "^4.2.0",
169
- "expo": "^53.0.9",
170
- "react": "19.0.0",
171
- "react-native": "0.79.2"
172
- }
173
- }
1
+ {
2
+ "name": "react-amwal-pay",
3
+ "version": "0.1.9",
4
+ "description": "amwal pay",
5
+ "main": "./lib/module/index.js",
6
+ "types": "./lib/typescript/src/index.d.ts",
7
+ "exports": {
8
+ ".": {
9
+ "source": "./src/index.tsx",
10
+ "types": "./lib/typescript/src/index.d.ts",
11
+ "default": "./lib/module/index.js"
12
+ },
13
+ "./package.json": "./package.json"
14
+ },
15
+ "files": [
16
+ "src",
17
+ "android",
18
+ "ios",
19
+ "lib",
20
+ "cpp",
21
+ "*.podspec",
22
+ "react-native.config.js",
23
+ "!ios/build",
24
+ "!android/build",
25
+ "!android/gradle",
26
+ "!android/gradlew",
27
+ "!android/gradlew.bat",
28
+ "!android/local.properties",
29
+ "!**/__tests__",
30
+ "!**/__fixtures__",
31
+ "!**/__mocks__",
32
+ "!**/.*"
33
+ ],
34
+ "scripts": {
35
+ "example": "yarn workspace react-amwal-pay-example",
36
+ "test": "jest",
37
+ "typecheck": "tsc",
38
+ "lint": "eslint \"**/*.{js,ts,tsx}\"",
39
+ "clean": "del-cli android/build example/android/build example/android/app/build example/ios/build lib",
40
+ "prepare": "bob build",
41
+ "release": "release-it --only-version",
42
+ "android": "expo run:android",
43
+ "ios": "expo run:ios"
44
+ },
45
+ "keywords": [
46
+ "react-native",
47
+ "ios",
48
+ "android"
49
+ ],
50
+ "repository": {
51
+ "type": "git",
52
+ "url": "git+https://https://github.com/amwal-pay/AnwalPaySDKReactNative.git"
53
+ },
54
+ "author": "amr saied <amr.elskaan@amwal-pay.com> (https://)",
55
+ "license": "MIT",
56
+ "bugs": {
57
+ "url": "https:///issues"
58
+ },
59
+ "homepage": "https://#readme",
60
+ "publishConfig": {
61
+ "registry": "https://registry.npmjs.org/"
62
+ },
63
+ "devDependencies": {
64
+ "@commitlint/config-conventional": "^19.6.0",
65
+ "@eslint/compat": "^1.2.7",
66
+ "@eslint/eslintrc": "^3.3.0",
67
+ "@eslint/js": "^9.22.0",
68
+ "@evilmartians/lefthook": "^1.5.0",
69
+ "@react-native-community/cli": "15.0.0-alpha.2",
70
+ "@react-native/babel-preset": "0.79.2",
71
+ "@react-native/eslint-config": "^0.78.0",
72
+ "@release-it/conventional-changelog": "^9.0.2",
73
+ "@types/crypto-js": "^4.2.2",
74
+ "@types/jest": "^29.5.5",
75
+ "@types/react": "^19.0.0",
76
+ "commitlint": "^19.6.1",
77
+ "del-cli": "^5.1.0",
78
+ "eslint": "^9.22.0",
79
+ "eslint-config-prettier": "^10.1.1",
80
+ "eslint-plugin-prettier": "^5.2.3",
81
+ "jest": "^29.7.0",
82
+ "prettier": "^3.0.3",
83
+ "react": "19.0.0",
84
+ "react-native": "0.79.2",
85
+ "react-native-builder-bob": "^0.40.11",
86
+ "release-it": "^17.10.0",
87
+ "turbo": "^1.10.7",
88
+ "typescript": "^5.8.3"
89
+ },
90
+ "peerDependencies": {
91
+ "react": "*",
92
+ "react-native": "*"
93
+ },
94
+ "workspaces": [
95
+ "example"
96
+ ],
97
+ "packageManager": "yarn@3.6.1",
98
+ "jest": {
99
+ "preset": "react-native",
100
+ "modulePathIgnorePatterns": [
101
+ "<rootDir>/example/node_modules",
102
+ "<rootDir>/lib/"
103
+ ]
104
+ },
105
+ "commitlint": {
106
+ "extends": [
107
+ "@commitlint/config-conventional"
108
+ ]
109
+ },
110
+ "release-it": {
111
+ "git": {
112
+ "commitMessage": "chore: release ${version}",
113
+ "tagName": "v${version}"
114
+ },
115
+ "npm": {
116
+ "publish": true
117
+ },
118
+ "github": {
119
+ "release": true
120
+ },
121
+ "plugins": {
122
+ "@release-it/conventional-changelog": {
123
+ "preset": {
124
+ "name": "angular"
125
+ }
126
+ }
127
+ }
128
+ },
129
+ "prettier": {
130
+ "quoteProps": "consistent",
131
+ "singleQuote": true,
132
+ "tabWidth": 2,
133
+ "trailingComma": "es5",
134
+ "useTabs": false
135
+ },
136
+ "react-native-builder-bob": {
137
+ "source": "src",
138
+ "output": "lib",
139
+ "targets": [
140
+ [
141
+ "module",
142
+ {
143
+ "esm": true
144
+ }
145
+ ],
146
+ [
147
+ "typescript",
148
+ {
149
+ "project": "tsconfig.build.json"
150
+ }
151
+ ]
152
+ ]
153
+ },
154
+ "codegenConfig": {
155
+ "name": "ReactAmwalPaySpec",
156
+ "type": "modules",
157
+ "jsSrcsDir": "src",
158
+ "android": {
159
+ "javaPackageName": "com.reactamwalpay"
160
+ }
161
+ },
162
+ "create-react-native-library": {
163
+ "languages": "kotlin-objc",
164
+ "type": "turbo-module",
165
+ "version": "0.50.3"
166
+ },
167
+ "dependencies": {
168
+ "crypto-js": "^4.2.0",
169
+ "expo": "^53.0.9",
170
+ "react": "19.0.0",
171
+ "react-native": "0.79.2"
172
+ }
173
+ }
@@ -1,98 +1,98 @@
1
- import { initiate, onCustomerId, onResponse, type AmwalPayConfig } from './index';
2
- import NetworkClient from './network/NetworkClient';
3
- import { type EventSubscription } from 'react-native';
4
-
5
-
6
- class AmwalPaySDK {
7
- private static instance: AmwalPaySDK;
8
-
9
- private onResponseSubscription: EventSubscription|null = null;
10
-
11
- private onCustomerIdSubscription: EventSubscription|null = null;
12
-
13
- private constructor() {
14
- // Initialize the event emitter
15
-
16
- }
17
-
18
- static getInstance(): AmwalPaySDK {
19
- if (!AmwalPaySDK.instance) {
20
- AmwalPaySDK.instance = new AmwalPaySDK();
21
- }
22
- return AmwalPaySDK.instance;
23
- }
24
-
25
- /**
26
- * Initiates the payment process by first fetching a session token and then starting the payment flow
27
- * @param config The payment configuration
28
- */
29
- async startPayment(config: Omit<AmwalPayConfig, 'sessionToken'>): Promise<void> {
30
- try {
31
- // Set up event listeners before starting the payment process
32
- this.setupEventListeners(config);
33
-
34
- // Get network client instance
35
- const networkClient = NetworkClient.getInstance();
36
-
37
- // Fetch session token
38
- const sessionToken = await networkClient.fetchSessionToken(
39
- config.environment,
40
- config.merchantId,
41
- config.customerId,
42
- config.secureHash
43
- );
44
-
45
- if (!sessionToken) {
46
- // If session token is null, the error has already been shown by NetworkClient
47
- return;
48
- }
49
-
50
- // Create complete config with session token
51
- const completeConfig: AmwalPayConfig = {
52
- ...config,
53
- sessionToken
54
- };
55
-
56
- // Initiate the payment process
57
- initiate(completeConfig);
58
- } catch (error) {
59
- console.error('Error starting payment:', error);
60
- }
61
- }
62
-
63
- dispose(): void {
64
- // Remove all event listeners
65
- this.removeEventListeners();
66
- }
67
-
68
- /**
69
- * Sets up event listeners for AmwalPay events
70
- * @param config The payment configuration containing callback functions
71
- */
72
- private setupEventListeners(config: Omit<AmwalPayConfig, 'sessionToken'>): void {
73
- // Remove any existing listeners
74
- this.removeEventListeners();
75
-
76
- this.onResponseSubscription = onResponse((response) => {
77
- console.log('Received AmwalPayResponse:', response);
78
- config.onResponse(response);
79
- });
80
-
81
- this.onCustomerIdSubscription = onCustomerId((customerId) => {
82
- console.log('Received customerId:', customerId);
83
- config.onCustomerId(customerId);
84
- });
85
- }
86
-
87
- /**
88
- * Removes all event listeners
89
- */
90
- private removeEventListeners(): void {
91
- this.onResponseSubscription?.remove();
92
- this.onCustomerIdSubscription?.remove();
93
- this.onResponseSubscription = null;
94
- this.onCustomerIdSubscription = null;
95
- }
96
- }
97
-
1
+ import { initiate, onCustomerId, onResponse, type AmwalPayConfig } from './index';
2
+ import NetworkClient from './network/NetworkClient';
3
+ import { type EventSubscription } from 'react-native';
4
+
5
+
6
+ class AmwalPaySDK {
7
+ private static instance: AmwalPaySDK;
8
+
9
+ private onResponseSubscription: EventSubscription|null = null;
10
+
11
+ private onCustomerIdSubscription: EventSubscription|null = null;
12
+
13
+ private constructor() {
14
+ // Initialize the event emitter
15
+
16
+ }
17
+
18
+ static getInstance(): AmwalPaySDK {
19
+ if (!AmwalPaySDK.instance) {
20
+ AmwalPaySDK.instance = new AmwalPaySDK();
21
+ }
22
+ return AmwalPaySDK.instance;
23
+ }
24
+
25
+ /**
26
+ * Initiates the payment process by first fetching a session token and then starting the payment flow
27
+ * @param config The payment configuration
28
+ */
29
+ async startPayment(config: Omit<AmwalPayConfig, 'sessionToken'>): Promise<void> {
30
+ try {
31
+ // Set up event listeners before starting the payment process
32
+ this.setupEventListeners(config);
33
+
34
+ // Get network client instance
35
+ const networkClient = NetworkClient.getInstance();
36
+
37
+ // Fetch session token
38
+ const sessionToken = await networkClient.fetchSessionToken(
39
+ config.environment,
40
+ config.merchantId,
41
+ config.customerId,
42
+ config.secureHash
43
+ );
44
+
45
+ if (!sessionToken) {
46
+ // If session token is null, the error has already been shown by NetworkClient
47
+ return;
48
+ }
49
+
50
+ // Create complete config with session token
51
+ const completeConfig: AmwalPayConfig = {
52
+ ...config,
53
+ sessionToken
54
+ };
55
+
56
+ // Initiate the payment process
57
+ initiate(completeConfig);
58
+ } catch (error) {
59
+ console.error('Error starting payment:', error);
60
+ }
61
+ }
62
+
63
+ dispose(): void {
64
+ // Remove all event listeners
65
+ this.removeEventListeners();
66
+ }
67
+
68
+ /**
69
+ * Sets up event listeners for AmwalPay events
70
+ * @param config The payment configuration containing callback functions
71
+ */
72
+ private setupEventListeners(config: Omit<AmwalPayConfig, 'sessionToken'>): void {
73
+ // Remove any existing listeners
74
+ this.removeEventListeners();
75
+
76
+ this.onResponseSubscription = onResponse((response) => {
77
+ console.log('Received AmwalPayResponse:', response);
78
+ config.onResponse(response);
79
+ });
80
+
81
+ this.onCustomerIdSubscription = onCustomerId((customerId) => {
82
+ console.log('Received customerId:', customerId);
83
+ config.onCustomerId(customerId);
84
+ });
85
+ }
86
+
87
+ /**
88
+ * Removes all event listeners
89
+ */
90
+ private removeEventListeners(): void {
91
+ this.onResponseSubscription?.remove();
92
+ this.onCustomerIdSubscription?.remove();
93
+ this.onResponseSubscription = null;
94
+ this.onCustomerIdSubscription = null;
95
+ }
96
+ }
97
+
98
98
  export default AmwalPaySDK;
@@ -36,6 +36,7 @@ export interface AmwalPayConfig {
36
36
  customerId: string | null;
37
37
  transactionType: TransactionType;
38
38
  sessionToken?: string;
39
+ transactionId?: string;
39
40
  onResponse: (response: AmwalPayResponse) => void;
40
41
  onCustomerId: (customerId: string) => void;
41
42
  }
@@ -52,6 +53,7 @@ export interface AmwalPayNativeConfig {
52
53
  customerId: string | null;
53
54
  transactionType: string;
54
55
  sessionToken?: string;
56
+ transactionId?: string;
55
57
  }
56
58
 
57
59
  export interface Spec extends TurboModule {
package/src/index.tsx CHANGED
@@ -7,6 +7,7 @@ import ReactAmwalPay, {
7
7
  type AmwalPayNativeConfig,
8
8
  } from './NativeReactAmwalPay';
9
9
  import AmwalPaySDK from './AmwalPaySDK';
10
+ import { UuidUtil } from './utils/UuidUtil';
10
11
  import type { EventSubscription } from 'react-native';
11
12
 
12
13
  // Create an event emitter for the native module
@@ -23,6 +24,7 @@ export function initiate(config: AmwalPayConfig): void {
23
24
  customerId: config.customerId,
24
25
  transactionType: config.transactionType,
25
26
  sessionToken: config.sessionToken,
27
+ transactionId: config.transactionId ?? UuidUtil.generateTransactionId(),
26
28
  };
27
29
 
28
30
  // Call the native module
@@ -43,4 +45,5 @@ export {
43
45
  type AmwalPayResponse,
44
46
  type AmwalPayConfig,
45
47
  AmwalPaySDK,
48
+ UuidUtil,
46
49
  };