react-amwal-pay 0.1.3 → 0.1.4
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/README.md +101 -101
- package/ReactAmwalPay.podspec +21 -21
- package/android/build.gradle +93 -93
- package/ios/ReactAmwalPay.m +14 -0
- package/ios/ReactAmwalPay.swift +111 -0
- package/lib/module/AmwalPaySDK.js +8 -8
- package/lib/module/AmwalPaySDK.js.map +1 -1
- package/lib/module/NativeReactAmwalPay.js.map +1 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/network/NetworkClient.js.map +1 -1
- package/lib/module/utils/SecureHashUtil.js.map +1 -1
- package/package.json +173 -168
- package/src/AmwalPaySDK.ts +97 -97
- package/src/network/NetworkClient.ts +83 -83
- package/src/utils/SecureHashUtil.ts +44 -44
- package/ios/ReactAmwalPay.h +0 -14
- package/ios/ReactAmwalPay.mm +0 -141
- package/lib/AmwalPay.d.ts +0 -47
- package/lib/AmwalPay.js +0 -63
- package/lib/AmwalPay.js.map +0 -1
- package/lib/index.d.ts +0 -4
- package/lib/index.js +0 -4
- package/lib/index.js.map +0 -1
- package/lib/screens/PaymentScreen.d.ts +0 -2
- package/lib/screens/PaymentScreen.js +0 -133
- package/lib/screens/PaymentScreen.js.map +0 -1
- package/lib/services/NetworkClient.d.ts +0 -10
- package/lib/services/NetworkClient.js +0 -65
- package/lib/services/NetworkClient.js.map +0 -1
- package/lib/utils/SecureHashUtil.d.ts +0 -9
- package/lib/utils/SecureHashUtil.js +0 -37
- package/lib/utils/SecureHashUtil.js.map +0 -1
package/README.md
CHANGED
|
@@ -1,101 +1,101 @@
|
|
|
1
|
-
# react-amwal-pay
|
|
2
|
-
|
|
3
|
-
A React Native library for integrating Amwal Pay payment gateway into your React Native applications.
|
|
4
|
-
|
|
5
|
-
## Installation
|
|
6
|
-
|
|
7
|
-
```sh
|
|
8
|
-
npm install react-amwal-pay
|
|
9
|
-
```
|
|
10
|
-
|
|
11
|
-
## Usage
|
|
12
|
-
|
|
13
|
-
```js
|
|
14
|
-
import {
|
|
15
|
-
AmwalPaySDK,
|
|
16
|
-
Environment,
|
|
17
|
-
Currency,
|
|
18
|
-
TransactionType,
|
|
19
|
-
type AmwalPayConfig,
|
|
20
|
-
type AmwalPayResponse
|
|
21
|
-
} from 'react-amwal-pay';
|
|
22
|
-
|
|
23
|
-
// Configure Amwal Pay
|
|
24
|
-
const config: AmwalPayConfig = {
|
|
25
|
-
environment: Environment.SIT, // or Environment.PRODUCTION
|
|
26
|
-
currency: Currency.OMR, // or other supported currencies
|
|
27
|
-
transactionType: TransactionType.CARD_WALLET,
|
|
28
|
-
locale: 'en', // or 'ar'
|
|
29
|
-
merchantId: '84131',
|
|
30
|
-
terminalId: '811018',
|
|
31
|
-
amount: '1',
|
|
32
|
-
secureHash: '8570CEED656C8818E4A7CE04F22206358F272DAD5F0227D322B654675ABF8F83',
|
|
33
|
-
customerId: 'customer-id', // optional
|
|
34
|
-
sessionToken: 'your-session-token', // optional
|
|
35
|
-
onCustomerId(customerId) {
|
|
36
|
-
console.log('Customer ID:', customerId);
|
|
37
|
-
},
|
|
38
|
-
onResponse(response) {
|
|
39
|
-
console.log('Payment Response:', response);
|
|
40
|
-
}
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
// Initialize and start payment
|
|
44
|
-
const handlePayment = async () => {
|
|
45
|
-
try {
|
|
46
|
-
// Validate required fields
|
|
47
|
-
if (!isConfigValid(config)) {
|
|
48
|
-
console.error('Please fill in all required fields');
|
|
49
|
-
return;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
const amwalPay = AmwalPaySDK.getInstance();
|
|
53
|
-
await amwalPay.startPayment(config);
|
|
54
|
-
} catch (error) {
|
|
55
|
-
console.error('Error starting payment:', error);
|
|
56
|
-
}
|
|
57
|
-
};
|
|
58
|
-
|
|
59
|
-
// Helper function to validate config
|
|
60
|
-
const isConfigValid = (config: Partial<AmwalPayConfig>): boolean => {
|
|
61
|
-
return Boolean(
|
|
62
|
-
config.environment &&
|
|
63
|
-
config.secureHash &&
|
|
64
|
-
config.currency &&
|
|
65
|
-
config.amount &&
|
|
66
|
-
config.merchantId &&
|
|
67
|
-
config.terminalId &&
|
|
68
|
-
config.locale &&
|
|
69
|
-
config.transactionType
|
|
70
|
-
);
|
|
71
|
-
};
|
|
72
|
-
```
|
|
73
|
-
|
|
74
|
-
## Configuration
|
|
75
|
-
|
|
76
|
-
The `AmwalPayConfig` interface includes the following properties:
|
|
77
|
-
|
|
78
|
-
- `environment`: The environment to use (SIT or PRODUCTION)
|
|
79
|
-
- `currency`: The currency for the transaction (e.g., OMR)
|
|
80
|
-
- `transactionType`: The type of transaction (e.g., CARD_WALLET)
|
|
81
|
-
- `locale`: The language locale ('en' or 'ar')
|
|
82
|
-
- `merchantId`: Your merchant ID
|
|
83
|
-
- `terminalId`: Your terminal ID
|
|
84
|
-
- `amount`: The transaction amount
|
|
85
|
-
- `secureHash`: Your secure hash for authentication
|
|
86
|
-
- `customerId`: (Optional) The customer's ID
|
|
87
|
-
- `sessionToken`: (Optional) Your session token
|
|
88
|
-
- `onCustomerId`: (Optional) Callback function for customer ID updates
|
|
89
|
-
- `onResponse`: (Optional) Callback function for payment response
|
|
90
|
-
|
|
91
|
-
## Contributing
|
|
92
|
-
|
|
93
|
-
See the [contributing guide](CONTRIBUTING.md) to learn how to contribute to the repository and the development workflow.
|
|
94
|
-
|
|
95
|
-
## License
|
|
96
|
-
|
|
97
|
-
MIT
|
|
98
|
-
|
|
99
|
-
---
|
|
100
|
-
|
|
101
|
-
Made with [create-react-native-library](https://github.com/callstack/react-native-builder-bob)
|
|
1
|
+
# react-amwal-pay
|
|
2
|
+
|
|
3
|
+
A React Native library for integrating Amwal Pay payment gateway into your React Native applications.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```sh
|
|
8
|
+
npm install react-amwal-pay
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
```js
|
|
14
|
+
import {
|
|
15
|
+
AmwalPaySDK,
|
|
16
|
+
Environment,
|
|
17
|
+
Currency,
|
|
18
|
+
TransactionType,
|
|
19
|
+
type AmwalPayConfig,
|
|
20
|
+
type AmwalPayResponse
|
|
21
|
+
} from 'react-amwal-pay';
|
|
22
|
+
|
|
23
|
+
// Configure Amwal Pay
|
|
24
|
+
const config: AmwalPayConfig = {
|
|
25
|
+
environment: Environment.SIT, // or Environment.PRODUCTION
|
|
26
|
+
currency: Currency.OMR, // or other supported currencies
|
|
27
|
+
transactionType: TransactionType.CARD_WALLET,
|
|
28
|
+
locale: 'en', // or 'ar'
|
|
29
|
+
merchantId: '84131',
|
|
30
|
+
terminalId: '811018',
|
|
31
|
+
amount: '1',
|
|
32
|
+
secureHash: '8570CEED656C8818E4A7CE04F22206358F272DAD5F0227D322B654675ABF8F83',
|
|
33
|
+
customerId: 'customer-id', // optional
|
|
34
|
+
sessionToken: 'your-session-token', // optional
|
|
35
|
+
onCustomerId(customerId) {
|
|
36
|
+
console.log('Customer ID:', customerId);
|
|
37
|
+
},
|
|
38
|
+
onResponse(response) {
|
|
39
|
+
console.log('Payment Response:', response);
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
// Initialize and start payment
|
|
44
|
+
const handlePayment = async () => {
|
|
45
|
+
try {
|
|
46
|
+
// Validate required fields
|
|
47
|
+
if (!isConfigValid(config)) {
|
|
48
|
+
console.error('Please fill in all required fields');
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
const amwalPay = AmwalPaySDK.getInstance();
|
|
53
|
+
await amwalPay.startPayment(config);
|
|
54
|
+
} catch (error) {
|
|
55
|
+
console.error('Error starting payment:', error);
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
// Helper function to validate config
|
|
60
|
+
const isConfigValid = (config: Partial<AmwalPayConfig>): boolean => {
|
|
61
|
+
return Boolean(
|
|
62
|
+
config.environment &&
|
|
63
|
+
config.secureHash &&
|
|
64
|
+
config.currency &&
|
|
65
|
+
config.amount &&
|
|
66
|
+
config.merchantId &&
|
|
67
|
+
config.terminalId &&
|
|
68
|
+
config.locale &&
|
|
69
|
+
config.transactionType
|
|
70
|
+
);
|
|
71
|
+
};
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
## Configuration
|
|
75
|
+
|
|
76
|
+
The `AmwalPayConfig` interface includes the following properties:
|
|
77
|
+
|
|
78
|
+
- `environment`: The environment to use (SIT or PRODUCTION)
|
|
79
|
+
- `currency`: The currency for the transaction (e.g., OMR)
|
|
80
|
+
- `transactionType`: The type of transaction (e.g., CARD_WALLET)
|
|
81
|
+
- `locale`: The language locale ('en' or 'ar')
|
|
82
|
+
- `merchantId`: Your merchant ID
|
|
83
|
+
- `terminalId`: Your terminal ID
|
|
84
|
+
- `amount`: The transaction amount
|
|
85
|
+
- `secureHash`: Your secure hash for authentication
|
|
86
|
+
- `customerId`: (Optional) The customer's ID
|
|
87
|
+
- `sessionToken`: (Optional) Your session token
|
|
88
|
+
- `onCustomerId`: (Optional) Callback function for customer ID updates
|
|
89
|
+
- `onResponse`: (Optional) Callback function for payment response
|
|
90
|
+
|
|
91
|
+
## Contributing
|
|
92
|
+
|
|
93
|
+
See the [contributing guide](CONTRIBUTING.md) to learn how to contribute to the repository and the development workflow.
|
|
94
|
+
|
|
95
|
+
## License
|
|
96
|
+
|
|
97
|
+
MIT
|
|
98
|
+
|
|
99
|
+
---
|
|
100
|
+
|
|
101
|
+
Made with [create-react-native-library](https://github.com/callstack/react-native-builder-bob)
|
package/ReactAmwalPay.podspec
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
require "json"
|
|
2
|
-
|
|
3
|
-
package = JSON.parse(File.read(File.join(__dir__, "package.json")))
|
|
4
|
-
|
|
5
|
-
Pod::Spec.new do |s|
|
|
6
|
-
s.name = "ReactAmwalPay"
|
|
7
|
-
s.version = package["version"]
|
|
8
|
-
s.summary = package["description"]
|
|
9
|
-
s.homepage = package["homepage"]
|
|
10
|
-
s.license = package["license"]
|
|
11
|
-
s.authors = package["author"]
|
|
12
|
-
|
|
13
|
-
s.platforms = { :ios => min_ios_version_supported }
|
|
14
|
-
s.source = { :git => "https://github.com/amwal-pay/AnwalPaySDKReactNative.git", :tag => "#{s.version}" }
|
|
15
|
-
|
|
16
|
-
s.source_files = "ios/**/*.{h,m,mm,
|
|
17
|
-
s.private_header_files = "ios/**/*.h"
|
|
18
|
-
|
|
19
|
-
s.dependency "amwalsdk"
|
|
20
|
-
|
|
21
|
-
end
|
|
1
|
+
require "json"
|
|
2
|
+
|
|
3
|
+
package = JSON.parse(File.read(File.join(__dir__, "package.json")))
|
|
4
|
+
|
|
5
|
+
Pod::Spec.new do |s|
|
|
6
|
+
s.name = "ReactAmwalPay"
|
|
7
|
+
s.version = package["version"]
|
|
8
|
+
s.summary = package["description"]
|
|
9
|
+
s.homepage = package["homepage"]
|
|
10
|
+
s.license = package["license"]
|
|
11
|
+
s.authors = package["author"]
|
|
12
|
+
|
|
13
|
+
s.platforms = { :ios => min_ios_version_supported }
|
|
14
|
+
s.source = { :git => "https://github.com/amwal-pay/AnwalPaySDKReactNative.git", :tag => "#{s.version}" }
|
|
15
|
+
|
|
16
|
+
s.source_files = "ios/**/*.{h,m,mm,swift}"
|
|
17
|
+
s.private_header_files = "ios/**/*.h"
|
|
18
|
+
|
|
19
|
+
s.dependency "amwalsdk"
|
|
20
|
+
install_modules_dependencies(s)
|
|
21
|
+
end
|
package/android/build.gradle
CHANGED
|
@@ -1,93 +1,93 @@
|
|
|
1
|
-
buildscript {
|
|
2
|
-
ext.getExtOrDefault = {name ->
|
|
3
|
-
return rootProject.ext.has(name) ? rootProject.ext.get(name) : project.properties['ReactAmwalPay_' + name]
|
|
4
|
-
}
|
|
5
|
-
|
|
6
|
-
repositories {
|
|
7
|
-
google()
|
|
8
|
-
mavenCentral()
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
dependencies {
|
|
12
|
-
classpath "com.android.tools.build:gradle:8.7.3"
|
|
13
|
-
// noinspection DifferentKotlinGradleVersion
|
|
14
|
-
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:${getExtOrDefault('kotlinVersion')}"
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
apply plugin: "com.android.library"
|
|
20
|
-
apply plugin: "kotlin-android"
|
|
21
|
-
|
|
22
|
-
apply plugin: "com.facebook.react"
|
|
23
|
-
|
|
24
|
-
def getExtOrIntegerDefault(name) {
|
|
25
|
-
return rootProject.ext.has(name) ? rootProject.ext.get(name) : (project.properties["ReactAmwalPay_" + name]).toInteger()
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
android {
|
|
29
|
-
namespace "com.reactamwalpay"
|
|
30
|
-
|
|
31
|
-
compileSdkVersion getExtOrIntegerDefault("compileSdkVersion")
|
|
32
|
-
|
|
33
|
-
defaultConfig {
|
|
34
|
-
minSdkVersion getExtOrIntegerDefault("minSdkVersion")
|
|
35
|
-
targetSdkVersion getExtOrIntegerDefault("targetSdkVersion")
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
buildFeatures {
|
|
39
|
-
buildConfig true
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
buildTypes {
|
|
43
|
-
release {
|
|
44
|
-
minifyEnabled false
|
|
45
|
-
shrinkResources false
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
lintOptions {
|
|
50
|
-
disable "GradleCompatible"
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
compileOptions {
|
|
54
|
-
sourceCompatibility JavaVersion.VERSION_1_8
|
|
55
|
-
targetCompatibility JavaVersion.VERSION_1_8
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
sourceSets {
|
|
59
|
-
main {
|
|
60
|
-
java.srcDirs += [
|
|
61
|
-
"generated/java",
|
|
62
|
-
"generated/jni"
|
|
63
|
-
]
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
repositories {
|
|
69
|
-
mavenCentral()
|
|
70
|
-
google()
|
|
71
|
-
}
|
|
72
|
-
rootProject.allprojects { Project subproject ->
|
|
73
|
-
subproject.repositories {
|
|
74
|
-
maven { url = uri("https://storage.googleapis.com/download.flutter.io") }
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
def kotlin_version = getExtOrDefault("kotlinVersion")
|
|
78
|
-
|
|
79
|
-
dependencies {
|
|
80
|
-
implementation "com.facebook.react:react-android"
|
|
81
|
-
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
|
|
82
|
-
implementation("com.amwal-pay:amwal_sdk:+"){
|
|
83
|
-
exclude group: 'com.android.support', module: 'support-v4'
|
|
84
|
-
exclude group: 'com.android.support', module: 'design'
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
react {
|
|
90
|
-
jsRootDir = file("../src/")
|
|
91
|
-
libraryName = "ReactAmwalPay"
|
|
92
|
-
codegenJavaPackageName = "com.reactamwalpay"
|
|
93
|
-
}
|
|
1
|
+
buildscript {
|
|
2
|
+
ext.getExtOrDefault = {name ->
|
|
3
|
+
return rootProject.ext.has(name) ? rootProject.ext.get(name) : project.properties['ReactAmwalPay_' + name]
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
repositories {
|
|
7
|
+
google()
|
|
8
|
+
mavenCentral()
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
dependencies {
|
|
12
|
+
classpath "com.android.tools.build:gradle:8.7.3"
|
|
13
|
+
// noinspection DifferentKotlinGradleVersion
|
|
14
|
+
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:${getExtOrDefault('kotlinVersion')}"
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
apply plugin: "com.android.library"
|
|
20
|
+
apply plugin: "kotlin-android"
|
|
21
|
+
|
|
22
|
+
apply plugin: "com.facebook.react"
|
|
23
|
+
|
|
24
|
+
def getExtOrIntegerDefault(name) {
|
|
25
|
+
return rootProject.ext.has(name) ? rootProject.ext.get(name) : (project.properties["ReactAmwalPay_" + name]).toInteger()
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
android {
|
|
29
|
+
namespace "com.reactamwalpay"
|
|
30
|
+
|
|
31
|
+
compileSdkVersion getExtOrIntegerDefault("compileSdkVersion")
|
|
32
|
+
|
|
33
|
+
defaultConfig {
|
|
34
|
+
minSdkVersion getExtOrIntegerDefault("minSdkVersion")
|
|
35
|
+
targetSdkVersion getExtOrIntegerDefault("targetSdkVersion")
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
buildFeatures {
|
|
39
|
+
buildConfig true
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
buildTypes {
|
|
43
|
+
release {
|
|
44
|
+
minifyEnabled false
|
|
45
|
+
shrinkResources false
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
lintOptions {
|
|
50
|
+
disable "GradleCompatible"
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
compileOptions {
|
|
54
|
+
sourceCompatibility JavaVersion.VERSION_1_8
|
|
55
|
+
targetCompatibility JavaVersion.VERSION_1_8
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
sourceSets {
|
|
59
|
+
main {
|
|
60
|
+
java.srcDirs += [
|
|
61
|
+
"generated/java",
|
|
62
|
+
"generated/jni"
|
|
63
|
+
]
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
repositories {
|
|
69
|
+
mavenCentral()
|
|
70
|
+
google()
|
|
71
|
+
}
|
|
72
|
+
rootProject.allprojects { Project subproject ->
|
|
73
|
+
subproject.repositories {
|
|
74
|
+
maven { url = uri("https://storage.googleapis.com/download.flutter.io") }
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
def kotlin_version = getExtOrDefault("kotlinVersion")
|
|
78
|
+
|
|
79
|
+
dependencies {
|
|
80
|
+
implementation "com.facebook.react:react-android"
|
|
81
|
+
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
|
|
82
|
+
implementation("com.amwal-pay:amwal_sdk:+"){
|
|
83
|
+
exclude group: 'com.android.support', module: 'support-v4'
|
|
84
|
+
exclude group: 'com.android.support', module: 'design'
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
react {
|
|
90
|
+
jsRootDir = file("../src/")
|
|
91
|
+
libraryName = "ReactAmwalPay"
|
|
92
|
+
codegenJavaPackageName = "com.reactamwalpay"
|
|
93
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
#import <React/RCTBridgeModule.h>
|
|
2
|
+
#import <React/RCTEventEmitter.h>
|
|
3
|
+
|
|
4
|
+
@interface RCT_EXTERN_MODULE(ReactAmwalPay, RCTEventEmitter)
|
|
5
|
+
|
|
6
|
+
RCT_EXTERN_METHOD(initiate:(NSDictionary *)config
|
|
7
|
+
resolver:(RCTPromiseResolveBlock)resolve
|
|
8
|
+
rejecter:(RCTPromiseRejectBlock)reject)
|
|
9
|
+
|
|
10
|
+
RCT_EXTERN_METHOD(onResponse:(RCTResponseSenderBlock)callback)
|
|
11
|
+
|
|
12
|
+
RCT_EXTERN_METHOD(onCustomerId:(RCTResponseSenderBlock)callback)
|
|
13
|
+
|
|
14
|
+
@end
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import Foundation
|
|
2
|
+
import amwalsdk
|
|
3
|
+
import React
|
|
4
|
+
|
|
5
|
+
@objc(ReactAmwalPay)
|
|
6
|
+
class ReactAmwalPay: RCTEventEmitter {
|
|
7
|
+
private var hasListeners = false
|
|
8
|
+
|
|
9
|
+
private func mapEnvironment(environment: String) -> Config.Environment {
|
|
10
|
+
switch environment {
|
|
11
|
+
case "PROD": return .PROD
|
|
12
|
+
case "UAT": return .UAT
|
|
13
|
+
case "SIT": return .SIT
|
|
14
|
+
default: return .PROD
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
private func mapCurrency(currency: String) -> Config.Currency {
|
|
19
|
+
switch currency {
|
|
20
|
+
case "OMR": return .OMR
|
|
21
|
+
default: return .OMR
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
private func mapTransactionType(transactionType: String) -> Config.TransactionType {
|
|
26
|
+
switch transactionType {
|
|
27
|
+
case "CARD_WALLET": return .cardWallet
|
|
28
|
+
case "NFC": return .nfc
|
|
29
|
+
case "APPLE_PAY": return .applePay
|
|
30
|
+
default: return .cardWallet
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
private func mapLocale(locale: String) -> Config.Locale {
|
|
35
|
+
switch locale {
|
|
36
|
+
case "en": return .en
|
|
37
|
+
case "ar": return .ar
|
|
38
|
+
default: return .en
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
private var onResponseCallback: RCTResponseSenderBlock?
|
|
43
|
+
private var onCustomerIdCallback: RCTResponseSenderBlock?
|
|
44
|
+
private func prepareConfig(config: [String: Any]) -> Config {
|
|
45
|
+
return Config(
|
|
46
|
+
environment: mapEnvironment(environment: config["environment"] as? String ?? "PROD"),
|
|
47
|
+
sessionToken: config["sessionToken"] as? String ?? "",
|
|
48
|
+
currency: mapCurrency(currency: config["currency"] as? String ?? "OMR"),
|
|
49
|
+
amount: config["amount"] as? String ?? "",
|
|
50
|
+
merchantId: config["merchantId"] as? String ?? "",
|
|
51
|
+
terminalId: config["terminalId"] as? String ?? "",
|
|
52
|
+
customerId: config["customerId"] as? String,
|
|
53
|
+
locale: mapLocale(locale: config["locale"] as? String ?? "en"),
|
|
54
|
+
transactionType: mapTransactionType(transactionType: config["transactionType"] as? String ?? "CARD_WALLET")
|
|
55
|
+
)
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
@objc
|
|
59
|
+
func initiate(_ config: [String: Any],
|
|
60
|
+
resolver resolve: @escaping RCTPromiseResolveBlock,
|
|
61
|
+
rejecter reject: @escaping RCTPromiseRejectBlock) {
|
|
62
|
+
DispatchQueue.main.async {
|
|
63
|
+
do {
|
|
64
|
+
let sdkConfig = self.prepareConfig(config: config)
|
|
65
|
+
let sdk = AmwalSDK()
|
|
66
|
+
|
|
67
|
+
guard let rootVC = UIApplication.shared.keyWindow?.rootViewController else {
|
|
68
|
+
reject("NO_ROOT_VC", "No root view controller found", nil)
|
|
69
|
+
return
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
let sdkVC = try sdk.createViewController(
|
|
73
|
+
config: sdkConfig,
|
|
74
|
+
onResponse: { [weak self] response in
|
|
75
|
+
self?.onResponseCallback?([[
|
|
76
|
+
"status": response != nil ? "success" : "error",
|
|
77
|
+
"message": response != nil ? "Transaction completed" : "Transaction failed",
|
|
78
|
+
"data": response ?? ""
|
|
79
|
+
]])
|
|
80
|
+
},
|
|
81
|
+
onCustomerId: { [weak self] customerId in
|
|
82
|
+
self?.onCustomerIdCallback?([customerId])
|
|
83
|
+
}
|
|
84
|
+
)
|
|
85
|
+
|
|
86
|
+
// Present modally (critical missing piece)
|
|
87
|
+
rootVC.present(sdkVC, animated: true)
|
|
88
|
+
|
|
89
|
+
resolve(true)
|
|
90
|
+
} catch {
|
|
91
|
+
print("Presentation failed: \(error.localizedDescription)")
|
|
92
|
+
reject("PRESENTATION_ERROR", error.localizedDescription, error)
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
@objc
|
|
98
|
+
func onResponse(_ callback: @escaping RCTResponseSenderBlock) {
|
|
99
|
+
onResponseCallback = callback
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
@objc
|
|
103
|
+
func onCustomerId(_ callback: @escaping RCTResponseSenderBlock) {
|
|
104
|
+
onCustomerIdCallback = callback
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
override static func requiresMainQueueSetup() -> Bool {
|
|
109
|
+
return true
|
|
110
|
+
}
|
|
111
|
+
}
|
|
@@ -15,9 +15,9 @@ class AmwalPaySDK {
|
|
|
15
15
|
return AmwalPaySDK.instance;
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
-
/**
|
|
19
|
-
* Initiates the payment process by first fetching a session token and then starting the payment flow
|
|
20
|
-
* @param config The payment configuration
|
|
18
|
+
/**
|
|
19
|
+
* Initiates the payment process by first fetching a session token and then starting the payment flow
|
|
20
|
+
* @param config The payment configuration
|
|
21
21
|
*/
|
|
22
22
|
async startPayment(config) {
|
|
23
23
|
try {
|
|
@@ -51,9 +51,9 @@ class AmwalPaySDK {
|
|
|
51
51
|
this.removeEventListeners();
|
|
52
52
|
}
|
|
53
53
|
|
|
54
|
-
/**
|
|
55
|
-
* Sets up event listeners for AmwalPay events
|
|
56
|
-
* @param config The payment configuration containing callback functions
|
|
54
|
+
/**
|
|
55
|
+
* Sets up event listeners for AmwalPay events
|
|
56
|
+
* @param config The payment configuration containing callback functions
|
|
57
57
|
*/
|
|
58
58
|
setupEventListeners(config) {
|
|
59
59
|
// Remove any existing listeners
|
|
@@ -68,8 +68,8 @@ class AmwalPaySDK {
|
|
|
68
68
|
});
|
|
69
69
|
}
|
|
70
70
|
|
|
71
|
-
/**
|
|
72
|
-
* Removes all event listeners
|
|
71
|
+
/**
|
|
72
|
+
* Removes all event listeners
|
|
73
73
|
*/
|
|
74
74
|
removeEventListeners() {
|
|
75
75
|
this.onResponseSubscription?.remove();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["initiate","onCustomerId","onResponse","NetworkClient","AmwalPaySDK","onResponseSubscription","onCustomerIdSubscription","constructor","getInstance","instance","startPayment","config","setupEventListeners","networkClient","sessionToken","fetchSessionToken","environment","merchantId","customerId","secureHash","completeConfig","error","console","dispose","removeEventListeners","response","log","remove"],"sourceRoot":"
|
|
1
|
+
{"version":3,"names":["initiate","onCustomerId","onResponse","NetworkClient","AmwalPaySDK","onResponseSubscription","onCustomerIdSubscription","constructor","getInstance","instance","startPayment","config","setupEventListeners","networkClient","sessionToken","fetchSessionToken","environment","merchantId","customerId","secureHash","completeConfig","error","console","dispose","removeEventListeners","response","log","remove"],"sourceRoot":"..\\..\\src","sources":["AmwalPaySDK.ts"],"mappings":";;AAAA,SAASA,QAAQ,EAAEC,YAAY,EAAEC,UAAU,QAA6B,YAAS;AACjF,OAAOC,aAAa,MAAM,4BAAyB;AAInD,MAAMC,WAAW,CAAC;EAGRC,sBAAsB,GAA2B,IAAI;EAErDC,wBAAwB,GAA2B,IAAI;EAEvDC,WAAWA,CAAA,EAAG;IACpB;EAAA;EAIF,OAAOC,WAAWA,CAAA,EAAgB;IAChC,IAAI,CAACJ,WAAW,CAACK,QAAQ,EAAE;MACzBL,WAAW,CAACK,QAAQ,GAAG,IAAIL,WAAW,CAAC,CAAC;IAC1C;IACA,OAAOA,WAAW,CAACK,QAAQ;EAC7B;;EAEA;AACF;AACA;AACA;EACE,MAAMC,YAAYA,CAACC,MAA4C,EAAiB;IAC9E,IAAI;MACF;MACA,IAAI,CAACC,mBAAmB,CAACD,MAAM,CAAC;;MAEhC;MACA,MAAME,aAAa,GAAGV,aAAa,CAACK,WAAW,CAAC,CAAC;;MAEjD;MACA,MAAMM,YAAY,GAAG,MAAMD,aAAa,CAACE,iBAAiB,CACxDJ,MAAM,CAACK,WAAW,EAClBL,MAAM,CAACM,UAAU,EACjBN,MAAM,CAACO,UAAU,EACjBP,MAAM,CAACQ,UACT,CAAC;MAED,IAAI,CAACL,YAAY,EAAE;QACjB;QACA;MACF;;MAEA;MACA,MAAMM,cAA8B,GAAG;QACrC,GAAGT,MAAM;QACTG;MACF,CAAC;;MAED;MACAd,QAAQ,CAACoB,cAAc,CAAC;IAC1B,CAAC,CAAC,OAAOC,KAAK,EAAE;MACdC,OAAO,CAACD,KAAK,CAAC,yBAAyB,EAAEA,KAAK,CAAC;IACjD;EACF;EAEAE,OAAOA,CAAA,EAAS;IACd;IACA,IAAI,CAACC,oBAAoB,CAAC,CAAC;EAC7B;;EAEA;AACF;AACA;AACA;EACUZ,mBAAmBA,CAACD,MAA4C,EAAQ;IAC9E;IACA,IAAI,CAACa,oBAAoB,CAAC,CAAC;IAE3B,IAAI,CAACnB,sBAAsB,GAAGH,UAAU,CAAEuB,QAAQ,IAAK;MACrDH,OAAO,CAACI,GAAG,CAAC,4BAA4B,EAAED,QAAQ,CAAC;MACnDd,MAAM,CAACT,UAAU,CAACuB,QAAQ,CAAC;IAC7B,CAAC,CAAC;IAEF,IAAI,CAACnB,wBAAwB,GAAGL,YAAY,CAAEiB,UAAU,IAAK;MAC3DI,OAAO,CAACI,GAAG,CAAC,sBAAsB,EAAER,UAAU,CAAC;MAC/CP,MAAM,CAACV,YAAY,CAACiB,UAAU,CAAC;IACjC,CAAC,CAAC;EACJ;;EAEA;AACF;AACA;EACUM,oBAAoBA,CAAA,EAAS;IACnC,IAAI,CAACnB,sBAAsB,EAAEsB,MAAM,CAAC,CAAC;IACrC,IAAI,CAACrB,wBAAwB,EAAEqB,MAAM,CAAC,CAAC;IACvC,IAAI,CAACtB,sBAAsB,GAAG,IAAI;IAClC,IAAI,CAACC,wBAAwB,GAAG,IAAI;EACtC;AACF;AAEA,eAAeF,WAAW","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["TurboModuleRegistry","Environment","Currency","TransactionType","getEnforcing"],"sourceRoot":"
|
|
1
|
+
{"version":3,"names":["TurboModuleRegistry","Environment","Currency","TransactionType","getEnforcing"],"sourceRoot":"..\\..\\src","sources":["NativeReactAmwalPay.ts"],"mappings":";;AACA,SAASA,mBAAmB,QAAQ,cAAc;AAGlD,WAAYC,WAAW,0BAAXA,WAAW;EAAXA,WAAW;EAAXA,WAAW;EAAXA,WAAW;EAAA,OAAXA,WAAW;AAAA;AAMvB,WAAYC,QAAQ,0BAARA,QAAQ;EAARA,QAAQ;EAAA,OAARA,QAAQ;AAAA;AAIpB,WAAYC,eAAe,0BAAfA,eAAe;EAAfA,eAAe;EAAfA,eAAe;EAAfA,eAAe;EAAA,OAAfA,eAAe;AAAA;;AAY3B;;AAgBA;;AAqBA,eAAeH,mBAAmB,CAACI,YAAY,CAAO,eAAe,CAAC","ignoreList":[]}
|
package/lib/module/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["ReactAmwalPay","Environment","Currency","TransactionType","AmwalPaySDK","initiate","config","nativeConfig","environment","secureHash","currency","amount","merchantId","terminalId","locale","customerId","transactionType","sessionToken","onResponse","callback","onCustomerId"],"sourceRoot":"
|
|
1
|
+
{"version":3,"names":["ReactAmwalPay","Environment","Currency","TransactionType","AmwalPaySDK","initiate","config","nativeConfig","environment","secureHash","currency","amount","merchantId","terminalId","locale","customerId","transactionType","sessionToken","onResponse","callback","onCustomerId"],"sourceRoot":"..\\..\\src","sources":["index.tsx"],"mappings":";;AAAA,OAAOA,aAAa,IAClBC,WAAW,EACXC,QAAQ,EACRC,eAAe,QAIV,0BAAuB;AAC9B,OAAOC,WAAW,MAAM,kBAAe;AAGvC;;AAEA,OAAO,SAASC,QAAQA,CAACC,MAAsB,EAAQ;EACrD,MAAMC,YAAkC,GAAG;IACzCC,WAAW,EAAEF,MAAM,CAACE,WAAW;IAC/BC,UAAU,EAAEH,MAAM,CAACG,UAAU;IAC7BC,QAAQ,EAAEJ,MAAM,CAACI,QAAQ;IACzBC,MAAM,EAAEL,MAAM,CAACK,MAAM;IACrBC,UAAU,EAAEN,MAAM,CAACM,UAAU;IAC7BC,UAAU,EAAEP,MAAM,CAACO,UAAU;IAC7BC,MAAM,EAAER,MAAM,CAACQ,MAAM;IACrBC,UAAU,EAAET,MAAM,CAACS,UAAU;IAC7BC,eAAe,EAAEV,MAAM,CAACU,eAAe;IACvCC,YAAY,EAAEX,MAAM,CAACW;EACvB,CAAC;;EAED;EACAjB,aAAa,CAACK,QAAQ,CAACE,YAAY,CAAC;AACtC;AAEA,OAAO,SAASW,UAAUA,CAACC,QAA8C,EAAoB;EAC3F,OAAOnB,aAAa,CAACkB,UAAU,CAACC,QAAQ,CAAC;AAC3C;AACA,OAAO,SAASC,YAAYA,CAACD,QAAsC,EAAoB;EACrF,OAAOnB,aAAa,CAACoB,YAAY,CAACD,QAAQ,CAAC;AAC7C;AAEA,SACElB,WAAW,EACXC,QAAQ,EACRC,eAAe,EAGfC,WAAW","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["Alert","Environment","SecureHashUtil","NetworkClient","constructor","getInstance","instance","getWebhookUrl","env","SIT","UAT","PROD","fetchSessionToken","merchantId","customerId","secureHashValue","webhookUrl","dataMap","secureHash","clearSecureHash","response","fetch","method","headers","body","JSON","stringify","responseData","json","ok","success","data","sessionToken","errorMessage","errorList","join","showErrorDialog","error","message","alert","text"],"sourceRoot":"
|
|
1
|
+
{"version":3,"names":["Alert","Environment","SecureHashUtil","NetworkClient","constructor","getInstance","instance","getWebhookUrl","env","SIT","UAT","PROD","fetchSessionToken","merchantId","customerId","secureHashValue","webhookUrl","dataMap","secureHash","clearSecureHash","response","fetch","method","headers","body","JSON","stringify","responseData","json","ok","success","data","sessionToken","errorMessage","errorList","join","showErrorDialog","error","message","alert","text"],"sourceRoot":"..\\..\\..\\src","sources":["network/NetworkClient.ts"],"mappings":";;AAAA,SAASA,KAAK,QAAQ,cAAc;AACpC,SAASC,WAAW,QAAQ,2BAAwB;AACpD,OAAOC,cAAc,MAAM,4BAAyB;AAEpD,MAAMC,aAAa,CAAC;EAGVC,WAAWA,CAAA,EAAG,CAAC;EAEvB,OAAOC,WAAWA,CAAA,EAAkB;IAClC,IAAI,CAACF,aAAa,CAACG,QAAQ,EAAE;MAC3BH,aAAa,CAACG,QAAQ,GAAG,IAAIH,aAAa,CAAC,CAAC;IAC9C;IACA,OAAOA,aAAa,CAACG,QAAQ;EAC/B;EAEQC,aAAaA,CAACC,GAAgB,EAAU;IAC9C,QAAQA,GAAG;MACT,KAAKP,WAAW,CAACQ,GAAG;QAClB,OAAO,iCAAiC;MAC1C,KAAKR,WAAW,CAACS,GAAG;QAClB,OAAO,iCAAiC;MAC1C,KAAKT,WAAW,CAACU,IAAI;QACnB,OAAO,8BAA8B;MACvC;QACE,OAAO,iCAAiC;IAC5C;EACF;EAEA,MAAMC,iBAAiBA,CACrBJ,GAAgB,EAChBK,UAAkB,EAClBC,UAAyB,EACzBC,eAAuB,EACC;IACxB,IAAI;MACF,MAAMC,UAAU,GAAG,IAAI,CAACT,aAAa,CAACC,GAAG,CAAC;MAE1C,MAAMS,OAAO,GAAG;QACdJ,UAAU;QACVC;MACF,CAAC;MAED,MAAMI,UAAU,GAAGhB,cAAc,CAACiB,eAAe,CAACJ,eAAe,EAAEE,OAAO,CAAC;MAE3E,MAAMG,QAAQ,GAAG,MAAMC,KAAK,CAAC,GAAGL,UAAU,+BAA+B,EAAE;QACzEM,MAAM,EAAE,MAAM;QACdC,OAAO,EAAE;UACP,QAAQ,EAAE,YAAY;UACtB,iBAAiB,EAAE,gBAAgB;UACnC,cAAc,EAAE;QAClB,CAAC;QACDC,IAAI,EAAEC,IAAI,CAACC,SAAS,CAAC;UACnBb,UAAU;UACVE,eAAe,EAAEG,UAAU;UAC3BJ;QACF,CAAC;MACH,CAAC,CAAC;MAEF,MAAMa,YAAY,GAAG,MAAMP,QAAQ,CAACQ,IAAI,CAAC,CAAC;MAE1C,IAAIR,QAAQ,CAACS,EAAE,IAAIF,YAAY,CAACG,OAAO,EAAE;QACvC,OAAOH,YAAY,CAACI,IAAI,CAACC,YAAY;MACvC,CAAC,MAAM;QACL,MAAMC,YAAY,GAAGN,YAAY,CAACO,SAAS,EAAEC,IAAI,CAAC,GAAG,CAAC,IAAI,eAAe;QACzE,IAAI,CAACC,eAAe,CAACH,YAAY,CAAC;QAClC,OAAO,IAAI;MACb;IACF,CAAC,CAAC,OAAOI,KAAK,EAAE;MACd,IAAI,CAACD,eAAe,CAAC,sBAAsB,CAAC;MAC5C,OAAO,IAAI;IACb;EACF;EAEQA,eAAeA,CAACE,OAAe,EAAQ;IAC7CtC,KAAK,CAACuC,KAAK,CACT,OAAO,EACPD,OAAO,EACP,CAAC;MAAEE,IAAI,EAAE;IAAK,CAAC,CACjB,CAAC;EACH;AACF;AAEA,eAAerC,aAAa","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["HmacSHA256","Hex","SecureHashUtil","clearSecureHash","secretKey","data","secureHashValue","concatenatedString","composeData","generateSecureHash","requestParameters","Object","entries","sort","keyA","keyB","localeCompare","filter","_","value","map","key","join","message","keyBytes","match","byte","parseInt","Error","keyHex","toString","padStart","hash","parse","toUpperCase","e","console","error"],"sourceRoot":"
|
|
1
|
+
{"version":3,"names":["HmacSHA256","Hex","SecureHashUtil","clearSecureHash","secretKey","data","secureHashValue","concatenatedString","composeData","generateSecureHash","requestParameters","Object","entries","sort","keyA","keyB","localeCompare","filter","_","value","map","key","join","message","keyBytes","match","byte","parseInt","Error","keyHex","toString","padStart","hash","parse","toUpperCase","e","console","error"],"sourceRoot":"..\\..\\..\\src","sources":["utils/SecureHashUtil.ts"],"mappings":";;AAAA,OAAOA,UAAU,MAAM,uBAAuB;AAC9C,OAAOC,GAAG,MAAM,mBAAmB;AAInC,MAAMC,cAAc,CAAC;EACnB,OAAOC,eAAeA,CAACC,SAAiB,EAAEC,IAAa,EAAU;IAC/D,OAAOA,IAAI,CAACC,eAAe;IAC3B,MAAMC,kBAAkB,GAAG,IAAI,CAACC,WAAW,CAACH,IAAI,CAAC;IACjD,OAAO,IAAI,CAACI,kBAAkB,CAACF,kBAAkB,EAAEH,SAAS,CAAC;EAC/D;EAEA,OAAeI,WAAWA,CAACE,iBAA0B,EAAU;IAC7D,OAAOC,MAAM,CAACC,OAAO,CAACF,iBAAiB,CAAC,CACrCG,IAAI,CAAC,CAAC,CAACC,IAAI,CAAC,EAAE,CAACC,IAAI,CAAC,KAAKD,IAAI,CAACE,aAAa,CAACD,IAAI,CAAC,CAAC,CAClDE,MAAM,CAAC,CAAC,CAACC,CAAC,EAAEC,KAAK,CAAC,KAAKA,KAAK,IAAI,IAAI,IAAIA,KAAK,KAAK,EAAE,CAAC,CACrDC,GAAG,CAAC,CAAC,CAACC,GAAG,EAAEF,KAAK,CAAC,KAAK,GAAGE,GAAG,IAAIF,KAAK,EAAE,CAAC,CACxCG,IAAI,CAAC,GAAG,CAAC;EACd;EAEA,OAAeb,kBAAkBA,CAACc,OAAe,EAAEnB,SAAiB,EAAU;IAC5E,IAAI;MACF;MACA,MAAMoB,QAAQ,GAAGpB,SAAS,CAACqB,KAAK,CAAC,OAAO,CAAC,EAAEL,GAAG,CAACM,IAAI,IAAIC,QAAQ,CAACD,IAAI,EAAE,EAAE,CAAC,CAAC;MAE1E,IAAI,CAACF,QAAQ,EAAE;QACb,MAAM,IAAII,KAAK,CAAC,2BAA2B,CAAC;MAC9C;;MAEA;MACA,MAAMC,MAAM,GAAGL,QAAQ,CAACJ,GAAG,CAACM,IAAI,IAAIA,IAAI,CAACI,QAAQ,CAAC,EAAE,CAAC,CAACC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,CAACT,IAAI,CAAC,EAAE,CAAC;;MAEhF;MACA,MAAMU,IAAI,GAAGhC,UAAU,CAACuB,OAAO,EAAEtB,GAAG,CAACgC,KAAK,CAACJ,MAAM,CAAC,CAAC;;MAEnD;MACA,OAAOG,IAAI,CAACF,QAAQ,CAAC7B,GAAG,CAAC,CAACiC,WAAW,CAAC,CAAC;IACzC,CAAC,CAAC,OAAOC,CAAC,EAAE;MACVC,OAAO,CAACC,KAAK,CAAC,+BAA+B,EAAEF,CAAC,CAAC;MACjD,OAAO,EAAE;IACX;EACF;AACF;AAEA,eAAejC,cAAc","ignoreList":[]}
|