#venkateshjsoft
1 messages ยท Page 1 of 1 (latest)
Hi there ๐ do you have a concern that you're looking for assistance with?
im currently getting the latest charge id using the payment intent id
but some cases, payment method is updated but im using my old payment intent id to get the payment charge which is not the latest
is there a way to get the charge id latest always
Hm, I'm not sure I'm grasping what you're trying to accomplish.
The latest_charge on the Payment Intent will contain the latest Charge object related to that Payment Intent. Is that not what you're referring to when you say you want to "get the charge id latest always"? Are you instead trying to get the most recent Charge by Customer, or something along those lines?
yes i want to get the latest charge id from the customer
we have some logic to use the very first payment intent which is user created to get the latest charge id
for example payment method is changed, and if I try to get the payment method from the very first payment intent id then i may not get the latest payment method right
Gotcha, then you can make a request to list Charges:
https://stripe.com/docs/api/charges/list
when doing so you can pass the ID of the Customer, that you want to see charges for, to the customer parameter and the results will only be Charges associated for that Customer.
You can set limit to 1 so you only retrieve the one most recent Charge.
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
User A paid using credit card with payment intent ABC
User A paid paid using ideal with new payment intent EFG
If I try to get the payment method using ABC, then I will be getting card
but I want to get ideal.
the above is the use case
if I limit to 1, will it take the return the very recent charge or the very first one?