1
0
mirror of https://github.com/bitwarden/server.git synced 2025-04-05 21:18:13 -05:00

Updated PayPal logic to add region custom field (#3127)

This commit is contained in:
Conner Turnbull 2023-07-24 12:48:18 -04:00 committed by GitHub
parent 51ee463a71
commit 4ec765ae19
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 29 additions and 11 deletions

View File

@ -95,12 +95,13 @@ public class ToolsController : Controller
SubmitForSettlement = true, SubmitForSettlement = true,
PayPal = new Braintree.TransactionOptionsPayPalRequest PayPal = new Braintree.TransactionOptionsPayPalRequest
{ {
CustomField = $"{btObjIdField}:{btObjId}" CustomField = $"{btObjIdField}:{btObjId},region:{_globalSettings.BaseServiceUri.CloudRegion}"
} }
}, },
CustomFields = new Dictionary<string, string> CustomFields = new Dictionary<string, string>
{ {
[btObjIdField] = btObjId.ToString() [btObjIdField] = btObjId.ToString(),
["region"] = _globalSettings.BaseServiceUri.CloudRegion
} }
}); });

View File

@ -750,12 +750,13 @@ public class StripeController : Controller
SubmitForSettlement = true, SubmitForSettlement = true,
PayPal = new Braintree.TransactionOptionsPayPalRequest PayPal = new Braintree.TransactionOptionsPayPalRequest
{ {
CustomField = $"{btObjIdField}:{btObjId}" CustomField = $"{btObjIdField}:{btObjId},region:{_globalSettings.BaseServiceUri.CloudRegion}"
} }
}, },
CustomFields = new Dictionary<string, string> CustomFields = new Dictionary<string, string>
{ {
[btObjIdField] = btObjId.ToString() [btObjIdField] = btObjId.ToString(),
["region"] = _globalSettings.BaseServiceUri.CloudRegion
} }
}); });

View File

@ -13,6 +13,7 @@ public interface ISubscriber
string SubscriberName(); string SubscriberName();
string BraintreeCustomerIdPrefix(); string BraintreeCustomerIdPrefix();
string BraintreeIdField(); string BraintreeIdField();
string BraintreeCloudRegionField();
string GatewayIdField(); string GatewayIdField();
bool IsUser(); bool IsUser();
string SubscriberType(); string SubscriberType();

View File

@ -111,6 +111,11 @@ public class Organization : ITableObject<Guid>, ISubscriber, IStorable, IStorabl
return "organization_id"; return "organization_id";
} }
public string BraintreeCloudRegionField()
{
return "region";
}
public string GatewayIdField() public string GatewayIdField()
{ {
return "organizationId"; return "organizationId";

View File

@ -101,6 +101,11 @@ public class User : ITableObject<Guid>, ISubscriber, IStorable, IStorableSubscri
return "user_id"; return "user_id";
} }
public string BraintreeCloudRegionField()
{
return "region";
}
public string GatewayIdField() public string GatewayIdField()
{ {
return "userId"; return "userId";

View File

@ -83,7 +83,8 @@ public class StripePaymentService : IPaymentService
Id = org.BraintreeCustomerIdPrefix() + org.Id.ToString("N").ToLower() + randomSuffix, Id = org.BraintreeCustomerIdPrefix() + org.Id.ToString("N").ToLower() + randomSuffix,
CustomFields = new Dictionary<string, string> CustomFields = new Dictionary<string, string>
{ {
[org.BraintreeIdField()] = org.Id.ToString() [org.BraintreeIdField()] = org.Id.ToString(),
[org.BraintreeCloudRegionField()] = _globalSettings.BaseServiceUri.CloudRegion
} }
}); });
@ -406,7 +407,8 @@ public class StripePaymentService : IPaymentService
Id = user.BraintreeCustomerIdPrefix() + user.Id.ToString("N").ToLower() + randomSuffix, Id = user.BraintreeCustomerIdPrefix() + user.Id.ToString("N").ToLower() + randomSuffix,
CustomFields = new Dictionary<string, string> CustomFields = new Dictionary<string, string>
{ {
[user.BraintreeIdField()] = user.Id.ToString() [user.BraintreeIdField()] = user.Id.ToString(),
[user.BraintreeCloudRegionField()] = _globalSettings.BaseServiceUri.CloudRegion
} }
}); });
@ -602,12 +604,13 @@ public class StripePaymentService : IPaymentService
SubmitForSettlement = true, SubmitForSettlement = true,
PayPal = new Braintree.TransactionOptionsPayPalRequest PayPal = new Braintree.TransactionOptionsPayPalRequest
{ {
CustomField = $"{subscriber.BraintreeIdField()}:{subscriber.Id}" CustomField = $"{subscriber.BraintreeIdField()}:{subscriber.Id},{subscriber.BraintreeCloudRegionField()}:{_globalSettings.BaseServiceUri.CloudRegion}"
} }
}, },
CustomFields = new Dictionary<string, string> CustomFields = new Dictionary<string, string>
{ {
[subscriber.BraintreeIdField()] = subscriber.Id.ToString() [subscriber.BraintreeIdField()] = subscriber.Id.ToString(),
[subscriber.BraintreeCloudRegionField()] = _globalSettings.BaseServiceUri.CloudRegion
} }
}); });
@ -991,12 +994,13 @@ public class StripePaymentService : IPaymentService
SubmitForSettlement = true, SubmitForSettlement = true,
PayPal = new Braintree.TransactionOptionsPayPalRequest PayPal = new Braintree.TransactionOptionsPayPalRequest
{ {
CustomField = $"{subscriber.BraintreeIdField()}:{subscriber.Id}" CustomField = $"{subscriber.BraintreeIdField()}:{subscriber.Id},{subscriber.BraintreeCloudRegionField()}:{_globalSettings.BaseServiceUri.CloudRegion}"
} }
}, },
CustomFields = new Dictionary<string, string> CustomFields = new Dictionary<string, string>
{ {
[subscriber.BraintreeIdField()] = subscriber.Id.ToString() [subscriber.BraintreeIdField()] = subscriber.Id.ToString(),
[subscriber.BraintreeCloudRegionField()] = _globalSettings.BaseServiceUri.CloudRegion
} }
}); });
@ -1290,7 +1294,8 @@ public class StripePaymentService : IPaymentService
Utilities.CoreHelpers.RandomString(3, upper: false, numeric: false), Utilities.CoreHelpers.RandomString(3, upper: false, numeric: false),
CustomFields = new Dictionary<string, string> CustomFields = new Dictionary<string, string>
{ {
[subscriber.BraintreeIdField()] = subscriber.Id.ToString() [subscriber.BraintreeIdField()] = subscriber.Id.ToString(),
[subscriber.BraintreeCloudRegionField()] = _globalSettings.BaseServiceUri.CloudRegion
} }
}); });