Skip to content

Instantly share code, notes, and snippets.

@dipeshhkc
Last active January 15, 2023 21:37
Show Gist options
  • Save dipeshhkc/720cc3e73421c3a67c5386c3cc5cf64b to your computer and use it in GitHub Desktop.
Save dipeshhkc/720cc3e73421c3a67c5386c3cc5cf64b to your computer and use it in GitHub Desktop.
import type { ActionFunction } from "@remix-run/server-runtime";
import { redirect } from "@remix-run/server-runtime";
import { stripeCheckout } from "~/stripe.server";
import { getPriceId } from "~/types/subscription";
import { getLoggedInUser } from "~/user.server";
export const action: ActionFunction = async ({ request }) => {
const user = await getLoggedInUser();
if (!user) {
return redirect("/");
}
const form = await request.formData();
const plan = form.get("plan") as string;
const priceId = getPriceId(plan)!;
const url = await stripeCheckout({
priceId,
plan,
user,
});
return redirect(url);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment