1
0
mirror of https://github.com/bitwarden/server.git synced 2025-06-30 07:36:14 -05:00

Signups Fail for Organization & User Names >30 Characters (#2923)

* Add a length limit to include only the LEFT 30

* Resolving PR comment

* Fix the failing test

* Add a comment to stripepayment

* Refactoring the code
This commit is contained in:
cyprain-okeke
2023-05-19 18:45:47 +01:00
committed by GitHub
parent 04e18ee8e7
commit 662ac7f059
2 changed files with 12 additions and 7 deletions

View File

@ -131,7 +131,7 @@ public class StripePaymentService : IPaymentService
new Stripe.CustomerInvoiceSettingsCustomFieldOptions()
{
Name = org.SubscriberType(),
Value = org.SubscriberName(),
Value = GetFirstThirtyCharacters(org.SubscriberName()),
},
},
},
@ -443,7 +443,7 @@ public class StripePaymentService : IPaymentService
new Stripe.CustomerInvoiceSettingsCustomFieldOptions()
{
Name = user.SubscriberType(),
Value = user.SubscriberName(),
Value = GetFirstThirtyCharacters(user.SubscriberName()),
},
}
},
@ -1358,7 +1358,7 @@ public class StripePaymentService : IPaymentService
new Stripe.CustomerInvoiceSettingsCustomFieldOptions()
{
Name = subscriber.SubscriberType(),
Value = subscriber.SubscriberName(),
Value = GetFirstThirtyCharacters(subscriber.SubscriberName()),
},
}
},
@ -1438,7 +1438,7 @@ public class StripePaymentService : IPaymentService
new Stripe.CustomerInvoiceSettingsCustomFieldOptions()
{
Name = subscriber.SubscriberType(),
Value = subscriber.SubscriberName(),
Value = GetFirstThirtyCharacters(subscriber.SubscriberName())
},
}
},
@ -1817,4 +1817,9 @@ public class StripePaymentService : IPaymentService
.OrderByDescending(i => i.Created).Select(i => new BillingInfo.BillingInvoice(i));
}
// We are taking only first 30 characters of the SubscriberName because stripe provide
// for 30 characters for custom_fields,see the link: https://stripe.com/docs/api/invoices/create
private static string GetFirstThirtyCharacters(string subscriberName) => string.IsNullOrWhiteSpace(subscriberName) ? "" : subscriberName.Substring(0, 30);
}