fix: log event data for payment_intent.created in stripe webhook handler
This commit is contained in:
parent
70736e4aa1
commit
baf92787a7
2 changed files with 19 additions and 11 deletions
|
|
@ -38,6 +38,7 @@ const handler = async (
|
|||
// Handle the event
|
||||
switch (event.type) {
|
||||
case "payment_intent.created": {
|
||||
console.log("PaymentIntent failed", event.data);
|
||||
const paymentIntent = event.data.object;
|
||||
const { id, metadata } = paymentIntent;
|
||||
|
||||
|
|
|
|||
|
|
@ -85,17 +85,24 @@ export const whIntentCreatedHandler = async ({
|
|||
paymentId: PaymentsId;
|
||||
pm_id: string;
|
||||
}) => {
|
||||
const paymentMethod = await stripe.paymentMethods.retrieve(pm_id);
|
||||
return await db
|
||||
.updateTable("payments")
|
||||
.set({
|
||||
intent_id: pIntentId,
|
||||
paymentstatus: PaymentStatusEnum.processing,
|
||||
paymentmethod: paymentMethod.type,
|
||||
})
|
||||
.where("id", "=", paymentId)
|
||||
.returning("id")
|
||||
.execute();
|
||||
try {
|
||||
const paymentMethod = await stripe.paymentMethods.retrieve(pm_id);
|
||||
return await db
|
||||
.updateTable("payments")
|
||||
.set({
|
||||
intent_id: pIntentId,
|
||||
paymentstatus: PaymentStatusEnum.processing,
|
||||
paymentmethod: paymentMethod.type,
|
||||
})
|
||||
.where("id", "=", paymentId)
|
||||
.returning("id")
|
||||
.execute();
|
||||
} catch (error) {
|
||||
throw new TRPCError({
|
||||
code: "INTERNAL_SERVER_ERROR",
|
||||
message: `Error whIntentCreatedHandler: ${(error as Error).message}`,
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
export const whIntentSucceededHandler = async ({
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue