#Marco by Endesa Srl

1 messages · Page 1 of 1 (latest)

strange compassBOT
neon flax
#

can you share more on what you're trying to do/achieve here?

frozen python
#

Hi Alex-stripe,
thanks for your answer.
I've an ecommerce with checkout and payment with Stripe.

#

If I execute a:
$stripe->checkout->sessions->all(['limit' => 1])
?

neon flax
#

i'm sorry but i don't understand. What are you trying to achieve i.e. why do you need the PaymentIntent?

trail notch
#

Without ID I can't intercept the payment outcome wekbhook
you'd generally use the checkout.session.completed webhook event, not the payment_intent.* ones.

frozen python
#

When I get the webhook event (payment_intent.payment_failed or payment_intent.succeeded), how do I figure out which payment it refers to?
Previously in sessions->create I was storing on DB the payment_intent and it was the same as the one I received on the webhook and I could cross-reference request and response

trail notch
#

yep this is a change in newer API versions really.

The way you're supposed to do this is listen to checkout.session.completed and then you can access the session->payment_intent at that point and do whatever you need to do with that

frozen python
trail notch
#

those are the parameters for creating a CheckoutSession

#

not the fields on the CheckoutSession.

frozen python
#

Thanks karllekko.
This is part of code of webhook:
`{
"id": "evt_3M9uiAEokIae2bxm08oSjT5Z",
"object": "event",
"api_version": "2022-11-15",
"created": 1669831729,
"data": {
"object": {
"id": "pi_3M9uiAEokIae2bxm03qPsomG",
"object": "payment_intent",
"amount": 5000,
"amount_capturable": 0,
"amount_details": {
"tip": {
}
},
"amount_received": 5000,

}On webhook have an ID. When I call$stripe->checkout->sessions->createhow do I retrieve the ID? Do I have to trigger a new webhook eventcheckout.sessions.completed` and retrieve it from there?
Am I understanding this correctly?

trail notch
frozen python
#

Previously I used the ->data->object->id

trail notch
#

again, no reason to listen to payment_intent.* event

#

when you use Checkout, when the customer pays, you get a checkout.session.completed webhook event, and you handle that one event and do everything you need to do