Skip to content

Customer Phone keep getting deleted #634

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

Open
wants to merge 1 commit into
base: next
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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