Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Request bill payment and if merchant decline payment till merchant still able to use App further #1321

Open
KapilAnncode opened this issue Feb 29, 2024 · 0 comments

Comments

@KapilAnncode
Copy link

app.get(
shopify.config.auth.callbackPath,
shopify.auth.callback(),
// Request payment if required
async (req, res, next) => {
const session = res.locals.shopify.session;
console.log("session: ", session);
const hasPayment = await shopify.api.billing.check({
session,
plans: ['My App Charge', "Multiple LineItems Plan", "Starter"],
// plans: ['My App Charge', 'Starter'],
isTest: true,
});

console.log("hasPayment: ", hasPayment);
if (hasPayment) {      
  next();
} else {
  res.redirect(
    await shopify.api.billing.request({
      session,
      plan: 'Starter',
      isTest: true,
    }),
  );
}

},
// Load the app otherwise
shopify.redirectToShopifyOrAppRoot(),
);

I tried to implement app billing at the time of app installation for app billing and if the merchant declined merchant still able to use the application but It shouldn't .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant