({
productId,
organizationId,
user,
ipAddress,
}: {
productId: string;
organizationId: string;
user: {
id: string;
firstName: string | null;
lastName: string | null;
email: string;
};
ipAddress: string;
})
| 44 | } |
| 45 | |
| 46 | export async function createCheckout({ |
| 47 | productId, |
| 48 | organizationId, |
| 49 | user, |
| 50 | ipAddress, |
| 51 | }: { |
| 52 | productId: string; |
| 53 | organizationId: string; |
| 54 | user: { |
| 55 | id: string; |
| 56 | firstName: string | null; |
| 57 | lastName: string | null; |
| 58 | email: string; |
| 59 | }; |
| 60 | ipAddress: string; |
| 61 | }) { |
| 62 | return polar.checkouts.create({ |
| 63 | // productPriceId: priceId, |
| 64 | products: [productId], |
| 65 | successUrl: getSuccessUrl( |
| 66 | process.env.DASHBOARD_URL || process.env.NEXT_PUBLIC_DASHBOARD_URL!, |
| 67 | organizationId, |
| 68 | ), |
| 69 | customerEmail: user.email, |
| 70 | customerName: [user.firstName, user.lastName].filter(Boolean).join(' '), |
| 71 | customerIpAddress: ipAddress, |
| 72 | metadata: { |
| 73 | organizationId, |
| 74 | userId: user.id, |
| 75 | }, |
| 76 | }); |
| 77 | } |
| 78 | |
| 79 | export async function cancelSubscription(subscriptionId: string) { |
| 80 | try { |
no test coverage detected