react-amwal-pay 0.1.8 → 0.1.10

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 CHANGED
@@ -1,128 +1,182 @@
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
- ### iOS Installation Note
12
-
13
- After pod installation, you need to set "Build Libraries for Distribution" to NO in Xcode:
14
-
15
- 1. Open your iOS project in Xcode
16
- 2. Go to Pods project
17
- 3. Select amwalsdk target
18
- 4. In Build Settings, search for "Build Libraries for Distribution"
19
- 5. Set it to NO
20
-
21
- ![Build Libraries Setting](https://github.com/amwal-pay/AnwalPaySDKReactNative/raw/master/docs/images/ios_install_note.png)
22
-
23
- #### Configuring amwalsdk Subspec
24
-
25
- The library uses amwalsdk as a dependency and supports both Release and Debug subspecs. By default, it uses the Debug subspec. To change this, you can set the `AMWAL_SUBSPEC` environment variable in your Podfile:
26
-
27
- ```ruby
28
- # In your Podfile
29
- ENV['AMWAL_SUBSPEC'] = 'Release' # or 'Debug'
30
- ```
31
-
32
- Or you can set it when running pod install:
33
-
34
- ```bash
35
- AMWAL_SUBSPEC=Release pod install
36
- ```
37
-
38
- ## Usage
39
-
40
- ```js
41
- import {
42
- AmwalPaySDK,
43
- Environment,
44
- Currency,
45
- TransactionType,
46
- type AmwalPayConfig,
47
- type AmwalPayResponse
48
- } from 'react-amwal-pay';
49
-
50
- // Configure Amwal Pay
51
- const config: AmwalPayConfig = {
52
- environment: Environment.SIT, // or Environment.PRODUCTION
53
- currency: Currency.OMR, // or other supported currencies
54
- transactionType: TransactionType.CARD_WALLET,
55
- locale: 'en', // or 'ar'
56
- merchantId: '84131',
57
- terminalId: '811018',
58
- amount: '1',
59
- secureHash: '8570CEED656C8818E4A7CE04F22206358F272DAD5F0227D322B654675ABF8F83',
60
- customerId: 'customer-id', // optional
61
- sessionToken: 'your-session-token', // optional
62
- onCustomerId(customerId) {
63
- console.log('Customer ID:', customerId);
64
- },
65
- onResponse(response) {
66
- console.log('Payment Response:', response);
67
- }
68
- };
69
-
70
- // Initialize and start payment
71
- const handlePayment = async () => {
72
- try {
73
- // Validate required fields
74
- if (!isConfigValid(config)) {
75
- console.error('Please fill in all required fields');
76
- return;
77
- }
78
-
79
- const amwalPay = AmwalPaySDK.getInstance();
80
- await amwalPay.startPayment(config);
81
- } catch (error) {
82
- console.error('Error starting payment:', error);
83
- }
84
- };
85
-
86
- // Helper function to validate config
87
- const isConfigValid = (config: Partial<AmwalPayConfig>): boolean => {
88
- return Boolean(
89
- config.environment &&
90
- config.secureHash &&
91
- config.currency &&
92
- config.amount &&
93
- config.merchantId &&
94
- config.terminalId &&
95
- config.locale &&
96
- config.transactionType
97
- );
98
- };
99
- ```
100
-
101
- ## Configuration
102
-
103
- The `AmwalPayConfig` interface includes the following properties:
104
-
105
- - `environment`: The environment to use (SIT or PRODUCTION)
106
- - `currency`: The currency for the transaction (e.g., OMR)
107
- - `transactionType`: The type of transaction (e.g., CARD_WALLET)
108
- - `locale`: The language locale ('en' or 'ar')
109
- - `merchantId`: Your merchant ID
110
- - `terminalId`: Your terminal ID
111
- - `amount`: The transaction amount
112
- - `secureHash`: Your secure hash for authentication
113
- - `customerId`: (Optional) The customer's ID
114
- - `sessionToken`: (Optional) Your session token
115
- - `onCustomerId`: (Optional) Callback function for customer ID updates
116
- - `onResponse`: (Optional) Callback function for payment response
117
-
118
- ## Contributing
119
-
120
- See the [contributing guide](CONTRIBUTING.md) to learn how to contribute to the repository and the development workflow.
121
-
122
- ## License
123
-
124
- MIT
125
-
126
- ---
127
-
128
- 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
+ ### iOS Installation Note
12
+
13
+ After pod installation, you need to set "Build Libraries for Distribution" to NO in Xcode:
14
+
15
+ 1. Open your iOS project in Xcode
16
+ 2. Go to Pods project
17
+ 3. Select amwalsdk target
18
+ 4. In Build Settings, search for "Build Libraries for Distribution"
19
+ 5. Set it to NO
20
+
21
+ ![Build Libraries Setting](https://github.com/amwal-pay/AnwalPaySDKReactNative/raw/master/docs/images/ios_install_note.png)
22
+
23
+ #### Configuring amwalsdk Subspec
24
+
25
+ The library uses amwalsdk as a dependency and supports both Release and Debug subspecs. By default, it uses the Debug subspec. To change this, you can set the `AMWAL_SUBSPEC` environment variable in your Podfile:
26
+
27
+ ```ruby
28
+ # In your Podfile
29
+ ENV['AMWAL_SUBSPEC'] = 'Release' # or 'Debug'
30
+ ```
31
+
32
+ Or you can set it when running pod install:
33
+
34
+ ```bash
35
+ AMWAL_SUBSPEC=Release pod install
36
+ ```
37
+
38
+ ## Usage
39
+
40
+ ```js
41
+ import {
42
+ AmwalPaySDK,
43
+ Environment,
44
+ Currency,
45
+ TransactionType,
46
+ UuidUtil,
47
+ type AmwalPayConfig,
48
+ type AmwalPayResponse
49
+ } from 'react-amwal-pay';
50
+
51
+ // Configure Amwal Pay
52
+ const config: AmwalPayConfig = {
53
+ environment: Environment.SIT, // or Environment.PRODUCTION
54
+ currency: Currency.OMR, // or other supported currencies
55
+ transactionType: TransactionType.CARD_WALLET,
56
+ locale: 'en', // or 'ar'
57
+ merchantId: '84131',
58
+ terminalId: '811018',
59
+ amount: '1',
60
+ secureHash: '8570CEED656C8818E4A7CE04F22206358F272DAD5F0227D322B654675ABF8F83',
61
+ customerId: 'customer-id', // optional
62
+ sessionToken: 'your-session-token', // optional
63
+ transactionId: 'custom-transaction-id', // optional: auto-generated if not provided
64
+ additionValues: { // optional: custom key-value pairs for SDK configuration
65
+ merchantIdentifier: 'merchant.applepay.amwalpay', // for Apple Pay configuration
66
+ customKey: 'customValue' // add more as needed
67
+ },
68
+ onCustomerId(customerId) {
69
+ console.log('Customer ID:', customerId);
70
+ },
71
+ onResponse(response) {
72
+ console.log('Payment Response:', response);
73
+ }
74
+ };
75
+
76
+ // Initialize and start payment
77
+ const handlePayment = async () => {
78
+ try {
79
+ // Validate required fields
80
+ if (!isConfigValid(config)) {
81
+ console.error('Please fill in all required fields');
82
+ return;
83
+ }
84
+
85
+ const amwalPay = AmwalPaySDK.getInstance();
86
+ await amwalPay.startPayment(config);
87
+ } catch (error) {
88
+ console.error('Error starting payment:', error);
89
+ }
90
+ };
91
+
92
+ // Helper function to validate config
93
+ const isConfigValid = (config: Partial<AmwalPayConfig>): boolean => {
94
+ return Boolean(
95
+ config.environment &&
96
+ config.secureHash &&
97
+ config.currency &&
98
+ config.amount &&
99
+ config.merchantId &&
100
+ config.terminalId &&
101
+ config.locale &&
102
+ config.transactionType
103
+ );
104
+ };
105
+ ```
106
+
107
+ ## UUID Generation
108
+
109
+ If you need to generate a custom transaction ID, you can use the built-in UUID utility:
110
+
111
+ ```js
112
+ import { UuidUtil } from 'react-amwal-pay';
113
+
114
+ // Generate a UUID for transaction ID
115
+ const transactionId = UuidUtil.generateTransactionId();
116
+
117
+ // Or use the lower-level generator
118
+ const uuid = UuidUtil.generateV4();
119
+ ```
120
+
121
+ The UUID utility generates lowercase UUIDs in v4 format, ensuring compatibility with the payment system.
122
+
123
+ ## Addition Values Configuration
124
+
125
+ The SDK supports `additionValues` parameter for passing custom key-value pairs that can be used for various SDK functionalities.
126
+
127
+ ### Default Addition Values
128
+
129
+ The SDK automatically provides default values:
130
+ - `merchantIdentifier`: "merchant.applepay.amwalpay" (used for Apple Pay configuration)
131
+
132
+ ### Usage
133
+
134
+ ```js
135
+ // Using default additionValues (automatically applied)
136
+ const config = {
137
+ // ... other configuration
138
+ // additionValues will automatically include merchantIdentifier
139
+ };
140
+
141
+ // Using custom additionValues
142
+ const customConfig = {
143
+ // ... other configuration
144
+ additionValues: {
145
+ merchantIdentifier: 'merchant.custom.identifier',
146
+ customKey: 'customValue'
147
+ }
148
+ };
149
+ ```
150
+
151
+ Custom `additionValues` will be merged with defaults, with custom values taking precedence.
152
+
153
+ ## Configuration
154
+
155
+ The `AmwalPayConfig` interface includes the following properties:
156
+
157
+ - `environment`: The environment to use (SIT or PRODUCTION)
158
+ - `currency`: The currency for the transaction (e.g., OMR)
159
+ - `transactionType`: The type of transaction (e.g., CARD_WALLET)
160
+ - `locale`: The language locale ('en' or 'ar')
161
+ - `merchantId`: Your merchant ID
162
+ - `terminalId`: Your terminal ID
163
+ - `amount`: The transaction amount
164
+ - `secureHash`: Your secure hash for authentication
165
+ - `customerId`: (Optional) The customer's ID
166
+ - `sessionToken`: (Optional) Your session token
167
+ - `transactionId`: (Optional) Unique transaction identifier - auto-generated if not provided
168
+ - `additionValues`: (Optional) Custom key-value pairs for SDK configuration (includes merchantIdentifier for Apple Pay)
169
+ - `onCustomerId`: (Optional) Callback function for customer ID updates
170
+ - `onResponse`: (Optional) Callback function for payment response
171
+
172
+ ## Contributing
173
+
174
+ See the [contributing guide](CONTRIBUTING.md) to learn how to contribute to the repository and the development workflow.
175
+
176
+ ## License
177
+
178
+ MIT
179
+
180
+ ---
181
+
182
+ Made with [create-react-native-library](https://github.com/callstack/react-native-builder-bob)
@@ -1,23 +1,23 @@
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
- # Default to Release subspec
20
- amwal_subspec = ENV['AMWAL_SUBSPEC'] || 'Debug'
21
- s.dependency "amwalsdk/#{amwal_subspec}"
22
- install_modules_dependencies(s)
23
- 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
+ # Default to Release subspec
20
+ amwal_subspec = ENV['AMWAL_SUBSPEC'] || 'Release'
21
+ s.dependency "amwalsdk/#{amwal_subspec}"
22
+ install_modules_dependencies(s)
23
+ end
@@ -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
+ }
@@ -1,14 +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
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