Simple question but no clear solutions, so far. I need my users subscribe to my metered billing plan (Usage based) in Stripe.
It doesn’t work with bubble.io stripe plugin because in “Subscribe user to plan” there is a placeholder “Quantity” which cannot be for Metered plans.
Now I need some other way to do that.
I have already created “Create customer” and retrieve customer id with stripe docs but I have problems what’s next. I would need to create this “window” with my product on the left and card credentials on right (for users) and buttom subscribe - so the customer can subscribe. How to do that.
I have already everything else with recording usage and reporting to stripe and webhooks. Just need some solutions with that, code or no code.
Thank you so much!
It sounds like you’re up to the step where you’ll want to call the checkout API, which creates a url for you to send the client to and they will enter their card details etc?
1 Like
exactly! would you like to help me with that? I would be very grateful because talking with stripe support is a terrible experience. Thanks
Sure think, the full documentation is here: Create a Session | Stripe API Reference
curl https://api.stripe.com/v1/checkout/sessions \
-u "sk_test_wsFx86XDJWwmE4dMskBgJYrt:" \
--data-urlencode success_url="https://example.com/success" \
-d "line_items[0][price]"=price_1MotwRLkdIwHu7ixYcPLm5uZ \
-d "line_items[0][quantity]"=2 \
-d mode=payment
Thats the demo call but you can add other params like customer fields if you’ve already set them up etc.
Then it will give a response which includes the url for payment processing.
Hope that all makes sense?
I have already created api calls for “Create a customer” and to retrive their customer id from stripe. So as I presume there would be a possibilty that this checkout session already be with a given user email (linked to customer id) seen? But I am not sure how should the api messege look like then? Price id and customer id as parameters? As it’s for metered billing quantity probably shouldn’t be used as for usage I have already created workflows. Thank you very much for your response! If had yet patience for these questions as well, would be perfect!
Yeah so with the checkout session you can reference the client id and associate that with this sign up.
You need the customer to sign up to the subscription, which you then report usage onto and that then bills the customer 
1 Like
Whole metered billing done, thank you for your help!
1 Like
Hi, Thanks for the advice here. I’ve run into a problem. I have created 2 API call steps:
- Create Customer
- Checkout Session
- Go to External page (using the session URL created in step 2).
The only way I could think to get checkout session to show up (so the user could subscribe to the plan) was to use the “external page”. It works, but there’s no way I can figure out how to then connect the subscription to the user in bubble.
If i used the official stripe plugin it manages to do this because it returns me to the page after checkout and allows me to update the user details. However, I cant use this for the same reason as the original poster as I’m using metered billing. Can Oliver or Olek explain this part of the process?
Thank you!