mirror of
https://github.com/bitwarden/server.git
synced 2025-04-06 21:48:12 -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:
parent
04e18ee8e7
commit
662ac7f059
@ -131,7 +131,7 @@ public class StripePaymentService : IPaymentService
|
|||||||
new Stripe.CustomerInvoiceSettingsCustomFieldOptions()
|
new Stripe.CustomerInvoiceSettingsCustomFieldOptions()
|
||||||
{
|
{
|
||||||
Name = org.SubscriberType(),
|
Name = org.SubscriberType(),
|
||||||
Value = org.SubscriberName(),
|
Value = GetFirstThirtyCharacters(org.SubscriberName()),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -443,7 +443,7 @@ public class StripePaymentService : IPaymentService
|
|||||||
new Stripe.CustomerInvoiceSettingsCustomFieldOptions()
|
new Stripe.CustomerInvoiceSettingsCustomFieldOptions()
|
||||||
{
|
{
|
||||||
Name = user.SubscriberType(),
|
Name = user.SubscriberType(),
|
||||||
Value = user.SubscriberName(),
|
Value = GetFirstThirtyCharacters(user.SubscriberName()),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -1358,7 +1358,7 @@ public class StripePaymentService : IPaymentService
|
|||||||
new Stripe.CustomerInvoiceSettingsCustomFieldOptions()
|
new Stripe.CustomerInvoiceSettingsCustomFieldOptions()
|
||||||
{
|
{
|
||||||
Name = subscriber.SubscriberType(),
|
Name = subscriber.SubscriberType(),
|
||||||
Value = subscriber.SubscriberName(),
|
Value = GetFirstThirtyCharacters(subscriber.SubscriberName()),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -1438,7 +1438,7 @@ public class StripePaymentService : IPaymentService
|
|||||||
new Stripe.CustomerInvoiceSettingsCustomFieldOptions()
|
new Stripe.CustomerInvoiceSettingsCustomFieldOptions()
|
||||||
{
|
{
|
||||||
Name = subscriber.SubscriberType(),
|
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));
|
.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);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -110,7 +110,7 @@ public class StripePaymentServiceTests
|
|||||||
Assert.Equal("S-1", organization.GatewaySubscriptionId);
|
Assert.Equal("S-1", organization.GatewaySubscriptionId);
|
||||||
Assert.True(organization.Enabled);
|
Assert.True(organization.Enabled);
|
||||||
Assert.Equal(DateTime.Today.AddDays(10), organization.ExpirationDate);
|
Assert.Equal(DateTime.Today.AddDays(10), organization.ExpirationDate);
|
||||||
|
var res = organization.SubscriberName();
|
||||||
await stripeAdapter.Received().CustomerCreateAsync(Arg.Is<Stripe.CustomerCreateOptions>(c =>
|
await stripeAdapter.Received().CustomerCreateAsync(Arg.Is<Stripe.CustomerCreateOptions>(c =>
|
||||||
c.Description == organization.BusinessName &&
|
c.Description == organization.BusinessName &&
|
||||||
c.Email == organization.BillingEmail &&
|
c.Email == organization.BillingEmail &&
|
||||||
@ -120,7 +120,7 @@ public class StripePaymentServiceTests
|
|||||||
c.InvoiceSettings.DefaultPaymentMethod == null &&
|
c.InvoiceSettings.DefaultPaymentMethod == null &&
|
||||||
c.InvoiceSettings.CustomFields != null &&
|
c.InvoiceSettings.CustomFields != null &&
|
||||||
c.InvoiceSettings.CustomFields[0].Name == "Organization" &&
|
c.InvoiceSettings.CustomFields[0].Name == "Organization" &&
|
||||||
c.InvoiceSettings.CustomFields[0].Value == organization.SubscriberName() &&
|
c.InvoiceSettings.CustomFields[0].Value == organization.SubscriberName().Substring(0, 30) &&
|
||||||
c.Address.Country == taxInfo.BillingAddressCountry &&
|
c.Address.Country == taxInfo.BillingAddressCountry &&
|
||||||
c.Address.PostalCode == taxInfo.BillingAddressPostalCode &&
|
c.Address.PostalCode == taxInfo.BillingAddressPostalCode &&
|
||||||
c.Address.Line1 == taxInfo.BillingAddressLine1 &&
|
c.Address.Line1 == taxInfo.BillingAddressLine1 &&
|
||||||
@ -173,7 +173,7 @@ public class StripePaymentServiceTests
|
|||||||
c.InvoiceSettings.DefaultPaymentMethod == paymentToken &&
|
c.InvoiceSettings.DefaultPaymentMethod == paymentToken &&
|
||||||
c.InvoiceSettings.CustomFields != null &&
|
c.InvoiceSettings.CustomFields != null &&
|
||||||
c.InvoiceSettings.CustomFields[0].Name == "Organization" &&
|
c.InvoiceSettings.CustomFields[0].Name == "Organization" &&
|
||||||
c.InvoiceSettings.CustomFields[0].Value == organization.SubscriberName() &&
|
c.InvoiceSettings.CustomFields[0].Value == organization.SubscriberName().Substring(0, 30) &&
|
||||||
c.Address.Country == taxInfo.BillingAddressCountry &&
|
c.Address.Country == taxInfo.BillingAddressCountry &&
|
||||||
c.Address.PostalCode == taxInfo.BillingAddressPostalCode &&
|
c.Address.PostalCode == taxInfo.BillingAddressPostalCode &&
|
||||||
c.Address.Line1 == taxInfo.BillingAddressLine1 &&
|
c.Address.Line1 == taxInfo.BillingAddressLine1 &&
|
||||||
|
Loading…
x
Reference in New Issue
Block a user