BA
Better Auth•2mo ago
Kimon

Stripe List Subscriptions with referenceId always throws 404

Hii, I just tried to implement the Stripe plugin on my website but unfortunately as soon as I try to fetch the active subscriptions using an organisation reference id it always throws a 404 error. I use SvelteKit, this is my implementation:
const { data: subscriptions } = await authClient.subscription.list({
referenceId: "TwaTAtP11GPvf3hrlumtNzkgJsBN8DPf",
});
console.dir(subscriptions);
const { data: subscriptions } = await authClient.subscription.list({
referenceId: "TwaTAtP11GPvf3hrlumtNzkgJsBN8DPf",
});
console.dir(subscriptions);
The reference ID is valid and has an active subscription. (See screenshot) I have also attached a screenshot of the network request with the 404 error. The referenceId was passed correctly in the request body. Without passing a referenceId it will not throw a 404 error, but will return an empty array. (Which is correct as I have no active subscription on the user id, only on the organisation id)
No description
No description
13 Replies
🌠kkMihai ⚡
did you import it on the server too? dumb question ngl on which version you on?
Kimon
KimonOP•2w ago
im on the latest version (1.2.7) does getting a subscirption via a reference id works for you? if you call
const { data: subscriptions } = await authClient.subscription.list({
referenceId: "TwaTAtP11GPvf3hrlumtNzkgJsBN8DPf",
});
console.dir(subscriptions);
const { data: subscriptions } = await authClient.subscription.list({
referenceId: "TwaTAtP11GPvf3hrlumtNzkgJsBN8DPf",
});
console.dir(subscriptions);
🌠kkMihai ⚡
theres no way to filter subscriptions like that, authClient.subscription.list() gets all the subscription linked to the logged in user
🌠kkMihai ⚡
you can do smth like this
No description
🌠kkMihai ⚡
@Ping this is kinda dumb if u ask me lmao
Kimon
KimonOP•2w ago
Stripe | Better Auth
Stripe plugin for Better Auth to manage subscriptions and payments.
Kimon
KimonOP•2w ago
but i just saw that the docs got changed, there is now a query wrapper around referenceId im gonna try that
🌠kkMihai ⚡
its listActiveSubscriptions method
Kimon
KimonOP•2w ago
its working now!! :) thank you for your help!!!
🌠kkMihai ⚡
authClient.subscription.listActiveSubscriptions what you did?
Kimon
KimonOP•2w ago
const { data: subscriptions } = await authClient.subscription.list({
query: {
referenceId: "3FVlQZ66Hky46WdpgWs9vSn4bfHwqOgD",
}
});
console.dir(subscriptions);
const { data: subscriptions } = await authClient.subscription.list({
query: {
referenceId: "3FVlQZ66Hky46WdpgWs9vSn4bfHwqOgD",
}
});
console.dir(subscriptions);
exactly like in the docs
🌠kkMihai ⚡
confusing
Kimon
KimonOP•2w ago
yeah 😅

Did you find this page helpful?