UNPKG

vnpay

Version:

An open-source nodejs library support to payment with VNPay

741 lines (734 loc) 27.2 kB
'use strict'; var chunkEYO267YS_cjs = require('./chunk-EYO267YS.cjs'); var chunkWTHM33JV_cjs = require('./chunk-WTHM33JV.cjs'); var chunkJGUV45TP_cjs = require('./chunk-JGUV45TP.cjs'); var chunkUOEGPC4B_cjs = require('./chunk-UOEGPC4B.cjs'); // src/services/logger.service.ts var _LoggerService = class _LoggerService { /** * Khởi tạo dịch vụ logger * @en Initialize logger service * * @param isEnabled - Cho phép log hay không * @en @param isEnabled - Enable logging or not * * @param customLoggerFn - Hàm logger tùy chỉnh * @en @param customLoggerFn - Custom logger function */ constructor(isEnabled = false, customLoggerFn) { this.isEnabled = false; this.loggerFn = chunkWTHM33JV_cjs.ignoreLogger; this.isEnabled = isEnabled; this.loggerFn = customLoggerFn || (isEnabled ? chunkWTHM33JV_cjs.consoleLogger : chunkWTHM33JV_cjs.ignoreLogger); } /** * Ghi log dữ liệu * @en Log data * * @param data - Dữ liệu cần log * @en @param data - Data to log * * @param options - Tùy chọn log * @en @param options - Logging options * * @param methodName - Tên phương thức gọi log * @en @param methodName - Method name that calls the log */ log(data, options, methodName) { if (!this.isEnabled) return; const logData = { ...data }; if (methodName) { Object.assign(logData, { method: methodName, createdAt: /* @__PURE__ */ new Date() }); } if (options?.logger && "fields" in options.logger) { const { type, fields } = options.logger; for (const key of Object.keys(logData)) { const keyAssert = key; if (type === "omit" && fields.includes(keyAssert) || type === "pick" && !fields.includes(keyAssert)) { delete logData[keyAssert]; } } } (options?.logger?.loggerFn || this.loggerFn)(logData); } }; chunkUOEGPC4B_cjs.__name(_LoggerService, "LoggerService"); var LoggerService = _LoggerService; // src/services/payment.service.ts var _PaymentService = class _PaymentService { /** * Khởi tạo dịch vụ thanh toán * @en Initialize payment service * * @param config - Cấu hình VNPay * @en @param config - VNPay configuration * * @param logger - Dịch vụ logger * @en @param logger - Logger service * * @param hashAlgorithm - Thuật toán băm * @en @param hashAlgorithm - Hash algorithm */ constructor(config, logger, hashAlgorithm) { this.bufferEncode = "utf-8"; this.config = config; this.hashAlgorithm = hashAlgorithm; this.logger = logger; this.defaultConfig = { vnp_TmnCode: config.tmnCode, vnp_Version: config.vnp_Version, vnp_CurrCode: config.vnp_CurrCode, vnp_Locale: config.vnp_Locale, vnp_Command: config.vnp_Command, vnp_OrderType: config.vnp_OrderType }; } /** * Phương thức xây dựng, tạo thành url thanh toán của VNPay * @en Build the payment url * * @param {BuildPaymentUrl} data - Thông tin thanh toán * @en @param {BuildPaymentUrl} data - Payment information * * @param {BuildPaymentUrlOptions<LoggerFields>} options - Tùy chọn * @en @param {BuildPaymentUrlOptions<LoggerFields>} options - Options * * @returns {string} - URL thanh toán * @en @returns {string} - Payment URL */ buildPaymentUrl(data, options) { const dataToBuild = { ...this.defaultConfig, ...data, // Multiply by 100 to follow VNPay standard vnp_Amount: data.vnp_Amount * 100 }; if (dataToBuild?.vnp_ExpireDate && !chunkWTHM33JV_cjs.isValidVnpayDateFormat(dataToBuild.vnp_ExpireDate)) { throw new Error( "Invalid vnp_ExpireDate format. Use `dateFormat` utility function to format it" ); } if (!chunkWTHM33JV_cjs.isValidVnpayDateFormat(dataToBuild?.vnp_CreateDate ?? 0)) { const timeGMT7 = chunkWTHM33JV_cjs.getDateInGMT7(); dataToBuild.vnp_CreateDate = chunkWTHM33JV_cjs.dateFormat(timeGMT7, "yyyyMMddHHmmss"); } const redirectUrl = chunkWTHM33JV_cjs.createPaymentUrl({ config: this.config, data: dataToBuild }); const signed = chunkWTHM33JV_cjs.calculateSecureHash({ secureSecret: this.config.secureSecret, data: redirectUrl.search.slice(1).toString(), hashAlgorithm: this.hashAlgorithm, bufferEncode: this.bufferEncode }); redirectUrl.searchParams.append("vnp_SecureHash", signed); const data2Log = { createdAt: /* @__PURE__ */ new Date(), method: "buildPaymentUrl", paymentUrl: options?.withHash ? redirectUrl.toString() : (() => { const cloneUrl = new URL(redirectUrl.toString()); cloneUrl.searchParams.delete("vnp_SecureHash"); return cloneUrl.toString(); })(), ...dataToBuild }; this.logger.log(data2Log, options, "buildPaymentUrl"); return redirectUrl.toString(); } }; chunkUOEGPC4B_cjs.__name(_PaymentService, "PaymentService"); var PaymentService = _PaymentService; // src/services/query.service.ts var _QueryService = class _QueryService { /** * Khởi tạo dịch vụ truy vấn * @en Initialize query service * * @param config - Cấu hình VNPay * @en @param config - VNPay configuration * * @param logger - Dịch vụ logger * @en @param logger - Logger service * * @param hashAlgorithm - Thuật toán băm * @en @param hashAlgorithm - Hash algorithm */ constructor(config, logger, hashAlgorithm) { this.bufferEncode = "utf-8"; this.config = config; this.logger = logger; this.hashAlgorithm = hashAlgorithm; } /** * Đây là API để hệ thống merchant truy vấn kết quả thanh toán của giao dịch tại hệ thống VNPAY. * @en This is the API for the merchant system to query the payment result of the transaction at the VNPAY system. * * @param {QueryDr} query - Dữ liệu truy vấn kết quả thanh toán * @en @param {QueryDr} query - The data to query payment result * * @param {QueryDrResponseOptions<LoggerFields>} options - Tùy chọn * @en @param {QueryDrResponseOptions<LoggerFields>} options - Options * * @returns {Promise<QueryDrResponse>} Kết quả truy vấn * @en @returns {Promise<QueryDrResponse>} The query result */ async queryDr(query, options) { const command = "querydr"; const dataQuery = { vnp_Version: this.config.vnp_Version ?? chunkEYO267YS_cjs.VNP_VERSION, ...query }; const queryEndpoint = this.config.endpoints.queryDrRefundEndpoint || chunkEYO267YS_cjs.QUERY_DR_REFUND_ENDPOINT; const url = new URL( chunkWTHM33JV_cjs.resolveUrlString( this.config.queryDrAndRefundHost || this.config.vnpayHost, queryEndpoint ) ); const stringToCreateHash = [ dataQuery.vnp_RequestId, dataQuery.vnp_Version, command, this.config.tmnCode, dataQuery.vnp_TxnRef, dataQuery.vnp_TransactionDate, dataQuery.vnp_CreateDate, dataQuery.vnp_IpAddr, dataQuery.vnp_OrderInfo ].map(String).join("|").replace(/undefined/g, ""); const requestHashed = chunkWTHM33JV_cjs.hash( this.config.secureSecret, Buffer.from(stringToCreateHash, this.bufferEncode), this.hashAlgorithm ); const body = { ...dataQuery, vnp_Command: command, vnp_TmnCode: this.config.tmnCode, vnp_SecureHash: requestHashed }; const response = await fetch(url.toString(), { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify(body) }); if (!response.ok) { throw new Error(`HTTP error! status: ${response.status}`); } const responseData = await response.json(); const message = chunkWTHM33JV_cjs.getResponseByStatusCode( responseData.vnp_ResponseCode?.toString() ?? "", this.config.vnp_Locale, chunkJGUV45TP_cjs.QUERY_DR_RESPONSE_MAP ); let outputResults = { isVerified: true, isSuccess: responseData.vnp_ResponseCode === "00" || responseData.vnp_ResponseCode === 0, message, ...responseData, vnp_Message: message }; const stringToCreateHashOfResponse = [ responseData.vnp_ResponseId, responseData.vnp_Command, responseData.vnp_ResponseCode, responseData.vnp_Message, this.config.tmnCode, responseData.vnp_TxnRef, responseData.vnp_Amount, responseData.vnp_BankCode, responseData.vnp_PayDate, responseData.vnp_TransactionNo, responseData.vnp_TransactionType, responseData.vnp_TransactionStatus, responseData.vnp_OrderInfo, responseData.vnp_PromotionCode, responseData.vnp_PromotionAmount ].map(String).join("|").replace(/undefined/g, ""); const responseHashed = chunkWTHM33JV_cjs.hash( this.config.secureSecret, Buffer.from(stringToCreateHashOfResponse, this.bufferEncode), this.hashAlgorithm ); if (responseData?.vnp_SecureHash && responseHashed !== responseData.vnp_SecureHash) { outputResults = { ...outputResults, isVerified: false, message: chunkWTHM33JV_cjs.getResponseByStatusCode( chunkJGUV45TP_cjs.WRONG_CHECKSUM_KEY, this.config.vnp_Locale, chunkJGUV45TP_cjs.QUERY_DR_RESPONSE_MAP ) }; } const data2Log = { createdAt: /* @__PURE__ */ new Date(), method: "queryDr", ...outputResults }; this.logger.log(data2Log, options, "queryDr"); return outputResults; } /** * Đây là API để hệ thống merchant gửi yêu cầu hoàn tiền cho giao dịch qua hệ thống Cổng thanh toán VNPAY. * @en This is the API for the merchant system to refund the transaction at the VNPAY system. * * @param {Refund} data - Dữ liệu yêu cầu hoàn tiền * @en @param {Refund} data - The data to request refund * * @param {RefundOptions<LoggerFields>} options - Tùy chọn * @en @param {RefundOptions<LoggerFields>} options - Options * * @returns {Promise<RefundResponse>} Kết quả hoàn tiền * @en @returns {Promise<RefundResponse>} The refund result */ async refund(data, options) { const vnp_Command = "refund"; const DEFAULT_TRANSACTION_NO_IF_NOT_EXIST = "0"; const dataQuery = { ...data, vnp_Command, vnp_Version: this.config.vnp_Version ?? chunkEYO267YS_cjs.VNP_VERSION, vnp_TmnCode: this.config.tmnCode, vnp_Amount: data.vnp_Amount * 100 }; const { vnp_Version, vnp_TmnCode, vnp_RequestId, vnp_TransactionType, vnp_TxnRef, vnp_TransactionNo = DEFAULT_TRANSACTION_NO_IF_NOT_EXIST, vnp_TransactionDate, vnp_CreateBy, vnp_CreateDate, vnp_IpAddr, vnp_OrderInfo } = dataQuery; const refundEndpoint = this.config.endpoints.queryDrRefundEndpoint || chunkEYO267YS_cjs.QUERY_DR_REFUND_ENDPOINT; const url = new URL( chunkWTHM33JV_cjs.resolveUrlString( this.config.queryDrAndRefundHost || this.config.vnpayHost, refundEndpoint ) ); const stringToHashOfRequest = [ vnp_RequestId, vnp_Version, vnp_Command, vnp_TmnCode, vnp_TransactionType, vnp_TxnRef, dataQuery.vnp_Amount, vnp_TransactionNo, vnp_TransactionDate, vnp_CreateBy, vnp_CreateDate, vnp_IpAddr, vnp_OrderInfo ].map(String).join("|").replace(/undefined/g, ""); const requestHashed = chunkWTHM33JV_cjs.hash( this.config.secureSecret, Buffer.from(stringToHashOfRequest, this.bufferEncode), this.hashAlgorithm ); const body = { ...dataQuery, vnp_SecureHash: requestHashed }; const response = await fetch(url.toString(), { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify(body) }); if (!response.ok) { throw new Error(`HTTP error! status: ${response.status}`); } const responseData = await response.json(); if (responseData?.vnp_Amount) { responseData.vnp_Amount = responseData.vnp_Amount / 100; } const message = chunkWTHM33JV_cjs.getResponseByStatusCode( responseData.vnp_ResponseCode?.toString() ?? "", data?.vnp_Locale ?? this.config.vnp_Locale, chunkJGUV45TP_cjs.REFUND_RESPONSE_MAP ); let outputResults = { isVerified: true, isSuccess: responseData.vnp_ResponseCode === "00" || responseData.vnp_ResponseCode === 0, message, ...responseData, vnp_Message: message }; if (Number(responseData.vnp_ResponseCode) <= 90 && Number(responseData.vnp_ResponseCode) >= 99) { const stringToCreateHashOfResponse = [ responseData.vnp_ResponseId, responseData.vnp_Command, responseData.vnp_ResponseCode, responseData.vnp_Message, responseData.vnp_TmnCode, responseData.vnp_TxnRef, responseData.vnp_Amount, responseData.vnp_BankCode, responseData.vnp_PayDate, responseData.vnp_TransactionNo, responseData.vnp_TransactionType, responseData.vnp_TransactionStatus, responseData.vnp_OrderInfo ].map(String).join("|").replace(/undefined/g, ""); const responseHashed = chunkWTHM33JV_cjs.hash( this.config.secureSecret, Buffer.from(stringToCreateHashOfResponse, this.bufferEncode), this.hashAlgorithm ); if (responseData?.vnp_SecureHash && responseHashed !== responseData.vnp_SecureHash) { outputResults = { ...outputResults, isVerified: false, message: chunkWTHM33JV_cjs.getResponseByStatusCode( chunkJGUV45TP_cjs.WRONG_CHECKSUM_KEY, this.config.vnp_Locale, chunkJGUV45TP_cjs.REFUND_RESPONSE_MAP ) }; } } const data2Log = { createdAt: /* @__PURE__ */ new Date(), method: "refund", ...outputResults }; this.logger.log(data2Log, options, "refund"); return outputResults; } }; chunkUOEGPC4B_cjs.__name(_QueryService, "QueryService"); var QueryService = _QueryService; // src/services/verification.service.ts var _VerificationService = class _VerificationService { /** * Khởi tạo dịch vụ xác thực * @en Initialize verification service * * @param config - Cấu hình VNPay * @en @param config - VNPay configuration * * @param logger - Dịch vụ logger * @en @param logger - Logger service * * @param hashAlgorithm - Thuật toán băm * @en @param hashAlgorithm - Hash algorithm */ constructor(config, logger, hashAlgorithm) { this.config = config; this.logger = logger; this.hashAlgorithm = hashAlgorithm; } /** * Phương thức xác thực tính đúng đắn của các tham số trả về từ VNPay * @en Method to verify the return url from VNPay * * @param {ReturnQueryFromVNPay} query - Đối tượng dữ liệu trả về từ VNPay * @en @param {ReturnQueryFromVNPay} query - The object of data return from VNPay * * @param {VerifyReturnUrlOptions<LoggerFields>} options - Tùy chọn * @en @param {VerifyReturnUrlOptions<LoggerFields>} options - Options * * @returns {VerifyReturnUrl} Kết quả xác thực * @en @returns {VerifyReturnUrl} The verification result */ verifyReturnUrl(query, options) { const { vnp_SecureHash = "", vnp_SecureHashType, ...cloneQuery } = query; if (typeof cloneQuery?.vnp_Amount !== "number") { const isValidAmount = chunkEYO267YS_cjs.numberRegex.test(cloneQuery?.vnp_Amount ?? ""); if (!isValidAmount) { throw new Error("Invalid amount"); } cloneQuery.vnp_Amount = Number(cloneQuery.vnp_Amount); } const searchParams = chunkWTHM33JV_cjs.buildPaymentUrlSearchParams(cloneQuery); const isVerified = chunkWTHM33JV_cjs.verifySecureHash({ secureSecret: this.config.secureSecret, data: searchParams.toString(), hashAlgorithm: this.hashAlgorithm, receivedHash: vnp_SecureHash }); let outputResults = { isVerified, isSuccess: cloneQuery.vnp_ResponseCode === "00", message: chunkWTHM33JV_cjs.getResponseByStatusCode( cloneQuery.vnp_ResponseCode?.toString() ?? "", this.config.vnp_Locale ) }; if (!isVerified) { outputResults = { ...outputResults, message: "Wrong checksum" }; } const result = { ...cloneQuery, ...outputResults, vnp_Amount: cloneQuery.vnp_Amount / 100 }; const data2Log = { createdAt: /* @__PURE__ */ new Date(), method: "verifyReturnUrl", ...result, vnp_SecureHash: options?.withHash ? vnp_SecureHash : void 0 }; this.logger.log(data2Log, options, "verifyReturnUrl"); return result; } /** * Phương thức xác thực tính đúng đắn của lời gọi ipn từ VNPay * * Sau khi nhận được lời gọi, hệ thống merchant cần xác thực dữ liệu nhận được từ VNPay, * kiểm tra đơn hàng có hợp lệ không, kiểm tra số tiền thanh toán có đúng không. * * @en Method to verify the ipn url from VNPay * * After receiving the call, the merchant system needs to verify the data received from VNPay, * check if the order is valid, check if the payment amount is correct. * * @param {ReturnQueryFromVNPay} query - Đối tượng dữ liệu trả về từ VNPay * @en @param {ReturnQueryFromVNPay} query - The object of data return from VNPay * * @param {VerifyIpnCallOptions<LoggerFields>} options - Tùy chọn * @en @param {VerifyIpnCallOptions<LoggerFields>} options - Options * * @returns {VerifyIpnCall} Kết quả xác thực * @en @returns {VerifyIpnCall} The verification result */ verifyIpnCall(query, options) { const hash2 = query.vnp_SecureHash; const silentOptions = { logger: { loggerFn: chunkWTHM33JV_cjs.ignoreLogger } }; const result = this.verifyReturnUrl( query, silentOptions ); const data2Log = { createdAt: /* @__PURE__ */ new Date(), method: "verifyIpnCall", ...result, ...options?.withHash ? { vnp_SecureHash: hash2 } : {} }; this.logger.log(data2Log, options, "verifyIpnCall"); return result; } }; chunkUOEGPC4B_cjs.__name(_VerificationService, "VerificationService"); var VerificationService = _VerificationService; // src/vnpay.ts var _VNPay = class _VNPay { /** * Khởi tạo đối tượng VNPay * @en Initialize VNPay instance * * @param {VNPayConfig} config - VNPay configuration */ constructor({ vnpayHost = chunkEYO267YS_cjs.VNPAY_GATEWAY_SANDBOX_HOST, queryDrAndRefundHost = chunkEYO267YS_cjs.VNPAY_GATEWAY_SANDBOX_HOST, vnp_Version = chunkEYO267YS_cjs.VNP_VERSION, vnp_CurrCode = "VND" /* VND */, vnp_Locale = "vn" /* VN */, testMode = false, paymentEndpoint = chunkEYO267YS_cjs.PAYMENT_ENDPOINT, endpoints = {}, ...config }) { if (testMode) { vnpayHost = chunkEYO267YS_cjs.VNPAY_GATEWAY_SANDBOX_HOST; queryDrAndRefundHost = chunkEYO267YS_cjs.VNPAY_GATEWAY_SANDBOX_HOST; } this.hashAlgorithm = config?.hashAlgorithm ?? "SHA512" /* SHA512 */; const initializedEndpoints = { paymentEndpoint: endpoints.paymentEndpoint || paymentEndpoint, queryDrRefundEndpoint: endpoints.queryDrRefundEndpoint || chunkEYO267YS_cjs.QUERY_DR_REFUND_ENDPOINT, getBankListEndpoint: endpoints.getBankListEndpoint || chunkEYO267YS_cjs.GET_BANK_LIST_ENDPOINT }; this.globalConfig = { vnpayHost, vnp_Version, vnp_CurrCode, vnp_Locale, vnp_OrderType: "other" /* Other */, vnp_Command: chunkEYO267YS_cjs.VNP_DEFAULT_COMMAND, paymentEndpoint: initializedEndpoints.paymentEndpoint, endpoints: initializedEndpoints, queryDrAndRefundHost, ...config }; this.loggerService = new LoggerService(config?.enableLog ?? false, config?.loggerFn); this.paymentService = new PaymentService( this.globalConfig, this.loggerService, this.hashAlgorithm ); this.verificationService = new VerificationService( this.globalConfig, this.loggerService, this.hashAlgorithm ); this.queryService = new QueryService( this.globalConfig, this.loggerService, this.hashAlgorithm ); } /** * Lấy cấu hình mặc định của VNPay * @en Get default config of VNPay * * @returns {DefaultConfig} Cấu hình mặc định * @en @returns {DefaultConfig} Default configuration */ get defaultConfig() { return { vnp_TmnCode: this.globalConfig.tmnCode, vnp_Version: this.globalConfig.vnp_Version, vnp_CurrCode: this.globalConfig.vnp_CurrCode, vnp_Locale: this.globalConfig.vnp_Locale, vnp_Command: this.globalConfig.vnp_Command, vnp_OrderType: this.globalConfig.vnp_OrderType }; } /** * Lấy danh sách ngân hàng được hỗ trợ bởi VNPay * @en Get list of banks supported by VNPay * * @returns {Promise<Bank[]>} Danh sách ngân hàng * @en @returns {Promise<Bank[]>} List of banks */ async getBankList() { const response = await fetch( chunkWTHM33JV_cjs.resolveUrlString( this.globalConfig.vnpayHost ?? chunkEYO267YS_cjs.VNPAY_GATEWAY_SANDBOX_HOST, this.globalConfig.endpoints.getBankListEndpoint ), { method: "POST", headers: { "Content-Type": "application/x-www-form-urlencoded" }, body: `tmn_code=${this.globalConfig.tmnCode}` } ); const bankList = await response.json(); for (const bank of bankList) { bank.logo_link = chunkWTHM33JV_cjs.resolveUrlString( this.globalConfig.vnpayHost ?? chunkEYO267YS_cjs.VNPAY_GATEWAY_SANDBOX_HOST, bank.logo_link.slice(1) ); } return bankList; } /** * Phương thức xây dựng, tạo thành url thanh toán của VNPay * @en Build the payment url * * @param {BuildPaymentUrl} data - Dữ liệu thanh toán cần thiết để tạo URL * @en @param {BuildPaymentUrl} data - Payment data required to create URL * * @param {BuildPaymentUrlOptions<LoggerFields>} options - Tùy chọn bổ sung * @en @param {BuildPaymentUrlOptions<LoggerFields>} options - Additional options * * @returns {string} URL thanh toán * @en @returns {string} Payment URL * @see https://sandbox.vnpayment.vn/apis/docs/thanh-toan-pay/pay.html#tao-url-thanh-toan */ buildPaymentUrl(data, options) { return this.paymentService.buildPaymentUrl(data, options); } /** * Phương thức xác thực tính đúng đắn của các tham số trả về từ VNPay * @en Method to verify the return url from VNPay * * @param {ReturnQueryFromVNPay} query - Đối tượng dữ liệu trả về từ VNPay * @en @param {ReturnQueryFromVNPay} query - The object of data returned from VNPay * * @param {VerifyReturnUrlOptions<LoggerFields>} options - Tùy chọn để xác thực * @en @param {VerifyReturnUrlOptions<LoggerFields>} options - Options for verification * * @returns {VerifyReturnUrl} Kết quả xác thực * @en @returns {VerifyReturnUrl} Verification result * @see https://sandbox.vnpayment.vn/apis/docs/thanh-toan-pay/pay.html#code-returnurl */ verifyReturnUrl(query, options) { return this.verificationService.verifyReturnUrl(query, options); } /** * Phương thức xác thực tính đúng đắn của lời gọi ipn từ VNPay * * Sau khi nhận được lời gọi, hệ thống merchant cần xác thực dữ liệu nhận được từ VNPay, * kiểm tra đơn hàng có hợp lệ không, kiểm tra số tiền thanh toán có đúng không. * * Sau đó phản hồi lại VNPay kết quả xác thực thông qua các `IpnResponse` * * @en Method to verify the ipn call from VNPay * * After receiving the call, the merchant system needs to verify the data received from VNPay, * check if the order is valid, check if the payment amount is correct. * * Then respond to VNPay the verification result through `IpnResponse` * * @param {ReturnQueryFromVNPay} query - Đối tượng dữ liệu từ VNPay qua IPN * @en @param {ReturnQueryFromVNPay} query - The object of data from VNPay via IPN * * @param {VerifyIpnCallOptions<LoggerFields>} options - Tùy chọn để xác thực * @en @param {VerifyIpnCallOptions<LoggerFields>} options - Options for verification * * @returns {VerifyIpnCall} Kết quả xác thực * @en @returns {VerifyIpnCall} Verification result * @see https://sandbox.vnpayment.vn/apis/docs/thanh-toan-pay/pay.html#code-ipn-url */ verifyIpnCall(query, options) { return this.verificationService.verifyIpnCall(query, options); } /** * Đây là API để hệ thống merchant truy vấn kết quả thanh toán của giao dịch tại hệ thống VNPAY. * @en This is the API for the merchant system to query the payment result of the transaction at the VNPAY system. * * @param {QueryDr} query - Dữ liệu truy vấn kết quả thanh toán * @en @param {QueryDr} query - The data to query payment result * * @param {QueryDrResponseOptions<LoggerFields>} options - Tùy chọn truy vấn * @en @param {QueryDrResponseOptions<LoggerFields>} options - Query options * * @returns {Promise<QueryDrResponse>} Kết quả truy vấn từ VNPay sau khi đã xác thực * @en @returns {Promise<QueryDrResponse>} Query result from VNPay after verification * @see https://sandbox.vnpayment.vn/apis/docs/truy-van-hoan-tien/querydr&refund.html#truy-van-ket-qua-thanh-toan-PAY */ async queryDr(query, options) { return this.queryService.queryDr(query, options); } /** * Đây là API để hệ thống merchant gửi yêu cầu hoàn tiền cho giao dịch qua hệ thống Cổng thanh toán VNPAY. * @en This is the API for the merchant system to refund the transaction at the VNPAY system. * * @param {Refund} data - Dữ liệu yêu cầu hoàn tiền * @en @param {Refund} data - The data to request refund * * @param {RefundOptions<LoggerFields>} options - Tùy chọn hoàn tiền * @en @param {RefundOptions<LoggerFields>} options - Refund options * * @returns {Promise<RefundResponse>} Kết quả hoàn tiền từ VNPay sau khi đã xác thực * @en @returns {Promise<RefundResponse>} Refund result from VNPay after verification * @see https://sandbox.vnpayment.vn/apis/docs/truy-van-hoan-tien/querydr&refund.html#hoan-tien-thanh-toan-PAY */ async refund(data, options) { return this.queryService.refund(data, options); } }; chunkUOEGPC4B_cjs.__name(_VNPay, "VNPay"); var VNPay = _VNPay; exports.VNPay = VNPay; //# sourceMappingURL=chunk-MVSF65JO.cjs.map //# sourceMappingURL=chunk-MVSF65JO.cjs.map