Skip to main content
POST
/
v1
/
payment_intents
/
{id}
/
cancel
Cancel a PaymentIntent
curl --request POST \
  --url https://api.leanrails.com/v1/payment_intents/{id}/cancel \
  --header 'Authorization: Basic <encoded-value>' \
  --header 'Content-Type: application/json' \
  --header 'Idempotency-Key: <idempotency-key>' \
  --data '
{
  "cancellation_reason": "<string>"
}
'
{
  "id": "pi_xxx",
  "object": "payment_intent",
  "amount": 2000,
  "currency": "usd",
  "status": "requires_payment_method",
  "created": 1234567890,
  "livemode": false,
  "amount_received": 2000,
  "capture_method": "automatic",
  "confirmation_method": "automatic",
  "customer": "cus_xxx",
  "payment_method": "pm_xxx",
  "description": "<string>",
  "metadata": {},
  "merchant_id": "mer_xxx",
  "client_secret": "pi_xxx_secret_xxx",
  "last_payment_error": {
    "type": "payment_error",
    "code": "<string>",
    "message": "<string>"
  },
  "charges": {
    "object": "list",
    "data": [
      {}
    ],
    "has_more": true
  },
  "canceled_at": 1234567890,
  "cancellation_reason": "<string>"
}

Authorizations

Authorization
string
header
required

Use your secret API key as the username with an empty password.

Headers

Idempotency-Key
string
required

Unique key to ensure idempotent requests.

Maximum string length: 255
X-API-Version
string

Override the API version for this request.

Path Parameters

id
string
required

Body

application/json
cancellation_reason
string

Reason for cancellation.

Response

The canceled PaymentIntent.

id
string
required
Example:

"pi_xxx"

object
enum<string>
required
Available options:
payment_intent
amount
integer
required
Example:

2000

currency
string
required
Example:

"usd"

status
enum<string>
required
Available options:
requires_payment_method,
requires_confirmation,
requires_action,
processing,
requires_capture,
canceled,
succeeded
created
integer
required

Unix timestamp.

Example:

1234567890

livemode
boolean
required
Example:

false

amount_received
integer
Example:

2000

capture_method
enum<string>
Available options:
automatic,
manual
confirmation_method
enum<string>
Available options:
automatic,
manual
customer
string | null
Example:

"cus_xxx"

payment_method
string | null
Example:

"pm_xxx"

description
string | null
metadata
object

Set of key-value pairs for storing additional information.

merchant_id
string
Example:

"mer_xxx"

client_secret
string
Example:

"pi_xxx_secret_xxx"

last_payment_error
object
charges
object
canceled_at
integer | null

Unix timestamp of cancellation.

Example:

1234567890

cancellation_reason
string | null