Shopify / shopify-app-template-node

MIT License
867 stars 391 forks source link

How to ensure billing plan with latest code version ? #1253

Closed ranjitatwal30 closed 1 year ago

ranjitatwal30 commented 1 year ago

Issue summary

Added billing config on web/shopify.js:

// 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 = {
  "App Monthly Plan": {
    // This is an example configuration that would do a one-time charge for $5 (only USD is currently supported)
    required: true,
    chargeName: "Monthly Plan",
    amount: 5.0,
    currencyCode: "USD",
    trialDays: 7,
    interval: BillingInterval.Every30Days,
  },
};

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

Expected behavior

User should be redirected to choose plan after installation

Actual behavior

No plan check or prompt

ranjitatwal30 commented 1 year ago

NVM, found this documentation: https://workshops.shopify.dev/workshops/usage-billing#4

kubenstein commented 1 week ago

Just want to add that check from https://workshops.shopify.dev/workshops/usage-billing#4 is performed only after app installation, if you close the tab and open app in new tab it wont be performed. You have to implement custom checks within normal app operation logic. I think the code in the workshop is misleading.