fix: update user customerId handlingto address data inconsistency
This commit is contained in:
parent
aea55ee4bb
commit
e556f72fc7
@ -84,10 +84,13 @@ export class StripeProvider implements PaymentProvider {
|
|||||||
|
|
||||||
// Find user id by customer id
|
// Find user id by customer id
|
||||||
const userId = await this.findUserIdByCustomerId(customerId);
|
const userId = await this.findUserIdByCustomerId(customerId);
|
||||||
// user does not exist, update user with customer id
|
// If no userId found, it means the user record exists (by email) but lacks customerId
|
||||||
// in case you deleted user in database, but forgot to delete customer in Stripe
|
// This can happen when user was created before Stripe integration or data got out of sync
|
||||||
|
// Fix the data inconsistency by updating the user's customerId field
|
||||||
if (!userId) {
|
if (!userId) {
|
||||||
console.log('User does not exist, update with customer id (hidden)');
|
console.log(
|
||||||
|
'User exists but missing customerId, fixing data inconsistency'
|
||||||
|
);
|
||||||
await this.updateUserWithCustomerId(customerId, email);
|
await this.updateUserWithCustomerId(customerId, email);
|
||||||
}
|
}
|
||||||
return customerId;
|
return customerId;
|
||||||
|
Loading…
Reference in New Issue
Block a user