react-amwal-pay 0.1.11 → 0.1.13
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 +110 -2
- package/android/src/main/java/com/reactamwalpay/ReactAmwalPayModule.kt +41 -10
- package/ios/ReactAmwalPay.swift +13 -1
- package/lib/module/AmwalPaySDK.js +3 -0
- package/lib/module/AmwalPaySDK.js.map +1 -1
- package/lib/module/NativeReactAmwalPay.js.map +1 -1
- package/lib/module/index.js +7 -4
- package/lib/module/index.js.map +1 -1
- package/lib/typescript/src/AmwalPaySDK.d.ts.map +1 -1
- package/lib/typescript/src/NativeReactAmwalPay.d.ts +4 -3
- package/lib/typescript/src/NativeReactAmwalPay.d.ts.map +1 -1
- package/lib/typescript/src/index.d.ts +1 -1
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/AmwalPaySDK.ts +19 -15
- package/src/NativeReactAmwalPay.ts +7 -6
- package/src/index.tsx +11 -6
package/README.md
CHANGED
|
@@ -4,11 +4,78 @@ A React Native library for integrating Amwal Pay payment gateway into your React
|
|
|
4
4
|
|
|
5
5
|
## Installation
|
|
6
6
|
|
|
7
|
+
### Prerequisites
|
|
8
|
+
|
|
9
|
+
- React Native project (0.79+)
|
|
10
|
+
- Node.js 18 or higher
|
|
11
|
+
- iOS: Xcode and CocoaPods installed
|
|
12
|
+
- Android: Android Studio and JDK installed
|
|
13
|
+
|
|
14
|
+
### Step 1: Install the Package
|
|
15
|
+
|
|
7
16
|
```sh
|
|
8
17
|
npm install react-amwal-pay
|
|
18
|
+
# or
|
|
19
|
+
yarn add react-amwal-pay
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
### Step 2: Configure React Native (Required)
|
|
23
|
+
|
|
24
|
+
Create or update `react-native.config.js` in your project root:
|
|
25
|
+
|
|
26
|
+
```javascript
|
|
27
|
+
const path = require('path');
|
|
28
|
+
const pkg = require('react-amwal-pay/package.json');
|
|
29
|
+
|
|
30
|
+
module.exports = {
|
|
31
|
+
project: {
|
|
32
|
+
ios: {
|
|
33
|
+
automaticPodsInstallation: true,
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
dependencies: {
|
|
37
|
+
[pkg.name]: {
|
|
38
|
+
root: path.join(__dirname, 'node_modules/react-amwal-pay'),
|
|
39
|
+
platforms: {
|
|
40
|
+
ios: {},
|
|
41
|
+
android: {},
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
};
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
### Step 3: iOS Setup
|
|
49
|
+
|
|
50
|
+
#### 3.1 Update Podfile
|
|
51
|
+
|
|
52
|
+
Add the following configuration to your `ios/Podfile` inside the `post_install` block:
|
|
53
|
+
|
|
54
|
+
```ruby
|
|
55
|
+
post_install do |installer|
|
|
56
|
+
react_native_post_install(installer, config[:reactNativePath])
|
|
57
|
+
|
|
58
|
+
# Set "Build Libraries for Distribution" to NO for amwalsdk
|
|
59
|
+
installer.pods_project.targets.each do |target|
|
|
60
|
+
if target.name == 'amwalsdk'
|
|
61
|
+
target.build_configurations.each do |config|
|
|
62
|
+
config.build_settings['BUILD_LIBRARY_FOR_DISTRIBUTION'] = 'NO'
|
|
63
|
+
config.build_settings['EXCLUDED_ARCHS[sdk=iphonesimulator*]'] = 'x86_64'
|
|
64
|
+
end
|
|
65
|
+
end
|
|
66
|
+
end
|
|
67
|
+
end
|
|
9
68
|
```
|
|
10
69
|
|
|
11
|
-
|
|
70
|
+
#### 3.2 Install Pods
|
|
71
|
+
|
|
72
|
+
```bash
|
|
73
|
+
cd ios
|
|
74
|
+
pod install
|
|
75
|
+
cd ..
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
#### 3.3 iOS Build Setting (Manual Step)
|
|
12
79
|
|
|
13
80
|
After pod installation, you need to set "Build Libraries for Distribution" to NO in Xcode:
|
|
14
81
|
|
|
@@ -20,7 +87,7 @@ After pod installation, you need to set "Build Libraries for Distribution" to NO
|
|
|
20
87
|
|
|
21
88
|

|
|
22
89
|
|
|
23
|
-
#### Configuring amwalsdk Subspec
|
|
90
|
+
#### 3.4 Configuring amwalsdk Subspec (Optional)
|
|
24
91
|
|
|
25
92
|
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
93
|
|
|
@@ -35,6 +102,45 @@ Or you can set it when running pod install:
|
|
|
35
102
|
AMWAL_SUBSPEC=Release pod install
|
|
36
103
|
```
|
|
37
104
|
|
|
105
|
+
### Step 4: Android Setup
|
|
106
|
+
|
|
107
|
+
No additional Android configuration is required. The SDK uses React Native's autolinking feature.
|
|
108
|
+
|
|
109
|
+
**Note:** The SDK requires minimum SDK 24 (Android 7.0). Ensure your `android/build.gradle` has:
|
|
110
|
+
|
|
111
|
+
```gradle
|
|
112
|
+
minSdkVersion = 24
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
### Step 5: Clean and Rebuild
|
|
116
|
+
|
|
117
|
+
After installation, clean and rebuild your project:
|
|
118
|
+
|
|
119
|
+
```bash
|
|
120
|
+
# iOS
|
|
121
|
+
cd ios
|
|
122
|
+
rm -rf Pods Podfile.lock
|
|
123
|
+
pod install
|
|
124
|
+
cd ..
|
|
125
|
+
|
|
126
|
+
# Android
|
|
127
|
+
cd android
|
|
128
|
+
./gradlew clean
|
|
129
|
+
cd ..
|
|
130
|
+
|
|
131
|
+
# Rebuild your app
|
|
132
|
+
npm run ios
|
|
133
|
+
# or
|
|
134
|
+
npm run android
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
### Troubleshooting
|
|
138
|
+
|
|
139
|
+
- **Pods fail to install**: Clean pods and reinstall (`rm -rf Pods Podfile.lock && pod install`)
|
|
140
|
+
- **Linking issues**: Ensure `react-native.config.js` is in your project root
|
|
141
|
+
- **Build errors**: Clean build folders and rebuild your project
|
|
142
|
+
- **iOS build errors**: Verify that "Build Libraries for Distribution" is set to NO for amwalsdk target
|
|
143
|
+
|
|
38
144
|
## Usage
|
|
39
145
|
|
|
40
146
|
```js
|
|
@@ -61,6 +167,7 @@ const config: AmwalPayConfig = {
|
|
|
61
167
|
customerId: 'customer-id', // optional
|
|
62
168
|
sessionToken: 'your-session-token', // optional
|
|
63
169
|
transactionId: 'custom-transaction-id', // optional: auto-generated if not provided
|
|
170
|
+
merchantReference: 'optional-merchant-reference', // optional: merchant reference for transaction tracking
|
|
64
171
|
additionValues: { // optional: custom key-value pairs for SDK configuration
|
|
65
172
|
merchantIdentifier: 'merchant.applepay.amwalpay', // for Apple Pay configuration
|
|
66
173
|
customKey: 'customValue' // add more as needed
|
|
@@ -165,6 +272,7 @@ The `AmwalPayConfig` interface includes the following properties:
|
|
|
165
272
|
- `customerId`: (Optional) The customer's ID
|
|
166
273
|
- `sessionToken`: (Optional) Your session token
|
|
167
274
|
- `transactionId`: (Optional) Unique transaction identifier - auto-generated if not provided
|
|
275
|
+
- `merchantReference`: (Optional) Merchant reference for transaction tracking
|
|
168
276
|
- `additionValues`: (Optional) Custom key-value pairs for SDK configuration (includes merchantIdentifier for Apple Pay)
|
|
169
277
|
- `onCustomerId`: (Optional) Callback function for customer ID updates
|
|
170
278
|
- `onResponse`: (Optional) Callback function for payment response
|
|
@@ -17,32 +17,61 @@ class ReactAmwalPayModule(reactContext: ReactApplicationContext) :
|
|
|
17
17
|
return NAME
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
private fun sendEvent(eventName: String, params: WritableMap?) {
|
|
20
|
+
private fun sendEvent(eventName: String, params: Any?) {
|
|
23
21
|
reactApplicationContext
|
|
24
22
|
.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter::class.java)
|
|
25
23
|
.emit(eventName, params)
|
|
26
24
|
}
|
|
25
|
+
|
|
26
|
+
private fun emitOnResponse(params: WritableMap) {
|
|
27
|
+
sendEvent("onResponse", params)
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
private fun emitOnCustomerId(customerId: String?) {
|
|
31
|
+
sendEvent("onCustomerId", customerId)
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
override fun addListener(eventName: String?) {
|
|
35
|
+
// Required for RN built in Event Emitter Calls.
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
override fun removeListeners(count: Double) {
|
|
39
|
+
// Required for RN built in Event Emitter Calls.
|
|
40
|
+
}
|
|
27
41
|
|
|
28
42
|
override fun initiate(config: ReadableMap) {
|
|
29
43
|
Log.d(NAME, "initiate called")
|
|
30
44
|
val activity = reactApplicationContext.currentActivity
|
|
31
45
|
if (activity == null) {
|
|
32
|
-
// Since we can't use Promise here (method signature must match the spec),
|
|
33
|
-
// we'll send an error event
|
|
34
46
|
val params = Arguments.createMap()
|
|
35
|
-
params.putString("type", "onResponse")
|
|
36
47
|
val errorData = Arguments.createMap()
|
|
37
48
|
errorData.putString("status", "ERROR")
|
|
38
49
|
errorData.putString("message", "Activity context is not available")
|
|
39
50
|
params.putMap("data", errorData)
|
|
40
|
-
|
|
51
|
+
emitOnResponse(params)
|
|
41
52
|
return
|
|
42
53
|
}
|
|
43
54
|
|
|
44
55
|
Log.d(NAME, "initiate got here")
|
|
45
56
|
try {
|
|
57
|
+
// Handle additionValues map
|
|
58
|
+
val additionValues = if (config.hasKey("additionValues")) {
|
|
59
|
+
val additionValuesMap = config.getMap("additionValues")
|
|
60
|
+
val map = mutableMapOf<String, String>()
|
|
61
|
+
additionValuesMap?.let { readableMap ->
|
|
62
|
+
val iterator = readableMap.keySetIterator()
|
|
63
|
+
while (iterator.hasNextKey()) {
|
|
64
|
+
val key = iterator.nextKey()
|
|
65
|
+
readableMap.getString(key)?.let { value ->
|
|
66
|
+
map[key] = value
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
map.toMap()
|
|
71
|
+
} else {
|
|
72
|
+
AmwalSDK.Config.generateDefaultAdditionValues()
|
|
73
|
+
}
|
|
74
|
+
|
|
46
75
|
val sdkConfig = AmwalSDK.Config(
|
|
47
76
|
environment = AmwalSDK.Config.Environment.valueOf(config.getString("environment") ?: ""),
|
|
48
77
|
sessionToken = config.getString("sessionToken") ?: "",
|
|
@@ -52,7 +81,10 @@ class ReactAmwalPayModule(reactContext: ReactApplicationContext) :
|
|
|
52
81
|
terminalId = config.getString("terminalId") ?: "",
|
|
53
82
|
locale = java.util.Locale(config.getString("locale") ?: "en"),
|
|
54
83
|
customerId = if (config.hasKey("customerId")) config.getString("customerId") else null,
|
|
55
|
-
transactionType = AmwalSDK.Config.TransactionType.valueOf(config.getString("transactionType") ?: "")
|
|
84
|
+
transactionType = AmwalSDK.Config.TransactionType.valueOf(config.getString("transactionType") ?: ""),
|
|
85
|
+
transactionId = if (config.hasKey("transactionId")) config.getString("transactionId") else AmwalSDK.Config.generateTransactionId(),
|
|
86
|
+
additionValues = additionValues,
|
|
87
|
+
merchantReference = if (config.hasKey("merchantReference")) config.getString("merchantReference") else null
|
|
56
88
|
)
|
|
57
89
|
|
|
58
90
|
// Ensure this runs on the UI thread
|
|
@@ -81,12 +113,11 @@ class ReactAmwalPayModule(reactContext: ReactApplicationContext) :
|
|
|
81
113
|
} catch (e: Exception) {
|
|
82
114
|
Log.e(NAME, "Error initializing AmwalSDK", e)
|
|
83
115
|
val params = Arguments.createMap()
|
|
84
|
-
params.putString("type", "onResponse")
|
|
85
116
|
val errorData = Arguments.createMap()
|
|
86
117
|
errorData.putString("status", "ERROR")
|
|
87
118
|
errorData.putString("message", e.message ?: "Unknown error")
|
|
88
119
|
params.putMap("data", errorData)
|
|
89
|
-
|
|
120
|
+
emitOnResponse(params)
|
|
90
121
|
}
|
|
91
122
|
}
|
|
92
123
|
|
package/ios/ReactAmwalPay.swift
CHANGED
|
@@ -42,6 +42,15 @@ class ReactAmwalPay: RCTEventEmitter {
|
|
|
42
42
|
private var onResponseCallback: RCTResponseSenderBlock?
|
|
43
43
|
private var onCustomerIdCallback: RCTResponseSenderBlock?
|
|
44
44
|
private func prepareConfig(config: [String: Any]) -> Config {
|
|
45
|
+
// Handle additionValues
|
|
46
|
+
var additionValues: [String: String] = Config.generateDefaultAdditionValues()
|
|
47
|
+
if let configAdditionValues = config["additionValues"] as? [String: String] {
|
|
48
|
+
// Merge with default values, allowing override
|
|
49
|
+
for (key, value) in configAdditionValues {
|
|
50
|
+
additionValues[key] = value
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
45
54
|
return Config(
|
|
46
55
|
environment: mapEnvironment(environment: config["environment"] as? String ?? "PROD"),
|
|
47
56
|
sessionToken: config["sessionToken"] as? String ?? "",
|
|
@@ -51,7 +60,10 @@ class ReactAmwalPay: RCTEventEmitter {
|
|
|
51
60
|
terminalId: config["terminalId"] as? String ?? "",
|
|
52
61
|
customerId: config["customerId"] as? String,
|
|
53
62
|
locale: mapLocale(locale: config["locale"] as? String ?? "en"),
|
|
54
|
-
transactionType: mapTransactionType(transactionType: config["transactionType"] as? String ?? "CARD_WALLET")
|
|
63
|
+
transactionType: mapTransactionType(transactionType: config["transactionType"] as? String ?? "CARD_WALLET"),
|
|
64
|
+
transactionId: config["transactionId"] as? String ?? Config.generateTransactionId(),
|
|
65
|
+
additionValues: additionValues,
|
|
66
|
+
merchantReference: config["merchantReference"] as? String
|
|
55
67
|
)
|
|
56
68
|
}
|
|
57
69
|
|
|
@@ -28,7 +28,9 @@ class AmwalPaySDK {
|
|
|
28
28
|
const networkClient = NetworkClient.getInstance();
|
|
29
29
|
|
|
30
30
|
// Fetch session token
|
|
31
|
+
console.log('Fetching session token for environment:', config.environment);
|
|
31
32
|
const sessionToken = await networkClient.fetchSessionToken(config.environment, config.merchantId, config.customerId, config.secureHash);
|
|
33
|
+
console.log('Session token result:', sessionToken ? 'Success' : 'Failed');
|
|
32
34
|
if (!sessionToken) {
|
|
33
35
|
// If session token is null, the error has already been shown by NetworkClient
|
|
34
36
|
return;
|
|
@@ -41,6 +43,7 @@ class AmwalPaySDK {
|
|
|
41
43
|
};
|
|
42
44
|
|
|
43
45
|
// Initiate the payment process
|
|
46
|
+
console.log('Initiating native payment with config:', JSON.stringify(completeConfig));
|
|
44
47
|
initiate(completeConfig);
|
|
45
48
|
} catch (error) {
|
|
46
49
|
console.error('Error starting payment:', error);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["initiate","onCustomerId","onResponse","NetworkClient","AmwalPaySDK","onResponseSubscription","onCustomerIdSubscription","constructor","getInstance","instance","startPayment","config","setupEventListeners","networkClient","
|
|
1
|
+
{"version":3,"names":["initiate","onCustomerId","onResponse","NetworkClient","AmwalPaySDK","onResponseSubscription","onCustomerIdSubscription","constructor","getInstance","instance","startPayment","config","setupEventListeners","networkClient","console","log","environment","sessionToken","fetchSessionToken","merchantId","customerId","secureHash","completeConfig","JSON","stringify","error","dispose","removeEventListeners","response","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,GAA6B,IAAI;EAEvDC,wBAAwB,GAA6B,IAAI;EAEzDC,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;MACAM,OAAO,CAACC,GAAG,CAAC,yCAAyC,EAAEJ,MAAM,CAACK,WAAW,CAAC;MAC1E,MAAMC,YAAY,GAAG,MAAMJ,aAAa,CAACK,iBAAiB,CACxDP,MAAM,CAACK,WAAW,EAClBL,MAAM,CAACQ,UAAU,EACjBR,MAAM,CAACS,UAAU,EACjBT,MAAM,CAACU,UACT,CAAC;MAEDP,OAAO,CAACC,GAAG,CAAC,uBAAuB,EAAEE,YAAY,GAAG,SAAS,GAAG,QAAQ,CAAC;MAEzE,IAAI,CAACA,YAAY,EAAE;QACjB;QACA;MACF;;MAEA;MACA,MAAMK,cAA8B,GAAG;QACrC,GAAGX,MAAM;QACTM;MACF,CAAC;;MAED;MACAH,OAAO,CAACC,GAAG,CAAC,wCAAwC,EAAEQ,IAAI,CAACC,SAAS,CAACF,cAAc,CAAC,CAAC;MACrFtB,QAAQ,CAACsB,cAAc,CAAC;IAC1B,CAAC,CAAC,OAAOG,KAAK,EAAE;MACdX,OAAO,CAACW,KAAK,CAAC,yBAAyB,EAAEA,KAAK,CAAC;IACjD;EACF;EAEAC,OAAOA,CAAA,EAAS;IACd;IACA,IAAI,CAACC,oBAAoB,CAAC,CAAC;EAC7B;;EAEA;AACF;AACA;AACA;EACUf,mBAAmBA,CAACD,MAA4C,EAAQ;IAC9E;IACA,IAAI,CAACgB,oBAAoB,CAAC,CAAC;IAE3B,IAAI,CAACtB,sBAAsB,GAAGH,UAAU,CAAE0B,QAAQ,IAAK;MACrDd,OAAO,CAACC,GAAG,CAAC,4BAA4B,EAAEa,QAAQ,CAAC;MACnDjB,MAAM,CAACT,UAAU,CAAC0B,QAAQ,CAAC;IAC7B,CAAC,CAAC;IAEF,IAAI,CAACtB,wBAAwB,GAAGL,YAAY,CAAEmB,UAAU,IAAK;MAC3DN,OAAO,CAACC,GAAG,CAAC,sBAAsB,EAAEK,UAAU,CAAC;MAC/CT,MAAM,CAACV,YAAY,CAACmB,UAAU,CAAC;IACjC,CAAC,CAAC;EACJ;;EAEA;AACF;AACA;EACUO,oBAAoBA,CAAA,EAAS;IACnC,IAAI,CAACtB,sBAAsB,EAAEwB,MAAM,CAAC,CAAC;IACrC,IAAI,CAACvB,wBAAwB,EAAEuB,MAAM,CAAC,CAAC;IACvC,IAAI,CAACxB,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":"../../src","sources":["NativeReactAmwalPay.ts"],"mappings":";;AACA,SAASA,mBAAmB,QAAQ,cAAc;
|
|
1
|
+
{"version":3,"names":["TurboModuleRegistry","Environment","Currency","TransactionType","getEnforcing"],"sourceRoot":"../../src","sources":["NativeReactAmwalPay.ts"],"mappings":";;AACA,SAASA,mBAAmB,QAAQ,cAAc;AAElD,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;;AAmBA;;AAwBA,eAAeH,mBAAmB,CAACI,YAAY,CAAO,eAAe,CAAC","ignoreList":[]}
|
package/lib/module/index.js
CHANGED
|
@@ -3,8 +3,10 @@
|
|
|
3
3
|
import ReactAmwalPay, { Environment, Currency, TransactionType } from "./NativeReactAmwalPay.js";
|
|
4
4
|
import AmwalPaySDK from "./AmwalPaySDK.js";
|
|
5
5
|
import { UuidUtil } from "./utils/UuidUtil.js";
|
|
6
|
-
|
|
6
|
+
import { NativeEventEmitter } from 'react-native';
|
|
7
7
|
|
|
8
|
+
// Create an event emitter for the native module
|
|
9
|
+
const eventEmitter = new NativeEventEmitter(ReactAmwalPay);
|
|
8
10
|
export function initiate(config) {
|
|
9
11
|
// Create default additionValues with merchantIdentifier for iOS if not provided
|
|
10
12
|
const defaultAdditionValues = {
|
|
@@ -26,17 +28,18 @@ export function initiate(config) {
|
|
|
26
28
|
transactionType: config.transactionType,
|
|
27
29
|
sessionToken: config.sessionToken,
|
|
28
30
|
transactionId: config.transactionId ?? UuidUtil.generateTransactionId(),
|
|
29
|
-
additionValues: finalAdditionValues
|
|
31
|
+
additionValues: finalAdditionValues,
|
|
32
|
+
merchantReference: config.merchantReference
|
|
30
33
|
};
|
|
31
34
|
|
|
32
35
|
// Call the native module
|
|
33
36
|
ReactAmwalPay.initiate(nativeConfig);
|
|
34
37
|
}
|
|
35
38
|
export function onResponse(callback) {
|
|
36
|
-
return
|
|
39
|
+
return eventEmitter.addListener('onResponse', callback);
|
|
37
40
|
}
|
|
38
41
|
export function onCustomerId(callback) {
|
|
39
|
-
return
|
|
42
|
+
return eventEmitter.addListener('onCustomerId', callback);
|
|
40
43
|
}
|
|
41
44
|
export { Environment, Currency, TransactionType, AmwalPaySDK, UuidUtil };
|
|
42
45
|
//# sourceMappingURL=index.js.map
|
package/lib/module/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["ReactAmwalPay","Environment","Currency","TransactionType","AmwalPaySDK","UuidUtil","initiate","config","defaultAdditionValues","merchantIdentifier","finalAdditionValues","additionValues","nativeConfig","environment","secureHash","currency","amount","merchantId","terminalId","locale","customerId","transactionType","sessionToken","transactionId","generateTransactionId","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;AACvC,SAASC,QAAQ,QAAQ,qBAAkB;
|
|
1
|
+
{"version":3,"names":["ReactAmwalPay","Environment","Currency","TransactionType","AmwalPaySDK","UuidUtil","NativeEventEmitter","eventEmitter","initiate","config","defaultAdditionValues","merchantIdentifier","finalAdditionValues","additionValues","nativeConfig","environment","secureHash","currency","amount","merchantId","terminalId","locale","customerId","transactionType","sessionToken","transactionId","generateTransactionId","merchantReference","onResponse","callback","addListener","onCustomerId"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":";;AAAA,OAAOA,aAAa,IAClBC,WAAW,EACXC,QAAQ,EACRC,eAAe,QAIV,0BAAuB;AAC9B,OAAOC,WAAW,MAAM,kBAAe;AACvC,SAASC,QAAQ,QAAQ,qBAAkB;AAC3C,SACEC,kBAAkB,QAEb,cAAc;;AAErB;AACA,MAAMC,YAAY,GAAG,IAAID,kBAAkB,CAACN,aAAoB,CAAC;AAEjE,OAAO,SAASQ,QAAQA,CAACC,MAAsB,EAAQ;EACrD;EACA,MAAMC,qBAAqB,GAAG;IAC5BC,kBAAkB,EAAE;EACtB,CAAC;EAED,MAAMC,mBAAmB,GAAG;IAC1B,GAAGF,qBAAqB;IACxB,GAAGD,MAAM,CAACI;EACZ,CAAC;EAED,MAAMC,YAAkC,GAAG;IACzCC,WAAW,EAAEN,MAAM,CAACM,WAAW;IAC/BC,UAAU,EAAEP,MAAM,CAACO,UAAU;IAC7BC,QAAQ,EAAER,MAAM,CAACQ,QAAQ;IACzBC,MAAM,EAAET,MAAM,CAACS,MAAM;IACrBC,UAAU,EAAEV,MAAM,CAACU,UAAU;IAC7BC,UAAU,EAAEX,MAAM,CAACW,UAAU;IAC7BC,MAAM,EAAEZ,MAAM,CAACY,MAAM;IACrBC,UAAU,EAAEb,MAAM,CAACa,UAAU;IAC7BC,eAAe,EAAEd,MAAM,CAACc,eAAe;IACvCC,YAAY,EAAEf,MAAM,CAACe,YAAY;IACjCC,aAAa,EAAEhB,MAAM,CAACgB,aAAa,IAAIpB,QAAQ,CAACqB,qBAAqB,CAAC,CAAC;IACvEb,cAAc,EAAED,mBAAmB;IACnCe,iBAAiB,EAAElB,MAAM,CAACkB;EAC5B,CAAC;;EAED;EACA3B,aAAa,CAACQ,QAAQ,CAACM,YAAY,CAAC;AACtC;AAEA,OAAO,SAASc,UAAUA,CAACC,QAA8C,EAAqB;EAC5F,OAAOtB,YAAY,CAACuB,WAAW,CAAC,YAAY,EAAED,QAAQ,CAAC;AACzD;AACA,OAAO,SAASE,YAAYA,CAACF,QAAsC,EAAqB;EACtF,OAAOtB,YAAY,CAACuB,WAAW,CAAC,cAAc,EAAED,QAAQ,CAAC;AAC3D;AAEA,SACE5B,WAAW,EACXC,QAAQ,EACRC,eAAe,EAGfC,WAAW,EACXC,QAAQ","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AmwalPaySDK.d.ts","sourceRoot":"","sources":["../../../src/AmwalPaySDK.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsC,KAAK,cAAc,EAAE,MAAM,SAAS,CAAC;AAKlF,cAAM,WAAW;IACf,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAc;IAErC,OAAO,CAAC,sBAAsB,
|
|
1
|
+
{"version":3,"file":"AmwalPaySDK.d.ts","sourceRoot":"","sources":["../../../src/AmwalPaySDK.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsC,KAAK,cAAc,EAAE,MAAM,SAAS,CAAC;AAKlF,cAAM,WAAW;IACf,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAc;IAErC,OAAO,CAAC,sBAAsB,CAAkC;IAEhE,OAAO,CAAC,wBAAwB,CAAkC;IAElE,OAAO;IAKP,MAAM,CAAC,WAAW,IAAI,WAAW;IAOjC;;;OAGG;IACG,YAAY,CAAC,MAAM,EAAE,IAAI,CAAC,cAAc,EAAE,cAAc,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;IAsC/E,OAAO,IAAI,IAAI;IAKf;;;OAGG;IACH,OAAO,CAAC,mBAAmB;IAe3B;;OAEG;IACH,OAAO,CAAC,oBAAoB;CAM7B;AAED,eAAe,WAAW,CAAC"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import type { TurboModule } from 'react-native';
|
|
2
|
-
import type { EventEmitter } from 'react-native/Libraries/Types/CodegenTypes';
|
|
3
2
|
export declare enum Environment {
|
|
4
3
|
SIT = "SIT",
|
|
5
4
|
UAT = "UAT",
|
|
@@ -33,6 +32,7 @@ export interface AmwalPayConfig {
|
|
|
33
32
|
additionValues?: {
|
|
34
33
|
[key: string]: string;
|
|
35
34
|
};
|
|
35
|
+
merchantReference?: string;
|
|
36
36
|
onResponse: (response: AmwalPayResponse) => void;
|
|
37
37
|
onCustomerId: (customerId: string) => void;
|
|
38
38
|
}
|
|
@@ -51,11 +51,12 @@ export interface AmwalPayNativeConfig {
|
|
|
51
51
|
additionValues?: {
|
|
52
52
|
[key: string]: string;
|
|
53
53
|
};
|
|
54
|
+
merchantReference?: string;
|
|
54
55
|
}
|
|
55
56
|
export interface Spec extends TurboModule {
|
|
56
57
|
initiate(config: AmwalPayNativeConfig): void;
|
|
57
|
-
|
|
58
|
-
|
|
58
|
+
addListener(eventName: string): void;
|
|
59
|
+
removeListeners(count: number): void;
|
|
59
60
|
}
|
|
60
61
|
declare const _default: Spec;
|
|
61
62
|
export default _default;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NativeReactAmwalPay.d.ts","sourceRoot":"","sources":["../../../src/NativeReactAmwalPay.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"NativeReactAmwalPay.d.ts","sourceRoot":"","sources":["../../../src/NativeReactAmwalPay.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAGhD,oBAAY,WAAW;IACrB,GAAG,QAAQ;IACX,GAAG,QAAQ;IACX,IAAI,SAAS;CACd;AAED,oBAAY,QAAQ;IAClB,GAAG,QAAQ;CACZ;AAED,oBAAY,eAAe;IACzB,GAAG,QAAQ;IACX,WAAW,gBAAgB;IAC3B,SAAS,cAAc;CACxB;AAED,MAAM,WAAW,gBAAgB;IAC/B,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAGD,MAAM,WAAW,cAAc;IAC7B,WAAW,EAAE,WAAW,CAAC;IACzB,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,QAAQ,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,eAAe,EAAE,eAAe,CAAC;IACjC,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,cAAc,CAAC,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;KAAE,CAAC;IAC3C,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,UAAU,EAAE,CAAC,QAAQ,EAAE,gBAAgB,KAAK,IAAI,CAAC;IACjD,YAAY,EAAE,CAAC,UAAU,EAAE,MAAM,KAAK,IAAI,CAAC;CAC5C;AAGD,MAAM,WAAW,oBAAoB;IACnC,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,eAAe,EAAE,MAAM,CAAC;IACxB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,cAAc,CAAC,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;KAAE,CAAC;IAC3C,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC5B;AAED,MAAM,WAAW,IAAK,SAAQ,WAAW;IAEvC,QAAQ,CAAC,MAAM,EAAE,oBAAoB,GAAG,IAAI,CAAC;IAC7C,WAAW,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACrC,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;CACtC;;AAED,wBAAuE"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Environment, Currency, TransactionType, type AmwalPayResponse, type AmwalPayConfig } from './NativeReactAmwalPay';
|
|
2
2
|
import AmwalPaySDK from './AmwalPaySDK';
|
|
3
3
|
import { UuidUtil } from './utils/UuidUtil';
|
|
4
|
-
import type
|
|
4
|
+
import { type EventSubscription } from 'react-native';
|
|
5
5
|
export declare function initiate(config: AmwalPayConfig): void;
|
|
6
6
|
export declare function onResponse(callback: (response: AmwalPayResponse) => void): EventSubscription;
|
|
7
7
|
export declare function onCustomerId(callback: (customerId: string) => void): EventSubscription;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.tsx"],"names":[],"mappings":"AAAA,OAAsB,EACpB,WAAW,EACX,QAAQ,EACR,eAAe,EACf,KAAK,gBAAgB,EACrB,KAAK,cAAc,EAEpB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,WAAW,MAAM,eAAe,CAAC;AACxC,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.tsx"],"names":[],"mappings":"AAAA,OAAsB,EACpB,WAAW,EACX,QAAQ,EACR,eAAe,EACf,KAAK,gBAAgB,EACrB,KAAK,cAAc,EAEpB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,WAAW,MAAM,eAAe,CAAC;AACxC,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAEL,KAAK,iBAAiB,EACvB,MAAM,cAAc,CAAC;AAKtB,wBAAgB,QAAQ,CAAC,MAAM,EAAE,cAAc,GAAG,IAAI,CA6BrD;AAED,wBAAgB,UAAU,CAAC,QAAQ,EAAE,CAAC,QAAQ,EAAE,gBAAgB,KAAK,IAAI,GAAG,iBAAiB,CAE5F;AACD,wBAAgB,YAAY,CAAC,QAAQ,EAAE,CAAC,UAAU,EAAE,MAAM,KAAK,IAAI,GAAG,iBAAiB,CAEtF;AAED,OAAO,EACL,WAAW,EACX,QAAQ,EACR,eAAe,EACf,KAAK,gBAAgB,EACrB,KAAK,cAAc,EACnB,WAAW,EACX,QAAQ,GACT,CAAC"}
|
package/package.json
CHANGED
package/src/AmwalPaySDK.ts
CHANGED
|
@@ -1,27 +1,27 @@
|
|
|
1
1
|
import { initiate, onCustomerId, onResponse, type AmwalPayConfig } from './index';
|
|
2
2
|
import NetworkClient from './network/NetworkClient';
|
|
3
|
-
import {
|
|
3
|
+
import { type EventSubscription } from 'react-native';
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
class AmwalPaySDK {
|
|
7
7
|
private static instance: AmwalPaySDK;
|
|
8
8
|
|
|
9
|
-
private onResponseSubscription: EventSubscription|null = null;
|
|
9
|
+
private onResponseSubscription: EventSubscription | null = null;
|
|
10
|
+
|
|
11
|
+
private onCustomerIdSubscription: EventSubscription | null = null;
|
|
10
12
|
|
|
11
|
-
private onCustomerIdSubscription: EventSubscription|null = null;
|
|
12
|
-
|
|
13
13
|
private constructor() {
|
|
14
14
|
// Initialize the event emitter
|
|
15
|
-
|
|
15
|
+
|
|
16
16
|
}
|
|
17
|
-
|
|
17
|
+
|
|
18
18
|
static getInstance(): AmwalPaySDK {
|
|
19
19
|
if (!AmwalPaySDK.instance) {
|
|
20
20
|
AmwalPaySDK.instance = new AmwalPaySDK();
|
|
21
21
|
}
|
|
22
22
|
return AmwalPaySDK.instance;
|
|
23
23
|
}
|
|
24
|
-
|
|
24
|
+
|
|
25
25
|
/**
|
|
26
26
|
* Initiates the payment process by first fetching a session token and then starting the payment flow
|
|
27
27
|
* @param config The payment configuration
|
|
@@ -30,30 +30,34 @@ class AmwalPaySDK {
|
|
|
30
30
|
try {
|
|
31
31
|
// Set up event listeners before starting the payment process
|
|
32
32
|
this.setupEventListeners(config);
|
|
33
|
-
|
|
33
|
+
|
|
34
34
|
// Get network client instance
|
|
35
35
|
const networkClient = NetworkClient.getInstance();
|
|
36
|
-
|
|
36
|
+
|
|
37
37
|
// Fetch session token
|
|
38
|
+
console.log('Fetching session token for environment:', config.environment);
|
|
38
39
|
const sessionToken = await networkClient.fetchSessionToken(
|
|
39
40
|
config.environment,
|
|
40
41
|
config.merchantId,
|
|
41
42
|
config.customerId,
|
|
42
43
|
config.secureHash
|
|
43
44
|
);
|
|
44
|
-
|
|
45
|
+
|
|
46
|
+
console.log('Session token result:', sessionToken ? 'Success' : 'Failed');
|
|
47
|
+
|
|
45
48
|
if (!sessionToken) {
|
|
46
49
|
// If session token is null, the error has already been shown by NetworkClient
|
|
47
50
|
return;
|
|
48
51
|
}
|
|
49
|
-
|
|
52
|
+
|
|
50
53
|
// Create complete config with session token
|
|
51
54
|
const completeConfig: AmwalPayConfig = {
|
|
52
55
|
...config,
|
|
53
56
|
sessionToken
|
|
54
57
|
};
|
|
55
|
-
|
|
58
|
+
|
|
56
59
|
// Initiate the payment process
|
|
60
|
+
console.log('Initiating native payment with config:', JSON.stringify(completeConfig));
|
|
57
61
|
initiate(completeConfig);
|
|
58
62
|
} catch (error) {
|
|
59
63
|
console.error('Error starting payment:', error);
|
|
@@ -64,7 +68,7 @@ class AmwalPaySDK {
|
|
|
64
68
|
// Remove all event listeners
|
|
65
69
|
this.removeEventListeners();
|
|
66
70
|
}
|
|
67
|
-
|
|
71
|
+
|
|
68
72
|
/**
|
|
69
73
|
* Sets up event listeners for AmwalPay events
|
|
70
74
|
* @param config The payment configuration containing callback functions
|
|
@@ -72,7 +76,7 @@ class AmwalPaySDK {
|
|
|
72
76
|
private setupEventListeners(config: Omit<AmwalPayConfig, 'sessionToken'>): void {
|
|
73
77
|
// Remove any existing listeners
|
|
74
78
|
this.removeEventListeners();
|
|
75
|
-
|
|
79
|
+
|
|
76
80
|
this.onResponseSubscription = onResponse((response) => {
|
|
77
81
|
console.log('Received AmwalPayResponse:', response);
|
|
78
82
|
config.onResponse(response);
|
|
@@ -83,7 +87,7 @@ class AmwalPaySDK {
|
|
|
83
87
|
config.onCustomerId(customerId);
|
|
84
88
|
});
|
|
85
89
|
}
|
|
86
|
-
|
|
90
|
+
|
|
87
91
|
/**
|
|
88
92
|
* Removes all event listeners
|
|
89
93
|
*/
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import type { TurboModule } from 'react-native';
|
|
2
2
|
import { TurboModuleRegistry } from 'react-native';
|
|
3
|
-
import type { EventEmitter } from 'react-native/Libraries/Types/CodegenTypes';
|
|
4
3
|
|
|
5
4
|
export enum Environment {
|
|
6
5
|
SIT = 'SIT',
|
|
@@ -13,9 +12,9 @@ export enum Currency {
|
|
|
13
12
|
}
|
|
14
13
|
|
|
15
14
|
export enum TransactionType {
|
|
16
|
-
NFC= 'NFC'
|
|
17
|
-
CARD_WALLET= 'CARD_WALLET',
|
|
18
|
-
APPLE_PAY= 'APPLE_PAY'
|
|
15
|
+
NFC = 'NFC',
|
|
16
|
+
CARD_WALLET = 'CARD_WALLET',
|
|
17
|
+
APPLE_PAY = 'APPLE_PAY'
|
|
19
18
|
}
|
|
20
19
|
|
|
21
20
|
export interface AmwalPayResponse {
|
|
@@ -38,6 +37,7 @@ export interface AmwalPayConfig {
|
|
|
38
37
|
sessionToken?: string;
|
|
39
38
|
transactionId?: string;
|
|
40
39
|
additionValues?: { [key: string]: string };
|
|
40
|
+
merchantReference?: string;
|
|
41
41
|
onResponse: (response: AmwalPayResponse) => void;
|
|
42
42
|
onCustomerId: (customerId: string) => void;
|
|
43
43
|
}
|
|
@@ -56,13 +56,14 @@ export interface AmwalPayNativeConfig {
|
|
|
56
56
|
sessionToken?: string;
|
|
57
57
|
transactionId?: string;
|
|
58
58
|
additionValues?: { [key: string]: string };
|
|
59
|
+
merchantReference?: string;
|
|
59
60
|
}
|
|
60
61
|
|
|
61
62
|
export interface Spec extends TurboModule {
|
|
62
63
|
// Change the parameter type to AmwalPayNativeConfig
|
|
63
64
|
initiate(config: AmwalPayNativeConfig): void;
|
|
64
|
-
|
|
65
|
-
|
|
65
|
+
addListener(eventName: string): void;
|
|
66
|
+
removeListeners(count: number): void;
|
|
66
67
|
}
|
|
67
68
|
|
|
68
69
|
export default TurboModuleRegistry.getEnforcing<Spec>('ReactAmwalPay');
|
package/src/index.tsx
CHANGED
|
@@ -8,16 +8,20 @@ import ReactAmwalPay, {
|
|
|
8
8
|
} from './NativeReactAmwalPay';
|
|
9
9
|
import AmwalPaySDK from './AmwalPaySDK';
|
|
10
10
|
import { UuidUtil } from './utils/UuidUtil';
|
|
11
|
-
import
|
|
11
|
+
import {
|
|
12
|
+
NativeEventEmitter,
|
|
13
|
+
type EventSubscription,
|
|
14
|
+
} from 'react-native';
|
|
12
15
|
|
|
13
16
|
// Create an event emitter for the native module
|
|
17
|
+
const eventEmitter = new NativeEventEmitter(ReactAmwalPay as any);
|
|
14
18
|
|
|
15
19
|
export function initiate(config: AmwalPayConfig): void {
|
|
16
20
|
// Create default additionValues with merchantIdentifier for iOS if not provided
|
|
17
21
|
const defaultAdditionValues = {
|
|
18
22
|
merchantIdentifier: 'merchant.applepay.amwalpay',
|
|
19
23
|
};
|
|
20
|
-
|
|
24
|
+
|
|
21
25
|
const finalAdditionValues = {
|
|
22
26
|
...defaultAdditionValues,
|
|
23
27
|
...config.additionValues,
|
|
@@ -36,17 +40,18 @@ export function initiate(config: AmwalPayConfig): void {
|
|
|
36
40
|
sessionToken: config.sessionToken,
|
|
37
41
|
transactionId: config.transactionId ?? UuidUtil.generateTransactionId(),
|
|
38
42
|
additionValues: finalAdditionValues,
|
|
43
|
+
merchantReference: config.merchantReference,
|
|
39
44
|
};
|
|
40
45
|
|
|
41
46
|
// Call the native module
|
|
42
47
|
ReactAmwalPay.initiate(nativeConfig);
|
|
43
48
|
}
|
|
44
49
|
|
|
45
|
-
export function onResponse(callback: (response: AmwalPayResponse) => void):EventSubscription {
|
|
46
|
-
return
|
|
50
|
+
export function onResponse(callback: (response: AmwalPayResponse) => void): EventSubscription {
|
|
51
|
+
return eventEmitter.addListener('onResponse', callback);
|
|
47
52
|
}
|
|
48
|
-
export function onCustomerId(callback: (customerId: string) => void):EventSubscription {
|
|
49
|
-
return
|
|
53
|
+
export function onCustomerId(callback: (customerId: string) => void): EventSubscription {
|
|
54
|
+
return eventEmitter.addListener('onCustomerId', callback);
|
|
50
55
|
}
|
|
51
56
|
|
|
52
57
|
export {
|