import { L as LoggerData, a as LoggerOptions } from './logger.type-DB5EozMg.cjs'; /** * @see https://sandbox.vnpayment.vn/apis/docs/loai-hang-hoa/ */ declare enum ProductCode { Food_Consumption = "100000", Phone_Tablet = "110000", ElectricAppliance = "120000", Computers_OfficeEquipment = "130000", Electronics_Sound = "140000", Books_Newspapers_Magazines = "150000", Sports_Picnics = "160000", Hotel_Tourism = "170000", Cuisine = "180000", Entertainment_Training = "190000", Fashion = "200000", Health_Beauty = "210000", Mother_Baby = "220000", KitchenUtensils = "230000", Vehicle = "240000", Pay = "250000", AirlineTickets = "250007", CardCode = "260000", Pharmacy_MedicalServices = "270000", Other = "other" } declare enum UrlService { sandbox = "https://sandbox.vnpayment.vn/paymentv2/vpcpay.html" } declare enum HashAlgorithm { SHA256 = "SHA256", SHA512 = "SHA512", MD5 = "MD5" } declare enum VnpCurrCode { VND = "VND" } declare enum VnpLocale { VN = "vn", EN = "en" } declare enum VnpCardType { ATM = "ATM", QRCODE = "QRCODE" } declare enum VnpTransactionType { PAYMENT = "01", FULL_REFUND = "02", PARTIAL_REFUND = "03" } declare enum RefundTransactionType { FULL_REFUND = "02", PARTIAL_REFUND = "03" } /** * Endpoints configuration for VNPay API * Allows overriding individual endpoints when the API changes */ interface EndpointConfig { /** * Payment endpoint path - defaults to 'paymentv2/vpcpay.html' */ paymentEndpoint?: string; /** * Query DR and Refund endpoint - defaults to 'merchant_webapi/api/transaction' */ queryDrRefundEndpoint?: string; /** * Get bank list endpoint - defaults to 'qrpayauth/api/merchant/get_bank_list' */ getBankListEndpoint?: string; } /** * Strong typing for the configuration of VNPay */ interface VNPayConfig { /** * VNPay host URL - defaults to sandbox if not provided */ vnpayHost?: string; /** * queryDr and refund host URL - defaults to sandbox if not provided */ queryDrAndRefundHost?: string; /** * TMN Code provided by VNPay */ tmnCode: string; /** * Secure secret provided by VNPay */ secureSecret: string; /** * VNPay API version - defaults to 2.1.0 */ vnp_Version?: string; /** * Currency code - defaults to VND */ vnp_CurrCode?: VnpCurrCode; /** * Locale for messages - defaults to Vietnamese */ vnp_Locale?: VnpLocale; /** * Enable test mode (uses sandbox URL) */ testMode?: boolean; /** * Hash algorithm to use - defaults to SHA512 */ hashAlgorithm?: HashAlgorithm; /** * Enable logging */ enableLog?: boolean; /** * Custom logger function */ loggerFn?: (data: unknown) => void; /** * Default order type - defaults to "other" */ vnp_OrderType?: ProductCode; /** * Default command - defaults to "pay" */ vnp_Command?: string; /** * Payment endpoint path - defaults to standard VNPay endpoint * @deprecated Use endpoints.paymentEndpoint instead */ paymentEndpoint?: string; /** * Custom endpoint configuration * Use this to override individual endpoints when the VNPay API changes */ endpoints?: EndpointConfig; } interface GlobalConfig extends VNPayConfig { vnpayHost: string; queryDrAndRefundHost: string; vnp_Version: string; vnp_CurrCode: VnpCurrCode; vnp_Locale: VnpLocale; vnp_OrderType: ProductCode; vnp_Command: string; paymentEndpoint: string; endpoints: EndpointConfig; } type DefaultConfig = Pick & { vnp_TmnCode: string; vnp_Locale: VnpLocale; }; type ResultVerified = { /** * Trạng thái giao dịch * * @en Transaction status * @example true */ isSuccess: boolean; /** * Trạng thái xác nhận tính đúng đắn, toàn vẹn khi nhận dữ liệu từ VNPay * * @en Verification status, true when data from VNPay is correct and verified * @example true */ isVerified: boolean; /** * Tin nhắn thông báo * * @en Error message * @example 'Giao dịch thành công' */ message: string; }; type BuildPaymentUrl = { /** * Số tiền thanh toán. Đã tự động tính toán theo đơn vị của VNPay. (100 lần số tiền của đơn hàng trong cơ sở dữ liệu của bạn) * Bạn không cần tự nhân với 100 nữa, thư viện này sẽ tự nhân 100 khi build url * @en Amount of payment. Automatically calculated according to the unit of VNPay. (100 times the amount of the order in your database) * You don't need to multiply by 100 yourself, this library will multiply by 100 when building the URL */ vnp_Amount: number; /** * Thông tin mô tả nội dung thanh toán (Tiếng Việt, không dấu). * @en Description of payment (Vietnamese, no accent) * @example Thanh toan don hang 12345 */ vnp_OrderInfo: string; /** * Mã tham chiếu của giao dịch tại hệ thống của merchant. * Mã này là duy nhất dùng để phân biệt các đơn hàng gửi sang VNPAY. * Không được trùng lặp trong ngày. * * `Đơn giản hóa: ID đơn hàng ở database của bạn` * * @en Reference code of transaction on merchant system. This code is unique to distinguish orders sent to VNPAY. Not duplicated in a day. * @example 123456 */ vnp_TxnRef: string; /** * Địa chỉ IP của khách hàng thực hiện giao dịch * @en IP address of customer who make transaction * @example 13.160.92.202 */ vnp_IpAddr: string; /** * URL thông báo kết quả giao dịch khi Khách hàng kết thúc thanh toán. * @en URL to notify result of transaction when customer finish payment * @example * ```sh * https://vnpay.js.org/payment-return * ``` */ vnp_ReturnUrl: string; /** * Là thời gian phát sinh giao dịch, định dạng yyyyMMddHHmmss(Time zone GMT+7) * * Nếu `vnp_CreateDate` truyền vào không đúng định dạng, sẽ tự động lấy thời gian hiện tại * * @en Transaction date format yyyyMMddHHmmss(Time zone GMT+7) * * If `vnp_CreateDate` is not in the correct format, it will be the current time * @example 20170829103111 * @example * ```ts * import { dateFormat } from 'vnpay'; * * // then * vnp_CreateDate: dateFormat(new Date()), * ``` */ vnp_CreateDate?: number; /** * Thời gian hết hạn thanh toán, định dạng yyyyMMddHHmmss(Time zone GMT+7) * * @en Time of expiration of payment, format yyyyMMddHHmmss(Time zone GMT+7) * @example 20170829103111 * @example * ```ts * import { dateFormat } from 'vnpay'; * * const tomorrow = new Date(); * tomorrow.setDate(tomorrow.getDate() + 1); * * // then * vnp_CreateDate: dateFormat(tomorrow), * ``` */ vnp_ExpireDate?: number; /** * Đơn vị tiền tệ sử dụng thanh toán. Hiện tại chỉ hỗ trợ VND * @en Currency code using for payment. Currently only support VND * @example * ```ts * import { VnpCurrCode } from 'vnpay/enums'; * * // then * vnp_CurrCode: VnpCurrCode.VND, * ``` * */ vnp_CurrCode?: GlobalConfig['vnp_CurrCode']; /** * Ngôn ngữ giao diện hiển thị. Hiện tại hỗ trợ Tiếng Việt (vn), Tiếng Anh (en) * @en Language display on payment gateway. Currently support Vietnamese (vn), English (en) * @example * ```ts * import { VnpLocale } from 'vnpay/enums'; * * // then * vnp_Locale: VnpLocale.VN, * ``` */ vnp_Locale?: GlobalConfig['vnp_Locale']; /** * Loại đơn hàng/ Mã sản phẩm * @en Order type/ Product Code * @default 'other' * @enum {ProductCode} - [ProductCode] */ vnp_OrderType?: GlobalConfig['vnp_OrderType']; /** * Mã Ngân hàng thanh toán * @en Bank code * @example NCB */ vnp_BankCode?: string; }; type BuildPaymentUrlLogger = LoggerData<{ createdAt: Date; paymentUrl: string; } & DefaultConfig & BuildPaymentUrl>; type BuildPaymentUrlOptions = { withHash?: boolean; } & LoggerOptions; type ReturnQueryFromVNPay = Pick & { /** * Số tiền thanh toán * @en Payment amount */ vnp_Amount: number | string; /** * Mã tmn của đối tác * @en Merchant tmn code */ vnp_TmnCode?: string; /** * Mã Ngân hàng thanh toán * @en Bank code * @example NCB */ vnp_BankCode?: string; /** * Mã giao dịch tại Ngân hàng * @en Transaction code at bank * @example NCB20170829152730 */ vnp_BankTranNo?: string; /** * Loại tài khoản/thẻ khách hàng sử dụng:`ATM`,`QRCODE` * @en Type of customer account/card used: `ATM`, `QRCODE` * @example ATM */ vnp_CardType?: VnpCardType | string; /** * Thời gian thanh toán. Định dạng: yyyyMMddHHmmss * @en Payment time. Format: yyyyMMddHHmmss * @example 20170829152730 */ vnp_PayDate?: number | string; /** * Mã giao dịch ghi nhận tại hệ thống VNPAY. * @en Transaction code recorded in VNPAY system. * @example 20170829153052 */ vnp_TransactionNo?: number | string; /** * Mã phản hồi kết quả thanh toán. Quy định mã trả lời 00 ứng với kết quả Thành công cho tất cả các API. * @en Response code of payment result. The response code 00 corresponds to the Successful result for all APIs. * @example 00 * @see https://sandbox.vnpayment.vn/apis/docs/bang-ma-loi/ */ vnp_ResponseCode: number | string; /** * Mã phản hồi kết quả thanh toán. Tình trạng của giao dịch tại Cổng thanh toán VNPAY. * * -00: Giao dịch thanh toán được thực hiện thành công tại VNPAY * * -Khác 00: Giao dịch không thành công tại VNPAY * * @en Response code of payment result. Status of transaction at VNPAY payment gateway. * * -00: Payment transaction is successful at VNPAY * * -Other 00: Payment transaction is not successful at VNPAY * * @example 00 * @see https://sandbox.vnpayment.vn/apis/docs/bang-ma-loi/ */ vnp_TransactionStatus?: number | string; /** * Mã kiểu bảo mật sử dụng để tạo mã checksum. Mã này phụ thuộc vào cấu hình của merchant và phiên bản api sử dụng. * Phiên bản hiện tại hỗ trợ `SHA256`, `HMACSHA512`. * * @en Security type code used to create checksum code. This code depends on the configuration of the merchant and the version of the api used. * The current version supports `SHA256`, `HMACSHA512`. * @example HMACSHA512 */ vnp_SecureHashType?: string; /** * Mã kiểm tra (checksum) để đảm bảo dữ liệu của giao dịch không bị thay đổi trong quá trình chuyển từ merchant sang VNPAY. * Việc tạo ra mã này phụ thuộc vào cấu hình của merchant và phiên bản api sử dụng. Phiên bản hiện tại hỗ trợ `SHA256`, `HMACSHA512`. * * @en Checksum to ensure that the transaction data is not changed during the transfer from merchant to VNPAY. * The creation of this code depends on the configuration of the merchant and the version of the api used. The current version supports `SHA256`, `HMACSHA512`. * */ vnp_SecureHash?: string; }; type QueryDr = Required & Pick> & { /** * Mã hệ thống merchant tự sinh ứng với mỗi yêu cầu truy vấn giao dịch. * Mã này là duy nhất dùng để phân biệt các yêu cầu truy vấn giao dịch. Không được trùng lặp trong ngày. * @en Merchant system code automatically generated for each transaction query request. * This code is unique to distinguish transaction query requests. Not duplicated in a day. * */ vnp_RequestId: string; /** * Thời gian ghi nhận giao dịch tại hệ thống của merchant tính theo GMT+7, định dạng: yyyyMMddHHmmss, tham khảo giá trị: * - Thanh toán PAY giống vnp_CreateDate của vnp_Command=pay * - Thanh toán bằng mã Token giống "vnp_create_date" của "vnp_Command=pay_and_create" và "vnp_command=token_pay" * * @en Transaction time recorded at merchant system according to GMT + 7, format: yyyyMMddHHmmss, refer to value: * - PAY payment same as vnp_CreateDate of vnp_Command = pay * - Payment by Token code same as "vnp_create_date" of "vnp_Command = pay_and_create" and "vnp_command = token_pay" */ vnp_TransactionDate: number; /** * Địa chỉ IP của máy chủ thực hiện gọi API * @en IP address of the server that calls the API */ vnp_IpAddr: string; /** * Mã giao dịch ghi nhận tại hệ thống VNPAY. * @en Transaction code recorded in VNPAY system. * @example 20170829153052 */ vnp_TransactionNo: number; }; type BodyRequestQueryDr = QueryDr & { vnp_SecureHash: string; vnp_TmnCode: string; vnp_Command: string; vnp_Version: string; }; type QueryDrResponseFromVNPay = Pick & { /** * Mã phản hồi kết quả xử lý của API. * Quy định mã trả lời 00 ứng với yêu cầu được thực hiện thành công. * Tham khảo thêm tại bảng mã lỗi. * * @en * Response code of API * If the API is executed successfully, the value of the response code is 00. * To learn more about the response code, refer to the table below. */ vnp_ResponseCode: string | number; /** * Loại giao dịch tại hệ thống VNPAY */ vnp_Command: string; /** * Thời gian thực hiện */ vnp_PayDate: string | number; /** * Mô tả thông tin yêu cầu * * @en Description of request */ vnp_OrderInfo: string; /** * Tình trạng thanh toán của giao dịch tại Cổng thanh toán VNPAY. * * @en Status of transaction payment at VNPAY payment gateway. */ vnp_TransactionStatus: string | number; vnp_SecureHash: string; /** * Mã Ngân hàng hoặc mã Ví điện tử thanh toán * @en Bank code or account number * @example NCB */ vnp_BankCode: string; /** * Mã hệ thống VNPAY tự sinh ứng với mỗi yêu cầu truy vấn giao dịch. * Mã này là duy nhất dùng để phân biệt các yêu cầu truy vấn giao dịch. Không trùng lặp trong ngày. * @en VNPAY system code automatically generated for each transaction query request. * This code is unique to distinguish transaction query requests. Not duplicated in a day. */ vnp_ResponseId: string; /** * Mô tả thông tin tương ứng với vnp_ResponseCode * @en Description of information corresponding to vnp_ResponseCode */ vnp_Message: string; /** * Loại giao dịch tại hệ thống VNPAY: * - 01: GD thanh toán * - 02: Giao dịch hoàn trả toàn phần * - 03: Giao dịch hoàn trả một phần */ vnp_TransactionType: VnpTransactionType; /** * Mã khuyến mại. Trong trường hợp khách hàng áp dụng mã QR khuyến mãi khi thanh toán. * @en Promotion code. In case customers apply QR promotion code when paying. */ vnp_PromotionCode?: string; /** * Số tiền khuyến mại. Trong trường hợp khách hàng áp dụng mã QR khuyến mãi khi thanh toán. * @en Promotion amount. In case customers apply QR promotion code when paying. */ vnp_PromotionAmount?: number; vnp_TransactionNo?: number | string; }; type QueryDrResponse = QueryDrResponseFromVNPay & ResultVerified; type QueryDrResponseLogger = LoggerData<{ createdAt: Date; } & QueryDrResponse>; type QueryDrResponseOptions = { withHash?: boolean; } & LoggerOptions; type Refund = Partial> & Pick & Pick & Partial> & { /** * Loại giao dịch tại hệ thống VNPAY: * - `02`: Giao dịch hoàn trả toàn phần * - `03`: Giao dịch hoàn trả một phần * * @en: * Type of transaction at the VNPAY system: * - `02`: Full refund * - `03`: Partial refund */ vnp_TransactionType: RefundTransactionType | string; /** * Người khởi tạo hoàn tiền. Có thể là tên user thực hiện hoàn tiền của merchant. * * @en * The name of user who create the refund transaction of merchant. */ vnp_CreateBy: string; /** * Thời gian phát sinh yêu cầu hoàn tiền (GMT +7) * * @en Time of refund request (GMT +7) */ vnp_CreateDate: number; }; type RefundResponseFromVNPay = Pick & { /** * Mã hệ thống VNPAY tự sinh ứng với mỗi yêu cầu hoàn trả giao dịch. * Mã này là duy nhất dùng để phân biệt các yêu cầu hoàn trả giao dịch. * Không được trùng lặp trong ngày * * @en VNPAY system code automatically generated for each refund transaction request. * The system code is unique for each refund transaction request. * Not duplicated in a day. */ vnp_ResponseId: string; /** * Mã API sử dụng, mã cho giao dịch thanh toán là "refund" * * @en API code used for payment, the transaction code is "refund" */ vnp_Command: string; /** * Mã hệ thống VNPAY */ vnp_TmnCode: string; /** * Nội dung của yêu cầu hoàn tiền * * @en Content of the refund request */ vnp_OrderInfo: string; }; type RefundResponse = ResultVerified & RefundResponseFromVNPay; type RefundResponseLogger = LoggerData<{ createdAt: Date; } & RefundResponse>; type RefundOptions = LoggerOptions; type VerifyReturnUrl = { /** * Trạng thái giao dịch * @en Transaction status * @example true */ isSuccess: boolean; /** * Trạng thái xác nhận tính đúng đắn, toàn vẹn khi nhận dữ liệu từ VNPay * * @en Verification status, true when data from VNPay is correct and verified * @example true */ isVerified: boolean; /** * Thông báo lỗi * @en Error message * @example 'Giao dịch thành công' */ message: string; } & ReturnQueryFromVNPay; type VerifyReturnUrlLogger = LoggerData<{ createdAt: Date; } & VerifyReturnUrl>; type VerifyReturnUrlOptions = { withHash?: boolean; } & LoggerOptions; type VerifyIpnCall = VerifyReturnUrl; type VerifyIpnCallLogger = LoggerData<{ createdAt: Date; } & VerifyIpnCall>; type VerifyIpnCallOptions = { withHash?: boolean; } & LoggerOptions; export { type BuildPaymentUrlLogger as B, type DefaultConfig as D, type EndpointConfig as E, type GlobalConfig as G, HashAlgorithm as H, ProductCode as P, type QueryDrResponseLogger as Q, type ReturnQueryFromVNPay as R, UrlService as U, type VNPayConfig as V, type BuildPaymentUrl as a, type BuildPaymentUrlOptions as b, type VerifyReturnUrlLogger as c, type VerifyReturnUrlOptions as d, type VerifyReturnUrl as e, type VerifyIpnCallLogger as f, type VerifyIpnCallOptions as g, type VerifyIpnCall as h, type QueryDr as i, type QueryDrResponseOptions as j, type QueryDrResponse as k, type RefundResponseLogger as l, type Refund as m, type RefundOptions as n, type RefundResponse as o, VnpLocale as p, type BodyRequestQueryDr as q, type QueryDrResponseFromVNPay as r, type RefundResponseFromVNPay as s, RefundTransactionType as t, type ResultVerified as u, VnpCardType as v, VnpCurrCode as w, VnpTransactionType as x };