Guidance on Implementing Time-Based and Usage-Based Billing in Shopify App

Hi everyone,

I’m currently building a Shopify public app using Remix and have implemented basic billing logic. Here’s a simplified version of my action function for creating a usage record:

import { ActionFunctionArgs } from "@remix-run/node";
import { authenticate, MONTHLY_PLAN } from "../shopify.server";

export const action = async ({ request }: ActionFunctionArgs) => {
  const { billing } = await authenticate.admin(request);

  const chargeBilling = await billing.createUsageRecord({
    description: "Usage record for product creation",
    price: {
      amount: 1,
      currencyCode: "USD",
    },
    isTest: true,
  });

  console.log(chargeBilling);

  // App logic
};

I would appreciate guidance on:

  1. Best practices for implementing usage-based billing, including setting usage limits or thresholds.
  2. Whether time-based billing (e.g., charging based on active time or intervals) is supported, and if so, how best to structure it.
  3. Any specific recommendations or gotchas when using billing.createUsageRecord() with the Shopify Billing API.
  4. How to tie these billing events to specific user actions (e.g., creating a product) while staying compliant with Shopify’s billing policies.

Thanks in advance for your help!