Duplicate Stripe customer

Hello! I'm using the Stripe plugin with Drizzle and Astro, everything works fine except that the Stripe customer is created twice: - One customer gets created when on sign up - One customer gets created when calling the subscription.update function to redirect to Stripe for the payment Did anybody experience the same problem? Thanks in advance
3 Replies
Giordano Piazza
Giordano PiazzaOP3mo ago
Little update: - A new Stripe customer is created along with a new "incomplete" subscription, as long as there is no "active" subscription (this happens when you start an upgrade but don't complete the purchase) - As soon as a subscription becomes "active", the customer ID will be reused for upgrades etc I believe the Stripe plugin is not getting the customer ID for subscriptions that are not "active"
Ping
Ping3mo ago
Hey can you show me how you're calling the subscription.upgrade?
Giordano Piazza
Giordano PiazzaOP3mo ago
@Ping sure, it's a basic upgrade call:
await client.subscription.upgrade({
plan: "pro",
successUrl: "/dashboard",
cancelUrl: "/pricing",
});
await client.subscription.upgrade({
plan: "pro",
successUrl: "/dashboard",
cancelUrl: "/pricing",
});
I also found out that if you create a new account and don't complete the purchase, it keeps creating customers in Stripe and rows in the subscription table with status "incomplete". Steps to reproduce: - Sign up new user - Call subscription.upgrade but don't complete the purchase (eg. go back once you reach Stripe's hosted page) - A new customer is created in Stripe and a new row in the subscription table with status "incomplete" - If you repeat the steps it keeps creating customers and subscription rows The problem "stops" once you complete a purchase and the subscription row becomes "active", at which point it starts re-using the stripe_customer_id stored in the active subscription

Did you find this page helpful?