support upgrade, downgrade, cancel

This commit is contained in:
Shawn Erquhart
2025-02-20 16:19:13 -05:00
parent 4e2b374c40
commit 26dc7b14c4
4 changed files with 97 additions and 32 deletions

View File

@@ -10,19 +10,20 @@ export const polar = new Polar<DataModel>(components.polar);
export const MAX_FREE_TODOS = 3;
export const MAX_PREMIUM_TODOS = 6;
export const { generateCheckoutLink } = polar.checkoutApi({
products: {
premium: "5fde8344-5fca-4d0b-adeb-2052cddfd9ed",
premiumPlus: "db548a6f-ff8c-4969-8f02-5f7301a36e7c",
},
getUserInfo: async (ctx) => {
const user = await ctx.runQuery(api.example.getCurrentUser);
return {
userId: user._id,
email: user.email,
};
},
});
export const { generateCheckoutLink, generateCustomerPortalUrl } =
polar.checkoutApi({
products: {
premium: "5fde8344-5fca-4d0b-adeb-2052cddfd9ed",
premiumPlus: "db548a6f-ff8c-4969-8f02-5f7301a36e7c",
},
getUserInfo: async (ctx) => {
const user = await ctx.runQuery(api.example.getCurrentUser);
return {
userId: user._id,
email: user.email,
};
},
});
// In a real app you'll set up authentication, we just use a
// fake user for the example.