Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -419,6 +419,7 @@ Props:
- `className`: (Optional) CSS class name
- `subscriptionId`: (Optional) ID of a subscription to upgrade. It must be on a
free pricing.
- `metadata`: (Optional) Metadata for additional information to the checkout

#### CustomerPortalLink

Expand Down
5 changes: 5 additions & 0 deletions src/client/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,13 +105,15 @@ export class Polar<
origin,
successUrl,
subscriptionId,
metadata,
}: {
productIds: string[];
userId: string;
email: string;
origin: string;
successUrl: string;
subscriptionId?: string;
metadata?: Record<string, string>;
},
): Promise<Checkout> {
const dbCustomer = await ctx.runQuery(
Expand Down Expand Up @@ -146,6 +148,7 @@ export class Polar<
subscriptionId,
embedOrigin: origin,
successUrl,
metadata,
...(productIds.length === 1
? { products: productIds }
: { products: productIds }),
Expand Down Expand Up @@ -309,6 +312,7 @@ export class Polar<
origin: v.string(),
successUrl: v.string(),
subscriptionId: v.optional(v.string()),
metadata: v.optional(v.record(v.string(), v.string())),
},
returns: v.object({
url: v.string(),
Expand All @@ -322,6 +326,7 @@ export class Polar<
subscriptionId: args.subscriptionId,
origin: args.origin,
successUrl: args.successUrl,
metadata: args.metadata,
});
return { url };
},
Expand Down
5 changes: 4 additions & 1 deletion src/react/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,14 @@ export const CheckoutLink = ({
children,
className,
subscriptionId,
metadata,
theme = "dark",
embed = true,
}: PropsWithChildren<{
polarApi: Pick<PolarComponentApi, "generateCheckoutLink">;
productIds: string[];
subscriptionId?: string;
metadata?: Record<string, string>;
className?: string;
theme?: "dark" | "light";
embed?: boolean;
Expand All @@ -60,10 +62,11 @@ export const CheckoutLink = ({
void generateCheckoutLink({
productIds,
subscriptionId,
metadata,
origin: window.location.origin,
successUrl: window.location.href,
}).then(({ url }) => setCheckoutLink(url));
}, [productIds, subscriptionId, embed, generateCheckoutLink]);
}, [productIds, subscriptionId, metadata, embed, generateCheckoutLink]);

return (
<a
Expand Down