From 315e8662f014046634ad897f5676d0dda9777365 Mon Sep 17 00:00:00 2001 From: Sebastian Rindom Date: Mon, 12 Oct 2020 09:08:44 +0200 Subject: [PATCH] hotfix(medusa-payment-stripe): fixes failing customer updates --- .../medusa-payment-stripe/src/subscribers/cart.js | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/packages/medusa-payment-stripe/src/subscribers/cart.js b/packages/medusa-payment-stripe/src/subscribers/cart.js index 95356a0667..c636ac5a0d 100644 --- a/packages/medusa-payment-stripe/src/subscribers/cart.js +++ b/packages/medusa-payment-stripe/src/subscribers/cart.js @@ -24,7 +24,9 @@ class CartSubscriber { const customer = await this.customerService_.retrieve(customer_id) - const stripeSession = payment_sessions.find(s => s.provider_id === "stripe") + const stripeSession = payment_sessions.find( + (s) => s.provider_id === "stripe" + ) if (!stripeSession) { return Promise.resolve() @@ -34,9 +36,12 @@ class CartSubscriber { stripeSession.data ) - let stripeCustomer = await this.stripeProviderService_.retrieveCustomer( - customer.metadata.stripe_id - ) + let stripeCustomer + if (customer.metadata && customer.metadata.stripe_id) { + stripeCustomer = await this.stripeProviderService_.retrieveCustomer( + customer.metadata.stripe_id + ) + } if (!stripeCustomer) { stripeCustomer = await this.stripeProviderService_.createCustomer(