-
Notifications
You must be signed in to change notification settings - Fork 29
Closed
Description
When trying to create a polar checkout session from the server, I'm seeing the following error:
ERROR [Better Auth]: Polar checkout creation failed. Error: Invalid URL
{
"status":"INTERNAL_SERVER_ERROR",
"body":
{
"code": "CHECKOUT_CREATION_FAILED",
"message": "Checkout creation failed"
},
"headers":{},
"statusCode": 500,
"name":"APIError"
}
I can create a checkout session just fine on the client side, so this is just isolated to the server.
The server code where I am trying to generate the checkout session, and is capturing the error that was pasted above:
if (!currentOrganizationSubscription.result.items.length) {
try {
await auth.api.checkout({
headers: request.headers,
body: {
slug: "essential",
referenceId: currentOrganization.id
}
});
} catch (error) {
console.log(JSON.stringify(error));
}
}
And my polar setup as defined inside of my better-auth config:
baseURL: Resource.App.stage === "local" ? "http://localhost:5173" : Resource.Production.url,
plugins: [
organization({
schema: {
organization: {
additionalFields: {
logo: {
type: "string",
input: false,
required: false,
returned: true
}
}
}
}
}),
sveltekitCookies(getRequestEvent),
polar({
client: polarClient,
createCustomerOnSignUp: false,
use: [
checkout({
products: [
{
productId: "2b85e21a-73ed-4b4c-9176-13b09e128480",
slug: "essential"
},
{
productId: "40e73b9a-7b97-4c64-abad-088ed31d3474",
slug: "premium"
}
],
successUrl: "/success?checkout_id={CHECKOUT_ID}",
authenticatedUsersOnly: true
}),
portal(),
webhooks({
secret: "secret",
onCustomerStateChanged: (payload) => {},
onOrderPaid: (payload) => {}
})
]
})
],
secret: "secret",
database: drizzleAdapter(db, {
provider: "pg"
}),
trustedOrigins: ["http://localhost:5173"],
emailAndPassword: {
enabled: true,
revokeSessionsOnPasswordReset: true
},
advanced: {
database: {
generateId: false
},
cookiePrefix: "app"
},
session: {
cookieCache: {
enabled: true,
maxAge: 5 * 60
}
}
Packages:
"@polar-sh/better-auth": "^1.1.1",
"@polar-sh/sdk": "^0.34.15",
"better-auth": "^1.3.8",
Any idea why I'm encountering this error? I'm hoping I'm just missing something obvious but I don't see what that could be.
Metadata
Metadata
Assignees
Labels
No labels