I followed all step in adding polar component to my convex application but I kept getting this error([CONVEX A(polarSub:generateCheckoutLink)] [Request ID: 638984d636378328] Server Error
Uncaught Error: Customer not created) for first time when i visit my pricing page which have this component( if (!user.subscription) {
return (
<CheckoutLink
embed={false}
polarApi={{
generateCheckoutLink: api.polarSub.generateCheckoutLink,
}}
productIds={[product.id]}
>
Get started
</CheckoutLink>
);
}).. am using "@convex-dev/polar": "^0.7.3",, "@polar-sh/sdk": "^0.42.2",,, "convex": "^1.31.4",.. so is there anyone who know how to solve it ?
#Using Polar
5 messages · Page 1 of 1 (latest)
Hi @modern isle. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
The knowledge sources don’t mention this specific Customer not created error, so I can’t say with certainty what’s wrong in your app. I can only point to how the Polar component is intended to be wired up and where things commonly go wrong.
A few things to double‑check against the docs:
- Polar client initialization
Make sure you’ve created a Polar client and exported its API functions, and that generateCheckoutLink you’re using in polarApi actually comes from that client:
// convex/polarSub.ts (example)
import { Polar } from "@convex-dev/polar";
import { api, components } from "./_generated/api";
export const polar = new Polar(components.polar, {
getUserInfo: async (ctx) => {
const user = await ctx.runQuery(api.example.getCurrentUser);
return {
userId: user._id,
email: user.email,
};
},
products: {
premiumMonthly: "product_id_from_polar",
premiumYearly: "product_id_from_polar",
},
// or via env vars:
// organizationToken, webhookSecret, server
});
export const {
changeCurrentSubscription,
cancelCurrentSubscription,
getConfiguredProducts,
listAllProducts,
generateCheckoutLink,
generateCustomerPortalUrl,
} = polar.api();
Then in your React code you’d pass:
<CheckoutLink
embed={false}
polarApi={{ generateCheckoutLink: api.polarSub.generateCheckoutLink }}
productIds={[product.id]}
>
Get started
</CheckoutLink>
getUserInfomust return a valid user
The Polar client relies on getUserInfo to find or create the customer. If that function can’t find a user or doesn’t return userId and email correctly, customer creation will fail. Ensure:
ctx.runQuery(api.example.getCurrentUser)(or your equivalent) always returns a user for logged‑in visitors.- That user has a valid
email. - You’re calling the pricing page only when the user is authenticated.
[Initialize client; Access subscription data]
- Polar configuration & webhooks
Confirm that:
POLAR_ORGANIZATION_TOKENis set in Convex env (or passed in the Polar config). [Component intro]- Webhooks are configured and
POLAR_WEBHOOK_SECRETis set, and you’ve registered routes inconvex/http.ts:
import { httpRouter } from "convex/server";
import { polar } from "./polarSub";
const http = httpRouter();
polar.registerRoutes(http as any);
export default http;
- Products exist and are synced
Make sure the product.id you pass is a valid Polar product that exists in Convex:
- You’ve created products in Polar.
- You’ve run
syncProductsat least once (if products pre‑existed). [Usage – products]
- Check Convex logs for the full stack trace
The docs suggest using the request ID ([Request ID: 638984d636378328]) to find the detailed error in Convex logs; that may show exactly why the customer creation failed (missing email, invalid token, etc.). [Debugging errors]
Because the sources don’t document this exact error string, I can’t give a definitive fix. If, after checking the above, it still fails, your next step is to:
- Grab the full server log for that request ID.
- Open an issue on the Polar component repo or ask in the Convex Discord with that stack trace. [Component intro; Feedback thread]