react-amwal-pay 0.1.8 → 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/README.md CHANGED
@@ -1,128 +1,147 @@
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
+ onCustomerId(customerId) {
65
+ console.log('Customer ID:', customerId);
66
+ },
67
+ onResponse(response) {
68
+ console.log('Payment Response:', response);
69
+ }
70
+ };
71
+
72
+ // Initialize and start payment
73
+ const handlePayment = async () => {
74
+ try {
75
+ // Validate required fields
76
+ if (!isConfigValid(config)) {
77
+ console.error('Please fill in all required fields');
78
+ return;
79
+ }
80
+
81
+ const amwalPay = AmwalPaySDK.getInstance();
82
+ await amwalPay.startPayment(config);
83
+ } catch (error) {
84
+ console.error('Error starting payment:', error);
85
+ }
86
+ };
87
+
88
+ // Helper function to validate config
89
+ const isConfigValid = (config: Partial<AmwalPayConfig>): boolean => {
90
+ return Boolean(
91
+ config.environment &&
92
+ config.secureHash &&
93
+ config.currency &&
94
+ config.amount &&
95
+ config.merchantId &&
96
+ config.terminalId &&
97
+ config.locale &&
98
+ config.transactionType
99
+ );
100
+ };
101
+ ```
102
+
103
+ ## UUID Generation
104
+
105
+ If you need to generate a custom transaction ID, you can use the built-in UUID utility:
106
+
107
+ ```js
108
+ import { UuidUtil } from 'react-amwal-pay';
109
+
110
+ // Generate a UUID for transaction ID
111
+ const transactionId = UuidUtil.generateTransactionId();
112
+
113
+ // Or use the lower-level generator
114
+ const uuid = UuidUtil.generateV4();
115
+ ```
116
+
117
+ The UUID utility generates lowercase UUIDs in v4 format, ensuring compatibility with the payment system.
118
+
119
+ ## Configuration
120
+
121
+ The `AmwalPayConfig` interface includes the following properties:
122
+
123
+ - `environment`: The environment to use (SIT or PRODUCTION)
124
+ - `currency`: The currency for the transaction (e.g., OMR)
125
+ - `transactionType`: The type of transaction (e.g., CARD_WALLET)
126
+ - `locale`: The language locale ('en' or 'ar')
127
+ - `merchantId`: Your merchant ID
128
+ - `terminalId`: Your terminal ID
129
+ - `amount`: The transaction amount
130
+ - `secureHash`: Your secure hash for authentication
131
+ - `customerId`: (Optional) The customer's ID
132
+ - `sessionToken`: (Optional) Your session token
133
+ - `transactionId`: (Optional) Unique transaction identifier - auto-generated if not provided
134
+ - `onCustomerId`: (Optional) Callback function for customer ID updates
135
+ - `onResponse`: (Optional) Callback function for payment response
136
+
137
+ ## Contributing
138
+
139
+ See the [contributing guide](CONTRIBUTING.md) to learn how to contribute to the repository and the development workflow.
140
+
141
+ ## License
142
+
143
+ MIT
144
+
145
+ ---
146
+
147
+ 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