Billing Examples

    This page explores some common billing uses cases and demonstrates how to model them with products and plans. The following examples follow a fictional company, SqueakyCar, that’s offering a car wash service. Washers come to the customer’s home to wash their cars.

    Simple monthly billing

    Many businesses begin with a simple monthly rate or “per-seat” pricing. This is modeled by specifying the amount on a Plan. Specify a quantity when creating a subscription to charge for multiple seats or licenses.

    SqueakyCar’s new car wash service charges $20 per car each month. First, they create a Product to describe what they’re selling—in this case, a weekly car washing service:

    curl https://api.stripe.com/v1/products \
     -u sk_test_BQokikJOvBiI2HlWgH4olfQ2: \
     -d name="Weekly Car Wash Service" \
     -d type=service
    # 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::Product.create({
        name: 'Weekly Car Wash Service',
        type: 'service',
    })
    
    # 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.Product.create(
      name='Weekly Car Wash Service',
      type='service',
    )
    
    // 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");
    
    StripeProduct::create(array(
      "name" => 'Weekly Car Wash Service',
      "type" => "service",
    );
    
    // 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> productParams = new HashMap<String, Object>();
    productParams.put("name", "Weekly Car Wash Service");
    productParams.put("type", "service");
    
    Product.create(productParams);
    
    // 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.products.create({
      name: 'Weekly Car Wash Service',
      type: 'service',
    }, function(err, product) {
      // 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.Key = "sk_test_BQokikJOvBiI2HlWgH4olfQ2"
    
    params := &stripe.ProductParams{
      Name: stripe.String("Weekly Car Wash Service"),
      Type: stripe.String(string(stripe.ProductTypeService)),
    }
    prod, _ := product.New(params)
    
    // 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
    StripeConfiguration.SetApiKey("sk_test_BQokikJOvBiI2HlWgH4olfQ2");
    
    var productService = new StripeProductService();
    StripeProduct product = productService.Create(new StripePlanProductCreateOptions {
        Name = "Weekly Car Wash Service",
        Type = "service",
    });
    

    Next, they add a plan to the product. The following example shows how to add a plan that bills $20 USD per month:

    curl https://api.stripe.com/v1/plans \
     -u sk_test_BQokikJOvBiI2HlWgH4olfQ2: \
     -d nickname="Standard Monthly" \
     -d product="{{CAR_WASH_PRODUCT_ID}}" \
     -d amount=2000 \
     -d currency=usd \
     -d interval=month \
     -d usage_type=licensed
    # 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::Plan.create(
      nickname: 'Standard Monthly'
      product: '{{CAR_WASH_PRODUCT_ID}}',
      amount: 2000,
      currency: 'usd'
      interval: 'month',
      usage_type: 'licensed'
    )
    
    # 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.Plan.create(
      nickname="Standard Monthly",
      product="{{CAR_WASH_PRODUCT_ID}}",
      amount=2000,
      currency="usd",
      interval="month",
      usage_type="licensed",
    )
    
    // 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");
    
    StripePlan::create(array(
      "nickname" => "Standard Monthly",
      "product" => "{{CAR_WASH_PRODUCT_ID}}",
      "amount" => 2000,
      "currency" => "usd",
      "interval" => "month",
      "usage_type" => "licensed",
    ));
    
    // 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> planParams = new HashMap<String, Object>();
    planParams.put("nickname", "Standard Monthly");
    planParams.put("product", "{{CAR_WASH_PRODUCT_ID}}");
    planParams.put("amount", 2000);
    planParams.put("currency", "usd");
    planParams.put("interval", "month");
    planParams.put("usage_type", "licensed");
    
    Plan.create(planParams);
    
    // 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.plans.create({
      nickname: "Standard Monthly",
      product: "{{CAR_WASH_PRODUCT_ID}}",
      amount: 2000,
      currency: "usd",
      interval: "month",
      usage_type: "licensed",
    }, function(err, plan) {
      // 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.Key = "sk_test_BQokikJOvBiI2HlWgH4olfQ2"
    
    params := &stripe.PlanParams{
      Nickname: stripe.String("Standard Monthly"),
      ProductID: stripe.String("{{CAR_WASH_PRODUCT_ID}}"),
      Amount: stripe.Int64(2000),
      Currency: stripe.String(string(stripe.CurrencyUSD)),
      Interval: stripe.String(string(stripe.PlanIntervalMonth)),
      UsageType: stripe.String(string(stripe.PlanUsageTypeLicensed)),
    }
    pl, _ := plan.New(params)
    
    // 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
    StripeConfiguration.SetApiKey("sk_test_BQokikJOvBiI2HlWgH4olfQ2");
    
    var planOptions = new StripePlanCreateOptions() {
      Nickname = "Standard Monthly"
      Product = "{{CAR_WASH_PRODUCT_ID}}"
      Amount = 2000,
      Interval = "month",
      Currency =  "usd",
      UsageType =  "licensed",
    };
    
    var planService = new StripePlanService();
    StripePlan plan = planService.Create(planOptions);
    

    This example demonstrates how to create a subscription to SqueakyCar’s service for a customer with two cars, specifying plan and quantity:

     curl https://api.stripe.com/v1/subscriptions \
    -u sk_test_BQokikJOvBiI2HlWgH4olfQ2: \
    -d customer="{{CUSTOMER_ID}}" \
    -d items[0][plan]="{{STANDARD_MONTHLY_USD_PLAN_ID}}" \
    -d items[0][quantity]=2
    # 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::Subscription.create(
      customer: '{{CUSTOMER_ID}}'
      items:[
        {
          plan: '{{STANDARD_MONTHLY_USD_PLAN_ID}}',
          quantity: 2
        }
      ]
    )
    
    # 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.Subscription.create(
      customer="{{CUSTOMER_ID}}",
      items=[
        {
          "plan": "{{STANDARD_MONTHLY_USD_PLAN_ID}}",
          "quantity": 2,
        },
      ]
    )
    
    // 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");
    
    StripeSubscription::create(array(
      "customer" => "{{CUSTOMER_ID}}",
      "items" => array(
        array(
          "plan" => "{{STANDARD_MONTHLY_USD_PLAN_ID}}",
          "quantity" => 2,
        ),
      )
    ));
    
    // 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> item = new HashMap<String, Object>();
    item.put("plan", "{{STANDARD_MONTHLY_USD_PLAN_ID}}");
    item.put("quantity", 2);
    
    Map<String, Object> items = new HashMap<String, Object>();
    items.put("0", item);
    
    Map<String, Object> params = new HashMap<String, Object>();
    params.put("customer", "{{CUSTOMER_ID}}");
    params.put("items", items);
    
    Subscription.create(params);
    
    // 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.subscriptions.create({
      customer: "{{CUSTOMER_ID}}",
      items: [
        {
          plan: "{{STANDARD_MONTHLY_USD_PLAN_ID}}",
          quantity: 2,
        },
      ]
    }, function(err, subscription) {
        // 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.Key = "sk_test_BQokikJOvBiI2HlWgH4olfQ2"
    
    params := &stripe.SubscriptionParams{
      Customer: stripe.String("{{CUSTOMER_ID}}"),
      Items: []*stripe.SubscriptionItemsParams{
        {
          Plan: stripe.String("{{STANDARD_MONTHLY_USD_PLAN_ID}}"),
          Quantity: stripe.Int64(2),
        },
      },
    }
    s, _ := sub.New(params)
    
    // 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
    StripeConfiguration.SetApiKey("sk_test_BQokikJOvBiI2HlWgH4olfQ2");
    
    var subscriptionOptions = new StripeSubscriptionCreateOptions() {
      PlanId = "{{STANDARD_MONTHLY_USD_PLAN_ID}}"
      Quantity = 2
    };
    
    var subscriptionService = new StripeSubscriptionService();
    StripeSubscription subscription = subscriptionService.Create("{{CUSTOMER_ID}}", subscriptionOptions);
    

    Varying Pricing

    Products can use multiple plans to define different pricing options. The product description is shared between plans and appears the same on the customer’s receipt or invoice—only the pricing differs based on the plan.

    As SqueakyCar’s product matures, they begin offering the same product at different price points. Specifically, certain customers are willing to pay for discounted up-front quarterly and yearly subscriptions. SqueakyCar creates a quarterly $57 plan:

     curl https://api.stripe.com/v1/plans \
    -u sk_test_BQokikJOvBiI2HlWgH4olfQ2: \
    -d nickname="Standard Quarterly" \
    -d amount=5700 \
    -d currency=usd \
    -d interval=month \
    -d interval_count=3 \
    -d product="{{CAR_WASH_PRODUCT_ID}}" \
    -d usage_type=licensed
    # 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::Plan.create(
      nickname: 'Standard Quarterly'
      product: '{{CAR_WASH_PRODUCT_ID}}',
      amount: 5700,
      currency: 'usd'
      interval: 'month',
      interval_count: 3,
      usage_type: 'licensed'
    )
    
    # 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.Plan.create(
      nickname="Standard Quarterly",
      product="{{CAR_WASH_PRODUCT_ID}}",
      amount=5700,
      currency="usd",
      interval="month",
      interval_count=3,
      usage_type="licensed",
    )
    
    // 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");
    
    StripePlan::create(array(
      "nickname" => "Standard Quarterly",
      "product" => "{{CAR_WASH_PRODUCT_ID}}",
      "amount" => 5700,
      "currency" => "usd",
      "interval" => "month",
      "interval_count" => 3,
      "usage_type" => "licensed",
    ));
    
    // 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> planParams = new HashMap<String, Object>();
    planParams.put("nickname", "Standard Quarterly");
    planParams.put("product", "{{CAR_WASH_PRODUCT_ID}}");
    planParams.put("amount", 5700);
    planParams.put("currency", "usd");
    planParams.put("interval", "month");
    planParams.put("interval_count", 3);
    planParams.put("usage_type", "licensed");
    
    Plan.create(planParams);
    
    // 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.plans.create({
      nickname: "Standard Quarterly",
      product: "{{CAR_WASH_PRODUCT_ID}}",
      amount: 5700,
      currency: "usd",
      interval: "month",
      interval_count: 3,
      usage_type: "licensed",
    }, function(err, plan) {
      // 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.Key = "sk_test_BQokikJOvBiI2HlWgH4olfQ2"
    
    params := &stripe.PlanParams{
      Nickname: stripe.String("Standard Quarterly"),
      ProductID: stripe.String("{{CAR_WASH_PRODUCT_ID}}"),
      Amount: stripe.Int64(5700),
      Currency: stripe.String(string(stripe.CurrencyUSD)),
      Interval: stripe.String(string(stripe.PlanIntervalMonth)),
      IntervalCount: stripe.Int64("3"),
      UsageType: stripe.String(string(stripe.PlanUsageTypeLicensed)),
    }
    pl, _ := plan.New(params)
    
    // 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
    StripeConfiguration.SetApiKey("sk_test_BQokikJOvBiI2HlWgH4olfQ2");
    
    var planOptions = new StripePlanCreateOptions() {
      Nickname = "Standard Quarterly"
      Product = "{{CAR_WASH_PRODUCT_ID}}"
      Amount = 5700,
      Interval = "month",
      IntervalCount = "3",
      Currency =  "usd",
      UsageType =  "licensed",
    };
    
    var planService = new StripePlanService();
    StripePlan plan = planService.Create(planOptions);
    

    And a yearly $220 plan:

     curl https://api.stripe.com/v1/plans \
    -u sk_test_BQokikJOvBiI2HlWgH4olfQ2: \
    -d nickname="Standard Yearly" \
    -d amount=22000 \
    -d currency=usd \
    -d interval=year \
    -d product="{{CAR_WASH_PRODUCT_ID}}" \
    -d usage_type=licensed
    # 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::Plan.create(
      nickname: 'Standard Yearly'
      product: '{{CAR_WASH_PRODUCT_ID}}',
      amount: 22000,
      currency: 'usd'
      interval: 'year',
      usage_type: 'licensed'
    )
    
    # 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.Plan.create(
      nickname="Standard Yearly",
      product="{{CAR_WASH_PRODUCT_ID}}",
      amount=22000,
      currency="usd",
      interval="year",
      usage_type="licensed",
    )
    
    // 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");
    
    StripePlan::create(array(
      "nickname" => "Standard Yearly",
      "product" => "{{CAR_WASH_PRODUCT_ID}}",
      "amount" => 22000,
      "currency" => "usd",
      "interval" => "year",
      "usage_type" => "licensed",
    ));
    
    // 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> planParams = new HashMap<String, Object>();
    planParams.put("nickname", "Standard Yearly");
    planParams.put("product", "{{CAR_WASH_PRODUCT_ID}}");
    planParams.put("amount", 22000);
    planParams.put("currency", "usd");
    planParams.put("interval", "year");
    planParams.put("usage_type", "licensed");
    
    Plan.create(planParams);
    
    // 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.plans.create({
      nickname: "Standard Yearly",
      product: "{{CAR_WASH_PRODUCT_ID}}",
      amount: 22000,
      currency: "usd",
      interval: "year",
      usage_type: "licensed",
    }, function(err, plan) {
      // 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.Key = "sk_test_BQokikJOvBiI2HlWgH4olfQ2"
    
    params := &stripe.PlanParams{
      Nickname: stripe.String("Standard Yearly"),
      ProductID: stripe.String("{{CAR_WASH_PRODUCT_ID}}"),
      Amount: stripe.Int64(22000),
      Currency: stripe.String(string(stripe.CurrencyUSD)),
      Interval: stripe.String(string(stripe.PlanIntervalYear)),
      UsageType: stripe.String(string(stripe.PlanUsageTypeLicensed)),
    }
    pl, _ := plan.New(params)
    
    // 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
    StripeConfiguration.SetApiKey("sk_test_BQokikJOvBiI2HlWgH4olfQ2");
    
    var planOptions = new StripePlanCreateOptions() {
      Nickname = "Standard Yearly"
      Product = "{{CAR_WASH_PRODUCT_ID}}"
      Amount = 22000,
      Interval = "year",
      Currency =  "usd",
      UsageType =  "licensed",
    };
    
    var planService = new StripePlanService();
    StripePlan plan = planService.Create(planOptions);
    

    As SqueakyCar expands to different markets, such as Canada, they can add pricing plans in different currencies:

     curl https://api.stripe.com/v1/plans \
    -u sk_test_BQokikJOvBiI2HlWgH4olfQ2: \
    -d nickname="Canadian Monthly" \
    -d amount=3500 \
    -d currency=cad \
    -d interval=month \
    -d product="{{CAR_WASH_PRODUCT_ID}}" \
    -d usage_type=licensed
    # 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::Plan.create(
      nickname: 'Canadian Monthly'
      product: '{{CAR_WASH_PRODUCT_ID}}',
      amount: 3500,
      currency: 'cad'
      interval: 'month',
      usage_type: 'licensed'
    )
    
    # 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.Plan.create(
      nickname="Canadian Monthly",
      product="{{CAR_WASH_PRODUCT_ID}}",
      amount=3500,
      currency="cad",
      interval="month",
      usage_type="licensed",
    )
    
    // 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");
    
    StripePlan::create(array(
      "nickname" => "Canadian Monthly",
      "product" => "{{CAR_WASH_PRODUCT_ID}}",
      "amount" => 3500,
      "currency" => "cad",
      "interval" => "month",
      "usage_type" => "licensed",
    ));
    
    // 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> planParams = new HashMap<String, Object>();
    planParams.put("nickname", "Canadian Monthly");
    planParams.put("product", "{{CAR_WASH_PRODUCT_ID}}");
    planParams.put("amount", 3500);
    planParams.put("currency", "cad");
    planParams.put("interval", "month");
    planParams.put("usage_type", "licensed");
    
    Plan.create(planParams);
    
    // 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.plans.create({
      nickname: "Canadian Monthly",
      product: "{{CAR_WASH_PRODUCT_ID}}",
      amount: 3500,
      currency: "cad",
      interval: "month",
      usage_type: "licensed",
    }, function(err, plan) {
      // 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.Key = "sk_test_BQokikJOvBiI2HlWgH4olfQ2"
    
    params := &stripe.PlanParams{
      Nickname: stripe.String("Canadian Monthly"),
      ProductID: stripe.String("{{CAR_WASH_PRODUCT_ID}}"),
      Amount: stripe.Int64(3500),
      Currency: stripe.String(string(stripe.CurrencyCAD)),
      Interval: stripe.String(string(stripe.PlanIntervalMonth)),
      UsageType: stripe.String(string(stripe.PlanUsageTypeLicensed)),
    }
    pl, _ := plan.New(params)
    
    // 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
    StripeConfiguration.SetApiKey("sk_test_BQokikJOvBiI2HlWgH4olfQ2");
    
    var planOptions = new StripePlanCreateOptions() {
      Nickname = "Canadian Monthly"
      Product = "{{CAR_WASH_PRODUCT_ID}}"
      Amount = 3500,
      Interval = "month",
      Currency =  "cad",
      UsageType =  "licensed",
    };
    
    var planService = new StripePlanService();
    StripePlan plan = planService.Create(planOptions);
    

    And the UK:

     curl https://api.stripe.com/v1/plans \
    -u sk_test_BQokikJOvBiI2HlWgH4olfQ2: \
    -d nickname="UK Monthly" \
    -d amount=1800 \
    -d currency=gbp \
    -d interval=month \
    -d product="{{CAR_WASH_PRODUCT_ID}}" \
    -d usage_type=licensed
    # 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::Plan.create(
      nickname: 'UK Monthly'
      product: '{{CAR_WASH_PRODUCT_ID}}',
      amount: 1800,
      currency: 'gbp'
      interval: 'month',
      usage_type: 'licensed'
    )
    
    # 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.Plan.create(
      nickname="UK Monthly",
      product="{{CAR_WASH_PRODUCT_ID}}",
      amount=1800,
      currency="gbp",
      interval="month",
      usage_type="licensed",
    )
    
    // 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");
    
    StripePlan::create(array(
      "nickname" => "UK Monthly",
      "product" => "{{CAR_WASH_PRODUCT_ID}}",
      "amount" => 1800,
      "currency" => "gbp",
      "interval" => "month",
      "usage_type" => "licensed",
    ));
    
    // 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> planParams = new HashMap<String, Object>();
    planParams.put("nickname", "UK Monthly");
    planParams.put("product", "{{CAR_WASH_PRODUCT_ID}}");
    planParams.put("amount", 1800);
    planParams.put("currency", "gbp");
    planParams.put("interval", "month");
    planParams.put("usage_type", "licensed");
    
    Plan.create(planParams);
    
    // 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.plans.create({
      nickname: "UK Monthly",
      product: "{{CAR_WASH_PRODUCT_ID}}",
      amount: 1800,
      currency: "gbp",
      interval: "month",
      usage_type: "licensed",
    }, function(err, plan) {
      // 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.Key = "sk_test_BQokikJOvBiI2HlWgH4olfQ2"
    
    params := &stripe.PlanParams{
      Nickname: stripe.String("UK Monthly"),
      ProductID: stripe.String("{{CAR_WASH_PRODUCT_ID}}"),
      Amount: stripe.Int64(1800),
      Currency: stripe.String(string(stripe.CurrencyGBP)),
      Interval: stripe.String(string(stripe.PlanIntervalMonth)),
      UsageType: stripe.String(string(stripe.PlanUsageTypeLicensed)),
    }
    pl, _ := plan.New(params)
    
    // 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
    StripeConfiguration.SetApiKey("sk_test_BQokikJOvBiI2HlWgH4olfQ2");
    
    var planOptions = new StripePlanCreateOptions() {
      Nickname = "UK Monthly"
      Product = "{{CAR_WASH_PRODUCT_ID}}"
      Amount = 1800,
      Interval = "month",
      Currency =  "gbp",
      UsageType =  "licensed",
    };
    
    var planService = new StripePlanService();
    StripePlan plan = planService.Create(planOptions);
    

    Flat fee

    You can subscribe the customer to two separate products to model a pricing structure that includes both a base fee and additional per-seat pricing. One product serves as the flat base price and the other product represents the variable per-seat pricing.

    SqueakyCar has seen a boom in multi-car households, so they are changing their pricing to introduce a new base fee that they will charge their customers alongside the per-car monthly fee. They create a Product and Plan for the base fee:

     curl https://api.stripe.com/v1/plans \
    -u sk_test_BQokikJOvBiI2HlWgH4olfQ2: \
    -d product[name]="Base Fee" \
    -d nickname="Monthly Base Fee" \
    -d amount=500 \
    -d currency=usd \
    -d interval=month \
    -d usage_type=licensed
    # 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::Plan.create(
      nickname: 'Monthly Base Fee'
      product: {
        name: 'Base Fee'
      },
      amount: 500,
      currency: 'usd'
      interval: 'month',
      usage_type: 'licensed'
    )
    
    # 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.Plan.create(
      nickname="Monthly Base Fee",
      product={
        "name": "Base Fee"
      },
      amount=500,
      currency="usd",
      interval="month",
      usage_type="licensed",
    )
    
    // 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");
    
    StripePlan::create(array(
      "nickname" => "Monthly Base Fee",
      "product" => array(
        "name" => "Base Fee"
      ),
      "amount" => 500,
      "currency" => "usd",
      "interval" => "month",
      "usage_type" => "licensed",
    ));
    
    // 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> productParams = new HashMap<String, Object>();
    productParams.put("name", "Base Fee");
    
    Map<String, Object> planParams = new HashMap<String, Object>();
    planParams.put("nickname", "Monthly Base Fee");
    planParams.put("product", productParams);
    planParams.put("amount", 500);
    planParams.put("currency", "usd");
    planParams.put("interval", "month");
    planParams.put("usage_type", "licensed");
    
    Plan.create(planParams);
    
    // 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.plans.create({
      nickname: "Monthly Base Fee",
      product: {
        name: "Base Fee"
      },
      amount: 500,
      currency: "usd",
      interval: "month",
      usage_type: "licensed",
    }, function(err, plan) {
      // 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.Key = "sk_test_BQokikJOvBiI2HlWgH4olfQ2"
    
    params := &stripe.PlanParams{
      Nickname: stripe.String("Monthly Base Fee"),
      Product: &stripe.PlanProductParams{
        Name: stripe.String("Base Fee"),
      },
      Amount: stripe.Int64(500),
      Currency: stripe.String(string(stripe.CurrencyUSD)),
      Interval: stripe.String(string(stripe.PlanIntervalMonth)),
      UsageType: stripe.String(string(stripe.PlanUsageTypeLicensed)),
    }
    pl, _ := plan.New(params)
    
    // 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
    StripeConfiguration.SetApiKey("sk_test_BQokikJOvBiI2HlWgH4olfQ2");
    
    var planOptions = new StripePlanCreateOptions() {
      Nickname = "Monthly Base Fee"
      Product: &stripe.ProductParams{
        Name: "Base Fee",
      },
      Amount = 500,
      Interval = "month",
      Currency =  "usd",
      UsageType =  "licensed",
    };
    
    var planService = new StripePlanService();
    StripePlan plan = planService.Create(planOptions);
    

    And a monthly plan that charges $15 per car:

     curl https://api.stripe.com/v1/plans \
    -u sk_test_BQokikJOvBiI2HlWgH4olfQ2: \
    -d nickname="Per Car Monthly" \
    -d amount=1500 \
    -d currency=usd \
    -d interval=month \
    -d product="{{CAR_WASH_PRODUCT_ID}}" \
    -d usage_type=licensed
    # 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::Plan.create(
      nickname: 'Per Car Monthly'
      product: '{{CAR_WASH_PRODUCT_ID}}',
      amount: 1500,
      currency: 'usd'
      interval: 'month',
      usage_type: 'licensed'
    )
    
    # 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.Plan.create(
      nickname="Per Car Monthly",
      product="{{CAR_WASH_PRODUCT_ID}}",
      amount=1500,
      currency="usd",
      interval="month",
      usage_type="licensed",
    )
    
    // 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");
    
    StripePlan::create(array(
      "nickname" => "Per Car Monthly",
      "product" => "{{CAR_WASH_PRODUCT_ID}}",
      "amount" => 1500,
      "currency" => "usd",
      "interval" => "month",
      "usage_type" => "licensed",
    ));
    
    // 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> planParams = new HashMap<String, Object>();
    planParams.put("nickname", "Per Car Monthly");
    planParams.put("product", "{{CAR_WASH_PRODUCT_ID}}");
    planParams.put("amount", 1500);
    planParams.put("currency", "usd");
    planParams.put("interval", "month");
    planParams.put("usage_type", "licensed");
    
    Plan.create(planParams);
    
    // 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.plans.create({
      nickname: "Per Car Monthly",
      product: "{{CAR_WASH_PRODUCT_ID}}",
      amount: 1500,
      currency: "usd",
      interval: "month",
      usage_type: "licensed",
    }, function(err, plan) {
      // 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.Key = "sk_test_BQokikJOvBiI2HlWgH4olfQ2"
    
    params := &stripe.PlanParams{
      Nickname: stripe.String("Per Car Monthly"),
      ProductID: stripe.String("{{CAR_WASH_PRODUCT_ID}}"),
      Amount: stripe.Int64(1500),
      Currency: stripe.String(string(stripe.CurrencyUSD)),
      Interval: stripe.String(string(stripe.PlanIntervalMonth)),
      UsageType: stripe.String(string(stripe.PlanUsageTypeLicensed)),
    }
    pl, _ := plan.New(params)
    
    // 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
    StripeConfiguration.SetApiKey("sk_test_BQokikJOvBiI2HlWgH4olfQ2");
    
    var planOptions = new StripePlanCreateOptions() {
      Nickname = "Per Car Monthly"
      Product = "{{CAR_WASH_PRODUCT_ID}}"
      Amount = 1500,
      Interval = "month",
      Currency =  "usd",
      UsageType =  "licensed",
    };
    
    var planService = new StripePlanService();
    StripePlan plan = planService.Create(planOptions);
    

    The following example demonstrates how to subscribe a customer with three cars to the base fee plan and the per-car plan:

     curl https://api.stripe.com/v1/subscriptions \
    -u sk_test_BQokikJOvBiI2HlWgH4olfQ2: \
    -d customer="{{CUSTOMER_ID}}" \
    -d items[0][plan]="{{BASE_FEE_PLAN_ID}}" \
    -d items[0][quantity]=1 \
    -d items[1][plan]="{{PER_CAR_PLAN_ID}}" \
    -d items[1][quantity]=3
    # 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::Subscription.create(
      customer: '{{CUSTOMER_ID}}'
      items:[
        {
          plan: '{{BASE_FEE_PLAN_ID}}',
          quantity: 1
        },{
          plan: '{{PER_CAR_PLAN_ID}}',
          quantity: 3
        }
      ]
    )
    
    # 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.Subscription.create(
      customer="{{CUSTOMER_ID}}",
      items=[
        {
          "plan": "{{BASE_FEE_PLAN_ID}}",
          "quantity": 1,
        },    {
          "plan": "{{PER_CAR_PLAN_ID}}",
          "quantity": 3,
        },
      ]
    )
    
    // 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");
    
    StripeSubscription::create(array(
      "customer" => "{{CUSTOMER_ID}}",
      "items" => array(
        array(
          "plan" => "{{BASE_FEE_PLAN_ID}}",
          "quantity" => 1,
        ),
        array(
          "plan" => "{{PER_CAR_PLAN_ID}}",
          "quantity" => 3,
        ),
      )
    ));
    
    // 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> firstItem = new HashMap<String, Object>();
    item.put("plan", "{{BASE_FEE_PLAN_ID}}");
    item.put("quantity", 1);
    
    Map<String, Object> secondItem = new HashMap<String, Object>();
    item.put("plan", "{{PER_CAR_PLAN_ID}}");
    item.put("quantity", 3);
    
    Map<String, Object> items = new HashMap<String, Object>();
    items.put("0", firstItem);
    items.put("1", secondItem);
    
    Map<String, Object> params = new HashMap<String, Object>();
    params.put("customer", "{{CUSTOMER_ID}}");
    params.put("items", items);
    
    Subscription.create(params);
    
    // 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.subscriptions.create({
      customer: "{{CUSTOMER_ID}}",
      items: [
        {
          plan: "{{BASE_FEE_PLAN_ID}}",
          quantity: 1,
        }, {
          plan: "{{PER_CAR_PLAN_ID}}",
          quantity: 3,
        },
      ]
    }, function(err, subscription) {
        // 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.Key = "sk_test_BQokikJOvBiI2HlWgH4olfQ2"
    
    params := &stripe.SubscriptionParams{
      Customer: stripe.String("{{CUSTOMER_ID}}"),
      Items: []*stripe.SubscriptionItemsParams{
        {
          Plan: stripe.String("{{BASE_FEE_PLAN_ID}}"),
          Quantity: stripe.Int64(1),
        }, {
          Plan: stripe.String("{{PER_CAR_PLAN_ID}}"),
          Quantity: stripe.Int64(3),
        },
      },
    }
    s, _ := sub.New(params)
    
    // 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
    StripeConfiguration.SetApiKey("sk_test_BQokikJOvBiI2HlWgH4olfQ2");
    
    var items = new List<StripeSubscriptionItemOption> {
        new StripeSubscriptionItemOption {
            PlanId = "{{BASE_FEE_PLAN_ID}}",
            Quantity = 1,
        },
        new StripeSubscriptionItemOption {
            PlanId = "{{PER_CAR_PLAN_ID}}",
            Quantity = 3,
        },
    };
    var subscriptionOptions = new StripeSubscriptionCreateOptions {
        Items = items,
    };
    
    var subscriptionService = new StripeSubscriptionService();
    StripeSubscription subscription = subscriptionService.Create("{{CUSTOMER_ID}}", subscriptionOptions);
    

    This results in a $50 charge every month: the $5 base monthly rate, plus $15 each for 3 cars.

    Usage-based pricing

    Metered billing is useful in cases where you want to charge your customers a granular amount based on their consumption of your service during the billing cycle, instead of explicitly setting quantities. For example, SqueakyCar can use metered billing to offer a service where they wash their customer’s cars as needed, and charge at the end of the month for the total number of washes.

    The following example shows how to set the value of usage_type to create a plan with metered billing. In this case, they charge $7 per car wash:

     curl https://api.stripe.com/v1/plans \
    -u sk_test_BQokikJOvBiI2HlWgH4olfQ2: \
    -d nickname="Metered Monthly Plan" \
    -d amount=700 \
    -d currency=usd \
    -d interval=month \
    -d product="{{CAR_WASH_PRODUCT_ID}}" \
    -d usage_type=metered
    # 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::Plan.create(
      nickname: 'Metered Monthly Plan'
      product: '{{CAR_WASH_PRODUCT_ID}}',
      amount: 700,
      currency: 'usd'
      interval: 'month',
      usage_type: 'metered'
    )
    
    # 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.Plan.create(
      nickname="Metered Monthly Plan",
      product="{{CAR_WASH_PRODUCT_ID}}",
      amount=700,
      currency="usd",
      interval="month",
      usage_type="metered",
    )
    
    // 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");
    
    StripePlan::create(array(
      "nickname" => "Metered Monthly Plan",
      "product" => "{{CAR_WASH_PRODUCT_ID}}",
      "amount" => 700,
      "currency" => "usd",
      "interval" => "month",
      "usage_type" => "metered",
    ));
    
    // 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> planParams = new HashMap<String, Object>();
    planParams.put("nickname", "Metered Monthly Plan");
    planParams.put("product", "{{CAR_WASH_PRODUCT_ID}}");
    planParams.put("amount", 700);
    planParams.put("currency", "usd");
    planParams.put("interval", "month");
    planParams.put("usage_type", "metered");
    
    Plan.create(planParams);
    
    // 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.plans.create({
      nickname: "Metered Monthly Plan",
      product: "{{CAR_WASH_PRODUCT_ID}}",
      amount: 700,
      currency: "usd",
      interval: "month",
      usage_type: "metered",
    }, function(err, plan) {
      // 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.Key = "sk_test_BQokikJOvBiI2HlWgH4olfQ2"
    
    params := &stripe.PlanParams{
      Nickname: stripe.String("Metered Monthly Plan"),
      ProductID: stripe.String("{{CAR_WASH_PRODUCT_ID}}"),
      Amount: stripe.Int64(700),
      Currency: stripe.String(string(stripe.CurrencyUSD)),
      Interval: stripe.String(string(stripe.PlanIntervalMonth)),
      UsageType: stripe.String(string(stripe.PlanUsageTypeMetered)),
    }
    pl, _ := plan.New(params)
    
    // 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
    StripeConfiguration.SetApiKey("sk_test_BQokikJOvBiI2HlWgH4olfQ2");
    
    var planOptions = new StripePlanCreateOptions() {
      Nickname = "Metered Monthly Plan"
      Product = "{{CAR_WASH_PRODUCT_ID}}"
      Amount = 700,
      Interval = "month",
      Currency =  "usd",
      UsageType =  "metered",
    };
    
    var planService = new StripePlanService();
    StripePlan plan = planService.Create(planOptions);
    

    Metered billing can also be applied in situations where the unit you are measuring is not strictly based on a sum. For example, imagine that in addition to car washing, SqueakyCar also rents out garage parking spots to their customers, and wants to charge for the maximum number of parking spots used per customer per month. SqueakyCar can configure this with the aggregate_usage parameter.

     curl https://api.stripe.com/v1/plans \
    -u sk_test_BQokikJOvBiI2HlWgH4olfQ2: \
    -d nickname="Monthly Parking Plan" \
    -d amount=20000 \
    -d currency=usd \
    -d interval=month \
    -d product="{{CAR_PARKING_PRODUCT_ID}}" \
    -d usage_type=metered \
    -d aggregate_usage=max
    # 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::Plan.create(
      nickname: 'Monthly Parking Plan'
      product: '{{CAR_PARKING_PRODUCT_ID}}',
      amount: 20000,
      currency: 'usd'
      interval: 'month',
      usage_type: 'metered'
      aggregate_usage: 'max'
    )
    
    # 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.Plan.create(
      nickname="Monthly Parking Plan",
      product="{{CAR_PARKING_PRODUCT_ID}}",
      amount=20000,
      currency="usd",
      interval="month",
      usage_type="metered",
      aggregate_usage="max",
    )
    
    // 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");
    
    StripePlan::create(array(
      "nickname" => "Monthly Parking Plan",
      "product" => "{{CAR_PARKING_PRODUCT_ID}}",
      "amount" => 20000,
      "currency" => "usd",
      "interval" => "month",
      "usage_type" => "metered",
      "aggregate_usage" => "max",
    ));
    
    // 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> planParams = new HashMap<String, Object>();
    planParams.put("nickname", "Monthly Parking Plan");
    planParams.put("product", "{{CAR_PARKING_PRODUCT_ID}}");
    planParams.put("amount", 20000);
    planParams.put("currency", "usd");
    planParams.put("interval", "month");
    planParams.put("usage_type", "metered");
    planParams.put("aggregate_usage", "max");
    
    Plan.create(planParams);
    
    // 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.plans.create({
      nickname: "Monthly Parking Plan",
      product: "{{CAR_PARKING_PRODUCT_ID}}",
      amount: 20000,
      currency: "usd",
      interval: "month",
      usage_type: "metered",
      aggregate_usage: "max",
    }, function(err, plan) {
      // 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.Key = "sk_test_BQokikJOvBiI2HlWgH4olfQ2"
    
    params := &stripe.PlanParams{
      Nickname: stripe.String("Monthly Parking Plan"),
      ProductID: stripe.String("{{CAR_PARKING_PRODUCT_ID}}"),
      Amount: stripe.Int64(20000),
      Currency: stripe.String(string(stripe.CurrencyUSD)),
      Interval: stripe.String(string(stripe.PlanIntervalMonth)),
      UsageType: stripe.String(string(stripe.PlanUsageTypeMetered)),
      AggregateUsage: stripe.String(string(stripe.PlanAggregateUsageMax)),
    }
    pl, _ := plan.New(params)
    
    // 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
    StripeConfiguration.SetApiKey("sk_test_BQokikJOvBiI2HlWgH4olfQ2");
    
    var planOptions = new StripePlanCreateOptions() {
      Nickname = "Monthly Parking Plan"
      Product = "{{CAR_PARKING_PRODUCT_ID}}"
      Amount = 20000,
      Interval = "month",
      Currency =  "usd",
      UsageType =  "metered",
      AggregateUsage =  "max",
    };
    
    var planService = new StripePlanService();
    StripePlan plan = planService.Create(planOptions);
    

    Imagine that a customer has two cars parked on June 1st, then parks a third car on the 15th, and later removes one of the first two cars on the 20th. The billed amount at the end of the month is $600 (three cars maximum usage during the month, charging $200 per car).

    Usage-based pricing can also be combined with flat fees (as shown above) to charge a flat monthly rate in addition to charging for usage over the billing cycle.

    Pricing tiers

    Plans can represent pricing tiers, allowing the unit cost to change with quantity or usage. SqueakyCar might, for example, want to offer lower rates for customers who use more washes per month. The following examples show two different ways to adjust pricing as usage increases: volume-based pricing and graduated pricing. To demonstrate these approaches to tiered pricing, we will use the following tiers:

    Number of car washes Price per wash
    1 - 5 $7
    6 - 10 $6.50
    11+ $6

    Volume-based pricing

    With volume-based pricing, the subscription item is billed at the tier corresponding to the amount of usage at the end of the period. To implement volume-based billing tiers, set volume as the value of tier_mode:

     curl https://api.stripe.com/v1/plans \
    -u sk_test_BQokikJOvBiI2HlWgH4olfQ2: \
    -d nickname="Car Wash Volume Pricing" \
    -d tiers[0][amount]=700 \
    -d tiers[0][up_to]=5 \
    -d tiers[1][amount]=650 \
    -d tiers[1][up_to]=10 \
    -d tiers[2][amount]=600 \
    -d tiers[2][up_to]=inf \
    -d currency=usd \
    -d interval=month \
    -d product="{{CAR_WASH_PRODUCT_ID}}" \
    -d tiers_mode=volume \
    -d billing_scheme=tiered \
    -d usage_type=metered
    # 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::Plan.create(
      nickname: 'Car Wash Volume Pricing',
      product: '{{CAR_WASH_PRODUCT_ID}}',
      currency: 'usd',
      interval: 'month',
      usage_type: 'metered',
      billing_scheme: 'tiered',
      tiers_mode: 'volume',
      tiers: [
        {
          amount: 700,
          up_to: '5',
        },{
          amount: 650,
          up_to: '10',
        },{
          amount: 600,
          up_to: 'inf',
        }
      ]
    )
    
    # 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.Plan.create(
      nickname="Car Wash Volume Pricing",
      product="{{CAR_WASH_PRODUCT_ID}}",
      currency="usd",
      interval="month",
      usage_type="metered",
      billing_scheme="tiered",
      tiers_mode="volume"
      tiers=[
        {
          "amount": 700,
          "up_to": "5",
        },{
          "amount": 650,
          "up_to": "10",
        },{
          "amount": 600,
          "up_to": "inf",
        },
      ]
    )
    
    // 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");
    
    StripePlan::create([
      "nickname" => "Car Wash Volume Pricing",
      "product" => "{{CAR_WASH_PRODUCT_ID}}",
      "currency" => "usd",
      "interval" => "month",
      "usage_type" => "metered",
      "billing_scheme" => "tiered",
      "tiers_mode" => "volume",
      "tiers" => [
        [
          "amount" => 700,
          "up_to" => "5",
        ],
        [
          "amount" => 650,
          "up_to" => "10",
        ],
        [
          "amount" => 600,
          "up_to" => "inf",
        ]
      ]
    ]);
    
    // 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> firstTier = new HashMap<String, Object>();
    item.put("amount", 700);
    item.put("up_to", "5");
    
    Map<String, Object> secondTier = new HashMap<String, Object>();
    item.put("amount", 650);
    item.put("up_to", "10");
    
    Map<String, Object> thirdTier = new HashMap<String, Object>();
    item.put("amount", 600);
    item.put("up_to", "inf");
    
    Map<String, Object> items = new HashMap<String, Object>();
    items.put("0", firstTier);
    items.put("1", secondTier);
    items.put("2", thirdTier);
    
    Map<String, Object> planParams = new HashMap<String, Object>();
    planParams.put("nickname", "Car Wash Volume Pricing");
    planParams.put("product", "{{CAR_WASH_PRODUCT_ID}}");
    planParams.put("currency", "usd");
    planParams.put("interval", "month");
    planParams.put("usage_type", "metered");
    planParams.put("billing_scheme", "tiered");
    planParams.put("tiers_mode", "volume");
    planParams.put("tiers", tiers);
    
    Plan.create(planParams);
    
    // 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.plans.create({
      nickname: "Car Wash Volume Pricing",
      product: "{{CAR_WASH_PRODUCT_ID}}",
      currency: "usd",
      interval: "month",
      usage_type: "metered",
      billing_scheme: "tiered",
      tiers_mode: "volume",
      tiers: [
        {
          amount: 700,
          up_to: '5',
        },{
          amount: 650,
          up_to: '10',
        },{
          amount: 600,
          up_to: 'inf}',
        }
      ]
    }, function(err, plan) {
      // 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.Key = "sk_test_BQokikJOvBiI2HlWgH4olfQ2"
    
    params := &stripe.PlanParams{
      Nickname: stripe.String("Car Wash Volume Pricing"),
      ProductID: stripe.String("{{CAR_WASH_PRODUCT_ID}}"),
      Currency: stripe.String(string(stripe.CurrencyUSD)),
      Interval: stripe.String(string(stripe.PlanIntervalMonth)),
      UsageType: stripe.String(string(stripe.PlanUsageTypeMetered)),
      BillingScheme: stripe.String(string(stripe.PlanBillingSchemeTiered)),
      TiersMode: stripe.String(stripe.String(stripe.PlanTiersModeVolume))),
      Tiers: []*stripe.PlanTier{
      {
        Amount: 700,
        UpTo: "5",
      }, {
        Amount: 650,
        UpTo: "10",
      }, {
        Amount: 600,
        UpTo: "inf",
      },
    }
    pl, _ := plan.New(params)
    
    // 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
    StripeConfiguration.SetApiKey("sk_test_BQokikJOvBiI2HlWgH4olfQ2");
    
    var tiers = new List<StripePlanTierOptions> {
        new StripPlanTierOptions {
            Amount = 700,
            UpTo = new StripePlanTierOptions.UpToBound() {
              Bound = "5"
            },
        },
        new StripPlanTierOptions {
            Amount = 650,
            UpTo = new StripePlanTierOptions.UpToBound() {
              Bound = "10"
            },
        },
        new StripPlanTierOptions {
            Amount = 600,
            UpTo = new StripePlanTierOptions.UpToInf(),
        },
    };
    var planOptions = new StripePlanCreateOptions() {
      Nickname = "Car Wash Volume Pricing"
      Product = "{{CAR_WASH_PRODUCT_ID}}"
      Interval = "month",
      Currency =  "usd",
      UsageType =  "metered",
      BillingScheme =  "tiered",
      TiersMode =  "volume",
      Tiers = tiers,
    };
    
    var planService = new StripePlanService();
    StripePlan plan = planService.Create(planOptions);
    

    Under volume-based pricing, a customer with 5 car washes is charged $35 at the end of the period: $7 for each of the 5 washes. However, if they accumulate 6 washes the following month, then all washes are billed at the 6-10 rate. That month, they are charged $39 ($6.50 × 6).

    Graduated pricing

    While similar to volume pricing, graduated pricing charges for the usage in each tier instead of applying a single price to all usage. Set the value of tiers_mode to graduated to use graduated tiers:

     curl https://api.stripe.com/v1/plans \
    -u sk_test_BQokikJOvBiI2HlWgH4olfQ2: \
    -d nickname="Car Wash Graduated Pricing" \
    -d tiers[0][amount]=700 \
    -d tiers[0][up_to]=5 \
    -d tiers[1][amount]=650 \
    -d tiers[1][up_to]=10 \
    -d tiers[2][amount]=600 \
    -d tiers[2][up_to]=inf \
    -d currency=usd \
    -d interval=month \
    -d product="{{CAR_WASH_PRODUCT_ID}}" \
    -d tiers_mode=graduated \
    -d billing_scheme=tiered \
    -d usage_type=metered
    # 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::Plan.create(
      nickname: 'Car Wash Graduated Pricing',
      product: '{{CAR_WASH_PRODUCT_ID}}',
      currency: 'usd',
      interval: 'month',
      usage_type: 'metered',
      billing_scheme: 'tiered',
      tiers_mode: 'graduated',
      tiers: [
        {
          amount: 700,
          up_to: '5',
        },{
          amount: 650,
          up_to: '10',
        },{
          amount: 600,
          up_to: 'inf',
        }
      ]
    )
    
    # 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.Plan.create(
      nickname="Car Wash Graduated Pricing",
      product="{{CAR_WASH_PRODUCT_ID}}",
      currency="usd",
      interval="month",
      usage_type="metered",
      billing_scheme="tiered"
      tiers_mode="graduated"
      tiers=[
        {
          "amount": 700,
          "up_to": "5",
        },{
          "amount": 650,
          "up_to": "10",
        },{
          "amount": 600,
          "up_to": "inf",
        },
      ]
    )
    
    // 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");
    
    StripePlan::create([
      "nickname" => "Car Wash Graduated Pricing",
      "product" => "{{CAR_WASH_PRODUCT_ID}}",
      "currency" => "usd",
      "interval" => "month",
      "usage_type" => "metered",
      "billing_scheme" => "tiered",
      "tiers_mode" => "graduated",
      "tiers" => [
        [
          "amount" => 700,
          "up_to" => "5",
        ],
        [
          "amount" => 650,
          "up_to" => "10",
        ],
        [
          "amount" => 600,
          "up_to" => "inf",
        ]
      ]
    ]);
    
    // 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> firstTier = new HashMap<String, Object>();
    item.put("amount", 700);
    item.put("up_to", "5");
    
    Map<String, Object> secondTier = new HashMap<String, Object>();
    item.put("amount", 650);
    item.put("up_to", "10");
    
    Map<String, Object> thirdTier = new HashMap<String, Object>();
    item.put("amount", 600);
    item.put("up_to", "inf");
    
    Map<String, Object> items = new HashMap<String, Object>();
    items.put("0", firstTier);
    items.put("1", secondTier);
    items.put("2", thirdTier);
    
    Map<String, Object> planParams = new HashMap<String, Object>();
    planParams.put("nickname", "Car Wash Graduated Pricing");
    planParams.put("product", "{{CAR_WASH_PRODUCT_ID}}");
    planParams.put("currency", "usd");
    planParams.put("interval", "month");
    planParams.put("usage_type", "metered");
    planParams.put("billing_scheme", "tiered");
    planParams.put("tiers_mode", "graduated");
    planParams.put("tiers", tiers);
    
    Plan.create(planParams);
    
    // 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.plans.create({
      nickname: "Car Wash Graduated Pricing",
      product: "{{CAR_WASH_PRODUCT_ID}}",
      currency: "usd",
      interval: "month",
      usage_type: "metered",
      billing_scheme: "tiered",
      tiers_mode: "graduated",
      tiers: [
        {
          amount: 700,
          up_to: '5',
        },{
          amount: 650,
          up_to: '10',
        },{
          amount: 600,
          up_to: 'inf}',
        }
      ]
    }, function(err, plan) {
      // 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.Key = "sk_test_BQokikJOvBiI2HlWgH4olfQ2"
    
    params := &stripe.PlanParams{
      Nickname: stripe.String("Car Wash Graduated Pricing"),
      ProductID: stripe.String("{{CAR_WASH_PRODUCT_ID}}"),
      Currency: stripe.String(string(stripe.CurrencyUSD)),
      Interval: stripe.String(string(stripe.PlanIntervalMonth)),
      UsageType: stripe.String(string(stripe.PlanUsageTypeMetered)),
      BillingScheme: stripe.String(string(stripe.PlanBillingSchemeTiered)),
      TiersMode: stripe.String(stripe.String(stripe.PlanTiersModeGraduated))),
      Tiers: []*stripe.PlanTier{
      {
        Amount: 700,
        UpTo: "5",
      }, {
        Amount: 650,
        UpTo: "10",
      }, {
        Amount: 600,
        UpTo: "inf",
      },
    }
    pl, _ := plan.New(params)
    
    // 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
    StripeConfiguration.SetApiKey("sk_test_BQokikJOvBiI2HlWgH4olfQ2");
    
    var tiers = new List<StripePlanTierOptions> {
        new StripPlanTierOptions {
            Amount = 700,
            UpTo = new StripePlanTierOptions.UpToBound() {
              Bound = "5"
            },
        },
        new StripPlanTierOptions {
            Amount = 650,
            UpTo = new StripePlanTierOptions.UpToBound() {
              Bound = "10"
            },
        },
        new StripPlanTierOptions {
            Amount = 600,
            UpTo = new StripePlanTierOptions.UpToInf(),
        },
    };
    var planOptions = new StripePlanCreateOptions() {
      Nickname = "Car Wash Graduated Pricing"
      Product = "{{CAR_WASH_PRODUCT_ID}}"
      Amount = 20000,
      Interval = "month",
      Currency =  "usd",
      UsageType =  "metered",
      BillingScheme =  "tiered",
      TiersMode =  "graduated",
      Tiers = tiers,
    };
    
    var planService = new StripePlanService();
    StripePlan plan = planService.Create(planOptions);
    

    With graduated pricing, 5 car washes result in the same charge as volume-based pricing—$35 total at $7 per wash. This changes as usage breaks out of the first tier. A customer with more than 5 washes is charged $7 per wash for the first 5 washes, then $6.50 for washes 6 through 10, and finally $7 per wash thereafter. A customer with 6 car washes would be charged $41.50, $35 for the first 5 washes and $6.50 for the 6th wash.

    Transforming usage

    Use the transform_usage option to aggregate usage before multiplying by unit cost. This is useful if you want to report a different quantity or usage before totaling price.

    SqueakyCar decided to expand their car wash offerings with a premium waxing service. Car waxing can be time consuming, so they charge an extra usage fee (another Product) based on the time washers spend waxing the car. Washers report the exact amount of time spent waxing the cars, but SqueakyCar doesn’t want to charge customers by the minute. Instead, they will charge for each hour spent waxing—even a partial hour.

    First, create the premium waxing product:

    curl https://api.stripe.com/v1/products \
       -u sk_test_BQokikJOvBiI2HlWgH4olfQ2: \
       -d name="Premium Wax Service" \
       -d unit_label="Hour(s)" \
       -d type=service
    
    # 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::Product.create({
        name: 'Premium Wax Service',
        unit_label: 'Hour(s)',
        type: 'service',
    })
    
    # 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.Product.create(
      name='Premium Wax Service',
      unit_label='Hour(s)',
      type='service',
    )
    
    // 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");
    
    StripeProduct::create(array(
      "name" => 'Premium Wax Service',
      "unit_label" => 'Hour(s)',
      "type" => "service",
    );
    
    // 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> productParams = new HashMap<String, Object>();
    productParams.put("name", "Premium Wax Service");
    productParams.put("unit_label", "Hour(s)");
    productParams.put("type", "service");
    
    Product.create(productParams);
    
    // 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.products.create({
      name: 'Premium Wax Service',
      unit_label: 'Hour(s)',
      type: 'service',
    }, function(err, product) {
      // 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.Key = "sk_test_BQokikJOvBiI2HlWgH4olfQ2"
    
    params := &stripe.ProductParams{
      Name: stripe.String("Premium Wax Service"),
      UnitLabel: stripe.String("Hour(s)"),
      Type: stripe.String(string(stripe.ProductTypeService)),
    }
    prod, _ := product.New(params)
    
    // 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
    StripeConfiguration.SetApiKey("sk_test_BQokikJOvBiI2HlWgH4olfQ2");
    
    var productService = new StripeProductService();
    StripeProduct product = productService.Create(new StripePlanProductCreateOptions {
        Name = "Premium Wax Service",
        UnitLabel = "Hour(s)",
        Type = "service",
    });
    

    Next, price the waxing service, charging $5 an hour and rounding up (to charge for a full hour even if only part of the hour is used):

     curl https://api.stripe.com/v1/plans \
    -u sk_test_BQokikJOvBiI2HlWgH4olfQ2: \
    -d nickname="Hours Waxing Rate" \
    -d amount=500 \
    -d currency=usd \
    -d interval=month \
    -d product="{{WAX_SERVICE_PRODUCT_ID}}" \
    -d transform_usage[divide_by]=60 \
    -d transform_usage[round]=up \
    -d usage_type=metered
    # 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::Plan.create(
      nickname: 'Hours Waxing Rate'
      product: '{{WAX_SERVICE_PRODUCT_ID}}',
      amount: 500,
      currency: 'usd'
      interval: 'month',
      usage_type: 'metered',
      transform_usage: {
        divide_by: 60,
        round: 'up',
      }
    )
    
    # 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.Plan.create(
      nickname="Hours Waxing Rate",
      product="{{WAX_SERVICE_PRODUCT_ID}}",
      amount=500,
      currency="usd",
      interval="month",
      usage_type="metered",
      transform_usage={
        "divide_by": 60,
        "round": up
      },
    )
    
    // 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");
    
    StripePlan::create(array(
      "nickname" => "Hours Waxing Rate",
      "product" => "{{WAX_SERVICE_PRODUCT_ID}}",
      "amount" => 500,
      "currency" => "usd",
      "interval" => "month",
      "usage_type" => "metered",
      "transform_usage" => array(
        "divide_by" => 60,
        "round" => "up",
      ),
    ));
    
    // 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> usageTansform = new HashMap<String, Object>();
    transform_usage.put("divide_by", 60)
    transform_usage.put("round", up)
    
    Map<String, Object> planParams = new HashMap<String, Object>();
    planParams.put("nickname", "Hours Waxing Rate");
    planParams.put("product", "{{WAX_SERVICE_PRODUCT_ID}}");
    planParams.put("amount", 500);
    planParams.put("currency", "usd");
    planParams.put("interval", "month");
    planParams.put("usage_type", "metered");
    planParams.put("usage_type", usageTansform");
    
    Plan.create(planParams);
    
    // 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.plans.create({
      nickname: "Hours Waxing Rate",
      product: "{{WAX_SERVICE_PRODUCT_ID}}",
      amount: 500,
      currency: "usd",
      interval: "month",
      usage_type: "metered",
      transform_usage: {
        divide_by: 60,
        round: 'up',
      }
    }, function(err, plan) {
      // 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.Key = "sk_test_BQokikJOvBiI2HlWgH4olfQ2"
    
    params := &stripe.PlanParams{
      Nickname: stripe.String("Hours Waxing Rate"),
      ProductID: stripe.String("{{WAX_SERVICE_PRODUCT_ID}}"),
      Amount: stripe.Int64(500),
      Currency: stripe.String(string(stripe.CurrencyUSD)),
      Interval: stripe.String(string(stripe.PlanIntervalMonth)),
      UsageType: stripe.String(string(stripe.PlanUsageTypeMetered)),
      TransformUsage: []*stripe.PlanTransformUsageParams{
        DivideBy: stripe.Int64(60),
        Round: stripe.String(string(stripe.PlanTransformUsageRoundUp)),
      }
    }
    pl, _ := plan.New(params)
    
    // 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
    StripeConfiguration.SetApiKey("sk_test_BQokikJOvBiI2HlWgH4olfQ2");
    
    var transformUsage = new StripeSubscriptionCreateOptions {
        DivideBy = 60,
        Round = "up",
    };
    
    var planOptions = new StripePlanCreateOptions() {
      Nickname = "Hours Waxing Rate"
      Product = "{{WAX_SERVICE_PRODUCT_ID}}"
      Amount = 500,
      Interval = "month",
      Currency =  "usd",
      UsageType =  "metered",
      TransformUsage = transformUsage,
    };
    
    var planService = new StripePlanService();
    StripePlan plan = planService.Create(planOptions);
    

    If a washer spends 150 minutes waxing a customer’s cars, that customer would be charged $15 for 3 hours of waxing (2 hours and 30 minutes, rounded up).

    Questions?

    We're always happy to help with code or other questions you might have! Search our documentation, contact support, or connect with our sales team. You can also chat live with other developers in #stripe on freenode.

    Was this page helpful? Yes No

    Send

    Thank you for helping improve Stripe's documentation. If you need help or have any questions, please consider contacting support.