#evan_09475
1 messages · Page 1 of 1 (latest)
am following this doc in my integration
I am collecting the new Pm with the same payment element when user clicks on an edit button in my website.
I generate payment method from createPaymentMethod in the client, and then I send the PM to my API.
In my API, in the edit request, I use the the new Pm to attach it to the customer and detach the old one
this works fine when changing payment methods from card to card or from card to google pay
But when I try to change to stripe
Am not sure how the flow will work
Because initialy when I create subscription with paypal I have to handle nextActions in my client in order to verify the payment
That's not a good way, you should use SetupIntents instead, to set up Payment Methods for future usage without charging the customer: https://stripe.com/docs/payments/save-and-reuse
Then you can use the created Payment Method and attach it to Subscription.
I do this when I create the subscription in the first place
but when I edit the subscriptions, you mean using the attach and detach payment methods is not ideal?
I should use set up intent when I edit
?
No, I mean using createPaymentMethod is not the ideal way.
Yes.
I actually followed the doc I sent earlier
Actually, when you create a Subscription, you don't need to create SetupIntents, you can just create a Subscription object and then use an attached Payment/SetupIntent to collect the Payment Method: https://stripe.com/docs/billing/subscriptions/build-subscriptions?ui=elements
Oh, yeah, there's an old way that uses this method, and also the newest. But anyway, it's only for creating Subscriptions. For updating you can use the SetupIntent.
When I set the setup intent, it should need the payment method the user selected on the client right ?
What do you mean by "payment method selected"?
You mean selecting an existing Payment Method, or choosing a Payment Method type?
Lets say the user in the edit mode, selected paypal and clicked submit, in the client I have to create PM and then forward it the API so I create the setup Intent based on the payment method passed from the client
No, if you follow the guide, you will see that it's more like:
- You create a SetupIntent on the backend.
- You send the client_secret to the frontend.
- The customer selects a Payment Method type and provides the details.
- The customer clicks Submit.
- You call
confirmSetup()on the frontend. - You can listen to webhook events and get the Payment Method ID from
setup_intent.succeededand use it to update your Subscription.
Alternatively, you can use a Checkout Session in "setup" mode: https://stripe.com/docs/payments/save-and-reuse?platform=web&ui=checkout