#ibgoldbergs
1 messages · Page 1 of 1 (latest)
Hello! Creating a Payment Method will succeed as long as the card number passes basic checks (like length, LUHN, etc.). It sounds like you're expecting transaction-related errors to be surfaced at that time, but that won't happen because no transaction has been attempted at that point.
Got it, so just because we are able to generate a paymentMethod does not mean the card is valid?
What is the best practice to validate that the card is okay so we can quickly give feedback to client
Can you describe your payment flow in a bit more detail?
Like is there a delay between when the payment info is provided and when the Subscription is created?
So we have a credit card component which creates a payment method
then we use payment method and hit an endpoint which creates a customer if one does not already exist... and if a subscription is warranted we create a subscription as well
we don't always create the subscription right away, depending on circumstances of business logic
To clarify, though, you're always collecting payment info even though you're only creating a Subscription sometimes? If you don't create a Subscription what do you use the payment info for?
if we dont create subscription right away, we just add the payment method to the customer and we have a daily lambda that will create the subscription when its time to
sort of like we implemented our own trial system, and we aren't using stripe trials yet
Okay, so you should be using a Setup Intent to validate the payment info and set it up for future use: https://stripe.com/docs/payments/save-and-reuse
Got it. So for our use case, it sounds like you recommend:
- Create paymentMethod on front end
- Hit our endpoint
- This endpoint will create the customer, attach payment method to customer
-
you recommend adding this step to create a SetupIntent (will validate card and we can pass back errors to front end)
- If credit card is validated we can create subscription right then and there OR create at a later date
does that seem right?
No. You should create a Setup Intent and pass its client secret to your frontend so the Setup Intent can be confirmed client-side.
After that you can attached the Payment Method to a new or existing Customer, then use it now or later for Subscriptions.
The SetupIntent documentation looks like it wants customer_id though, so don't we need the customer first?
You can create and use a Setup Intent without a Customer, then attach the resulting Payment Method to a Customer after the fact.
We recommend you create the Customer first in the docs, but you don't need to do it in that order.
You can see in the API reference that customer is optional: https://stripe.com/docs/api/setup_intents/create#create_setup_intent-customer
Roger that. I think I have enough info to work on. Very helpful, thanks.
No problem! If you need anything else let us know!