Re: Shopify Remix App - Usage Based Pricing

Shopify Remix App - Usage Based Pricing

WeAreMode
Shopify Partner
5 0 4

I'm building a Shopify App using the remix app template which will have usage based pricing based on the number of objects created and published by the merchant. So for example if the merchant creates 150 objects they will be charged for the 150 objects every month.

 

I've followed the documentation here: https://shopify.dev/docs/api/shopify-app-remix/v2/apis/billing and created a plan with a lineItem with the interval set too

 

 

 

lineItems: [
    {
        amount: 0.05,
        currencyCode: 'USD',
        interval: BillingInterval.Usage,
    },
],

 

 

 

But I can't find any further information from this point on how to apply this charge based on the merchants usage each month. Has anyone successfully setup usage based pricing in a remix app which can shed some light on how best to approach this?

Replies 4 (4)

abhishek1108
Shopify Partner
6 0 1

I am stuck at the same stage. If anyone can help ? 
requirement: i want to create a recurring charge of amount 0 that will be accepted post installation and then based upon usage i will be updating the the amount before billing each month. 

syedusama0786
Shopify Partner
47 2 11

Do you find any solution ? @WeAreMode @abhishek1108 

WeAreMode
Shopify Partner
5 0 4

Hi @syedusama0786 @abhishek1108 

 

We did end up solving this, we have stored the line_item_id in the database when creating the charge. Then we needed to use the appUsageRecordCreate graphQL mutation to create the charge.

 

For us we created a cron job which ran on the 1st each month to calculate how much their usage was and apply it this way. But cron jobs in Remix wasn't simple.

syedusama0786
Shopify Partner
47 2 11

Thanks for reply @WeAreMode 

I think, Usage based billing will be added in code same as we added it in Node.js template.
I have all the code and i will use the same code and hope it will work.
It also use appUsageRecordCreate graphql mutation.