#amandaj-adhoc-payments
1 messages · Page 1 of 1 (latest)
Thanks! Basically i have a client that wants to accept payments on his website of any value. They manage their inventory outside of stripe and need to allow customers to put in a custom amount and submit payment
Gotcha. Are you planning on using Stripe Checkout or Elements?
Let me know if you aren't familiar with the differences there
Stripe Checkout is our pre-built Checkout versus using Elements is a custom form that you build. You can see both in our docs here: https://stripe.com/docs/payments/accept-a-payment
With Stripe Checkout you will redirect the customer to our hosted Checkout page
Versus with Payment Element you mount the iframe to collect card details directly on the website.
So just depends on what you are looking for
Stripe Checkout is the easier one to integrate
lets go with stripe checkout for now as the client is wanting this done asap
Cool. So with Stripe Checkout you will create a form to collect the desired amount you want to charge, then you pass that amount back to your server when the customer clicks your "checkout" button and you set that as the amount to charge via the line_items.price_data.unit_amount (https://stripe.com/docs/api/checkout/sessions/create#create_checkout_session-line_items-price_data-unit_amount) when you create the Checkout Session and redirect the user.
Recommend reading through the docs I linked above which will give you a sense of how to integrate Checkout overall
The extra piece is just adding your own form to collect amount and dynamically setting the unit_amount on the Checkout Session based on that amount
And if the desired amount is going to change from customer to customer? Would i need to create a checkout session for the desired amount anytime I know a customer is going to be paying?
Yep that's how Checkout works. You create a Checkout Session every time a customer pays
That is how you get the URL to redirect the user to
okay. and if I dont want to have to create a checkout session for every customer would the elements be a better route? basically once I set this up for the client i would like to step back but theyre going to have no clue how to do so.
You would not actually create the Checkout Sessions manually. Your code does that automatically upon the customer clicking your "checkout" or "pay" button (or whatever you name it).
Same would hold true for Elements... you would programmatically create a PaymentIntent in that case.
Oh right okay that makes sense! sorry i'm pretty clueless on this stuff.
No problem. Like I said, I'd give a read fully through the above doc (https://stripe.com/docs/payments/accept-a-payment) and then come back with any questions we can help with!