#kwac_code
1 messages ¡ Page 1 of 1 (latest)
đ Welcome to your new thread!
â˛ď¸ We'll be here soon! Typically we respond in a few minutes, but sometimes we might take a bit longer if the server is busy or if you have a particularly tricky question.
âąď¸ We close idle threads, which makes them read-only. Once a thread is closed it won't be reopened, but you can always start a new thread if you have another question.
đ This thread will always be available, even after it's closed. You can find it again using Discord's search, or you can save this link: https://discord.com/channels/841573134531821608/1326883454570201089
đ Have more to share? Add more details, code, screenshots, videos, etc. below.
Below are links to other discussions we've had with you in the past week in case you want to review that information. If your question is related to one of these previous discussions, please provide a comprehensive summary of the current state and what you need help with now. We help many users simultaneously, so a summary allows us to resolve your issue as soon as possible.
import Stripe from 'stripe';
export default defineEventHandler(async (event) => {
const stripe = new Stripe(process.env.STRIPE_SECRET_KEY)
const headers = event.node.req.headers;
const body = await readRawBody(event);
const sig = headers["stripe-signature"];
let hookEvent;
try{
hookEvent = stripe.webhooks.constructEvent(
body,
sig,
process.env.ENDPOINT_SECRET
)
}catch(error){
throw createError({ status: 400, message: error })
}
switch(hookEvent.type){
case "payment_intent.created":
console.log("payment intent created");
break;
case "payment_intent.succeeded":
const intentSucceeded = hookEvent.data.object;
console.log("payment intent succeeded " + intentSucceeded);
break;
case "charge.succeeded":
const chargeSucceeded = hookEvent.data.object;
console.log("charge was successful " + chargeSucceeded);
break;
default:
console.log(`unhandled event type ${hookEvent.type}`)
}
})
Ready! You are using Stripe API Version [2024-09-30.acacia]. Your webhook signing secret is whsec_693438147a85388c0b754f8391794f3e9908c5484e2827729cb91903c49ede13 (^C to quit)
2025-01-09 13:55:02 --> payment_intent.created [evt_3QfKKHKPj3JfoYa71a3zpNpz]
2025-01-09 13:55:02 <-- [403] POST http://localhost:3000/api/payment/webhook [evt_3QfKKHKPj3JfoYa71a3zpNpz]
2025-01-09 13:55:04 --> payment_intent.succeeded [evt_3QfKKHKPj3JfoYa7143O6LVG]
2025-01-09 13:55:04 <-- [403] POST http://localhost:3000/api/payment/webhook [evt_3QfKKHKPj3JfoYa7143O6LVG]
2025-01-09 13:55:04 --> charge.succeeded [evt_3QfKKHKPj3JfoYa71kUUpRw6]
2025-01-09 13:55:04 <-- [403] POST http://localhost:3000/api/payment/webhook [evt_3QfKKHKPj3JfoYa71kUUpRw6]
2025-01-09 13:55:06 --> charge.updated [evt_3QfKKHKPj3JfoYa71M2atDEB]
2025-01-09 13:55:06 <-- [403] POST http://localhost:3000/api/payment/webhook [evt_3QfKKHKPj3JfoYa71M2atDEB]
hi there!
you need to check your backend server logs to understand why your server is returning a 403 error
The HTTP 403 Forbidden client error response status code indicates that the server understood the request but refused to process it.
Does this code seem correct?
the 403 error means your code is never executed, the server directly refuses the request.
yes i know what it means
then you know the error is not in your code.