Cancel payment
POST/v1/payments/{paymentId}/cancel
Requires a bearer token.
In this mock: Allowed while the payment is created, started or capturable. Otherwise 409 P0502.
Path parameters
paymentId required |
string |
The payment_id of the payment you’re cancelling. |
Example request
curl -X POST "https://publicapi.payments.platform-engineering.com/v1/payments/{paymentId}/cancel" \
-H "Authorization: Bearer $TOKEN"
Responses
204: No Content
400: Cancellation of payment failed
code |
string |
An API error codethat explains why the payment failed.<br><br>code only appears if the payment failed. |
description |
string |
Additional details about the error. |
field |
string |
The parameter in your request that's causing the error. |
header |
string |
The header in your request that's causing the error. |
{
"code": "P0102",
"description": "Invalid attribute value: amount. Must be less than or equal to 10000000",
"field": "amount",
"header": "Idempotency-Key"
}
401: Your API key is missing or invalid. Read more about [authenticating GOV.UK Pay API requests](https://docs.payments.service.gov.uk/api_reference/#authentication)
404: Not found
code |
string |
An API error codethat explains why the payment failed.<br><br>code only appears if the payment failed. |
description |
string |
Additional details about the error. |
field |
string |
The parameter in your request that's causing the error. |
header |
string |
The header in your request that's causing the error. |
{
"code": "P0102",
"description": "Invalid attribute value: amount. Must be less than or equal to 10000000",
"field": "amount",
"header": "Idempotency-Key"
}
409: Conflict
code |
string |
An API error codethat explains why the payment failed.<br><br>code only appears if the payment failed. |
description |
string |
Additional details about the error. |
field |
string |
The parameter in your request that's causing the error. |
header |
string |
The header in your request that's causing the error. |
{
"code": "P0102",
"description": "Invalid attribute value: amount. Must be less than or equal to 10000000",
"field": "amount",
"header": "Idempotency-Key"
}
429: Too many requests
{
"code": "P0900",
"description": "Too many requests"
}
500: Downstream system error
code |
string |
An API error codethat explains why the payment failed.<br><br>code only appears if the payment failed. |
description |
string |
Additional details about the error. |
field |
string |
The parameter in your request that's causing the error. |
header |
string |
The header in your request that's causing the error. |
{
"code": "P0102",
"description": "Invalid attribute value: amount. Must be less than or equal to 10000000",
"field": "amount",
"header": "Idempotency-Key"
}