Add `minimum` one-time donation amont to validation error map
This commit is contained in:
parent
5fb158635c
commit
2f21e930e2
|
@ -777,7 +777,9 @@ public class SubscriptionController {
|
||||||
minCurrencyAmountMajorUnits);
|
minCurrencyAmountMajorUnits);
|
||||||
if (minCurrencyAmountMinorUnits.compareTo(amount) > 0) {
|
if (minCurrencyAmountMinorUnits.compareTo(amount) > 0) {
|
||||||
throw new BadRequestException(Response.status(Status.BAD_REQUEST)
|
throw new BadRequestException(Response.status(Status.BAD_REQUEST)
|
||||||
.entity(Map.of("error", "amount_below_currency_minimum")).build());
|
.entity(Map.of(
|
||||||
|
"error", "amount_below_currency_minimum",
|
||||||
|
"minimum", minCurrencyAmountMajorUnits.toString())).build());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -128,16 +128,24 @@ class SubscriptionControllerTest {
|
||||||
@Test
|
@Test
|
||||||
void testCreateBoostPaymentIntentAmountBelowCurrencyMinimum() {
|
void testCreateBoostPaymentIntentAmountBelowCurrencyMinimum() {
|
||||||
when(STRIPE_MANAGER.convertConfiguredAmountToStripeAmount(any(), any())).thenReturn(new BigDecimal(250));
|
when(STRIPE_MANAGER.convertConfiguredAmountToStripeAmount(any(), any())).thenReturn(new BigDecimal(250));
|
||||||
|
when(STRIPE_MANAGER.supportsCurrency("usd")).thenReturn(true);
|
||||||
final Response response = RESOURCE_EXTENSION.target("/v1/subscription/boost/create")
|
final Response response = RESOURCE_EXTENSION.target("/v1/subscription/boost/create")
|
||||||
.request()
|
.request()
|
||||||
.post(Entity.json("""
|
.post(Entity.json("""
|
||||||
{
|
{
|
||||||
"currency": "USD",
|
"currency": "USD",
|
||||||
"amount": 249,
|
"amount": 249,
|
||||||
"level": null
|
"level": null
|
||||||
}
|
}
|
||||||
"""));
|
"""));
|
||||||
assertThat(response.getStatus()).isEqualTo(400);
|
assertThat(response.getStatus()).isEqualTo(400);
|
||||||
|
assertThat(response.hasEntity()).isTrue();
|
||||||
|
assertThat(response.readEntity(Map.class))
|
||||||
|
.isNotNull()
|
||||||
|
.containsAllEntriesOf(Map.of(
|
||||||
|
"error", "amount_below_currency_minimum",
|
||||||
|
"minimum", "2.50"
|
||||||
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
Loading…
Reference in New Issue