$ npm install @tokoinofficial/t-chain-payment
$ yarn add @tokoinofficial/t-chain-payment
Sandbox mode (running on testnet)
import Payment from "@tokoinofficial/t-chain-payment";
Payment.init({ api_key: api-key, mode: 'sandbox' });
Production mode (running on mainnet)
import Payment from "@tokoinofficial/t-chain-payment";
Payment.init({ api_key: api-key });
api_key
is the public key. It will be generated in the cms of t-chain.
const params = {
amount: 1000,
notes: "order_id",
currency: "IDR",
};
Payment.deposit(params, callbackFunc);
Notes:
- currency : USD/IDR (default: USD)
- Support for VND as currency is coming soon
callbackFunc(res) {
const tnxHash = res.hash;
}
const params = {
amount: 1000,
notes: "order-123-456,
currency: "IDR",
};
Payment.deposit(params, (res) => {
this.transaction_hash = res.hash;
});
const params = {
amount: 1000,
notes: "order-123-456",
currency: "IDR",
};
Payment.generateQrCode(params).then((res) => {
this.qrCode = res;
});
Notes:
- currency : USD/IDR (default: USD)
- Support for VND as currency is coming soon
Next step:
- User use T-Wallet app to scan the QR Code.
- The merchant backend application will receive the transaction via
HookURL
when the payment is completed.
HookURL
: the URL that the merchant provides to T-Chain. It is set when creating a project or updating the account management page of T-Chain for merchants.
Data structure
sent via Hook URL :
{
"tnx_hash": string,
"deposit_address": string,
"deposit_id": string,
"offchain": string,
"notes": string,
"amount": string,
"type": string,
"status": string,
"deposited_at": string
}
status
is Pending
or Success
type
is Deposit
or withdraw