#bongowilliams

1 messages ยท Page 1 of 1 (latest)

lethal thistleBOT
hollow depot
#

Hi there, it's not always the case. payment_intent.succeeded event is fired when a payment is succeeded. However, a completed checkout session doesn't always mean the payment is succeeded.

vast python
#

ah, okay. is there a event i could rely on that would indicate payment status also to check before the user is returned?

hollow depot
#

For instance, if the customer choose a payment method that can't be immediately confirmed, the paymentIntent status will be pending even though the checkout session is completed.

vast python
#

sure

#

so should i look at the checkout.session.completed - event then as something that will fire before the user is returned?

#

or in most instances, like for card payments, will the payment intend be succeeded / completed and event fired before the user is returned?

#

im just wondering what the most reliable way to update our databse of the paid status is before the user is returned to our page (so we can show 'paid' in the UI)

hollow depot
#

As I explained earlier, checkout.session.completed doesn't always mean a payment is succeeded, it only means that the customer has completed the checkout session. You should listen to payment_intent.succeeded if you want to update your internal system for successful payments.

vast python
#

ok

#

thanks, are there any best practices in terms of delays, or was to handle the return url from checkout to allow time for the checkout.session.completed webhook to be received? or is it usually, for standard payments that can be confirmed by stripe straight away, safe to assume it will be fired before the return redirect process begins

hollow depot
#

I guess you want to present the payment result to your user in the page rendered by return URL, am I right?

#

You can add a ?session_id={CHECKOUT_SESSION_ID} at the end of the success_url, so that Stripe will substitute it with the session ID during redirection. So in you backend code, you can retrieve this session and its associated paymentIntent and inform your customer the payment status based on paymentIntent.

vast python
#

yeah that's correct, we'd like to do that

#

oh great, thats good advice, thank you! i'll do that

vast python
#

thats working! which php function can I then use to grab the payment intent using the checkout session id provided ?

#

really appreciate the tip Jack!

#

just trying to work it out in this format:

    ['stripe_account' => $from_connected_account_id
]);```
hollow depot
vast python
#

oh that's really helpful, i didnt know that, i was making multiple calls in some cases

hollow depot
#

response expansion is very useful, you can save some round-trips ๐Ÿ™‚

vast python
#

yeah that's cool!

#

speeds things up too

#
    'id' => $session_id,
    'expand' => ['payment_intent'],
    ],['stripe_account' => $from_connected_account_id
]);```
#

does this seem like the right format here? if the session is creawted for a connected account user of ours?

#

all g, i confirm its correct. thank you so much

#

and im guessing i can just use the status of the payment intent? if status='succeeded' then we can assume its paid succesfully?

hollow depot
#

Yes you are right!

vast python
#

okay thats all worked wonderfully thanks so much