Cancel Payment Error Codes
This section documents validation and business rule errors for the Cancel Payment (/payments/{paymentId}/cancel) endpoint.
Error Code Summary – Cancel Payment
| Error Title Reference | Error Title | HTTP Status | Detail Message | Scenario | Resolution |
|---|---|---|---|---|---|
| Missing Cancellation Reason | INVALID_REQUEST | 400 BAD REQUEST | paymentCancellationReason must not be null | Reason not provided | Include a valid cancellation reason in the request |
| Invalid Cancellation Reason Enum | INVALID_REQUEST | 400 BAD REQUEST | Failed to read HTTP message Please review API specs https://docs.healthsafepay.com/api-reference/ | Reason is not one of: DUPLICATE, FRAUDULENT, REQUESTED_BY_CUSTOMER, ABANDONED | Use only allowed values: DUPLICATE, FRAUDULENT, REQUESTED_BY_CUSTOMER, or ABANDONED |
| Invalid Payment Id | INVALID_REQUEST | 400 BAD REQUEST | Invalid Payment, Payment Id: [${paymentId}], Payment Status: [COMPLETED] | Payment is already completed or invalid | Ensure payment is in a cancellable state (Only AUTHORIZED and ACCEPTED payments can be cancelled) |
| Invalid Payment Id Format | INVALID_REQUEST | 400 BAD REQUEST | Invalid payment id | Payment id is not found or is malformed | Provide a valid payment ID in the correct UUID format |
Error Codes Details
Cancel Payment Errors
Missing cancellation Reason
Missing Cancellation Reason
Occurs when the cancellation reason is not provided.
Sample Error Response:
{
"title": "INVALID_REQUEST",
"status": 400,
"detail": "paymentCancellationReason must not be null"
}
Invalid cancellation Reason
Invalid Cancellation Reason Enum
Occurs when the cancellation reason is not one of the allowed enum values: DUPLICATE, FRAUDULENT, REQUESTED_BY_CUSTOMER, ABANDONED.
Sample Error Response:
{
"title": "INVALID_REQUEST",
"status": 400,
"detail": "Failed to read HTTP message Please review API specs https://docs.healthsafepay.com/api-reference/"
}
Invalid Payment Id
Invalid Payment Id
Occurs when the payment is already completed or invalid.
Sample Error Response:
{
"title": "INVALID_REQUEST",
"status": 400,
"detail": "Invalid Payment, Payment Id: [12345], Payment Status: [COMPLETED]"
}
Invalid Payment Id Format
Invalid Payment Id Format
Occurs when the payment id is not found or is malformed.
Sample Error Response:
{
"title": "INVALID_REQUEST",
"status": 400,
"detail": "Invalid payment id"
}