debug: add verbose console logs to payments.ts
This commit is contained in:
1 parent
d093c0b531
commit
0e5ef799a8
1 file changed
+4
@@ -5,6 +5,7 @@ const OMISE_SECRET_KEY = process.env.OMISE_SECRET_KEY || "";
|
|||||||
|
|
||||||
export const paymentsRoute = new Elysia({ prefix: "/payments" })
|
export const paymentsRoute = new Elysia({ prefix: "/payments" })
|
||||||
.post("/charge", async ({ body, set }) => {
|
.post("/charge", async ({ body, set }) => {
|
||||||
|
console.log("[Payment Charge] Incoming request body:", JSON.stringify(body));
|
||||||
try {
|
try {
|
||||||
const { orderId, amount, type, token } = body as {
|
const { orderId, amount, type, token } = body as {
|
||||||
orderId: number;
|
orderId: number;
|
||||||
@@ -14,6 +15,7 @@ export const paymentsRoute = new Elysia({ prefix: "/payments" })
|
|||||||
};
|
};
|
||||||
|
|
||||||
if (!OMISE_SECRET_KEY) {
|
if (!OMISE_SECRET_KEY) {
|
||||||
|
console.error("[Payment Charge] Error: OMISE_SECRET_KEY is empty");
|
||||||
set.status = 500;
|
set.status = 500;
|
||||||
return { error: "Omise secret key is not configured" };
|
return { error: "Omise secret key is not configured" };
|
||||||
}
|
}
|
||||||
@@ -93,6 +95,7 @@ export const paymentsRoute = new Elysia({ prefix: "/payments" })
|
|||||||
})
|
})
|
||||||
});
|
});
|
||||||
const source = await sourceRes.json() as any;
|
const source = await sourceRes.json() as any;
|
||||||
|
console.log("[Payment Charge] Omise PromptPay Source response:", JSON.stringify(source));
|
||||||
if (source.error) {
|
if (source.error) {
|
||||||
set.status = 400;
|
set.status = 400;
|
||||||
return { error: source.message || "Failed to create PromptPay source" };
|
return { error: source.message || "Failed to create PromptPay source" };
|
||||||
@@ -115,6 +118,7 @@ export const paymentsRoute = new Elysia({ prefix: "/payments" })
|
|||||||
})
|
})
|
||||||
});
|
});
|
||||||
const charge = await chargeRes.json() as any;
|
const charge = await chargeRes.json() as any;
|
||||||
|
console.log("[Payment Charge] Omise PromptPay Charge response:", JSON.stringify(charge));
|
||||||
if (charge.error) {
|
if (charge.error) {
|
||||||
set.status = 400;
|
set.status = 400;
|
||||||
return { error: charge.message || "Failed to create PromptPay charge" };
|
return { error: charge.message || "Failed to create PromptPay charge" };
|
||||||
|
|||||||
Reference in new issue
Block a user