#jacyespinosa-payment_intent
1 messages ยท Page 1 of 1 (latest)
yes I am.
Great, you can listen to the checkout session event -> checkout.session.completed and you can get the payment_intent ID from the session object.
but i dont know how to access that payment_intent when I am redirected to success.html
If you are listening to the payment_intent.succeeded event, you can get the payment_intent from the object itself
So in your code it should be `payment_intent = event['data']['object']
i am able to fetch the data while in webhook route, but I'm having trouble query'ing my db while in webhook route.
Therefore, I am trying to retrieve the payment_intent when I am redirected to success.html, but I used this stripe.checkout.Session.list(limit=1), it is a totally different payment_intent data compare to the one that the webhook route spit out. I checked my dashboard after everything, the payment_intent from the thanks route says that payment is Incomplete, however, the webhook route's payment_intent says 'Completed' according to my dashboard.
Sorry, it sounds confusing...
the payment_intent from the thanks route says -> How did you get this payment_intent? from checkout.session.completed webhook ?
I'm so sorry... can you please elaborate?
You mentioned that you have retrieved two payment_intents and their status are different, one is from the 'thanks route' and the other is via the webhook route.
So I would like to understand more on the 'thanks route' and see how did you retrieve the payment_intent.
Oh okay. So I retrieved the payment_intent data in thanks route by using the above code.
pi_3K646jLsctVhWk9r18cwIhDa was retrieved while in thanks route, yet when I checked my Dashboard, the payment is incomplete. But the other payment_intent pi_3K646iLsctVhWk9r0zY2uhPb, was retrieved in webhook route.
please ignore that first 3 payment_intents in the db screenshot.
thanks route:
checkout_session = stripe.checkout.Session.list(limit=1)
print(checkout_session)
This is what it looks like.
payment_intent = checkout_session['data'][0]['payment_intent']
Is how I was able to grabbed the payment_intent data.
They are different payment_intents.
Give me a second, let me take a look on your PIs
appreciate you a lot
It seems like you have created two checkout sessions at the same time and only one checkout session is proceeded.
which part did I create another checkout session? was it because of this line: checkout_session = stripe.checkout.Session.list(limit=1) ?
I see.. uhmm where do you think I created the second checkout session based on the screenshot that I've shared with you?
I don't see any codes related to session creation in the screenshot, if you can share with me the code, I am happy to help.
BTW, I noticed that your fulfillment logic is based on the success page, and I highly recommend you to use webhook instead.
Oh sure. Let me try my best to capture everything Stripe related here. Just a sec:
You can learn more about order fulfillment with webhook here https://stripe.com/docs/payments/checkout/fulfill-orders
Here are the screenshots that's all stripe related
I hope this one helps with finding root of the problem... Thank you so much again for helping me out.. I've been stuck with problem for almost the whole day.. ๐ฆ
in the create-checkout-session route, why do you need both 'GET' and 'POST' methods?
to be honest with you, it's just a habit for me to add both methods... ๐
I would suggest you to put some log in he create-checkout-session route, to observe and figure out why it is invoked twice.
what do you mean by that? sorry i'm a beginner... ๐ really appreciate your patience
Are you using Flask?
yes
Maybe you can learn a bit about Flask logging here https://flask.palletsprojects.com/en/2.0.x/logging/
so you would sugges to have the users/customers log in to their own account?
to be able to access the create-checkout-session?
Sorry for the confusion, I mean logging, not log in.
could you give me an example of how i would incorporate that?
https://flask.palletsprojects.com/en/2.0.x/logging/ Here is how you do logging with flask.
Hi @stray tangle I am unable to help to you debug your own Flask application.
So far we can conclude that the checkout session is created twice and that's why you see two different payment_intents with different status, and now you need to troubleshooting your app to avoid duplicate checkout session creation.