@haroldtran/react-native-pax 0.1.7
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/LICENSE +20 -0
- package/README.md +311 -0
- package/android/build.gradle +82 -0
- package/android/gradle.properties +5 -0
- package/android/libs/POSLink_Core.jar +0 -0
- package/android/src/main/AndroidManifest.xml +4 -0
- package/android/src/main/java/com/paxposlink/PaxPoslinkModule.java +355 -0
- package/android/src/main/java/com/paxposlink/PaxPoslinkPackage.java +28 -0
- package/ios/PaxPoslink.h +12 -0
- package/ios/PaxPoslink.mm +27 -0
- package/ios/PaxPoslink.xcodeproj/project.pbxproj +274 -0
- package/ios/PaxPoslink.xcodeproj/project.xcworkspace/contents.xcworkspacedata +4 -0
- package/lib/commonjs/index.js +48 -0
- package/lib/commonjs/index.js.map +1 -0
- package/lib/commonjs/package.json +1 -0
- package/lib/module/index.js +37 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/package.json +1 -0
- package/lib/typescript/commonjs/index.d.ts +9 -0
- package/lib/typescript/commonjs/index.d.ts.map +1 -0
- package/lib/typescript/commonjs/package.json +1 -0
- package/lib/typescript/module/index.d.ts +9 -0
- package/lib/typescript/module/index.d.ts.map +1 -0
- package/lib/typescript/module/package.json +1 -0
- package/package.json +185 -0
- package/react-native-pax-poslink.podspec +35 -0
- package/src/index.tsx +77 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2023 santinello
|
|
4
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
5
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
6
|
+
in the Software without restriction, including without limitation the rights
|
|
7
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
8
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
9
|
+
furnished to do so, subject to the following conditions:
|
|
10
|
+
|
|
11
|
+
The above copyright notice and this permission notice shall be included in all
|
|
12
|
+
copies or substantial portions of the Software.
|
|
13
|
+
|
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
15
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
16
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
17
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
18
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
19
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
20
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,311 @@
|
|
|
1
|
+
# @haroldtran/react-native-pax
|
|
2
|
+
|
|
3
|
+
[](https://badge.fury.io/js/%40haroldtran%2Freact-native-pax)
|
|
4
|
+
[](https://opensource.org/licenses/MIT)
|
|
5
|
+
|
|
6
|
+
React Native library to integrate with PAX payment devices using the POSLink SDK. This library provides a bridge between React Native applications and PAX payment terminals for processing various payment transactions.
|
|
7
|
+
|
|
8
|
+
**Maintained and enhanced by [@phattran1201](https://github.com/phattran1201)**
|
|
9
|
+
|
|
10
|
+
## Features
|
|
11
|
+
|
|
12
|
+
- 🔄 Initialize PAX device connection
|
|
13
|
+
- 💳 Process credit card payments (Sale, Auth, Post-Auth)
|
|
14
|
+
- 🔄 Handle transaction adjustments and voids
|
|
15
|
+
- 📊 Batch operations and settlement
|
|
16
|
+
- 🔙 Process returns and refunds
|
|
17
|
+
- 📱 Support for both iOS and Android platforms
|
|
18
|
+
|
|
19
|
+
## Installation
|
|
20
|
+
|
|
21
|
+
```sh
|
|
22
|
+
npm install @haroldtran/react-native-pax
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
or with yarn:
|
|
26
|
+
|
|
27
|
+
```sh
|
|
28
|
+
yarn add @haroldtran/react-native-pax
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
### iOS Setup
|
|
32
|
+
|
|
33
|
+
1. Navigate to your iOS project directory and install pods:
|
|
34
|
+
```sh
|
|
35
|
+
cd ios && pod install
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
2. Make sure your iOS deployment target is 11.0 or higher in your `Podfile`:
|
|
39
|
+
```ruby
|
|
40
|
+
platform :ios, '11.0'
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
### Android Setup
|
|
44
|
+
|
|
45
|
+
The Android setup is automatic. The library will be linked automatically when you rebuild your project.
|
|
46
|
+
|
|
47
|
+
## Usage
|
|
48
|
+
|
|
49
|
+
### Import the library
|
|
50
|
+
|
|
51
|
+
```js
|
|
52
|
+
import {
|
|
53
|
+
initPOSLink,
|
|
54
|
+
makePayment,
|
|
55
|
+
makeAuth,
|
|
56
|
+
makePostAuth,
|
|
57
|
+
makeReturn,
|
|
58
|
+
makeAdjustment,
|
|
59
|
+
voidTransaction,
|
|
60
|
+
closeBatch
|
|
61
|
+
} from '@haroldtran/react-native-pax';
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
### Initialize Connection
|
|
65
|
+
|
|
66
|
+
First, initialize the connection to your PAX device:
|
|
67
|
+
|
|
68
|
+
```js
|
|
69
|
+
try {
|
|
70
|
+
const success = await initPOSLink(
|
|
71
|
+
'TCP', // Connection type: 'UART', 'TCP', 'SSL', 'HTTP', 'HTTPS', 'BLUETOOTH', 'USB', 'AIDL'
|
|
72
|
+
'30000', // Timeout in milliseconds
|
|
73
|
+
false, // Use proxy
|
|
74
|
+
'192.168.1.100', // Device IP (for TCP/IP connections)
|
|
75
|
+
'10009' // Port number
|
|
76
|
+
);
|
|
77
|
+
|
|
78
|
+
if (success) {
|
|
79
|
+
console.log('PAX device initialized successfully');
|
|
80
|
+
}
|
|
81
|
+
} catch (error) {
|
|
82
|
+
console.error('Failed to initialize PAX device:', error);
|
|
83
|
+
}
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
### Process a Payment
|
|
87
|
+
|
|
88
|
+
```js
|
|
89
|
+
try {
|
|
90
|
+
const result = await makePayment('10.00', '1.50'); // amount, tip
|
|
91
|
+
console.log('Payment result:', result);
|
|
92
|
+
|
|
93
|
+
// Result contains transaction details like:
|
|
94
|
+
// - AuthCode
|
|
95
|
+
// - RefNum
|
|
96
|
+
// - ApprovedAmount
|
|
97
|
+
// - CardType
|
|
98
|
+
// - MaskedPAN
|
|
99
|
+
// etc.
|
|
100
|
+
} catch (error) {
|
|
101
|
+
console.error('Payment failed:', error);
|
|
102
|
+
}
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
### Authorization Only
|
|
106
|
+
|
|
107
|
+
```js
|
|
108
|
+
try {
|
|
109
|
+
const result = await makeAuth('25.00');
|
|
110
|
+
console.log('Authorization result:', result);
|
|
111
|
+
} catch (error) {
|
|
112
|
+
console.error('Authorization failed:', error);
|
|
113
|
+
}
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
### Post Authorization (Capture)
|
|
117
|
+
|
|
118
|
+
```js
|
|
119
|
+
try {
|
|
120
|
+
const result = await makePostAuth(
|
|
121
|
+
'25.00', // amount
|
|
122
|
+
'REF123456', // original reference number
|
|
123
|
+
'AUTH123' // authorization code
|
|
124
|
+
);
|
|
125
|
+
console.log('Post-auth result:', result);
|
|
126
|
+
} catch (error) {
|
|
127
|
+
console.error('Post-auth failed:', error);
|
|
128
|
+
}
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
### Process a Return
|
|
132
|
+
|
|
133
|
+
```js
|
|
134
|
+
try {
|
|
135
|
+
const result = await makeReturn('15.00');
|
|
136
|
+
console.log('Return result:', result);
|
|
137
|
+
} catch (error) {
|
|
138
|
+
console.error('Return failed:', error);
|
|
139
|
+
}
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
### Void a Transaction
|
|
143
|
+
|
|
144
|
+
```js
|
|
145
|
+
try {
|
|
146
|
+
const result = await voidTransaction(
|
|
147
|
+
'REF123456', // original reference number
|
|
148
|
+
'AUTH123' // authorization code
|
|
149
|
+
);
|
|
150
|
+
console.log('Void result:', result);
|
|
151
|
+
} catch (error) {
|
|
152
|
+
console.error('Void failed:', error);
|
|
153
|
+
}
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
### Adjust a Transaction
|
|
157
|
+
|
|
158
|
+
```js
|
|
159
|
+
try {
|
|
160
|
+
const result = await makeAdjustment(
|
|
161
|
+
'12.50', // new amount
|
|
162
|
+
'REF123456' // original reference number
|
|
163
|
+
);
|
|
164
|
+
console.log('Adjustment result:', result);
|
|
165
|
+
} catch (error) {
|
|
166
|
+
console.error('Adjustment failed:', error);
|
|
167
|
+
}
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
### Close Batch
|
|
171
|
+
|
|
172
|
+
```js
|
|
173
|
+
try {
|
|
174
|
+
const result = await closeBatch();
|
|
175
|
+
console.log('Batch close result:', result);
|
|
176
|
+
|
|
177
|
+
// Result contains batch summary:
|
|
178
|
+
// - BatchNum
|
|
179
|
+
// - CreditCount, CreditAmount
|
|
180
|
+
// - DebitCount, DebitAmount
|
|
181
|
+
// etc.
|
|
182
|
+
} catch (error) {
|
|
183
|
+
console.error('Batch close failed:', error);
|
|
184
|
+
}
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
## API Reference
|
|
188
|
+
|
|
189
|
+
### initPOSLink(type, timeout, proxy, ip?, port?)
|
|
190
|
+
|
|
191
|
+
Initializes the connection to the PAX device.
|
|
192
|
+
|
|
193
|
+
**Parameters:**
|
|
194
|
+
- `type` (string): Connection type - 'UART', 'TCP', 'SSL', 'HTTP', 'HTTPS', 'BLUETOOTH', 'USB', 'AIDL'
|
|
195
|
+
- `timeout` (string): Timeout in milliseconds
|
|
196
|
+
- `proxy` (boolean): Whether to use proxy
|
|
197
|
+
- `ip` (string, optional): Device IP address (for network connections)
|
|
198
|
+
- `port` (string, optional): Port number (for network connections)
|
|
199
|
+
|
|
200
|
+
**Returns:** `Promise<boolean>`
|
|
201
|
+
|
|
202
|
+
### makePayment(amount, tip?)
|
|
203
|
+
|
|
204
|
+
Processes a sale transaction.
|
|
205
|
+
|
|
206
|
+
**Parameters:**
|
|
207
|
+
- `amount` (string): Transaction amount
|
|
208
|
+
- `tip` (string, optional): Tip amount (default: "0")
|
|
209
|
+
|
|
210
|
+
**Returns:** `Promise<PaymentResponse>`
|
|
211
|
+
|
|
212
|
+
### makeAuth(amount)
|
|
213
|
+
|
|
214
|
+
Processes an authorization-only transaction.
|
|
215
|
+
|
|
216
|
+
**Parameters:**
|
|
217
|
+
- `amount` (string): Authorization amount
|
|
218
|
+
|
|
219
|
+
**Returns:** `Promise<PaymentResponse>`
|
|
220
|
+
|
|
221
|
+
### makePostAuth(amount, refNum, authCode)
|
|
222
|
+
|
|
223
|
+
Captures a previously authorized transaction.
|
|
224
|
+
|
|
225
|
+
**Parameters:**
|
|
226
|
+
- `amount` (string): Capture amount
|
|
227
|
+
- `refNum` (string): Original reference number
|
|
228
|
+
- `authCode` (string): Authorization code
|
|
229
|
+
|
|
230
|
+
**Returns:** `Promise<PaymentResponse>`
|
|
231
|
+
|
|
232
|
+
### makeReturn(amount)
|
|
233
|
+
|
|
234
|
+
Processes a return transaction.
|
|
235
|
+
|
|
236
|
+
**Parameters:**
|
|
237
|
+
- `amount` (string): Return amount
|
|
238
|
+
|
|
239
|
+
**Returns:** `Promise<PaymentResponse>`
|
|
240
|
+
|
|
241
|
+
### makeAdjustment(amount, refNum)
|
|
242
|
+
|
|
243
|
+
Adjusts a previous transaction amount.
|
|
244
|
+
|
|
245
|
+
**Parameters:**
|
|
246
|
+
- `amount` (string): New amount
|
|
247
|
+
- `refNum` (string): Original reference number
|
|
248
|
+
|
|
249
|
+
**Returns:** `Promise<PaymentResponse>`
|
|
250
|
+
|
|
251
|
+
### voidTransaction(refNum, authCode)
|
|
252
|
+
|
|
253
|
+
Voids a previous transaction.
|
|
254
|
+
|
|
255
|
+
**Parameters:**
|
|
256
|
+
- `refNum` (string): Original reference number
|
|
257
|
+
- `authCode` (string): Authorization code
|
|
258
|
+
|
|
259
|
+
**Returns:** `Promise<PaymentResponse>`
|
|
260
|
+
|
|
261
|
+
### closeBatch()
|
|
262
|
+
|
|
263
|
+
Closes the current batch and settles transactions.
|
|
264
|
+
|
|
265
|
+
**Returns:** `Promise<BatchResponse>`
|
|
266
|
+
|
|
267
|
+
## Response Objects
|
|
268
|
+
|
|
269
|
+
### PaymentResponse
|
|
270
|
+
|
|
271
|
+
Contains transaction details including:
|
|
272
|
+
- `AuthCode`: Authorization code
|
|
273
|
+
- `RefNum`: Reference number
|
|
274
|
+
- `ApprovedAmount`: Approved amount
|
|
275
|
+
- `CardType`: Type of card used
|
|
276
|
+
- `MaskedPAN`: Masked card number
|
|
277
|
+
- `ResultCode`: Transaction result code
|
|
278
|
+
- `ResultTxt`: Result description
|
|
279
|
+
- And many more fields...
|
|
280
|
+
|
|
281
|
+
### BatchResponse
|
|
282
|
+
|
|
283
|
+
Contains batch settlement details including:
|
|
284
|
+
- `BatchNum`: Batch number
|
|
285
|
+
- `CreditCount` / `CreditAmount`: Credit transaction totals
|
|
286
|
+
- `DebitCount` / `DebitAmount`: Debit transaction totals
|
|
287
|
+
- `ResultCode`: Batch result code
|
|
288
|
+
- And more batch summary fields...
|
|
289
|
+
|
|
290
|
+
## Requirements
|
|
291
|
+
|
|
292
|
+
- React Native 0.63+
|
|
293
|
+
- iOS 11.0+
|
|
294
|
+
- Android API level 21+
|
|
295
|
+
- PAX payment terminal with POSLink SDK support
|
|
296
|
+
|
|
297
|
+
## Contributing
|
|
298
|
+
|
|
299
|
+
See the [contributing guide](CONTRIBUTING.md) to learn how to contribute to the repository and the development workflow.
|
|
300
|
+
|
|
301
|
+
## License
|
|
302
|
+
|
|
303
|
+
MIT
|
|
304
|
+
|
|
305
|
+
## Support
|
|
306
|
+
|
|
307
|
+
For PAX device documentation and support, visit [PAX Developer Portal](https://developer.pax.us).
|
|
308
|
+
|
|
309
|
+
---
|
|
310
|
+
|
|
311
|
+
Made with [create-react-native-library](https://github.com/callstack/react-native-builder-bob)
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
buildscript {
|
|
2
|
+
repositories {
|
|
3
|
+
google()
|
|
4
|
+
mavenCentral()
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
dependencies {
|
|
8
|
+
classpath "com.android.tools.build:gradle:7.2.1"
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
def isNewArchitectureEnabled() {
|
|
13
|
+
return rootProject.hasProperty("newArchEnabled") && rootProject.getProperty("newArchEnabled") == "true"
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
apply plugin: "com.android.library"
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
def appProject = rootProject.allprojects.find { it.plugins.hasPlugin('com.android.application') }
|
|
20
|
+
|
|
21
|
+
if (isNewArchitectureEnabled()) {
|
|
22
|
+
apply plugin: "com.facebook.react"
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
def getExtOrDefault(name) {
|
|
26
|
+
return rootProject.ext.has(name) ? rootProject.ext.get(name) : project.properties["PaxPoslink_" + name]
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
def getExtOrIntegerDefault(name) {
|
|
30
|
+
return rootProject.ext.has(name) ? rootProject.ext.get(name) : (project.properties["PaxPoslink_" + name]).toInteger()
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
android {
|
|
34
|
+
compileSdkVersion getExtOrIntegerDefault("compileSdkVersion")
|
|
35
|
+
|
|
36
|
+
defaultConfig {
|
|
37
|
+
minSdkVersion getExtOrIntegerDefault("minSdkVersion")
|
|
38
|
+
targetSdkVersion getExtOrIntegerDefault("targetSdkVersion")
|
|
39
|
+
buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled().toString()
|
|
40
|
+
}
|
|
41
|
+
buildTypes {
|
|
42
|
+
release {
|
|
43
|
+
minifyEnabled false
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
lintOptions {
|
|
48
|
+
disable "GradleCompatible"
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
compileOptions {
|
|
52
|
+
sourceCompatibility JavaVersion.VERSION_1_8
|
|
53
|
+
targetCompatibility JavaVersion.VERSION_1_8
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
repositories {
|
|
59
|
+
mavenCentral()
|
|
60
|
+
google()
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
dependencies {
|
|
65
|
+
// For < 0.71, this will be from the local maven repo
|
|
66
|
+
// For > 0.71, this will be replaced by `com.facebook.react:react-android:$version` by react gradle plugin
|
|
67
|
+
//noinspection GradleDynamicVersion
|
|
68
|
+
implementation "com.facebook.react:react-native:+"
|
|
69
|
+
|
|
70
|
+
//! https://developer.pax.us/resources/section/250038301709316096?sectionName=POSLink%202&articleId=352771637260593152
|
|
71
|
+
//! POSLink_Core_Android_V2.00.07_20240914
|
|
72
|
+
//! https://developer.pax.us/api/v1/files/314390436447793152/download/private#POSLink_Semi_Integration_Java_Android_V2.01.00_20240914.zip
|
|
73
|
+
implementation files('libs/POSLink_Core.jar')
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
if (isNewArchitectureEnabled()) {
|
|
77
|
+
react {
|
|
78
|
+
jsRootDir = file("../src/")
|
|
79
|
+
libraryName = "PaxPoslink"
|
|
80
|
+
codegenJavaPackageName = "com.paxposlink"
|
|
81
|
+
}
|
|
82
|
+
}
|
|
Binary file
|