import { G as GlobalConfig } from './vnpay-config.type-YW_Aqnnn.cjs';
export { E as EndpointConfig, V as VNPayConfig } from './vnpay-config.type-YW_Aqnnn.cjs';
import { VnpLocale, VnpCardType, VnpTransactionType, RefundTransactionType } from './enums.cjs';

type Bank = {
    /**
     * Mã ngân hàng
     *
     * @en Bank code
     */
    bank_code: string;
    /**
     * Tên ngân hàng
     *
     * @en Bank name
     */
    bank_name: string;
    /**
     * Đường dẫn logo của ngân hàng
     *
     * @en Logo link
     */
    logo_link: string;
    bank_type: number;
    display_order: number;
};

type DefaultConfig = Pick<GlobalConfig, 'vnp_Version' | 'vnp_CurrCode' | 'vnp_Command' | 'vnp_OrderType'> & {
    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 representing a logger function.
 * @template T - The type of data the logger function accepts.
 */
type LoggerFn<T> = (data: T) => void;
/**
 * Type representing logger data.
 * @template T - The type of the data object.
 */
type LoggerData<T extends object> = T & {
    /**
     * The method used for logging.
     */
    method: string;
};
/**
 * Type representing logger options.
 * @template T - The type of the data object.
 * @template Fields - The keys of the data object.
 */
type LoggerOptions<T, Fields extends keyof T> = {
    /**
     * The logger configuration, which can be one of three types:
     * - 'all': log all fields, optionally using a custom logger function.
     * - 'omit': omit certain fields from logging, optionally using a custom logger function.
     * - 'pick': log only certain fields, optionally using a custom logger function.
     */
    logger: {
        type?: 'all';
        /**
         * An optional custom logger function for logging all fields.
         */
        loggerFn?: LoggerFn<T>;
    } | {
        type: 'omit';
        fields: Fields[];
        /**
         * An optional custom logger function for logging all fields except those specified.
         */
        loggerFn?: LoggerFn<Omit<T, Fields>>;
    } | {
        type: 'pick';
        fields: Fields[];
        /**
         * An optional custom logger function for logging only the specified fields.
         */
        loggerFn?: LoggerFn<Pick<T, Fields>>;
    };
};

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<Fields extends keyof BuildPaymentUrlLogger> = {
    withHash?: boolean;
} & LoggerOptions<BuildPaymentUrlLogger, Fields>;
type GenerateQrResponse = {
    /**
     * Mã phản hồi từ VNPay
     * @en Response code from VNPay
     * @example '00'
     */
    code: string;
    /**
     * Thông báo kết quả giao dịch
     * @en Message of transaction result
     * @example 'Success'
     */
    message: string;
    /**
     * Nội dung QR code
     * @en QR code content
     * @example '000201010212...'
     */
    qrcontent: string;
};
type GenerateQrResponseLogger = LoggerData<{
    createdAt: Date;
    qrcontent?: string;
    qrcontentLength?: number;
} & Omit<GenerateQrResponse, 'qrcontent'>>;
type GenerateQrResponseOptions<Fields extends keyof GenerateQrResponseLogger> = LoggerOptions<GenerateQrResponseLogger, Fields>;

type ReturnQueryFromVNPay = Pick<BuildPaymentUrl, 'vnp_OrderInfo' | 'vnp_TxnRef'> & {
    /**
     * 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<BuildPaymentUrl, 'vnp_TxnRef' | 'vnp_OrderInfo' | 'vnp_CreateDate'> & Pick<ReturnQueryFromVNPay, 'vnp_TxnRef'>> & {
    /**
     * 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<BuildPaymentUrl, 'vnp_TxnRef' | 'vnp_Amount'> & {
    /**
     * 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<Fields extends keyof QueryDrResponseLogger> = {
    withHash?: boolean;
} & LoggerOptions<QueryDrResponseLogger, Fields>;

type Refund = Partial<Pick<QueryDr, 'vnp_TransactionNo'>> & Pick<QueryDr, 'vnp_RequestId' | 'vnp_TransactionDate' | 'vnp_IpAddr'> & Pick<BuildPaymentUrl, 'vnp_Amount' | 'vnp_OrderInfo' | 'vnp_TxnRef'> & Partial<Pick<BuildPaymentUrl, 'vnp_Locale'>> & {
    /**
     * 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<QueryDrResponseFromVNPay, 'vnp_TxnRef' | 'vnp_Amount' | 'vnp_ResponseCode' | 'vnp_Message' | 'vnp_BankCode' | 'vnp_PayDate' | 'vnp_TransactionNo' | 'vnp_TransactionType' | 'vnp_TransactionStatus' | 'vnp_SecureHash'> & {
    /**
     * 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<Fields extends keyof RefundResponseLogger> = LoggerOptions<RefundResponseLogger, Fields>;

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<Fields extends keyof VerifyReturnUrlLogger> = {
    withHash?: boolean;
} & LoggerOptions<VerifyReturnUrlLogger, Fields>;

type VerifyIpnCall = VerifyReturnUrl;
type VerifyIpnCallLogger = LoggerData<{
    createdAt: Date;
} & VerifyIpnCall>;
type VerifyIpnCallOptions<Fields extends keyof VerifyIpnCallLogger> = {
    withHash?: boolean;
} & LoggerOptions<VerifyIpnCallLogger, Fields>;

export { type Bank, type BodyRequestQueryDr, type BuildPaymentUrl, type BuildPaymentUrlLogger, type BuildPaymentUrlOptions, type DefaultConfig, type GenerateQrResponse, type GenerateQrResponseLogger, type GenerateQrResponseOptions, GlobalConfig, type LoggerData, type LoggerOptions, type QueryDr, type QueryDrResponse, type QueryDrResponseFromVNPay, type QueryDrResponseLogger, type QueryDrResponseOptions, type Refund, type RefundOptions, type RefundResponse, type RefundResponseFromVNPay, type RefundResponseLogger, type ResultVerified, type ReturnQueryFromVNPay, type VerifyIpnCall, type VerifyIpnCallLogger, type VerifyIpnCallOptions, type VerifyReturnUrl, type VerifyReturnUrlLogger, type VerifyReturnUrlOptions };
