Return 409 when setting a payment method that hasn't finished initialization

This commit is contained in:
Ravi Khadiwala
2024-12-16 14:20:24 -06:00
committed by Jon Chambers
parent a96c0ec7a3
commit 6460327372
2 changed files with 9 additions and 0 deletions

View File

@@ -712,6 +712,11 @@ public class SubscriptionController {
// a missing customer ID indicates the client made requests out of order,
// and needs to call create_payment_method to create a customer for the given payment method
new ClientErrorException(Status.CONFLICT)))
.exceptionally(ExceptionUtils.exceptionallyHandler(SubscriptionException.InvalidArguments.class, e -> {
// Here, invalid arguments must mean that the client has made requests out of order, and needs to finish
// setting up the paymentMethod first
throw new ClientErrorException(Status.CONFLICT);
}))
.thenApply(customer -> Response.ok().build());
}