I’ve read a lot of forum posts about problems with line_items but I’m still stuck.
My initialize call is correct, I have the data displayed.
key : line_items
value : line_items[0][price]=price_1Q16iIBG8gDoGKFTHszpB2SN&line_items[0][quantity]=2&line_items[1][price]=price_1Q16ioBG8gDoGKFTt6kpNWO3&line_items[1][quantity]=10&
Hey Simon - any progress/new discoveries on this? I’m encountering the same problem.
@gregoryjohn (sorry to randomly mention you) - I’ve been following your Bubble SaaS course and am stuck right here as well. Have you had anyone reach out on this section with multiple line_items?
My problem has been with the line_items not being recognized (error code below):
Your error implies an invalid integer. Can you show me a screenshot of your call
and explain the use-case for 2 lines items for a Saas like the one from the course?
Here is a screenshot of how to initialise your checkout session call with 2 line items:
There’s so much topic about Stripe and how to format dynamically line items… please take time to search on forum. There’s a lot of different solutions provided already
For the use case, we are a nonprofit donation platform where users can choose to donate to any nonprofit organization in the United States. We use an external API to fetch this list since there are 1.8M nonprofits in the United States I’ve simply been following th Saas course for a starting point since I’ve had no technical background. Note, also because of this we are using price_data in Stripe because we cannot create 1.8M products within to create a Price ID.
For this reason as well, we’ve created an e-commerce experience with a cart, etc. so users can choose how much they want to donate, whether monthly or once, etc.
We’ve use a lot of price_data parameters from Stripe to get this data together, but here is that screenshot:
The line items are:
line_items[0][quantity]
line_items[0][price_data][unit_amount]
line_items[0][price_data][currency]
line_items[0][price_data][recurring][interval]
line_items[0][price_data][product_data][name]
line_items[0][price_data][product_data][description]
line_items[0][price_data][product_data][images]
If you want a shopping cart experience (variable nonprofits and pricing), you’ll need to configure this call using a JSON object instead of parameters like I’ve shown you on the course.
It will look something like this (but with slightly different formatting for dynamic values)
{
"quantity": 1,
"price_data": {
"unit_amount": 1000,
"currency": "usd",
"product_data": {
"name": "Donation to Nonprofit A",
"description": "Thank you for your generous donation.",
"images": ["https://yourdomain.com/imageA.jpg"]
},
"recurring": {
"interval": "month"
}
}
}
I’m walking out the door for dinner now but will make a note to come back to you on this.
You cannot use JSON with stripe. (Not directly. There’s a plugin that can convert it to something that you can use with stripe)
But if you only have one item, you can encode it directly in API connector.
The main issue actually is that you didn’t set the content-type header (application/x-www-form-urlencoded). You may need to also switch to raw instead of JSON for body type, but from what I know, it should work in JSON mode too (default header will be overwritted)
Got it, I’ve been messing around with the JSON and am continuing to have some issues of Stripe recognizing the data so that must be it (we did fortunately have content-type set in the header already)
This is not easy because if you use parameters, Bubble will encode them as JSON even if you set a content-type header (I’ve reported this issue, but they closed the request without fixing this). However, if you select queryst checkbox for all parameters, bubble will overwrite header (but send the parameters as querystring, that not all API that will accept to use querystring like url encoded form)
So you can delete parameters and use body like
key=value&key2_value and this will work.
If you have multiple line_items and need to dynamically change the # of line_items possible, I suggest to use this plugin: JSON Serialize to URL query Plugin | Bubble that was made for that (Stripe in mind) that will convert the JSON payload to the url encoded version.
Understood, thank you for all of your time, knowledge, and input Jici.
Based off of the brief “browsing” I’ve done, I’m going to give the following plug-in a quick shot and see if it will give us a similar outcome to what I’m trying to build here. (Stripe Checkout (Shopping Cart) Plugin | Bubble)
Option #3 will be to go with the Stripe Elements route and truly build out a custom checkout flow.