mirror of
https://github.com/bitwarden/server.git
synced 2025-04-08 14:38:15 -05:00
custom ids to braintree customers
This commit is contained in:
parent
98bd42dde1
commit
856e331ef3
@ -6,6 +6,7 @@ using Braintree;
|
|||||||
using Bit.Core.Exceptions;
|
using Bit.Core.Exceptions;
|
||||||
using Bit.Core.Models.Business;
|
using Bit.Core.Models.Business;
|
||||||
using Bit.Core.Enums;
|
using Bit.Core.Enums;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
namespace Bit.Core.Services
|
namespace Bit.Core.Services
|
||||||
{
|
{
|
||||||
@ -222,7 +223,11 @@ namespace Bit.Core.Services
|
|||||||
var customerResult = await _gateway.Customer.CreateAsync(new CustomerRequest
|
var customerResult = await _gateway.Customer.CreateAsync(new CustomerRequest
|
||||||
{
|
{
|
||||||
PaymentMethodNonce = paymentToken,
|
PaymentMethodNonce = paymentToken,
|
||||||
Email = user.Email
|
Email = user.Email,
|
||||||
|
CustomFields = new Dictionary<string, string>
|
||||||
|
{
|
||||||
|
[user.BraintreeIdField()] = user.Id.ToString()
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
if(!customerResult.IsSuccess() || customerResult.Target.PaymentMethods.Length == 0)
|
if(!customerResult.IsSuccess() || customerResult.Target.PaymentMethods.Length == 0)
|
||||||
@ -336,7 +341,11 @@ namespace Bit.Core.Services
|
|||||||
var result = await _gateway.Customer.CreateAsync(new CustomerRequest
|
var result = await _gateway.Customer.CreateAsync(new CustomerRequest
|
||||||
{
|
{
|
||||||
Email = subscriber.BillingEmailAddress(),
|
Email = subscriber.BillingEmailAddress(),
|
||||||
PaymentMethodNonce = paymentToken
|
PaymentMethodNonce = paymentToken,
|
||||||
|
CustomFields = new Dictionary<string, string>
|
||||||
|
{
|
||||||
|
[subscriber.BraintreeIdField()] = subscriber.Id.ToString()
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
if(!result.IsSuccess())
|
if(!result.IsSuccess())
|
||||||
|
@ -54,7 +54,11 @@ namespace Bit.Core.Services
|
|||||||
{
|
{
|
||||||
PaymentMethodNonce = paymentToken,
|
PaymentMethodNonce = paymentToken,
|
||||||
Email = org.BillingEmail,
|
Email = org.BillingEmail,
|
||||||
Id = org.BraintreeCustomerIdPrefix() + org.Id.ToString("N").ToLower() + randomSuffix
|
Id = org.BraintreeCustomerIdPrefix() + org.Id.ToString("N").ToLower() + randomSuffix,
|
||||||
|
CustomFields = new Dictionary<string, string>
|
||||||
|
{
|
||||||
|
[org.BraintreeIdField()] = org.Id.ToString()
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
if(!customerResult.IsSuccess() || customerResult.Target.PaymentMethods.Length == 0)
|
if(!customerResult.IsSuccess() || customerResult.Target.PaymentMethods.Length == 0)
|
||||||
@ -174,7 +178,11 @@ namespace Bit.Core.Services
|
|||||||
{
|
{
|
||||||
PaymentMethodNonce = paymentToken,
|
PaymentMethodNonce = paymentToken,
|
||||||
Email = user.Email,
|
Email = user.Email,
|
||||||
Id = user.BraintreeCustomerIdPrefix() + user.Id.ToString("N").ToLower() + randomSuffix
|
Id = user.BraintreeCustomerIdPrefix() + user.Id.ToString("N").ToLower() + randomSuffix,
|
||||||
|
CustomFields = new Dictionary<string, string>
|
||||||
|
{
|
||||||
|
[user.BraintreeIdField()] = user.Id.ToString()
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
if(!customerResult.IsSuccess() || customerResult.Target.PaymentMethods.Length == 0)
|
if(!customerResult.IsSuccess() || customerResult.Target.PaymentMethods.Length == 0)
|
||||||
@ -767,7 +775,11 @@ namespace Bit.Core.Services
|
|||||||
PaymentMethodNonce = paymentToken,
|
PaymentMethodNonce = paymentToken,
|
||||||
Email = subscriber.BillingEmailAddress(),
|
Email = subscriber.BillingEmailAddress(),
|
||||||
Id = subscriber.BraintreeCustomerIdPrefix() + subscriber.Id.ToString("N").ToLower() +
|
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<string, string>
|
||||||
|
{
|
||||||
|
[subscriber.BraintreeIdField()] = subscriber.Id.ToString()
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
if(!customerResult.IsSuccess() || customerResult.Target.PaymentMethods.Length == 0)
|
if(!customerResult.IsSuccess() || customerResult.Target.PaymentMethods.Length == 0)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user