#hakan_-checkout-webhook

1 messages ยท Page 1 of 1 (latest)

narrow surge
#

Hello ๐Ÿ‘‹
It is fired almost instantly but it may sometimes take a few seconds to reach your endpoint due to network delays

cedar hinge
narrow surge
cedar hinge
#

or its enough safe to say the success is always faster

cedar hinge
#

poll the api

narrow surge
#

I mean if your success page depends on results from checkout session, then instead of waiting for the webhook to arrive, you can call the API to retrieve the session object

cedar hinge
#

i am doing that excatly but just after retrieving the session object I am making checks if a payment was going through so when a user made before it means I want to cancel the old subcription and keep the newly created. when the webhook arrives faster, my software cancels the newly created subscription. thats the problem!

narrow surge
#

maybe add a check to see if the subscription was recently created or something

#

before cancelling

cedar hinge
#

wait, when I use a checkout.completed webhook it sends also the session to it or subscription details?

cedar hinge
#

what data will send checkout.completed is my question becaue when i get a subscription id and retrieve the details again I can ensure the delay you know

narrow surge
cedar hinge
#

like for this checkout the invoice

narrow surge
#

latest invoice for what exactly?
Checkout sessions don't have invoices. The subscription would.

cedar hinge
narrow surge
cedar hinge
#

instead

narrow surge
#

I'm confused, why can't you use it exactly? like because you aren't sure if the payment went through?

cedar hinge
#

nono I confused myself too a few moments but for the webhook where I want to save the invoice into my database I just need a paid state for the future so everytime when stripe charges my server saves the invoices data etc.

#

@narrow surge

narrow surge
#

there should be an invoice.paid event as well

cedar hinge
narrow surge
cedar hinge
#

ah yeah so i can just get the invoice perfect

narrow surge
cedar hinge
narrow surge
#

after a successful payment?

cedar hinge
#

so not all

#

just invoice.paid

#

so i can proper test here

broken axle
cedar hinge
broken axle
#

That's expected. We also don't guarantee the ordering of events, so it's usually best to account for exactly which event has the data you're looking for

cedar hinge
#

or only locally

broken axle
#

I think the speed is comparable, but likely marginally faster via CLI

cedar hinge
#

i see. hm sounds lke i need to delay the invoice.paid ๐Ÿ˜ฆ

broken axle
#

Why?

cedar hinge
#

couze it will bite with the other webhook

#

a race

broken axle
#

Ahhh, okay, so you have a race condition

#

Yep

#

Gimme a quick minute to read the back-scroll and see if any better suggestions come to mind. Usually I wouldn't advise anyone to wait for a webhook before doing a mostly unrelated process

cedar hinge
#

i just want to give the user immediatly the service. when I listen with the webhook with paypal before I waited 1 minute which was horrible

#

i dont want to wait even 5 seconds, the user should getimmediatly upgraded

broken axle
#

Wait, so you're only handling order fulfillment with the webhook event?

#

You shouldn't need to wait for invoice.paid

cedar hinge
#

no within the success

#

success URL

#

but the webhook saves a new invoice.paid with the subscription id

broken axle
#

checkout.session.completed only ever fires when a payment is successful, so you should just use that.

#

And the customer is only ever redirected to your success_url if a payment succeeds (except if you're using delayed payment methods)

cedar hinge
#

oh wait, the user will not be redirected to success_url when they use something like sepa?

#

that makes it worse ๐Ÿ˜ฆ

#

nope, even with delayed I get the redirect

broken axle
cedar hinge
#

No i dont want to await the user

#

you said above they will not ?

broken axle
#

I don't understand the question. Can you rephrase?

cedar hinge
#

i just mean, will invoice.paid webhook always be faster than checkout?

broken axle
#

No. Like I said, we can't guarantee the ordering of webhooks. You should only rely on Checkout events when possible.

cedar hinge
broken axle
#

What do you mean by "limit calling webhooks"? Do you mean "limit the webhook events your endpoint is listening for"?

cedar hinge
#

using the invoice.paid thing

broken axle
#

I still don't understand. Are you saying you want to only listen for a webhook if it's for a specific invoice and a specific event?

cedar hinge
#

since checkout comes after invoice.paid I don't have any association

fervent thunder
#

Hi ๐Ÿ‘‹ I"m stepping in since @broken axle has to go.

#

What is the problem when you receive the checkout.session.completed event?

cedar hinge
#

im not using checkout webhooks at all. I am just using the success redirect URL

#

now when I have the checkout success redirect I can get the client data into my database (so later I can reference). what happens is though I listen to a webhook called "invoice.paid" so everytime when stripe charges (also for the first subscription creation) an invoice , stripe sends the data to my server

#

now, invoice.paid arrives BEFORE checkout on my server without any user association ...

#

so I get customer id and everything but its not connected to my database

#

@fervent thunder

fervent thunder
#

Well then use the checkout.session.completed event and expand the customer ID you receive. That should solve the problem

cedar hinge
#

so checkout.session.completed runs before invoice.paid?

#

im woundering how others do it, thats a basic problem

fervent thunder
#

The timing of different webhook event deliveries can vary depending on a number of factors so you cannot depend on specific timing in your integration.

#

If you want to get the Customer information from the Invoice object you can retrieve the related invoice.subscription and expand the customer

cedar hinge
#

I already have that everything

#

Hm thanks for now

fervent thunder
#

invoice.paid arrives BEFORE checkout on my server without any user association
So are you saying you don't create a user until their info is returned by the return_url from Checkout?

cedar hinge
#

I can't know user payment details before user goes to checkout... Yes

#

but I have a dirty solution

cedar hinge
#

what it will be next time?

#

subscription_current

or something ?

#

like at least anything else

fervent thunder
#

So you create a user record before you know payment details and fill it in later.

i got subscription_create for the invoice for first time
What property are you talking about here?

cedar hinge
#

sounds like i talk to a wall ? ๐Ÿ˜ฆ

#

the invoice object man what else

fervent thunder
#

There are other people on this server I am also trying to help so sometimes I will take a couple minutes to get back to you

#

the invoice object man what else
What property in the invoice object?

cedar hinge
#

i get that but this chat here is not a help at all unfortunately

fervent thunder
#

There's more than one

cedar hinge
#

billing_reason

fervent thunder
cedar hinge
fervent thunder
#

The success URL redirecting the user back to your interface?

fervent thunder
#

It should. But you can also listen to customer.subscription.created or customer.subscription.updated event to receive the Subscription object as well.

cedar hinge
#

i hope so...

cedar hinge
#

within a subscription

fervent thunder
#

What are you updating in that case? Why make the API request?

fervent thunder
#

Why? If you are passing the same value?

cedar hinge
#

what happens

#

at paypal I got email notifications every single time even value was 1:1

plain bough
#

๐Ÿ‘‹ I'm hopping in since @fervent thunder has to head out

#

Really at this point I'd say the best thing for you to do is to test all these things out in test mode yourself - you have a lot of very specific questions about what behavior is the same vs different compared to paypal, and the best way to confirm it is just to test it out

cedar hinge
#

of a subscription

plain bough
cedar hinge
plain bough
cedar hinge
#

possible to customize it per product?

#

i mean, my customers want to read terms and privacy policy on invoices not of company, but the product itself etc etc

plain bough
#

Did you read the rest of that page? We cover other ways to customize the invoice like the memo and footer which you can control through the API

cedar hinge
lyric prawn
#

๐Ÿ‘‹ Taking over from this thread

#

Could you elaborate more what you expect after adding tax ID?

cedar hinge
#

I added a tax from my company but its not showing up in the invoice........

#

invocice PDF

lyric prawn
#

Could you share the invoice ID (in_xxx)?

cedar hinge
#

i have tax id both test and live mode

lyric prawn
#

Tax shows up in invoice PDF and invoice link as well

cedar hinge
#

the tax, but we are talking about TAX ID

#

my id

#

is nowhere

#

this here my friend

#

tax informations on invoices

lyric prawn
#

Ah I see! I'm looking into it now

cedar hinge
cedar hinge
cedar hinge
lyric prawn
#

I can't find anything at the moment. Checking with my coworker

cedar hinge
#

I want to go live soon. :(

lyric prawn
#

Your tax ID is not set as default

#

Only when default tax ID is set, then it'll be displayed

cedar hinge
lyric prawn
#

๐Ÿ‘