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

function getRequestBody(ctx) {
  if (ctx.request && ctx.request.body && Object.keys(ctx.request.body).length > 0) {
    return ctx.request.body;
  }
  if (typeof ctx.getBody === "function") {
    return ctx.getBody() || {};
  }
  return {};
}

module.exports = {
  "POST /biz_payment/confirm-offline": async (ctx) => {
    const body = getRequestBody(ctx);
    const row = await logic.confirmOfflinePayment(body);
    ctx.success(row);
  },
  "POST /biz_payment/confirm-link": async (ctx) => {
    const body = getRequestBody(ctx);
    const row = await logic.confirmLinkPayment(body);
    ctx.success(row);
  },
};
