#venkateshjsoft
1 messages · Page 1 of 1 (latest)
I created new payment intent and user authorize the payment and payment posted successfully.
When I collect the new payment for the same user, a new payment intent is created.
is there way I can get the old payment intent id for the new payment
because we store the first payment intent id for as a reference for the future payments
When we get the webhook for the new payment, it will be the new payment intent id so im not sure how to find our the oringal payment id so I can link it in my system.
clear?
You could list all PaymentIntents for a given customer ID: https://stripe.com/docs/api/payment_intents/list
When I check the new payment I see the old payment intent as Setup for future usage
is there a way I can get it from the api
because getting all the payment intent for the customer then filter it with the one I have it my system can cause performance issues
no, unfortuantely we don't provide a simple API field to indicate if the PaymentMethod has been set up before
when I make new payment for the same user with the original payment intent id, your api is creating new payment intent
and I believe the webhook also comes with the new payment intent id
so you mean only the customer id is the field to find the original payment intent id?
every new payment on a saved card is a new PaymentIntent yes
yep, that, or storing the IDs in your database etc
im storing the original payment id
payment intent id
but how can I get the original payment intent id from the new webhook
well you can't directly, since the webhook has nothing to do with any old PaymentIntents, it's about the PaymentIntent it's about.
yes but when I make new payment, im using the old payment intent id right
so as mentioned you can list old PaymentIntents in the API, while handling the webhook, if you need to.
no?
the old PaymentIntent ID has nothing to do with it. As I said, every new payment on a saved card is a new PaymentIntent.
wait
let me explain again
- I create new payment intent and store the payment intent id. I set this payment intent for future usage.
- User authorize the payment
- Payment completed and I received a webhook with the same payment intent id.
- I sent new payment request again after few days with the same payment intent id.
- Payment completed and I received a webhook with the new payment intent id.
in the step 5, I would like to know the original payment id which I used to post the payment in the step 4
sent new payment request again after few days with the same payment intent id.
that's not how it works though
you can't use the same PaymentIntent ID, it woudn't work at all. You create a new PaymentIntent ID when you're doing a new payment request
so the question doesn't make sense, so it's hard to answer
im able to make another payment with the same payment intent id
I can give the request if you want
first payment request: req_JBQ2Wc7Lyfy3UA
second payment request: req_CvtcankKTwfBxX
yeah, and those are two different PaymentIntents, as I said.
yes they are 2 different payment intent for the same user
im able to make another payment with the same payment intent id
maybe you mean the same "payment method id" ? 🙂
but when I make second payment request, im passing the orignial payment intent id (first payment)
then how stripe is able to charge the same customer again
no you're not? https://dashboard.stripe.com/test/logs/req_CvtcankKTwfBxX is your second payment request. What exact parameter there in the call you make is "the original payment intent id"?
because you passed us the Customer and PaymentMethod ID to charge and tell us to charge it.
{
"paymentintent_id" : "pi_3NrdpnB4yD6nPBkB1KzXtHgK",
"amount" : 5600,
"type" : 1
}
this is the request im passing, I think stripe has some logic internally to find the payment method and transform the request
that's not the request being passed to our API though
so I assume you use some third party library/framework that I wouldn't know about
yes I got it
maybe that framework does some magic internally to figure out who the PaymentIntent belonged to and re-charge it , sure
yes your are correct
there is some logic internally gets the customer id using the payment intent and then get the last charge id and payment method from the last charge id
anyways its clear now. Thanks
one last question. is there a way to identify if the payment intent created is for the first time?
from the webhook
do you mean, is it the first PaymentIntent for that customer?
yes
We configure webhook and we have to process the payment intent differently
so we need to knwo if its for the first time or subsequent payment
You could list all PaymentIntents for a given customer ID: https://stripe.com/docs/api/payment_intents/list and if the list is empty then the PaymentIntent you are going to create is the first one
or I suppose since it's a webhook after the PaymentIntent was created, if the list has 1 entry, then it's the first, and if it has more than 1, it's not