Reputation: 11861
How do I get the price for a subscription product in Stripe where there is volume pricing? The Pricing API docs are here.
For example, in the Stripe dashboard I create a single subscription product priced at $10/month for the first 5 units, $5 thereafter. So if the user enters 5 into a numeric input on a webpage then I want to display $50. If the user enters 6, I want to display $30. I want the value from Stripe, not try and calculate it in the browser.
The Stripe docs on subscriptions don't seem to cover anything other than multiple tiered products, each with a fixed price.
When I create the subscription I can set the quantity, but I want to display the price before the user commits to buying.
Note: this question specifically relates to using the Stripe API and is not about getting the price by using a vendor product.
Upvotes: 1
Views: 2933
Reputation: 7459
You can use the Upcoming Invoice API for this. In particular, you'd want to provide pricing & quantity with the subscription_items
parameter to simulate a new subscription:
curl https://api.stripe.com/v1/invoices/upcoming \
-u sk_test_123: \
-d customer=cus_456 \
-d 'subscription_items[0][price]=price_789' \
-d 'subscription_items[0][quantity]=10'
If this is for a new customer, you'll need to create a Customer to use with the API, as the customer
parameter is required. You can create a customer with just a description -- it's not necessary to collect personal details up front.
Upvotes: 2