Stripe API - Create new subscription

Hi, I am building out my own stripe connection for more flexibility, I am at the area where I need to make an API call to “Create a Subscription”. On the Stripe Dashboard, I have created a Product with 5 different prices. Now to create the Call, I get an error on Bubble API Connector.

Bellow is my setup and error message." On the second Parameter Key, I have tried making it “Items”, but still receive the same error message.


take the parameters off and use the JSON object and provide your dynamic data there. It’s your items array that’s improperly formated.

delete the parameters you have and try

{
“customer”: “”,
“items[0][price]”: “”
}

The other parameters you have listed for creating a subscription to a customer for a price already in stripe system is useless.

@miracle

You have the wrong formatting for the parameter: items.price_data.unit_amount

Try using items[][price_data][unit_amount]

I have created the in-depth stripe-bubble series-

Do checkout

Hi @doug.burden
Thanks for the response. The reason i have these other parameters is, I am building something that allows a user to donate on a recurring base, and choose their own amount.
I was thinking those fields were going to help modify the individual subscription for an individual Customer.

i am new to this, what do you think?

I’m not sure what you’re referring to, or what exactly you’re trying to do?.. Is the API call still not working?

Nope.
It says, “Invalid request (check your POST parameters): unable to determine value for parameter: items.”

If the user is going to choose their own prices for recurring charges, you’d need to first make an API call to create a new recurring price with the amount the user chooses and the interval of charges - ie: weekly, monthly, yearly; then subscribe user to the ‘price’.

You can currently do this with the Stripe.js 2 plugin made by Copilot.

Ahh I see.

I thought i could just create one general product and price, and have customers choose them but modify their own price in the subscription level.
Just new to this whole API thing :grimacing:

Let me play around with something, if I get it to work how you’re talking about I’ll share screen shots to help you get up and running.

1 Like

Have you looked at the Stripe API docs for creating a subscription?..

there are quite a few required parameters that you’re missing:
items[][price_data][currency]
items[][price_data][product]
items[][price_data][recurring][interval]

Also, you can’t have both price and price_data paramaters (you’re either using a predefined price from your Stripe account, or defining one in the call… you can’t do both).

So get rid of the items[][price] parameter, and be sure to include ALL of the required parameters (as per the docs):

items[][price_data][currency]
items[][price_data][unit_amount]
items[][price_data][product]
items[][price_data][recurring][interval]

I’ve just tested this for myself, and everything works as it should.

Will this work if just create one general product and price, and have customers choose them but modify their own price in the subscription level?

Yep (and confirmed in my own testing)… but don’t just take my word for it… test it for yourself.

1 Like

Can you please send a screen shot of your setup, let me see what i am doing wrong, My head is going nuts now…lol

This is what’s working for me:

1 Like

here is your option to create multiple prices under 1 general product and let the user choose the price


Then when you charge the user the price id that was created they’ll automatically be on the recurring cycle

1 Like

This might be a dumb question for you Pros, but can I use “one product and one price” and have the customer modify the Price unit amount on the Subscription level so that the Original Product and Price remain the same for other users to lift from?

Used Case:
I am actually building a simple system for people to give donations to an organization.
In Stripe I have

  1. Created a Product called “Donation”
  2. Created 5 different prices
    a. $1.00 (OneTime)
    b. $1.00 (per Week)
    c. $1.00 (per Month)

The idea is to have it set up (If possible) in such a way that, let say
John wants to donate $100 every week, starting on November 1st, 2022, when the button is clicked, an API call to create a subscription from the price b. ($1.00 (per Week)) whose recurring is already set to weekly, and then modify the pricing and attach it to the customer’s subscription
BUT DOESN’T CHANGE THE ORIGINAL PRICE.

Like i said, I am new to this API stuff

Thanks for all your assistance

Yes… that’s exactly what I’ve assumed you’re trying to do… and what I’ve already explained how to do in this thread…

1 Like