From 4f1ef9a039bb0648611bb99d5df4c264b58e68de Mon Sep 17 00:00:00 2001 From: Ehren Kret Date: Fri, 19 Nov 2021 10:11:33 -0600 Subject: [PATCH] Add additional http status codes to /v1/subscription/boost/receipt_credentials --- .../textsecuregcm/controllers/SubscriptionController.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/service/src/main/java/org/whispersystems/textsecuregcm/controllers/SubscriptionController.java b/service/src/main/java/org/whispersystems/textsecuregcm/controllers/SubscriptionController.java index 3b9c50eda..4057dada0 100644 --- a/service/src/main/java/org/whispersystems/textsecuregcm/controllers/SubscriptionController.java +++ b/service/src/main/java/org/whispersystems/textsecuregcm/controllers/SubscriptionController.java @@ -55,6 +55,7 @@ import javax.ws.rs.core.Context; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; import javax.ws.rs.core.Response.Status; +import org.apache.commons.lang3.StringUtils; import org.signal.zkgroup.InvalidInputException; import org.signal.zkgroup.VerificationFailedException; import org.signal.zkgroup.receipts.ReceiptCredentialRequest; @@ -562,10 +563,13 @@ public class SubscriptionController { return stripeManager.getPaymentIntent(request.getPaymentIntentId()) .thenCompose(paymentIntent -> { if (paymentIntent == null) { + throw new WebApplicationException(Status.NOT_FOUND); + } + if (StringUtils.equalsIgnoreCase("processing", paymentIntent.getStatus())) { throw new WebApplicationException(Status.NO_CONTENT); } - if (!"succeeded".equalsIgnoreCase(paymentIntent.getStatus())) { - throw new WebApplicationException(Status.NO_CONTENT); + if (!StringUtils.equalsIgnoreCase("succeeded", paymentIntent.getStatus())) { + throw new WebApplicationException(Status.PAYMENT_REQUIRED); } ReceiptCredentialRequest receiptCredentialRequest; try {