Documentation for using the @payos/node package
Step 1: Assure that you have installed the library
With Npm: npm install @payos/node
With Yarn: yarn add @payos/node
Step 2: Import the library and initialize your PayOS
const payOS = require("@payos/node");
const payosApi = new payOS.default({
clientId: "",
apiKey: "",
checksumKey: "",
});
import payOS from "@payos/node";
const payosApi = new payOS({
clientId: "",
apiKey: "",
checksumKey: "",
});
Don't forget to fill 3 field: clientId, apiKey and checksumKey from your payOS account.
Now, you can use
1. Create Payment Link:
let result = await payosApi.createPaymentLink({
orderCode: 234234,
amount: 1000,
description: "Thanh toan don hang",
items: [
{
name: "Mì tôm hảo hảo ly",
quantity: 1,
price: 1000,
},
],
cancelUrl: "https://your-domain.com",
returnUrl: "https://your-domain.com",
});
Type:
PaymentLinkType {
orderCode: number;
amount: number;
description: string;
items: { name: string; quantity: number; price: number }[];
cancelUrl: string;
returnUrl: string;
signature?: string;
buyerName?: string;
buyerEmail?: string;
buyerPhone?: string;
buyerAddress?: string;
}
2. Get Information of Payment:
let result = await payosApi.getInformationPayment(orderId);
let result = await payosApi.getInformationPayment(1234);
Type:
orderId: String | Number
3. Confirm Webhook:
let result = await payosApi.confirmWebhook({
webhookUrl: "https://your-domain.com/payment/payos_transfer_handler"
});
Type:
{ webhookUrl: String }