Setting Subscription Quantities

One way to change the amount billed to a customer is to use quantities. Quantities are often used to have your subscriptions reflect either multiple simultaneous purchases or to easily support multiple payment amounts.

By default, each subscription is to one instance of a plan, but Stripe does allow you to subscribe a customer to multiple quantities of a plan to flexibly adjust the amount billed each period.

For example, say you run a hosting company through which a customer may host 5 sites at a cost of $9.99 per month. You could create a plan for $49.95 and subscribe the customer to it. But then you would also need $9.99, $19.98, and other plans. Furthermore, the billing of $49.95 for 5 hosted sites would not be easily distinguished from your customers on your deluxe hosting plan at a cost of $49.95. The solution is to subscribe your customer to 5 of the $9.99 plan.

As another example, if the amount each customer pays can vary greatly, you could end up with too many plans to address all possible cases, and yet still need to create new plans for new situations. Alternatively, you could create a $1 plan and subscribe each customer to the appropriate quantity, thereby creating virtual $5 plans, $8 plans, $17 plans, and so forth.

To set the quantity of a plan, provide that argument and value when creating or updating the subscription:

# Set your secret key: remember to change this to your live secret key in production
# See your keys here: https://dashboard.stripe.com/account/apikeys
Stripe.api_key = "sk_test_BQokikJOvBiI2HlWgH4olfQ2"

Stripe::Customer.create(
  :source => token,
  :plan => "basic_monthly",
  :email => "[email protected]",
  :quantity => 5
)
# Set your secret key: remember to change this to your live secret key in production
# See your keys here: https://dashboard.stripe.com/account/apikeys
stripe.api_key = "sk_test_BQokikJOvBiI2HlWgH4olfQ2"

stripe.Customer.create(
  source=token,
  plan="basic_monthly",
  email="[email protected]",
  quantity=5
)
// Set your secret key: remember to change this to your live secret key in production
// See your keys here: https://dashboard.stripe.com/account/apikeys
\Stripe\Stripe::setApiKey("sk_test_BQokikJOvBiI2HlWgH4olfQ2");

\Stripe\Customer::create(array(
  "source" => $token,
  "plan" => "basic_monthly",
  "email" => "[email protected]",
  "quantity" => 5
));
// Set your secret key: remember to change this to your live secret key in production
// See your keys here: https://dashboard.stripe.com/account/apikeys
var stripe = require("stripe")("sk_test_BQokikJOvBiI2HlWgH4olfQ2");

stripe.customers.create({
  source: token,
  plan: "basic_monthly",
  email: "[email protected]",
  quantity: 5
}, function(err, customer) {
  // asynchronously called
});
// Set your secret key: remember to change this to your live secret key in production
// See your keys here: https://dashboard.stripe.com/account/apikeys
Stripe.apiKey = "sk_test_BQokikJOvBiI2HlWgH4olfQ2";

Map<String, Object> customerParams = new HashMap<String, Object>();
customerParams.put("source", token);
customerParams.put("plan", "basic_monthly");
customerParams.put("email", "[email protected]");
customerParams.put("quantity", 5);

Customer.create(customerParams);

Multiple quantities of a plan are billed using one invoice, and are prorated when subscriptions are changed, including when you change just the quantities involved.

Varying billing amounts

Some users need full flexibility in computing billing amounts. For example, you might have a conceptual subscription that has a base cost of $10 per month, and a $5 per-seat cost each month. We recommend representing these billing relationships by creating a base plan that is only $1 per month, or even $0.01 per month. This lets you use quantity parameter to bill each user very flexibly. In an example with a $10 base cost and three $5 seats, you could use a $1 per month base plan, and set quantity=25 to achieve the desired total cost of $25 for the month.

Next up