flutterwave-rn-pos
v0.2.0
Published
Flutterwave POS React Native SDK
Downloads
4
Maintainers
Readme
Flutterwave React Native POS SDK
Flutterwave POS React Native SDK is the official library that makes it easier to carry out transaction related actions on pos terminals
Table of Contents
Installation
npm install flutterwave-rn-pos
or
yarn add flutterwave-rn-pos
Usage
Import the methods you want to use from the package in your JavaScript/TypeScript code:
import {
performKeyExchange,
performTransaction,
printReceipt,
performReprintAndEOD,
viewTransactionHistory,
} from 'flutterwave-rn-pos';
// key exchange
// ...
const result = await performTransaction(
200,
false,
['CARD', 'TRANSFER'],
'3.2.1'
);
Key Exchange
A key exchange is done to get the terminal parameters. This should be performed upon launch of your application before you start making transactions. To do this, follow the steps below:
const ParameterResponse = await performKeyExchange(
'Flutterwave',
'https://flutterwave.com/waveLogo.png'
);
The merchantName
represents a unique identifier for your business and customLogoUrl
is an optional parameter for your custom logo.
Transactions
To perform a transaction, you'll need the following parameters
Amount
shouldPrint
transactionTypes
and AppVersion
🚨 Note: The possible values for Transaction Types include: ‘CARD’, ‘TRANSFER’, ‘USSD’, ‘MOMO’, and ‘QR’.
const transactionResponse = await performTransaction(
200, // Amount
false, // Should Print
['CARD', 'TRANSFER'], // Transaction Types
'3.2.1' // App Version
);
Once the function is launched, the POS will take over and complete the card processing flow. When this is completed, the transaction details are returned as a json string.
Printing
To print a receipt, design your receipt such that each line represents an instance of the PrintField object. Add each line as a print field to a array. To do this, follow the steps below:
const printResponse = await printReceipt([
{
header: 'Flutterwave',
alignment: 'center',
textSize: 40,
bold: true,
},
{
header: 'RRN',
body: '1234567890',
bold: false,
alignment: 'left',
textSize: 30,
},
{
header: 'Amount',
body: '100.0',
bold: true,
alignment: 'center',
textSize: 30,
},
]);
When the terminal completes the printing process, A response is returned as a callback contain a json with the same pattern as the TransactionResponse but with the data field set to null.
Reprint And EOD
To reprint transactions and perform end of day actions, follow the steps below:
const reprint = await performReprintAndEOD();
The POS will take over and complete the process once the function is launched.
TRANSACTION HISTORY
To view all transactions that have been made on the POS device, follow the steps below:
const launchHistory = await viewTransactionHistory();
The POS will take over and complete the process once the function is launched.
Support
For additional assistance using this library, contact the developer experience (DX) team via email or on slack.
You can also follow us @FlutterwaveEng and let us know what you think 😊.
Contributing
See the contributing guide to learn how to contribute to the repository and the development workflow.
License
MIT
By contributing to the {{language}} library, you agree that your contributions will be licensed under its MIT license.
Copyright (c) Flutterwave Inc.