diff --git a/src/Core/Services/Implementations/BraintreePaymentService.cs b/src/Core/Services/Implementations/BraintreePaymentService.cs index 344c7db1de..c205235fd7 100644 --- a/src/Core/Services/Implementations/BraintreePaymentService.cs +++ b/src/Core/Services/Implementations/BraintreePaymentService.cs @@ -6,6 +6,7 @@ using Braintree; using Bit.Core.Exceptions; using Bit.Core.Models.Business; using Bit.Core.Enums; +using System.Collections.Generic; namespace Bit.Core.Services { @@ -222,7 +223,11 @@ namespace Bit.Core.Services var customerResult = await _gateway.Customer.CreateAsync(new CustomerRequest { PaymentMethodNonce = paymentToken, - Email = user.Email + Email = user.Email, + CustomFields = new Dictionary + { + [user.BraintreeIdField()] = user.Id.ToString() + } }); if(!customerResult.IsSuccess() || customerResult.Target.PaymentMethods.Length == 0) @@ -336,7 +341,11 @@ namespace Bit.Core.Services var result = await _gateway.Customer.CreateAsync(new CustomerRequest { Email = subscriber.BillingEmailAddress(), - PaymentMethodNonce = paymentToken + PaymentMethodNonce = paymentToken, + CustomFields = new Dictionary + { + [subscriber.BraintreeIdField()] = subscriber.Id.ToString() + } }); if(!result.IsSuccess()) diff --git a/src/Core/Services/Implementations/StripePaymentService.cs b/src/Core/Services/Implementations/StripePaymentService.cs index 007abcd86a..501deb46fe 100644 --- a/src/Core/Services/Implementations/StripePaymentService.cs +++ b/src/Core/Services/Implementations/StripePaymentService.cs @@ -54,7 +54,11 @@ namespace Bit.Core.Services { PaymentMethodNonce = paymentToken, Email = org.BillingEmail, - Id = org.BraintreeCustomerIdPrefix() + org.Id.ToString("N").ToLower() + randomSuffix + Id = org.BraintreeCustomerIdPrefix() + org.Id.ToString("N").ToLower() + randomSuffix, + CustomFields = new Dictionary + { + [org.BraintreeIdField()] = org.Id.ToString() + } }); if(!customerResult.IsSuccess() || customerResult.Target.PaymentMethods.Length == 0) @@ -174,7 +178,11 @@ namespace Bit.Core.Services { PaymentMethodNonce = paymentToken, Email = user.Email, - Id = user.BraintreeCustomerIdPrefix() + user.Id.ToString("N").ToLower() + randomSuffix + Id = user.BraintreeCustomerIdPrefix() + user.Id.ToString("N").ToLower() + randomSuffix, + CustomFields = new Dictionary + { + [user.BraintreeIdField()] = user.Id.ToString() + } }); if(!customerResult.IsSuccess() || customerResult.Target.PaymentMethods.Length == 0) @@ -767,7 +775,11 @@ namespace Bit.Core.Services PaymentMethodNonce = paymentToken, Email = subscriber.BillingEmailAddress(), Id = subscriber.BraintreeCustomerIdPrefix() + subscriber.Id.ToString("N").ToLower() + - Utilities.CoreHelpers.RandomString(3, upper: false, numeric: false) + Utilities.CoreHelpers.RandomString(3, upper: false, numeric: false), + CustomFields = new Dictionary + { + [subscriber.BraintreeIdField()] = subscriber.Id.ToString() + } }); if(!customerResult.IsSuccess() || customerResult.Target.PaymentMethods.Length == 0)