Skip to content

Commit

Permalink
Customer Phone keep getting deleted
Browse files Browse the repository at this point in the history
  • Loading branch information
Sberla84 committed Jul 8, 2024
1 parent 6c5966d commit c13a0cd
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions firestore-stripe-payments/functions/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,18 @@

import * as admin from 'firebase-admin';
import { getEventarc } from 'firebase-admin/eventarc';
import { Timestamp } from 'firebase-admin/firestore';
import * as functions from 'firebase-functions';
import Stripe from 'stripe';
import config from './config';
import {
Product,
CustomerData,
Price,
Product,
Subscription,
CustomerData,
TaxRate,
} from './interfaces';
import * as logs from './logs';
import config from './config';
import { Timestamp } from 'firebase-admin/firestore';

const apiVersion = '2022-11-15';
const stripe = new Stripe(config.stripeSecretKey, {
Expand Down Expand Up @@ -515,9 +515,12 @@ const copyBillingDetailsToCustomer = async (
): 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 });
if(!phone){
await stripe.customers.update(customer, { name, address });
} else {
await stripe.customers.update(customer, { name, phone, address });
}
};

/**
* Manage subscription status changes.
*/
Expand Down

0 comments on commit c13a0cd

Please sign in to comment.