Cancel payment

POST/v1/payments/{paymentId}/cancel

You can use this endpoint to cancel an unfinished payment.

Requires a bearer token.

In this mock: Allowed while the payment is created, started or capturable. Otherwise 409 P0502.

Path parameters

NameTypeDescription
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

NameTypeDescription
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

NameTypeDescription
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

NameTypeDescription
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

NameTypeDescription
code string A GOV.UK Pay API error code. You can find out more about this code in our documentation.
description string Additional details about the error
{
  "code": "P0900",
  "description": "Too many requests"
}

500: Downstream system error

NameTypeDescription
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"
}