#shaon
1 messages · Page 1 of 1 (latest)
Hi there!
What do you mean by "get the payment intent from stripe"?
Have you read this documentation that explained PaymentIntent + PaymentElement? https://stripe.com/docs/payments/accept-a-payment?platform=web&ui=elements
So I'm using stripe elements in a checkout screen whereby the user enters in some credit card details. Historically I've used the following:
stripe.Subscription.retrieve(
subscription_id,
stripe_account=stripe_app_id,
expand=["latest_invoice.payment_intent"],
api_key=api_key,
)
payment_intent = subscription["latest_invoice"]["payment_intent"]
But this will only get me the payment intent from the last time the user paid but not the new payment method the user just used
What is your end goal? To create a new subscription?
Yes correct
Do you have an existing payment method you want to reuse, or you want to collect a new payment method from the customer?
Yes exactly
So what will happen sometimes is a user will have paid for something but then they want to change their plan
but pay with a new credit card that is different to the one they used for the last invoice
currently my implementation will just use the last invoice's payment method but i would like to use the new one they just entered in checkout instead
well you can use https://stripe.com/docs/api/payment_methods/customer_list to see all the PaymentMethods attached to a customer
if it's not attached, then you can't use it. So it depends how you built the ability for them to pay, since it's possible to do a one-time payment that does not the save the card. It's hard to understand your setup without a specific example you share.
ok i'll have a think about how to use the customer payment methods list you've mentioned for my use case