#ilamathi-setup
1 messages ยท Page 1 of 1 (latest)
Hi there! I will try my best to assist you!
I was wondering if this payment was one-off or subscription?
it's for recurring, but after sometime user want to stop to use that payment method kind of scenario
If there is a subscription created for the customer, in order to update the payment method, there are 2 updates required:
- The default payment method for the customer
- The payment method for the subscription
i.e. the customer would first need to create a new PaymentMethod object and attach it to the customer object: https://stripe.com/docs/api/payment_methods/attach
You can then detach the existing PaymentMethod: https://stripe.com/docs/api/payment_methods/detach
And finally update the subscription's PaymentMethod to the latest attached new PaymentMethod: https://stripe.com/docs/api/subscriptions/update#update_subscription-default_payment_method
I am using the stripe platform only for the payment process and not using the subscription feature from stripe.. So here we are using the prebuilt checkout page from stripe and there we collected card details for future payment usage purpose as well.. From the checkout session i get the payment method id and will store in our platform.. Then i will use this payment method id for the future usage by creating the payment intent with this Id.. Now customer want to stop this payment method and use some other for the future payment.. So only just i am looking for the option to remove this future usage authorization for that payment method..
I see, in this case, you can detach the PaymentMethod from the customer object.
And attach the new PaymentMethod and use this for the future payments ๐
Actually detach, will just remove/detach this payment method from the customer, still the source will be there in the stripe right?
Or the entire payment_method & saved card details will be deleted?
Hi
Hello, sorry for the delay, just came back from a meeting
I have just tested, detaching payment method from customer will remove it
It will also disappear from the dashboard
Hope this helps ๐
ok so this detach will remove the payment_method & card details from the stripe platform itself right?
Yes
Even if you try to attach it to the same customer object again, the following error will result:
"error": {
"message": "This PaymentMethod was previously used without being attached to a Customer or was detached from a Customer, and may not be used again.",
"type": "invalid_request_error"
}
}```
Meaning you can't reuse it again ๐
Ok..
Also i came to know, the stripe prebuilt checkout page doesn't display all the user saved card & it only pre-populate with most recent card (mode: payment) is it true? If i want to provide a option to customer to select any one of the saved card, do we any option for that?
This is a good question, let me double check
Checkout Session itself does not allow a selection of the different PaymentMethod attached to a Customer object.
There are a number of other ways where the customer can select the card details, e.g.
- via Google Pay/Apple Pay and the card details are saved in their account for selection
- it is saved in the user's browser's cache
Ok from the checkout page we won;t have option to choose different card.. Either we can go with pre-populated card or click cahnge card and enter new card and go.. is that correct?
Yes
Do we have this listing all the saved card options in the stripe UI elements?
Unfortunately Payment Element does not have a card listing option for a specific customer either
But there is nothing stopping you from building a drop down list in your UI
oh ok.. any other option to do that? Actually i could see listing payment method API where i can get all the cards and display right?
There is an option to list all the payment methods for a specific customer: https://stripe.com/docs/api/payment_methods/list#list_payment_methods-customer
Awesome! We are thinking on the same page ๐ฅณ
But in this Payment API Listing for example customer saved 5 card and in that only one are set up for future usage.. But this payment_methods api response doesn't have that flag to identify.. Can u pls confirm?
There can be 2 options in your UI:
- To select an existing PaymentMethod from the drop down list via the above API.
- To enter a new payment method via Payment Element
Good point! Let me test this out!
Good news! If the setup_future_usage is not defined, the card is not saved to the customer!
Even when I list the PaymentMethods, the card is not there!
i.e. Only if setup_future_usage: true when attempting payment, the PaymentMethod is saved to the Customer object, otherwise we do not attach it to the customer.
Hope this helps! ๐
Actually this setup_future_usage have multiple value like offline, online..etc.. if this is mentioned as offline, we can use for future payment without user interaction ...
so i need to differentiate that out of other payment method
that's y i looking for this setup_future_usage flag or any other falg for this purpose
Thank you for your feedback!
You are right, this on_session and off_session info is only available in the PaymentIntent object itself, it is not exposed on the PaymentMethod
So i can not identify that offline future usage with this API
IS any other suggestion/option for this?
Hey, taking over here! Let me catch-up
So I understand, you're looking for a field on a pm_xxx object that determines whether it is setup for on/off session payments?
yes
That's not currently available I'm afraid
Why not just use off-session in every instance?
We have plan to offer both one time purchase & recurring payment as well.. For one time purchase flow no need to go with off-line instance & that will notify user with terms. "This card saved and will be used for future payment as well like that"
Then I recommend you set something on the metadata of the Payment Method
While creating the session i can set the metadata and that can be get it in this pm call?
That's not possible, no
ok.. then no other way.. i have to go with offline for all use case
That would be recommendation for the time being, yes
Ok thanks..
Is there any option to delete the saved payment_method other than detach pm from the customer API ?
Sure, np!
one more QQ, For save card expiry case, stripe will send mail to customer before 30 days.. Even the customer didn't update the card details on the next auto payment with payment-intent we will get the card expiry error right? Also is this notified with webhook events?
stripe will send mail to customer before 30 days
If you have that configured, yes
Even the customer didn't update the card details on the next auto payment with payment-intent we will get the card expiry error right
Assuming the bank declines the payment, yes. The recurring PI will fail
Also is this notified with webhook events?
Likely https://stripe.com/docs/api/events/types#event_types-invoice.payment_failed
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.