1

Create Usage Record

Published Aug 25, 2022

With metered billing, you charge your customers based on their consumption of your service during the billing cycle, instead of explicitly setting quantities. Use this action to create a usage record for metered billing. [See the docs](https://stripe.com/docs/api/usage_records/create) for more information

Script stripe
Other submissions
  • Submitted by rossmccrann Deno
    Created 577 days ago
    1
    import stripe from "npm:stripe@^11";
    2
    
    
    3
    type Stripe = {
    4
      token: string;
    5
    };
    6
    export async function main(
    7
      sk: Stripe,
    8
      subscriptionId: string,
    9
      quantity: number
    10
    ) {
    11
      const client = new stripe.Stripe(sk.token, {
    12
        apiVersion: "2022-11-15",
    13
        httpClient: stripe.createFetchHttpClient(),
    14
      });
    15
    
    
    16
      return await client.subscriptionItems.createUsageRecord(subscriptionId, {
    17
        quantity,
    18
      });
    19
    }
    20
    
    
  • Submitted by hugo989 Bun
    Created 185 days ago
    1
    import stripe from "stripe@^11";
    2
    
    
    3
    type Stripe = {
    4
      token: string;
    5
    };
    6
    export async function main(
    7
      sk: Stripe,
    8
      subscriptionId: string,
    9
      quantity: number
    10
    ) {
    11
      const client = new stripe.Stripe(sk.token, {
    12
        apiVersion: "2022-11-15",
    13
        httpClient: stripe.createFetchHttpClient(),
    14
      });
    15
    
    
    16
      return await client.subscriptionItems.createUsageRecord(subscriptionId, {
    17
        quantity,
    18
      });
    19
    }
    20