Enable Billing in Latest Shopify Nodejs embedded app template create with CLI.

Solved

Enable Billing in Latest Shopify Nodejs embedded app template create with CLI.

syedusama0786
Shopify Partner
47 2 11

Hey Community!
I am working on a Shopify embedded app, created using CLI and Nodejs latest template but I am facing a problem in enabling Recurring Billing. I am not able to enable the billing. I want to know how I can enable the billing in Nodejs latest Template. When I was using the old Template it works fine but due to a change in the template, I didn't able to enable billing in it. I done the same that is written in shopify.js file which is in the template but it didn't work.
This is the code for Enable billing in Shopify I use.

 

import { BillingInterval, LATEST_API_VERSION, BillingReplacementBehavior } from "@shopify/shopify-api";
import { shopifyApp } from "@shopify/shopify-app-express";
import { SQLiteSessionStorage } from "@shopify/shopify-app-session-storage-sqlite";
import { restResources } from "@shopify/shopify-api/rest/admin/2023-01";
const DB_PATH = `${process.cwd()}/database.sqlite`;

// The transactions with Shopify will always be marked as test transactions, unless NODE_ENV is production.
// See the ensureBilling helper to learn more about billing in this template.
const billingConfig = {
  "My Shopify Charge": {
    // This is an example configuration that would do a one-time charge for $5 (only USD is currently supported)
    amount: 5.0,
    currencyCode: "USD",
    interval: BillingInterval.Every30Days,
  },
};

const shopify = shopifyApp({
  api: {
    apiVersion: LATEST_API_VERSION,
    restResources,
    billing: billingConfig, //undefined or replace with billingConfig above to enable example billing
  },
  auth: {
    path: "/api/auth",
    callbackPath: "/api/auth/callback",
  },
  webhooks: {
    path: "/api/webhooks",
  },
  // This should be replaced with your preferred storage strategy
  sessionStorage: new SQLiteSessionStorage(DB_PATH),
});

export default shopify;

 


Please Guide me Thanks in advance!

Accepted Solution (1)
syedusama0786
Shopify Partner
47 2 11

This is an accepted solution.

@ranawaqarahmad Hey bro! Please check the following post. and please let me know if you got something. I think it will help you. I am also checking it.
https://community.shopify.com/c/shopify-apis-and-sdks/billing-plans-for-our-apps-node-template-in-sh...

View solution in original post

Replies 10 (10)

ranawaqarahmad
Shopify Partner
13 0 4

@syedusama0786 I'm also having the same issue... Have you found something? If so please share it with me too. Thanks...

 

syedusama0786
Shopify Partner
47 2 11

Didn't Got yet

ranawaqarahmad
Shopify Partner
13 0 4

okay..

syedusama0786
Shopify Partner
47 2 11

This is an accepted solution.

@ranawaqarahmad Hey bro! Please check the following post. and please let me know if you got something. I think it will help you. I am also checking it.
https://community.shopify.com/c/shopify-apis-and-sdks/billing-plans-for-our-apps-node-template-in-sh...

syedusama0786
Shopify Partner
47 2 11

@ranawaqarahmad Hey!
I got the solution and I enable my billing on the new template...

rayvvond
Shopify Partner
13 1 4

Hi @syedusama0786 !

Could you explain the solution? Thanks !

syedusama0786
Shopify Partner
47 2 11

yes sure what do you want to know?

rayvvond
Shopify Partner
13 1 4

Hi @syedusama0786,
I am new to shopify application development.

I am trying to follow the documentation for billing plan implementation. But there is nothing happening on my sandbox.
I tried to understand the shared link information by creating a /api/auth/callback route and to test the billing, but nothing.
There must be some detail that a novice can't understand in the documentation.
I would like to know step by step how to activate billing plans.
Thanks for your help.

rayvvond
Shopify Partner
13 1 4

I have found that : https://workshops.shopify.dev/workshops/usage-billing#4
containing a better explanation

syedusama0786
Shopify Partner
47 2 11

@rayvvond Bro I also use this link to enable billing you have to use the billing code as an middleware in index.js file.