Search... Ctrl + K

Create Usage Record (stripe)
One script reply has been approved by the moderators Verified

Created by rossmccrann 107 days ago Used 30 times 1 Point

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 for more information

No comments yet

Points: 0
deno
One script reply has been approved by the moderators
Ap­pro­ved
import * as wmill from "https://deno.land/x/windmill@v1.34.0/mod.ts";
import Stripe from "https://esm.sh/stripe?target=deno";

export async function main(
  stripe_con: wmill.Resource<"stripe">,
  subscription_item_id: string,
  quantity: number,
  timestamp: number
) {
  const token = stripe_con["token"];
  const stripe = Stripe(
    `${token}`,
    {
      httpClient: Stripe.createFetchHttpClient(),
    },
  );

  const usageRecord = await stripe.subscriptionItems.createUsageRecord(
    `${subscription_item_id}`,
    { quantity: quantity, timestamp: timestamp },
  );

  return await usageRecord.json();
}

Submitted by rossmccrann 107 days ago

Edited 107 days ago

No comments yet