We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent b169432 commit 629f746Copy full SHA for 629f746
app/server-fns/polar.ts
@@ -117,6 +117,26 @@ export const getCheckoutUrlServerFn = createServerFn({
117
throw signInPricingRedirect;
118
}
119
120
+ let customerId = user.polarCustomerId;
121
+
122
+ if (!customerId) {
123
+ const customer = await polar.customers.create({
124
+ email: user.email,
125
+ metadata: {
126
+ userId,
127
+ },
128
+ });
129
130
+ await db
131
+ .update(users)
132
+ .set({
133
+ polarCustomerId: customer.id,
134
+ })
135
+ .where(eq(users.id, userId));
136
137
+ customerId = customer.id;
138
+ }
139
140
const products = await getProductsServerFn();
141
142
const product = products.find((x) => x.nameId === data.productName);
0 commit comments