From fa3bb0c081f7a7b8170c7e37271c613b8e577bd2 Mon Sep 17 00:00:00 2001 From: Kyle Spearrin Date: Mon, 12 Aug 2019 11:15:05 -0400 Subject: [PATCH] set customer source and method earlier --- .../Implementations/StripePaymentService.cs | 30 +++++++++---------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/src/Core/Services/Implementations/StripePaymentService.cs b/src/Core/Services/Implementations/StripePaymentService.cs index b9608d0ed3..f92723d8af 100644 --- a/src/Core/Services/Implementations/StripePaymentService.cs +++ b/src/Core/Services/Implementations/StripePaymentService.cs @@ -332,6 +332,20 @@ namespace Bit.Core.Services var stripePaymentMethod = paymentMethodType == PaymentMethodType.Card || paymentMethodType == PaymentMethodType.BankAccount || paymentMethodType == PaymentMethodType.Credit; + string stipeCustomerPaymentMethodId = null; + string stipeCustomerSourceToken = null; + if(stripePaymentMethod) + { + if(paymentToken.StartsWith("pm_")) + { + stipeCustomerPaymentMethodId = paymentToken; + } + else + { + stipeCustomerSourceToken = paymentToken; + } + } + if(user.Gateway == GatewayType.Stripe && !string.IsNullOrWhiteSpace(user.GatewayCustomerId)) { if(!string.IsNullOrWhiteSpace(paymentToken)) @@ -349,24 +363,10 @@ namespace Bit.Core.Services catch { } } - string stipeCustomerPaymentMethodId = null; if(customer == null && !string.IsNullOrWhiteSpace(paymentToken)) { - string stipeCustomerSourceToken = null; var stripeCustomerMetadata = new Dictionary(); - - if(stripePaymentMethod) - { - if(paymentToken.StartsWith("pm_")) - { - stipeCustomerPaymentMethodId = paymentToken; - } - else - { - stipeCustomerSourceToken = paymentToken; - } - } - else if(paymentMethodType == PaymentMethodType.PayPal) + if(paymentMethodType == PaymentMethodType.PayPal) { var randomSuffix = Utilities.CoreHelpers.RandomString(3, upper: false, numeric: false); var customerResult = await _btGateway.Customer.CreateAsync(new Braintree.CustomerRequest