#bruno-paymentmethods

1 messages · Page 1 of 1 (latest)

clever panther
#

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

  1. nothing happens(creating a PaymentMethod is just creating an object in Stripe, it doesn't check anything else or contact banks).
  2. 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.

remote ridge
#

Thank you for the detailed response.
Our overall use cases for stripe.createPaymentMethod() are in the context of subscriptions:

  1. 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.
  2. 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!

winged lark
#

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?

clever panther
winged lark
#

Sorry to jump in @clever panther can you advise (not using checkout) the flow for subscriptions

  1. Create stripe customer id , store in our own database
  2. 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?

remote ridge
winged lark
#

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.

remote ridge
#

I'm also not sure why that's the recommended flow, but everyone suggests it now.

clever panther
#

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

winged lark
#

ok so now i have to re-write it all oh boy

remote ridge
#

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

winged lark
#

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!

winged lark
#

@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?

clever panther
#

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

winged lark
#

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 :

  1. 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?
clever panther
#

well you can create the subscription when you load the page

winged lark
#

in which scenario would that happen?

clever panther
#

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

winged lark
#

you mean when the user selects PRO PLAN, without submitting, just selected the plan?

clever panther
#

yep you can do it at that point

winged lark
#

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?

clever panther
#

create sub, confirm PI, versus attach PM, create sub, confirm PI