#thomas-d
1 messages · Page 1 of 1 (latest)
Can you share the Payment Intent ID (pi_xxx)?
You want me to share it here?
Yup! Sharing payment intent here is fine since only Stripe staff is able to access it
but I just wanted to know if it was possible because I want to implement this in my site (cancellation of a payment if a customer wants to cancel an appointment). but here is the id :cs_test_a1v8g9tf6FYmEUSfcisbEVYetKSzEHhwMxNMxgwJPqL1M8GVTnLaalWxIr (but this is a test payment)
Ah I see! This is not Payment Intent (pi_xxx). If you want to cancel a Checkout Session, Expire a Checkout Session API should be used: https://stripe.com/docs/api/checkout/sessions/expire
Canceling a Payment Intent API can only be used when a Payment Intent (pi_xxx) is created. When the Checkout Session isn't completed, no Payment Intent will be created
It can be broken down into two flows:
- Customer hasn't completed Checkout Session, Expire Checkout Session API should be used: https://stripe.com/docs/api/checkout/sessions/expire
- Customer completes the payment, then
payment_intentwill be available incheckout.session.completedevent. You can then use Cancel Payment Intent API: https://stripe.com/docs/api/payment_intents/cancel
I have this error : Only Checkout Sessions with a status in ["open"] can be expired. This Checkout Session has a status of complete
But the payment is not completed on the interface of stripe
Can you share the Checkout Session ID (cs_xxx) that this error is shown?
Oh wait
My bad
cs_test_a1v8g9tf6FYmEUSfcisbEVYetKSzEHhwMxNMxgwJPqL1M8GVTnLaalWxIr was completed, which fell into case 2 that I mentioned above
After cs_test_a1v8g9tf6FYmEUSfcisbEVYetKSzEHhwMxNMxgwJPqL1M8GVTnLaalWxIr is completed, Payment Intent ID pi_3NcN2TBp4Rgye6f30Nwj2zwe is available in checkout.session.completed event: https://dashboard.stripe.com/test/events/evt_1NcN2UBp4Rgye6f3MdFSqG7r
Sign in to the Stripe Dashboard to manage business payments and operations in your account. Manage payments and refunds, respond to disputes and more.
You should use pi_3NcN2TBp4Rgye6f30Nwj2zwe in Cancel Payment Intent API: https://stripe.com/docs/api/payment_intents/cancel
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
ok but i don't have the payment_intent in session object when i create a session. So i need to get this and after Cancel Payment Intent API ? Do you have a link in the doc for get the payment ?
payment_intent will only be available after the payment is completed. Your system should subscribe to checkout.session.completed event to get the payment intent ID. Here's the guide about handling checkout.session.completed events
Ok thank you i go try this !