const logic = require("../service/biz_subscription_logic");
const audit = require("../utils/biz_audit");



module.exports = {
  "POST /biz_payment/confirm-offline": async (ctx) => {
    const body = ctx.getBody();
    const row = await logic.confirmOfflinePayment(body);
    await audit.logAudit({
      admin_user_id: audit.pickAdminId(ctx),
      action: "biz_payment.confirm_offline",
      resource_type: "biz_subscription",
      resource_id: body.subscription_id,
      detail: { payment_ref: body.payment_ref },
    });
    ctx.success(row);
  },
  "POST /biz_payment/confirm-link": async (ctx) => {
    const body = ctx.getBody();
    const row = await logic.confirmLinkPayment(body);
    await audit.logAudit({
      admin_user_id: audit.pickAdminId(ctx),
      action: "biz_payment.confirm_link",
      resource_type: "biz_subscription",
      resource_id: body.subscription_id,
      detail: { payment_ref: body.payment_ref },
    });
    ctx.success(row);
  },
};
