fix(stripe): onCustomerCreate should be called even if update user isn't returned (#4716)

This commit is contained in:
Bereket Engida
2025-09-17 23:25:29 +00:00
committed by GitHub
parent a8776d3332
commit f11d365e79
3 changed files with 14 additions and 15 deletions
@@ -125,6 +125,7 @@ export const createInternalAdapter = (
undefined,
context,
);
return createdUser as T & User;
},
createAccount: async <T extends Record<string, any>>(
+12 -14
View File
@@ -1242,21 +1242,19 @@ export const stripe = <O extends StripeOptions>(options: O) => {
userId: user.id,
},
});
const updatedUser =
await ctx.context.internalAdapter.updateUser(user.id, {
stripeCustomerId: stripeCustomer.id,
});
if (!updatedUser) {
logger.error("#BETTER_AUTH: Failed to create customer");
} else {
await options.onCustomerCreate?.(
{
stripeCustomer,
user,
await ctx.context.internalAdapter.updateUser(user.id, {
stripeCustomerId: stripeCustomer.id,
});
await options.onCustomerCreate?.(
{
stripeCustomer,
user: {
...user,
stripeCustomerId: stripeCustomer.id,
},
ctx,
);
}
},
ctx,
);
}
},
},
+1 -1
View File
@@ -188,7 +188,7 @@ export interface StripeOptions {
onCustomerCreate?: (
data: {
stripeCustomer: Stripe.Customer;
user: User;
user: User & { stripeCustomerId: string };
},
ctx: GenericEndpointContext,
) => Promise<void>;