Hi there,
I'm trying to add Stripe to my website and I found something strange. I guess I forgot something, but can't find the info... so:
I have that button which call
It opens the Stripe page. On that page, if you click the "back to website" link, and try again to subscribe, you got the following error
query: 'insert into "subscriptions" ("id", "plan", "reference_id", "stripe_customer_id", "stripe_subscription_id", "status", "period_start", "period_end", "cancel_at_period_end", "seats", "created_at", "updated_at") values ($1, $2, $3, $4, default, $5, default, default, default, $6, default, default) returning "id", "plan", "reference_id", "stripe_customer_id", "stripe_subscription_id", "status", "period_start", "period_end", "cancel_at_period_end", "seats", "created_at", "updated_at"',
params: [Array],
[cause]: [error: duplicate key value violates unique constraint "subscriptions_reference_id_unique"] {
length: 275,
severity: 'ERROR',
code: '23505',
detail: 'Key (reference_id)=(phDhsbH.....0bKoq9NTl) already exists.',
hint: undefined,
position: undefined,
internalPosition: undefined,
internalQuery: undefined,
where: undefined,
schema: 'public',
table: 'subscriptions',
column: undefined,
dataType: undefined,
constraint: 'subscriptions_reference_id_unique',
file: 'nbtinsert.c',
line: '673',
routine: '_bt_check_unique'
}
}
query: 'insert into "subscriptions" ("id", "plan", "reference_id", "stripe_customer_id", "stripe_subscription_id", "status", "period_start", "period_end", "cancel_at_period_end", "seats", "created_at", "updated_at") values ($1, $2, $3, $4, default, $5, default, default, default, $6, default, default) returning "id", "plan", "reference_id", "stripe_customer_id", "stripe_subscription_id", "status", "period_start", "period_end", "cancel_at_period_end", "seats", "created_at", "updated_at"',
params: [Array],
[cause]: [error: duplicate key value violates unique constraint "subscriptions_reference_id_unique"] {
length: 275,
severity: 'ERROR',
code: '23505',
detail: 'Key (reference_id)=(phDhsbH.....0bKoq9NTl) already exists.',
hint: undefined,
position: undefined,
internalPosition: undefined,
internalQuery: undefined,
where: undefined,
schema: 'public',
table: 'subscriptions',
column: undefined,
dataType: undefined,
constraint: 'subscriptions_reference_id_unique',
file: 'nbtinsert.c',
line: '673',
routine: '_bt_check_unique'
}
}
I'm using Drizzle and the screenshot is my better-auth config. I guess I'm missing some "cancelation" but I can't figure how/where