#crazylit.dev

1 messages · Page 1 of 1 (latest)

elder lantern
#

hello @grim meteor! could you explain more on what you mean by the checkout will be successful but won't call the webhook? I don't really understand this portion

grim meteor
#

Wait up

#

@twin lantern is my backend dev

#

He'll explain the problem

#

@elder lantern

grim meteor
#

So the checkout is successful

#

But then stripe won't trigger the event

#

It will if it's on test mode

#

But not on live mode

#

@twin lantern right?

twin lantern
#

Yes, we are using stripe CLI on the server to trigger the events and complete the purchase after successfull checkout

elder lantern
#

can you share your account id? it'd look like acct_123

grim meteor
#

Wait up

grim meteor
#

acct_1IcvxjEMiRIxVc48

#

@elder lantern

elder lantern
#

looking at your account, you've setup several webhook endpoints

#

which one are you having trouble with specifically?

#

and what is the specific event that you're listening for but is not triggering in live mode?

grim meteor
#

@twin lantern

twin lantern
#

I'm using this endpint :
app.post(
"/api/webhook",
bodyParser.raw({ type: "application/json" }),
async (request, response) => {

if (
payload.data.object.mode == "subscription" &&
payload.type === "checkout.session.completed"
) {
//do something
}

if (payload.type === "checkout.session.completed") {
const session = await stripe.checkout.sessions.retrieve(
payload.data.object.id,
{
expand: ["line_items"],
}
);
//do something
}

}

grim meteor
#

@elder lantern

elder lantern
#

what about the endpoint url?

twin lantern
#

sorry, which url?

elder lantern
#

if you login to this link : https://dashboard.stripe.com/webhooks, you can see all the webhook url(s) that you've setup to receive webhook events in production. Which one are you expecting to receive the checkout.session.completed event on?

twin lantern
#

Okay, Wait up

grim meteor
#

@elder lantern

elder lantern
#

attempting to access it through the browser is showing the same 521 error

twin lantern
elder lantern
#

you can either complete a live checkout session i.e. finish paying for something, or you can use the Stripe CLI to trigger an event

twin lantern
#

I already using the stripe CLI

#

running as a service in the background

elder lantern
#

stripe trigger <event> --api-key=sk_live_1234
i think this might work

twin lantern
#

How can I use this?
do you mean instead of this ?
stripe listen --forward-to localhost:5002/api/webhook

elder lantern
#

is it because this url is not publicly accessible?

twin lantern
#

no it is live now

grim meteor
elder lantern
#

you will see a resend button

grim meteor
#

okay

elder lantern
#

can you click on it and see if it's delivered successfully this time?

elder lantern
#

that's an error from your server, you're going to need to figure out why it's returning a 405 now

twin lantern
grim meteor
#

I think we are using wrong webhook

#

we should use saucedproxies one

twin lantern
#

should I remove webhook setup from the dashboard becuse I'm not using it?

elder lantern
#

if you're not using it, i'd suggest removing it to avoid any confusion

twin lantern
#

okay I'll do this

#

After I do this, what should I do next?

elder lantern
twin lantern
#

Now I removed webhook setup for dashboard and tested the purchasing in the test mode for saucedproxies and it is working so?

grim meteor
#

@elder lantern

elder lantern
#

you would probably wait for a checkout session in live mode, to make sure everything is working fine in production

grim meteor
#

it doesn't

#

that's the problem

#

do I try again?

#

in live mode?

elder lantern
#

what doesn't work in production? you'd need to provide more context like what is the error message for example?

grim meteor
#

we get redirected to success page

#

but it should also trigger an event in backend

#

that dosen't happenm

elder lantern
#

i don't see you doing anything in live mode

#

are you testing in test mode or in live mode?

#

you've setup the sauceproxies webhook url in live mode, if you're creating a Checkout Session in test mode - the event would naturally be created in test mode (and your sauceproxies webhook url wouldn't receive anything since it's in live mode)

grim meteor
#

what else is needed?

elder lantern
#

i don't see any logs to create a Checkout Session in your live mode logs

grim meteor
#

yeah because that's the fresh one, we had in past

#

like yesterday we had checkouts

#

money was recieved

elder lantern
#

you just created your sauceproxies webhook url today

#

and your checkout sessions were done yesterday

#

so you won't have any checkout events delivered to your sauceproxies webhook url yet

grim meteor
#

and it wasn't working it

#

*either

#

so

#

@twin lantern deleted it few minutes ago

#

don't you see logs for that webhook either?

elder lantern
#

i see the log to create the sauceproxies webhook

#

but like i mentioned, you need to have a new checkout created and completed for an event to be sent to that newly created webhook

grim meteor
#

yes we are awar

#

*aware

#

but you should be able to see old logs too right?

elder lantern
#

maybe you can explain more on what you want to do with the old logs?

grim meteor
#

yesterday we bought stuff in live mode

#

and the payment came through

#

but event was probably not triggered

#

so can you see

#

if you can see any logs for successful payment and find the error causeD?

elder lantern
#

the reason why you didn't receive it, was probably because delivery failed due to 521 error

#

if you login to that page, you can view all of the attempts

elder lantern
#

heya @grim meteor! we can continue here

grim meteor
elder lantern
grim meteor
#

Hey

#

can you tellme

#

w

#

what type of request is that?

#

@elder lantern

elder lantern
#

they're post requests

grim meteor
#

okay

#

and what type of response does it need?

elder lantern
#

200

grim meteor
#

I mean content type

elder lantern
grim meteor
#

I am not the dev for this

elder lantern
#

it doesn't need any content type, all we really need is for your endpoint to return 2xx HTTP status code to Stripe.

grim meteor
#

got it

#

so in test mode, stripe doesn't make such post requests? @elder lantern

elder lantern
#

Stripe sends webhook events in test mode, and they are also using POST. Have you checked if the event was sent using the Stripe Dashboard?

grim meteor
#

in test mode?

#

nah

celest sparrow
#

@grim meteor what do you need help with?

grim meteor
#

hey

#

can you read the past convo

#

this is the status I get now

#

still it won't work

#

@celest sparrow

celest sparrow
#

@grim meteor Can I ask you to provide more detailed inforamtion than a txt file dump? What is blocking you, what isn't working? That txt is just a client-side confirmation in Checkout

grim meteor
celest sparrow
#

Please, try to provide a detailed summary of what you need help with. There is a ton of backlog that is unclear (I tried to skim) and there are 14 other people asking questions right now

grim meteor
#

So we are using stripe cli for webhook events to trigger a backend process on succesful checkout, after checkout we get success message (redirected by stripe) but the backend is not triggered, but this happens only in live mode, in test mode it works perfectly

celest sparrow
#

Stripe CLI is purely for Test mode environments. So you likely are not using this in production right? Do you see the event sent to your webhook endpoint?

#

do you have an example event id?

grim meteor
#

wait so you mean

#

stripe cli won't work for live mode in stripe?

#

@twin lantern

#

@celest sparrow

celest sparrow
#

I don't really grasp why you'd use the CLI for live mode. In production you have a real server that is available publicly already, you configure your HTTPS endpoint where we send events directly

grim meteor
#

i see

celest sparrow
#

does that unblock you @stark salmon ?

#

sorry wrong auto-complete, damn you Discord

#

@grim meteor does that unblock you?

grim meteor
#

he'll come in abit

twin lantern
#

Hey

#

I'm using stripe CLI to trigger the events
In test mode it works perfectly

#

But in live mode it doesn't work

#

And the stripe cli is listening for the events

grim meteor
#

@celest sparrow

celest sparrow
#

you just @ me with the same exact question though

#

did you read what I said above? There's no reason to use the CLI in Live mode, so don't do that

twin lantern
#

So what should I use to listen for the events

celest sparrow
#

Webhooks are just HTTP requests to your server. They work the same as any parts of your web application already

#

It works the same as when you do a post or submit on your app in javascript. It's a "route" in your app that we hit directly since your server is publicly available