Skip to content

Feature Request: Example for Usage-Based Billing in Shopify Remix App #2218

Open
@sanjaymakwana05

Description

@sanjaymakwana05

Overview

I would like to request an official example or documentation on implementing usage-based billing in a Shopify Remix app. The current Remix framework supports subscription-based billing, but clear guidance on creating and recording usage charges dynamically would be very helpful.

Problem Statement
Currently, the Shopify Remix billing API supports app subscriptions, but the usage-based billing implementation is unclear. Many developers face issues when trying to:

Create a usage-based subscription plan with a capped amount.
Charge merchants dynamically when a usage event occurs.
Retrieve and use subscriptionLineItemId for tracking.

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
};

Why This is Important
Many Shopify app developers are migrating to Remix but lack clear billing examples.
Incorrect implementation can lead to failed charges and billing errors.
Providing an official Shopify Remix usage-based billing example would help developers avoid common pitfalls.
Additional Context
It would be helpful if the example includes:

Creating the subscription
Retrieving subscriptionLineItemId
Recording usage charges dynamically
Handling Shopify API responses and errors
Would the Shopify team be able to provide an official example or update the Shopify Remix billing documentation to cover this use case?

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions