Best practices for usage-based billing on embedded Shopify app

Hi everyone,

I’m building an embedded Shopify app that acts as an affiliate marketplace. Merchants connect their store, their products are displayed on our marketplace, and when a customer clicks “Buy”, they’re redirected to the merchant’s Shopify store via a cart permalink with a storefront access token.

I want to charge a 5% commission on sales attributed to my app.

My current implementation plan:

  1. Billing setup: Use appSubscriptionCreate with usagePricingDetails
  2. Order attribution: Use storefront access token + cart permalink so orders have my app as the source/sales channel
  3. Charging commissions: Call appUsageRecordCreate for each order attributed to my app
  4. Order detection:
    • orders/paid webhook, filter by source_name

My questions:

  1. Is this the right approach for usage-based affiliate commissions? Or is there a better pattern?
  2. Order attribution: How do I reliably detect that an order came from my app? I’m using cart permalinks
  3. Billing flow UX: After appSubscriptionCreate, I redirect to the confirmationUrl using
    window.top.location.href (App Bridge v4).
  4. When to create the subscription?
  5. Webhook vs Polling ?