Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import type { LoaderFunctionArgs } from "@remix-run/node";
- import { redirect } from "@remix-run/node";
- import { authenticate, LIFETIME_BASIC_PLAN } from "app/shopify.server";
- // import { Updatepreloader } from "~/utils/preload.server";
- export const loader = async ({ request }: LoaderFunctionArgs) => {
- const { billing, session } = await authenticate.admin(request);
- let { shop } = session;
- let myShop: string = shop.replace(".myshopify.com", "");
- const billingCheck = await billing.require({
- plans: [LIFETIME_BASIC_PLAN],
- onFailure: async () =>
- billing.request({
- plan: LIFETIME_BASIC_PLAN,
- isTest: true,
- returnUrl: `https://admin.shopify.com/store/${myShop}/apps/${process.env.APP_NAME}/app/plan`,
- }),
- });
- const subscription = billingCheck.appSubscriptions[0];
- if (!subscription) {
- return redirect("/app/lifetime-basic");
- }
- // Add the following line to redirect to the annual plan page
- return redirect("/app/plan");
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement