Re: Error: Error while billing the store

Error: Error while billing the store

areesha
Shopify Partner
4 0 0

Please Help..
I'm facing an issue while processing the billing. It throws an error: Error while billing the store.

Code for selecting the Plan:

import {  redirect } from "@remix-run/node";
import { authenticate, MONTHLY_PLAN, ANNUAL_PLAN } from "../shopify.server";


export const loader = async ({ request }) => {
  const { billing, session } = await authenticate.admin(request);
  let { shop } = session;
  let myShop = shop.replace(".myshopify.com", "");

  await billing.require({
    plans: [MONTHLY_PLAN],
    onFailure: async () => billing.request({
      plan: MONTHLY_PLAN,
      isTest: true,
      returnUrl: `https://admin.shopify.com/store/${myShop}/apps/${process.env.APP_NAME}/app/pricing`,
    }),
  });
  // App logic

  return null;
};
Replies 3 (3)

instasell
Shopify Partner
15 0 3

The error message you're seeing usually results from an issue with the billing method associated with your Shopify account. Here are a few steps you should consider:

 

1. Double-check your payment details: Ensure that the credit card details on your Shopify account are valid and up-to-date. You can do this by going to Settings > Billing in your Shopify admin.

 

2. Contact your bank: Sometimes, your bank may block certain transactions for security reasons. It might be a good idea to reach out to your bank to ensure they aren't blocking the payment.

 

3. Retry the transaction: If your payment details are correct and your bank isn't blocking the transaction, retry the process. There may have been a temporary issue with Shopify's payment gateway.

 

If the problem persists, it might be related to the code you're using. Your code seems to be trying to switch the billing plan between monthly and annual. If the selected plan is not available or there's an issue with the process, it might result in an error. 

 

Also, consider using the 'Postship Order Tracking' app which provides an intuitive, beautiful order tracking page for your customers. It also offers a smart order lookup page to manage & analyze all your shipping data in one place, increasing customer loyalty and providing powerful shipping analytics.

 

For more specific help, consider reaching out to Shopify's support or the developer community.

Instasell

MaverickStudio
Shopify Partner
101 32 34

Hey @areesha,

Can you confirm that the distribution is set to public? You can't access the Biling API without it.  

Screenshot 2024-07-23 174659.pngScreenshot 2024-07-23 174749.png

♥ If you found my solution helpful, please consider giving it a Like and marking it as the ✔ Accepted Solution


Try our WhatsApp Chat Button Widget with multipe agents.Supachat: WhatsApp Chat Button


A Product of Maverick Studio

MaverickStudio
Shopify Partner
101 32 34

@areesha 

Try this block of code

import { LoaderFunctionArgs, redirect } from '@remix-run/node';
import {
	ANNUAL_PLAN,
	authenticate,
	MONTHLY_PLAN,
} from '../shopify.server';

export const loader = async ({ request }: LoaderFunctionArgs) => {
	const { billing, session } = await authenticate.admin(request);
	let { shop } = session;
	let myShop = shop.replace('.myshopify.com', '');

	const billingCheck = await billing.require({
		plans: [MONTHLY_PLAN, ANNUAL_PLAN],
		isTest: true,
		onFailure: () => redirect('/pricing'),
	});

	const subscription = billingCheck.appSubscriptions[0];
	console.log(
		`Shop is on ${subscription.name} (id ${subscription.id})`
	);

	// App logic

	return null;
};

♥ If you found my solution helpful, please consider giving it a Like and marking it as the ✔ Accepted Solution


Try our WhatsApp Chat Button Widget with multipe agents.Supachat: WhatsApp Chat Button


A Product of Maverick Studio