I am upgrading to the latest Stripe API version (2020-03-02) and I am not sure how to access the values on my customer object as it now just shows the union of the properties between Stripe.Customer and Stripe.DeletedCustomer.
Any tips on how to check the type and convert to a Stripe.Customer type?
I am getting the following error:
Property 'metadata' does not exist on type 'Customer | DeletedCustomer'. Property 'metadata' does not exist on type 'DeletedCustomer'.
const customer: Stripe.Customer | Stripe.DeletedCustomer = await stripe.customers.retrieve(customerId);
const uid = customer.metadata.firebaseUID;
Note that Customer and DeletedCustomer are interfaces:
namespace Stripe {
interface DeletedCustomer {
id: string;
object: 'customer';
deleted: true;
}
interface Customer {
id: string;
metadata: Metadata;
...
}
}