#codex_webhooks
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/1240119781663703131
đ Have more to share? Add more details, code, screenshots, videos, etc. below.
Here is the checkout session
stripe.checkout.sessions.create(
{
line_items: [
{
price: price.stripePriceId,
quantity: 1,
},
],
discounts: [
{
coupon: coupon?.stripeCouponId,
},
],
mode: "subscription",
success_url: `https://${ctx.gymHost}/QRCodes/user?id=${input.gymUser}`,
cancel_url: `https://${ctx.gymHost}/?cancelled=true`,
metadata: {
daysHoursId: input.daysHoursId.toString(),
gymUser: input.gymUser,
event: "classSubscription",
gymId: ctx.gymId,
expirationDates: input.expirationDates.toString(),
},
subscription_data: {
metadata: {
daysHoursId: input.daysHoursId.toString(),
gymUser: input.gymUser,
event: "classSubscription",
gymId: ctx.gymId,
expirationDates: input.expirationDates.toString(),
},
},
});
hello! gimme a while to take a look
I'm a bit confused by what you meant by modifying the checkout session to prevent an empty array - do you mean perform a check on your end to ensure that a valid coupon is being passed in?
if that's the case then yes, you should do so. However, I do think that your code should be able to handle the situation whereby there's no coupon
yes, if the coupon is null pass in undefined instead of an array
what if the customer accidentally deletes the coupon in the Checkout Session?
So do you know why the invoice paid is not even entering the api route?
what api route are you referring to?
the webhook one for /api/Finances/Subscriptions
that sounds like your own code, you would want to step through your own code to debug
The problem is it's not even properly entering it, I am trying to log along multiple steps of the code and there isn't even one log
I think step 1 here would be to check if your webhook endpoint is receiving that event. Have you done that?
Well the subscription one was completed without a problem, and the invoice paid is going to the same route
looking at the Stripe Dashboard : https://dashboard.stripe.com/events/evt_1PGAOsGl4imgjXWLi8v59gG2 - I see your webhook endpoint is returning 405 (Method Not Allowed)
Sign in to the Stripe Dashboard to manage business payments and operations in your account. Manage payments and refunds, respond to disputes and more.
Yeah I checked my webhook there is no return with 405
You should check with your hosting provider and then check through your server logs. The webhook delivery was definitely attempted, somewhere along the way, your server is returning a 405. We can't really provide any additional insights at this point since the response is from your server
I did check my server thats where I got this message (there is more but I can't send it all at once)
us_Q6N9vgdEC7cmVn
at StripeError.generate (file:///var/task/node_modules/stripe/esm/Error.js:7:20)
at res.toJSON.then.StripeAPIError.message (file:///var/task/node_modules/stripe/esm/RequestSender.js:102:43)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
type: 'StripeInvalidRequestError',
raw: {
message: 'No active discount for subscription sub_id on customer cus_id',
request_log_url: 'https://dashboard.stripe.com/logs/req_qlmhOo9QumTgv3?t=1715732722',
Wait actually I think that dashboard log can help me I'll take a look at it
It works now thankyou