var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
  for (var name in all)
    __defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
  if (from && typeof from === "object" || typeof from === "function") {
    for (let key of __getOwnPropNames(from))
      if (!__hasOwnProp.call(to, key) && key !== except)
        __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  }
  return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);

// src/components/pay/toB/components/Content/utils.ts
var utils_exports = {};
__export(utils_exports, {
  handleEftposPay: () => handleEftposPay,
  isEftposPay: () => isEftposPay
});
module.exports = __toCommonJS(utils_exports);
var import_types = require("../../types");
var isEftposPay = (code) => {
  return [
    import_types.PayMethodCode.EFTPOS_PAYO,
    import_types.PayMethodCode.EFTPOS_TYRO,
    import_types.PayMethodCode.EFTPOS_WINDCAVE,
    import_types.PayMethodCode.EFTPOS_LINKLY
  ].includes(code);
};
var handleEftposPay = (action, params, successCallback) => {
  const { payMethod, order, symbol, network, type } = params;
  console.log("tob_pay_handleEftposPay", params);
  action == null ? void 0 : action({
    type: "pisell1.handleEftposPaySource",
    data: "normal",
    callback() {
    }
  });
  action == null ? void 0 : action({
    type: "pisell1.openEftposPay",
    data: {
      code: payMethod.code,
      terminal: { network: network.online },
      apiParams: {
        order_id: order == null ? void 0 : order.id,
        name: (payMethod == null ? void 0 : payMethod.name) || "",
        symbol,
        amount: (order == null ? void 0 : order.expect_amount) || "0.00"
      },
      visible: true,
      mode: type ? type : "pay"
    },
    callback({ status, params: params2 }) {
      console.log("tob_pay_openEftposPay_callback", status, params2);
      if (status === "success") {
        const result = {
          amount: Number(params2 == null ? void 0 : params2.amount),
          // 支付金额
          code: payMethod.code,
          // 支付类型code
          id: payMethod.id,
          // 支付类型id
          name: payMethod.name,
          // 支付类型name
          type: payMethod.type,
          // 支付类型type
          voucher_id: "",
          // 手续费配置信息
          service_charge: {
            percentage: params2 == null ? void 0 : params2.surPercentRate,
            amount: params2 == null ? void 0 : params2.surMoney
          },
          metadata: {
            unique_payment_number: params2 == null ? void 0 : params2.uniquePaymentNumber
          }
        };
        successCallback == null ? void 0 : successCallback({ result, status, params: params2 });
      }
    }
  });
};
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
  handleEftposPay,
  isEftposPay
});
