Skip to main content
Version: v1

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 ReferenceError TitleHTTP StatusDetail MessageScenarioResolution
Missing Cancellation ReasonINVALID_REQUEST400 BAD REQUESTpaymentCancellationReason must not be nullReason not providedInclude a valid cancellation reason in the request
Invalid Cancellation Reason EnumINVALID_REQUEST400 BAD REQUESTFailed to read HTTP message Please review API specs https://docs.healthsafepay.com/api-reference/Reason is not one of: DUPLICATE, FRAUDULENT, REQUESTED_BY_CUSTOMER, ABANDONEDUse only allowed values: DUPLICATE, FRAUDULENT, REQUESTED_BY_CUSTOMER, or ABANDONED
Invalid Payment IdINVALID_REQUEST400 BAD REQUESTInvalid Payment, Payment Id: [${paymentId}], Payment Status: [COMPLETED]Payment is already completed or invalidEnsure payment is in a cancellable state (Only AUTHORIZED and ACCEPTED payments can be cancelled)
Invalid Payment Id FormatINVALID_REQUEST400 BAD REQUESTInvalid payment idPayment id is not found or is malformedProvide 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"
}