πŸ› οΈHow to use SDK

POS25 provides a fully supported Typescript, Python, and Mobile SDK.

To integrate with the function of SDK you have just defined the POS25 object

// Initialize client object
import POS25 from "pos25";
const posClient = new POS25("<Token>")

The token is used for authentication. You can get token from API to test this SDK

Get a list chain that POS25 supported

// Get a list chain that POS25 supported
const chains = await posClient.getChainsSuported()
console.log(chains)
// This is the result
/**
[
    {
        "name": "SCROLL",
        "chain_id": 534352,
        "logo": "https://s2.coinmarketcap.com/static/img/coins/64x64/26998.png"
    },
]
*/

Get a list of assets of the chain that POS25 supported

// Get a list assets of chain that POS25 supported
const assets = await posClient.getAssetsSuported("<chain_id:str>")
console.log(assets)
// This is the result
/**
 [
    {
        "asset": "USDT",
        "chain": "SCROLL",
        "chain_id": 534352,
        "decimal": 6,
        "logo": "https://s3.ap-southeast-1.amazonaws.com/static.atomsolution.vn/usdt.png"
    }
]
*/
const paymentData = await posClient.createPaymentLink(
    "<orderID: str>",
    "<amount: str>",
    "<asset: str>",
    "<chainID: int>",
    "<currency: str>",
    "<feeValue: str>",
    "<serialNumber: str>"
)
console.log(assets)
// This is the result
/**
{
    "qr_url": "https://app.pos25.app/qr-scan?&order_id=010001&contract_address=0x48736b8AC81E0fa279b571B25C698D631a4407A1&currency_address=0x55d398326f99059ff775485246999027b3197955&transaction_amount=0.001&act=DEPOSIT&chain_id=22222&decimal=6",
    "rate_usd": 23000,
    "expire_at": "04/11/2023 22:50:31"
}
*/

Payment with NFC

Note: The input of the function has an argument token. This token is the payment token that is created at the TRAM wallet and sent to POS device via NFC.

const payNFC = await posClient.payNFC(
    "<token: str>",
    "<amount: str>",
    "<orderID: str>"
    "<serialNumber: str>"
)
console.log(assets)
// This is the result
/**
True: if the transaction is executed successfully.
False: if having error happens when executing the transaction
*/

Additional information

Last updated