Polar not working

I tried polar subscriptions but when i do checkout i get this error
2025-03-05T18:05:39.702Z ERROR [Better Auth]: Polar checkout creation failed. Error: Invalid URL
⨯ [Error [APIError]: Checkout creation failed] {
status: 'INTERNAL_SERVER_ERROR',
body: [Object],
headers: {},
statusCode: 500,
digest: '2697661159'
}
2025-03-05T18:05:39.702Z ERROR [Better Auth]: Polar checkout creation failed. Error: Invalid URL
⨯ [Error [APIError]: Checkout creation failed] {
status: 'INTERNAL_SERVER_ERROR',
body: [Object],
headers: {},
statusCode: 500,
digest: '2697661159'
}
but i think the polar developers have not integrated headers cause when i add headers are not being passed
export const checkout = async () => {
await auth.api.polarCheckout({
query: {
productId: "6a77ff44-8349-436a-a46b-483cc3ba9f64",
},
params: {
slug: "pro",
},
headers: await headers(),
});
};
export const checkout = async () => {
await auth.api.polarCheckout({
query: {
productId: "6a77ff44-8349-436a-a46b-483cc3ba9f64",
},
params: {
slug: "pro",
},
headers: await headers(),
});
};
9 Replies
dD0K
dD0K7d ago
you can just redirect to "url"/api/auth/checkout/"slug" if you have the item properly set it up in your auth.ts
Troy
TroyOP7d ago
Nice but how can i check current user subscription state also can help
dD0K
dD0K7d ago
they're all listed in "url"/api/auth/subscriptions/list this is assuming you have the better auth catch all route under /api/auth/[...all]/route.ts btw the polar docs for this are pretty decent
dD0K
dD0K7d ago
Polar
BetterAuth - Polar
Payments and Checkouts made dead simple with BetterAuth
Troy
TroyOP6d ago
yeah with new latest version they have fixed it thanks mate
David
David6d ago
@Troy so your :
export const checkout = async () => {
await auth.api.polarCheckout({
query: {
productId: "6a77ff44-8349-436a-a46b-483cc3ba9f64",
},
params: {
slug: "pro",
},
headers: await headers(),
});
};
export const checkout = async () => {
await auth.api.polarCheckout({
query: {
productId: "6a77ff44-8349-436a-a46b-483cc3ba9f64",
},
params: {
slug: "pro",
},
headers: await headers(),
});
};
works now ?
Troy
TroyOP6d ago
no i changed the implementation now am redirecting user to checkout url by specifying the product slug
`/api/auth/checkout/pro`
`/api/auth/checkout/pro`
and for the portal i use this url also
`/api/auth/portal`
`/api/auth/portal`
but make sure your products are here
polar({
...,
enableCustomerPortal: true,
checkout: {
enabled: true,
products: [
{
productId: "1234",
slug: "basic",
},
{
productId: "1234",
slug: "pro",
},
],
successUrl: "/dashboard/settings/billing?status=success&checkout_id={CHECKOUT_ID}",
},
});
polar({
...,
enableCustomerPortal: true,
checkout: {
enabled: true,
products: [
{
productId: "1234",
slug: "basic",
},
{
productId: "1234",
slug: "pro",
},
],
successUrl: "/dashboard/settings/billing?status=success&checkout_id={CHECKOUT_ID}",
},
});
David
David6d ago
Alright, so you're using the automatically generated route for checkout and portal, created by the Polar plugin.
Troy
TroyOP6d ago
Yes

Did you find this page helpful?