Help with Stripe payments
Hi I have a problem with Stripe. I have test mode on, and when completing a payment with the test card (4242), payment is successful but on my DB looks like "incomplete" instead of "trialing", does anyone know why?
This is my code implementation:
async function handlePlanClick(planId: string) {
try {
setLoading(planId);
const result = await authClient.subscription.upgrade({
plan: planId,
successUrl:
${process.env.NEXT_PUBLIC_URL}/dashboard
,
cancelUrl: ${process.env.NEXT_PUBLIC_URL}/dashboard/plans
,
annual: billingCycle === "yearly",
});
if (result.error) {
console.error('Subscription error:', result.error);
return;
}
} catch (error) {
console.error('Error upgrading subscription:', error);
} finally {
setLoading(null);
}
}
2. Also I have another doubt, but not my main concern since I think I already got an idea but any help would be appreciated. Basically if anyone clicks on a plan, gets redirected to checkout, but if he cancels for example, I already have a row on my DB with a reference ID created and marked as incomplete, now if that same user tries to click again on "upgrade plan"; nothing happens and a error 500 pops because my referenceID is UNIQUE. (as i said i think i got a solution for this but i bet you are way smarter and better coder than me, so any help is appreciated)
Thank you a lot guys, hoping any1 can help!
0 Replies