Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Customer Phone keeps getting deleted after subscription dele #625

Open
rossano-montori opened this issue May 22, 2024 · 0 comments
Open

Comments

@rossano-montori
Copy link

Bug report

  • Extension name: invertase/stripe-firebase-extensions

Describe the bug

On events: customer.subscription.created
The webhook handleWebHook keeps overwriting with empty value the customer phone to the customer profile.
In my stripe API call to create a checkout i run correctly with

 phone_number_collection: {
    enabled: true,
  },

Indeed my payment page does force you to insert phone number.

In details, this is what's going wrong, i've spotted the error in the soure code:

functions/src/index.ts

  // NOTE: This is a costly operation and should happen at the very end.
  // Copy the billing deatils to the customer object.
  if (createAction && subscription.default_payment_method) {
    await copyBillingDetailsToCustomer(
      subscription.default_payment_method as Stripe.PaymentMethod
    );
  }
  // the copyBillingDetailsToCustomer implementation, the bug is easily spotted once you go live, the phone from billing_details is always empty even if you have 
const copyBillingDetailsToCustomer = async (
  payment_method: Stripe.PaymentMethod
): Promise<void> => {
  const customer = payment_method.customer as string;
  const { name, phone, address } = payment_method.billing_details;
  await stripe.customers.update(customer, { name, phone, address });
};

Code

To Reproduce

Just give it a try, whatever payment that requires phone ends up with a empty phone field on customer page on stripe and in firebase payment. The only place where it doesn't get erased is inside the invoice.

Expected behavior

It is expected that the phone number gets updated when it's available; if for some reasons the phone number is empty (due to stripe errors or stripe delay in the update), it should not overwrite the pre-existing value.

Screenshots

logs payment log customerupdated log

Kind Regards

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant