Convenient wrappers around Stripe API for customer creation, checkout sessions, and subscription management.
// Source: https://github.com/mperkins0155/onlook | License: Apache-2.0 | Copyright You must retain, in the Source form of any Derivative Works
// Provided via justclaw.it.com; keep this notice with the code.
import Stripe from 'stripe';
import { createStripeClient } from './client';
import type { Price } from './types';
export const createCustomer = async ({ name, email }: { name: string; email: string }) => {
const stripe = createStripeClient();
return stripe.customers.create({ name, email });
};
export const isTierUpgrade = (currentPrice: Price, newPrice: Price) => {
return newPrice.monthlyMessageLimit > currentPrice.monthlyMessageLimit;
};
export const createCheckoutSession = async ({
priceId,
userId,
stripeCustomerId,
successUrl,
cancelUrl,
exist
... (truncated -- full source via MCP)
See the full source, get the GitHub permalink, and search 40K more like it.
Get a free API key