Skip to content

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

@KapilAnncode

Description

@KapilAnncode

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 .

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions