Creating a subscription in stripe fails.
I am trying to create a user and the creation process goes smoothly, the user is created in the database and also the stripe customer id is then updated in the database.
But then I need to create a subscription for the user and I am using the auth.api.upgradeSubscription as mentioned in the docs. This fails.
const subscription = await auth.api.upgradeSubscription({
body: {
plan: "Starter Monthly", // required
referenceId: updatedUserWithCustomerId.id, // required
annual: false,
successUrl: process.env.NEXT_PUBLIC_URL, // required
cancelUrl: process.env.NEXT_PUBLIC_URL, // required
returnUrl: process.env.NEXT_PUBLIC_URL,
disableRedirect: true, // required
}, // This endpoint requires session cookies.
headers: ctx.headers,
});
Using a hono and trpc backend and I am doing all this on the backend.
There is no error returned, it is just empty.
It would have been nice to create a default subscription when the user is created in auth.ts somehow. But I guess this is more of a feature request rather than reality 🙂
0 Replies