@meewmeew/payos-bun
Version:
The payOS library provides convenient access to the payOS API from applications written in server-side JavaScript.
126 lines (122 loc) • 3.62 kB
TypeScript
// Generated by dts-bundle-generator v9.5.1
export type CheckoutRequestType = {
orderCode: number;
amount: number;
description: string;
cancelUrl: string;
returnUrl: string;
signature?: string;
items?: {
name: string;
quantity: number;
price: number;
}[];
buyerName?: string;
buyerEmail?: string;
buyerPhone?: string;
buyerAddress?: string;
expiredAt?: number;
};
export type CheckoutResponseDataType = {
bin: string;
accountNumber: string;
accountName: string;
amount: number;
description: string;
orderCode: number;
paymentLinkId: string;
status: string;
checkoutUrl: string;
qrCode: string;
};
export type PaymentLinkDataType = {
id: string;
orderCode: number;
amount: number;
amountPaid: number;
amountRemaining: number;
status: string;
createdAt: string;
transactions: TransactionType[];
cancellationReason: string | null;
canceledAt: string | null;
};
export type TransactionType = {
reference: string;
amount: number;
accountNumber: string;
description: string;
transactionDateTime: string;
virtualAccountName: string | null;
virtualAccountNumber: string | null;
counterAccountBankId: string | null;
counterAccountBankName: string | null;
counterAccountName: string | null;
counterAccountNumber: string | null;
};
export type WebhookType = {
code: string;
desc: string;
data: WebhookDataType;
signature: string;
};
export type WebhookDataType = {
orderCode: number;
amount: number;
description: string;
accountNumber: string;
reference: string;
transactionDateTime: string;
paymentLinkId: string;
code: string;
desc: string;
counterAccountBankId?: string | null;
counterAccountBankName?: string | null;
counterAccountName?: string | null;
counterAccountNumber?: string | null;
virtualAccountName?: string | null;
virtualAccountNumber?: string | null;
};
export declare class PayOS {
private clientId;
private apiKey;
private checksumKey;
/**
* Create a payOS object to use payment channel methods. Credentials are fields provided after creating a payOS payment channel
* @param {string} clientId Client ID of the payOS payment channel
* @param {string} apiKey Api Key of the payOS payment channel
* @param {string} checksumKey Checksum Key of the payOS payment channel
*/
constructor(clientId: string, apiKey: string, checksumKey: string);
/**
* Create a payment link for the order data passed in the parameter
* @param {CheckoutRequestType} paymentData Payment data
*/
createPaymentLink(paymentData: CheckoutRequestType): Promise<CheckoutResponseDataType>;
/**
* Get payment information of an order that has created a payment link
* @param {number | string} orderId Order Id
*/
getPaymentLinkInformation(orderId: string | number): Promise<PaymentLinkDataType>;
/**
* Validate the Webhook URL of a payment channel and add or update the Webhook URL for that Payment Channel if successful.
* @param {string} webhookUrl Your Webhook URL
*/
confirmWebhook(webhookUrl: string): Promise<string>;
/**
* Cancel the payment link of the order
* @param {number | string} orderId Order ID
* @param {string} cancellationReason Reason for canceling payment link (optional)
*/
cancelPaymentLink(orderId: string | number, cancellationReason?: string): Promise<PaymentLinkDataType>;
/**
* Verify data received via webhook after payment
* @param webhookBody Request body received from webhook
* @return {WebhookDataType} Payment data if payment data is valid, otherwise returns null
*/
verifyWebhookData(webhookBody: WebhookType): WebhookDataType | null;
}
export {
PayOS as default,
};
export {};