# Multiple line\_items in bubble API connector Stripe

**URL:** <https://forum.bubble.io/t/multiple-line-items-in-bubble-api-connector-stripe/340708>\
**Category:** APIs\
**Created:** [September 25, 2024, 1:01pm UTC](https://forum.bubble.io/t/multiple-line-items-in-bubble-api-connector-stripe/340708 "2024-09-25T13:01:22Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![simon.roge](https://avatars.discourse-cdn.com/v4/letter/s/48db29/32.png) [@simon.roge](https://forum.bubble.io/u/simon.roge)\
**Post date:** [September 25, 2024, 1:01pm UTC](https://forum.bubble.io/t/multiple-line-items-in-bubble-api-connector-stripe/340708/1 "2024-09-25T13:01:23Z")

</div>

Hey guys,

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&

 ![image](https://us1.discourse-cdn.com/bubble/original/3X/8/9/89216d313751345feb06183f22b6edc87175ac7b.png)

As soon as I want to make the call in a workflow, it throws me this error.

![image](https://us1.discourse-cdn.com/bubble/original/3X/e/a/ea962e264232670a3391d63cc3bc6c34b10d2502.png)

![image](https://us1.discourse-cdn.com/bubble/original/3X/5/6/5617790daa507a5d334bc7308766475948e9bcdc.png)

Do you have an idea of what I’m doing wrong ?

Thanks in advance,  
Simon

---

<div class="post-metadata">

**Author:** ![whedrick](https://avatars.discourse-cdn.com/v4/letter/w/ed8c4c/32.png) [@whedrick](https://forum.bubble.io/u/whedrick)\
**Post date:** [October 31, 2024, 3:08pm UTC](https://forum.bubble.io/t/multiple-line-items-in-bubble-api-connector-stripe/340708/2 "2024-10-31T15:08:09Z")

</div>

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):

{  
"error": {  
"code": "parameter\_invalid\_integer",  
"doc\_url": "[Error codes | Stripe Documentation](https://stripe.com/docs/error-codes/parameter-invalid-integer&quot;),  
"message": "Invalid integer: 20, 10",  
"param": "line\_items[0][price\_data][unit\_amount]",  
"request\_log\_url": "(removed for security);,  
"type": "invalid\_request\_error"  
}  
}

---

<div class="post-metadata">

**Author:** ![gregoryjohn](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/gregoryjohn/32/209419_2.png) [@gregoryjohn](https://forum.bubble.io/u/gregoryjohn)\
**Post date:** [October 31, 2024, 3:50pm UTC](https://forum.bubble.io/t/multiple-line-items-in-bubble-api-connector-stripe/340708/3 "2024-10-31T15:50:33Z")

</div>

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:

 ![Screenshot 2024-10-31 at 15.44.48](https://us1.discourse-cdn.com/bubble/original/3X/8/9/89d6d66964871ce73e84e921cc4972dbc495ef6e.png)

---

<div class="post-metadata">

**Author:** ![Jici](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/jici/32/30722_2.png) [@Jici](https://forum.bubble.io/u/Jici)\
**Post date:** [October 31, 2024, 3:53pm UTC](https://forum.bubble.io/t/multiple-line-items-in-bubble-api-connector-stripe/340708/4 "2024-10-31T15:53:01Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![whedrick](https://avatars.discourse-cdn.com/v4/letter/w/ed8c4c/32.png) [@whedrick](https://forum.bubble.io/u/whedrick)\
**Post date:** [October 31, 2024, 4:55pm UTC](https://forum.bubble.io/t/multiple-line-items-in-bubble-api-connector-stripe/340708/5 "2024-10-31T16:55:06Z")

</div>

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]

 ![Screenshot 2024-10-31 at 12.48.55 PM](https://us1.discourse-cdn.com/bubble/original/3X/4/b/4b4f22ec6a11439b2fe4186162e62fc9d4fc39b7.png)

---

<div class="post-metadata">

**Author:** ![gregoryjohn](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/gregoryjohn/32/209419_2.png) [@gregoryjohn](https://forum.bubble.io/u/gregoryjohn)\
**Post date:** [October 31, 2024, 5:11pm UTC](https://forum.bubble.io/t/multiple-line-items-in-bubble-api-connector-stripe/340708/6 "2024-10-31T17:11:31Z")

</div>

I understand. Big project!

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)

```auto
{
      "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.

---

<div class="post-metadata">

**Author:** ![whedrick](https://avatars.discourse-cdn.com/v4/letter/w/ed8c4c/32.png) [@whedrick](https://forum.bubble.io/u/whedrick)\
**Post date:** [October 31, 2024, 5:26pm UTC](https://forum.bubble.io/t/multiple-line-items-in-bubble-api-connector-stripe/340708/7 "2024-10-31T17:26:00Z")

</div>

You’re a rockstar - thanks for the quick response and all of the information you’re pouring into us new Bubble users through Basecamp, YouTube, etc.

Will start playing around with JSON and see what I can get fixed. Thank you sir!

---

<div class="post-metadata">

**Author:** ![Jici](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/jici/32/30722_2.png) [@Jici](https://forum.bubble.io/u/Jici)\
**Post date:** [October 31, 2024, 7:41pm UTC](https://forum.bubble.io/t/multiple-line-items-in-bubble-api-connector-stripe/340708/8 "2024-10-31T19:41:35Z")

</div>

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)

---

<div class="post-metadata">

**Author:** ![whedrick](https://avatars.discourse-cdn.com/v4/letter/w/ed8c4c/32.png) [@whedrick](https://forum.bubble.io/u/whedrick)\
**Post date:** [October 31, 2024, 7:56pm UTC](https://forum.bubble.io/t/multiple-line-items-in-bubble-api-connector-stripe/340708/9 "2024-10-31T19:56:47Z")

</div>

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)

---

<div class="post-metadata">

**Author:** ![Jici](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/jici/32/30722_2.png) [@Jici](https://forum.bubble.io/u/Jici)\
**Post date:** [October 31, 2024, 8:05pm UTC](https://forum.bubble.io/t/multiple-line-items-in-bubble-api-connector-stripe/340708/10 "2024-10-31T20:05:25Z")

</div>

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](https://bubble.io/plugin/json-serialize-to-url-query-1620746367567x329671693196591100) that was made for that (Stripe in mind) that will convert the JSON payload to the url encoded version.

---

<div class="post-metadata">

**Author:** ![whedrick](https://avatars.discourse-cdn.com/v4/letter/w/ed8c4c/32.png) [@whedrick](https://forum.bubble.io/u/whedrick)\
**Post date:** [October 31, 2024, 9:02pm UTC](https://forum.bubble.io/t/multiple-line-items-in-bubble-api-connector-stripe/340708/11 "2024-10-31T21:02:21Z")

</div>

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](https://bubble.io/plugin/stripe-checkout-shopping-cart-1688799678956x627756525425786900))

Option #3 will be to go with the Stripe Elements route and truly build out a custom checkout flow.

Thank you!
