#SteveAlopex - Stripe Checkout
1 messages ยท Page 1 of 1 (latest)
Hi ๐
You can use Stripe pre-defined prices. But you can also specify the price_data for the line_items in a Checkout Session:
https://stripe.com/docs/api/checkout/sessions/create#create_checkout_session-line_items-price_data
I also want to clarify that, if you integrate the Payment Element, Apple/Google pay is included.
https://stripe.com/docs/payments/payment-element
Oh awesome, for some reason I thought the payment element didnt have it.
So with the hosted checkout, I can define my my ID's and prices via what I already have in Firebase, it doesnt have to be products that have been imported into stripe?
That's not what the line_items.price_data does. If you want to use Price IDs you will need to create Stripe Price records. If you use line_items.price_data you will specify the details such as currency, unit_amount, and product or product_data.
Awesome! This was a big help thank you so much
Honestly, I would still create Price objects in Stripe. It makes reporting later on much easier
You could script it though, pulling data from Firebase and creating Prices
Using the Prices API
https://stripe.com/docs/api/prices/create
My only issue with the current workflow is we pull these out of a System called STORIS with a poor API that we built our own api to pull it in and store data in our GraphQL server but I dont see why we couldnt make another hook to pull it in?
Do the whole thing in Test mode (where you can wipe out all your data with the click of a button), and when you know your integration is just how you want it you switch to Live mode
We just store whats in a users cart via firebase not any actual product data
Ah okay
So meta deta in Elements is how i would pull additional data into Stripe orders correct?
No let's take a step back there. Elements are front-end tools that are used to collect payment details (Card Element, Payment Element). metadata is a property/parameter on Stripe objects.
What are you trying to achieve with metadata?
Ideally, when a user gets to our cart/checkout using Payment Element
We want to just collect a few things
Name
Address
Email
Phone
During their payment
Okay the Payment Element won't do that for you all the time.
The Payment Element is designed to adjust the information it collects based on the Payment Method the user selects to optimize acceptance
I may be mixing up Payment Element with Custom Payment Flow
The Payment Element is what is used on the front-end
The interface you see is the Payment Element
And if you change the Payment Method selected you should see the inputs change
This doc shows how to accept a payment using either the Payment Element or Checkout.
https://stripe.com/docs/payments/accept-a-payment?platform=web&ui=checkout
Is there anyway to collect user data this way or is this strictly accepting payment.
This deals with mainly Rural alaskans and furniture so ideally after purchase the store calls the buy using the phone Shipping address and name they provide to set up the shipping process
In that case Checkout may be a more suitable technology. You can specify shipping address collection by passing in the allowed_countries parameter: https://stripe.com/docs/api/checkout/sessions/create#create_checkout_session-shipping_address_collection
I tested creating a Checkout Session by specifying shipping_address_collection.allowed_countries as ['US'] and setting phone_number_collection.enabled=True. I was able to generate the following Checkout form that I think meets the needs you described earlier.
I was just playing with it too.
So this route would require me to have the products in Stripe correct to get the PriceID from Stripe? I can just throw in our Product ID and Price for item on the fly from our API?
Not quite.
If you did not want to create a Price or Product record in Stripe, you would need to provide those details as the price_data and product_data.
There is an example of this in the code snippets on the earlier doc I linked but this is basically what it could look like:
line_items=[{
'price_data': {
'currency': 'usd',
'product_data': {
'name': 'T-shirt',
},
'unit_amount': 2000,
},
'quantity': 1,
}],
So in this case, rather than providing the IDs of Products and Prices that exist in Stripe, you provide enough data to identify a Price or Product
Perfect, okay! I think i got everything i need thank. Thank you so much for going in circles with me
Sure thing! It's why we are here ๐