#bruno-paymentmethods
1 messages · Page 1 of 1 (latest)
In general you should use client side of confirmation of PaymentIntents rather than directly creating PaymentMethods. What's the overall use case?
To answer the questions
- nothing happens(creating a PaymentMethod is just creating an object in Stripe, it doesn't check anything else or contact banks).
- Not really. We don't clean them up. They just exist and you can ignore them(they can't be listed in any API call, you can only retrieve them if you know the ID
Note also you should use the PaymentMethod immediately since they contain a CVC the customer entered, and we have to purge CVCs from our systems within a certain time period for PCI reasons , so if you use a "stale" PaymentMethod then that payment won't be able to send the CVC to the bank to check it. So overall you should just use client side confirmation of PaymentIntents.
Thank you for the detailed response.
Our overall use cases for stripe.createPaymentMethod() are in the context of subscriptions:
- Create payment method just before starting a subscription - we're still not sure if we'll go with
stripe.createPaymentMethod()because stripe recommends other approaches. - Use it for updating customer's default credit card (when a customer already has active or 'past_due' subscription). To my knowledge we HAVE to use
stripe.createPaymentMethod()for this.
@clever panther any input on the above is welcome, thanks!
Hi @remote ridge I am doing exactly that followed form strips docs for subscriptions. (which seems to be updated now)
my flow is
- Create customer id store in database
- Add payment method and attach to customer id
- Create subscription on customer id.
@clever panther you mentioned we should use paymentIntent rather then create payment method for subscription, any benefit?
@remote ridge
- yep you should use our recommended approach(
default_incompletesubscriptions) - you should use SetupIntents for that : https://stripe.com/docs/payments/save-and-reuse + set e.g. https://stripe.com/docs/api/customers/update#update_customer-invoice_settings-default_payment_method
or you can use Checkout (we have a worked guide for that flow at https://stripe.com/docs/payments/checkout/subscriptions/update-payment-details)
Sorry to jump in @clever panther can you advise (not using checkout) the flow for subscriptions
- Create stripe customer id , store in our own database
- Normally as @remote ridge is doing i would then createPaymentMethod which attachs the card to the customer
3)createSubscription
but how would i chaneg the above to use elements?
@winged lark here's the tutorial you can look up: https://stripe.com/docs/billing/subscriptions/build-subscription?ui=elements
yup looking at it,, it seems it was updated from last year, where previoulsy they would suggest to attach a payment method first. now its the other way around.
I'm also not sure why that's the recommended flow, but everyone suggests it now.
yes it was changed so now you create the Subscription first, then take the first invoice's PaymentIntent and confirm that client-side, instead of passing the PM from the frontend to the backend
it's because it makes working with non-card payment methods easier, and it also avoids an API call(attaching the PM to the customer) in the core checkout flow, and that API call also sometimes did an unnecessary validation of the card(we sometimes do a $0 charge on the card when attaching it to a customer) which caused some confusion and complications with 3D Secure
ok so now i have to re-write it all oh boy
Yea, custom stripe integration is hard.
I did another custom stripe integration 5 years ago - it was a lot simpler. No 3DS, loose PCI compliance...
@clever panther thanks a lot for elaborating the reason
i did authorize.net 15 years ago, it was a mess, but fully hosted on our page. no pci back then, and no https clear text!
@clever panther Hi again, the docs say to create the subscription with incomplete first, then come back to front end to complete the payment.. why? Cannot i send the card element details and subscription in one shot to the backend?
you'd create the subscription when the page loads, is the intention
and then your frontend just calls one function in Javascript(confirmPayment) which collects the payment details, pays the first invoice, and activates the subscription
in many cases the user will select a subscription and enter payment details and hit one single submit button.. but in the docs, it seems to separate these steps? it says :
- create subscription first and wait for the client_secret, then call stripe.confirmCardPayment when the customer submit the elements form? -- this means it has to be clicked twice?
well you can create the subscription when you load the page
in which scenario would that happen?
e.g. if you use something like server-side rendering, as part of the your route ("/subscription-page") you create the Subscription then and embed the client secret into the HTML directly
you mean when the user selects PRO PLAN, without submitting, just selected the plan?
yep you can do it at that point
but they may change.
its like adding to cart, before actually adding to cart..
i dont see how less api calls are made. as when the subscription response is returned, the confirm card payment request is sent back.. still 2 api calls no?
create sub, confirm PI, versus attach PM, create sub, confirm PI