const require_storeTypes = require("../../types/storeTypes.js");
//#region src/components/pay/toB/components/Content/utils.ts
const isEftposPay = (code) => {
	return [
		require_storeTypes.PayMethodCode.EFTPOS_PAYO,
		require_storeTypes.PayMethodCode.EFTPOS_TYRO,
		require_storeTypes.PayMethodCode.EFTPOS_WINDCAVE,
		require_storeTypes.PayMethodCode.EFTPOS_LINKLY
	].includes(code);
};
/**
* @title: 处理eftpos支付
* @description: 处理eftpos支付
* @param {any} action 引擎action
* @param {any} params 参数
* @param {any} successCallback 成功回调
*/
const handleEftposPay = (action, params, successCallback) => {
	const { payMethod, order, symbol, network, type } = params;
	console.log("tob_pay_handleEftposPay", params);
	action === null || action === void 0 || action({
		type: "pisell1.handleEftposPaySource",
		data: "normal",
		callback() {}
	});
	action === null || action === void 0 || action({
		type: "pisell1.openEftposPay",
		data: {
			code: payMethod.code,
			terminal: { network: network.online },
			apiParams: {
				order_id: order === null || order === void 0 ? void 0 : order.id,
				name: (payMethod === null || payMethod === void 0 ? void 0 : payMethod.name) || "",
				symbol,
				amount: (order === null || order === void 0 ? void 0 : order.expect_amount) || "0.00"
			},
			visible: true,
			mode: type ? type : "pay"
		},
		callback({ status, params }) {
			console.log("tob_pay_openEftposPay_callback", status, params);
			if (status === "success") {
				const result = {
					amount: Number(params === null || params === void 0 ? void 0 : params.amount),
					code: payMethod.code,
					id: payMethod.id,
					name: payMethod.name,
					type: payMethod.type,
					voucher_id: "",
					service_charge: {
						percentage: params === null || params === void 0 ? void 0 : params.surPercentRate,
						amount: params === null || params === void 0 ? void 0 : params.surMoney
					},
					metadata: { unique_payment_number: params === null || params === void 0 ? void 0 : params.uniquePaymentNumber }
				};
				successCallback === null || successCallback === void 0 || successCallback({
					result,
					status,
					params
				});
			}
		}
	});
};
//#endregion
exports.handleEftposPay = handleEftposPay;
exports.isEftposPay = isEftposPay;
