React Native native module for PAX devices
npm install @haroldtran/react-native-pax

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.
Maintained and enhanced by @phattran1201
- š Initialize PAX device connection via TCP/IP
- š³ Process credit and debit card payments (Sale)
- š Handle voids (Void Sale)
- š Batch operations and settlement
- š Process refunds (Return)
- š± Android platform support (iOS implementation pending)
``sh`
yarn add @haroldtran/react-native-pax
ā ļø Note: iOS implementation is currently not complete. Only Android is fully supported at this time.
1. Navigate to your iOS project directory and install pods:
`sh`
cd ios && pod install
2. Make sure your iOS deployment target is 11.0 or higher in your Podfile:
`ruby`
platform :ios, '11.0'
The Android setup is automatic. The library will be linked automatically when you rebuild your project.
`js`
import {
initPOSLink,
makePayment,
makeRefund,
makeVoid,
makeCloseBatch
} from '@haroldtran/react-native-pax';
First, initialize the connection to your PAX device:
`js`
try {
const result = await initPOSLink('192.168.1.100'); // Pass the IP address of the POS device
console.log('PAX device initialized:', result);
} catch (error) {
console.error('Failed to initialize PAX device:', error);
}
`js
import { CreditTransactionType } from '@haroldtran/react-native-pax/lib/typescript/module/type';
try {
const paymentResult = await makePayment(
'txn-123', // id (optional)
1000, // amount in cents (e.g., 1000 = $10.00)
150, // tip in cents (optional, e.g., 150 = $1.50)
CreditTransactionType.Credit, // paymentType (1 = Credit, 2 = Debit)
'ECR123' // ecrRefNum (optional)
);
console.log('Payment result:', paymentResult);
// paymentResult contains:
// - status: boolean
// - isPaymentSuccess: boolean
// - cardHolder: string
// - cardNumber: string (masked)
// - refNum: string
// - transactionId: string
// - amount: string
// - tipAmount: string
// - cardType: string
// - entryMethod: string
// - and more transaction details
} catch (error) {
console.error('Payment failed:', error);
}
`
`js`
try {
const refundResult = await makeRefund({
amount: 1500 // amount in cents (e.g., 1500 = $15.00)
});
console.log('Refund result:', refundResult);
// refundResult is a PaxResponseModel object
} catch (error) {
console.error('Refund failed:', error);
}
`js`
try {
const voidResult = await makeVoid({
amount: 1500 // amount in cents (e.g., 1500 = $15.00)
});
console.log('Void result:', voidResult);
// voidResult is a PaxResponseModel object
} catch (error) {
console.error('Void failed:', error);
}
`js`
try {
const batchResult = await makeCloseBatch();
console.log('Batch close result:', batchResult);
// batchResult is a PaxResponseModel object
} catch (error) {
console.error('Batch close failed:', error);
}
#### initPOSLink(ip)
Initializes the connection to the PAX device.
Parameters:
- ip (string): Device IP address
Returns: Promise
#### makePayment(id?, amount, tip?, paymentType?, ecrRefNum?)
Initiates a payment transaction.
Parameters:
- id (string, optional): Transaction IDamount
- (number): Payment amount in cents (e.g., 1000 = $10.00)tip
- (number, optional): Tip amount in cents (e.g., 150 = $1.50)paymentType
- (number, optional): Type of payment (1 = Credit, 2 = Debit, see CreditTransactionType enum)ecrRefNum
- (string, optional): ECR reference number
Returns: Promise
#### makeRefund(data)
Initiates a refund transaction.
Parameters:
- data (object): Object containing:amount
- (number): The amount to refund in cents
Returns: Promise
#### makeVoid(data)
Voids a transaction for the given amount.
Parameters:
- data (object): Object containing:amount
- (number): The amount to void in cents
Returns: Promise
#### makeCloseBatch()
Closes the current batch of transactions.
Returns: Promise
The response object returned by all transaction functions. Key fields include:
Status & Result:
- status (boolean): Overall operation success statusisPaymentSuccess
- (boolean): Payment-specific success flagmessage
- (string): Response message or error description
Transaction Details:
- id (string): Transaction IDtransactionId
- (string): Global unique transaction identifiertransactionNo
- (string): Transaction sequence numberrefNum
- (string): Reference numbertransactionDateTime
- (string): Date/time of transaction
Card & Payment Info:
- cardType (string): Card type/brand (e.g., VISA, MASTERCARD)cardNumber
- (string): Masked card numbercardHolder
- (string): Card holder nameentryMethod
- (string): How card was entered (SWIPED_MSD, CONTACT_CHIP, CONTACTLESS_CHIP, etc.)
Amount Details:
- amount (string): Transaction amounttipAmount
- (string): Tip amountsurcharge
- (string): Additional fees/surcharge
Additional Data:
- data (object): Detailed response data including account info, trace info, AVS info, etc.sn
- (string): Serial number
Available payment types:
- CreditTransactionType.Credit (1): Credit card transactionCreditTransactionType.Debit
- (2): Debit card transactionCreditTransactionType.Empty
- (0): Not set/default
See src/type.ts` for the complete interface definition.
- React Native 0.63+
- Android API level 21+ (Full support)
- iOS 11.0+ (Limited support - implementation pending)
- PAX payment terminal with POSLink SDK support
- TCP/IP network connection to PAX terminal
| Feature | Android | iOS |
| --------------------- | ------- | --- |
| Initialize Connection | ā
| ā |
| Payment Processing | ā
| ā |
| Refunds | ā | ā |
| Voids | ā | ā |
| Batch Operations | ā | ā |
See the contributing guide to learn how to contribute to the repository and the development workflow.
MIT
For PAX device documentation and support, visit PAX Developer Portal.