Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/main/java/com/stripe/mpp/Parsing.java
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ static Receipt parsePaymentReceipt(String header) {

String status = str(map, "status");
if (status == null) throw new ParseException("Missing status");
if (!"success".equals(status)) throw new ParseException("Invalid receipt status: " + status);

String timestampStr = str(map, "timestamp");
if (timestampStr == null) throw new ParseException("Missing timestamp");
Expand Down
17 changes: 17 additions & 0 deletions src/test/java/com/stripe/mpp/ParsingTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,23 @@ void receiptParseRejectsMissingMethod() {
.hasMessageContaining("method");
}

@Test
void receiptParseRejectsNonSuccessStatus() {
// Regression test for AGR-2026-086: an otherwise well-formed receipt
// whose status is anything other than "success" (e.g. "failed", as a
// malicious or buggy server might send) must be rejected, not parsed
// into a usable Receipt. status presence alone was previously
// sufficient; canonical mppx requires the literal value "success".
String header = ChallengeId.b64urlEncode(
"{\"method\":\"tempo\",\"reference\":\"ref-123\",\"status\":\"failed\","
+ "\"timestamp\":\"2025-01-01T12:00:00Z\"}"
);

assertThatThrownBy(() -> Receipt.fromPaymentReceipt(header))
.isInstanceOf(com.stripe.mpp.error.ParseException.class)
.hasMessageContaining("status");
}

@Test
void receiptParseRejectsInvalidMethodId() {
String header = ChallengeId.b64urlEncode(
Expand Down