#codex_webhooks

1 messages ¡ Page 1 of 1 (latest)

ancient yokeBOT
#

👋 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.

delicate birch
#

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(),
            },
          },
        });
crisp sleet
#

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

delicate birch
#

yes, if the coupon is null pass in undefined instead of an array

crisp sleet
#

what if the customer accidentally deletes the coupon in the Checkout Session?

delicate birch
#

So do you know why the invoice paid is not even entering the api route?

crisp sleet
#

what api route are you referring to?

delicate birch
#

the webhook one for /api/Finances/Subscriptions

crisp sleet
#

that sounds like your own code, you would want to step through your own code to debug

delicate birch
#

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

crisp sleet
#

I think step 1 here would be to check if your webhook endpoint is receiving that event. Have you done that?

delicate birch
#

Well the subscription one was completed without a problem, and the invoice paid is going to the same route

crisp sleet
delicate birch
#

Yeah I checked my webhook there is no return with 405

crisp sleet
#

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

delicate birch
#

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