1.1.3 • Published 8 months ago
payostest v1.1.3
Here's a guide to integrating PayOS into your app
Step 1: Assure that you have installed the library
With Npm: npm install payostest With Yarn: yarn add payostest
Step 2: Import the library and initialize your PayOS
const payOS = require("payostest");
//You can use import instead
import payOS from "payostest";
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: "",
returnUrl: "",
});
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(234234);
Type:
{orderId: String | Number}
3. Confirm Webhook:
let result = await payosApi.confirmWebhook({ webhookUrl: "https://1589-14-241-231-139.ngrok-free.app/payment/payos_transfer_handler" });
Type:
{WebhookUrl: String}