#cnguyen
1 messages ยท Page 1 of 1 (latest)
On the Stripe example, we have to create the customer first, then create the PI with the cus_XXX (to have the pi_secret) and init the Stripe Element with the pi_secret. Then make the payment.
But, on my side, I arrive to the payment form with the customer info, the price and the Stripe Element already displayed
And, when the user enter his card and click pay. I would like to create the customer, then create the pi and validate it. Something like that. TO avoid to make multiple call to the WS (one for customer creation and create the pi. Then display the card form to add the pi_secret infos inside. Not sure about the flow
And on my pi, I will set the offline setup_future_usage for later
Yes currently for using the payment element you need to create the intent first, though we're working on offering more integration patterns here
OK so with Stripe Element, there is no choice to create the PI first
It means I have to create the customer first too ? And if I want to create the customer only on payment success?
So :
- Before to display the card form, I have to call a WS to create the customer. And create the PI with the customer info (in order to have the customer with the attached pm)
- I receive the pi_secret. Then I can display the form.
So, if the user decide to do nothing on the payment page, I will have a "losing" PI and customer ?
I thought that we can use the StripeElement to have a pm_XXX. Then I can call a WS with the pm_XXX and create the customer and the pi_XXX with that. Then, the user can validate the payment?
Like that I create the customer and the PI only after that the shopper is OK to pay (enter his credit card and valid)
You can't currently create the PM like that first, no, but we're working on that ๐
Yes, you'd need to create the PI up front for now, then cancel it and/or delete a customer if you're using customers
mmmm ok
And when I create the customer (using the email id), I have to check if the customer exist before to create him ?
And, are you sure because I see that there is a the stripe.createPaymentMethod ?
If you want to deduplicate that way, yes
You can do this with the Card Element, yes, not the Payment Element
oh sorry I would like to speak about the cad element since the beginning
Card elemnt is possible with html css php ?
Yes you would be able to use the card element with all of those
It is also worth noting that we do have a beta that allows you to create payment methods with the payment element. It is a decently different flow but if it makes sense for you you may want to apply https://stripe.com/docs/payments/defer-intent-creation-confirm-server
I will check
So the flow with the card element could be more interesintg to avoid to create customer for nothing non ?
You could certainly use that to avoid having to create a customer if that wouldn't work for your needs
That being said you can re-use customer/payment intent objects, so recycling them could potentially be less cumbersome if you don't like creating so many
OK
And What is the best option between the card element and the stripe element ?
with the card element, I have to attach the customer and the PM myself ?
We typically recommend using the payment element as it is newer and more feature-rich
Sometimes creating extra objects isn't great but can be worth the functionality you get in return
ok so for you, the best is to create the payment element with the pi_secret
and to do that, I have to create the customer and the pi before to display the payment element to the customer
right ?
That is the typically recommended path but you can use the older element if that makes more sense for you
ok I will take a look. With the Card Element, I have to create the pi before anyway ? Or it means that I can wait to have the pm_XXX generated by the Card Element, then create the PI with the pm_XXX generated ?
Card Element requires the PI up front: https://stripe.com/docs/payments/card-element
so it's exactly the same than the Stripe Element. No advantage to use it
Correct
OK I will use the new way so
And to check if the customer exists. What is the best way ?
You would likely want to store customer information in your own database and then perform a check against the customer data. Similarly, you can use the Search Customer function to check your Stripe customers: https://stripe.com/docs/api/customers/search
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
oh it's a new feature to search like that !
Yep! It has been around for a little while at this point, but I believe it's less than a year old
I believe you'll need to update to some API version > 2022-03-25
I have to specify it in my stripe dashboard too ? or I cann let the old versin ?
because I'm afraid to break something
Things should be backwards compatible in virtually every case, but if you want to be extra careful, you can specify the API version on a request-by-request basis instead: https://stripe.com/docs/api/versioning
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.