PlexySDK DOCS

Cancel Payments

Learn how to cancel authorized payments and release reserved funds

Cancel Payments

Cancellation releases an authorization without collecting funds. Use this when you no longer need to complete a payment that has been authorized but not yet captured.

When to Cancel

Cancel a payment when:

  • Customer changes their mind before you ship or fulfill
  • Order cannot be fulfilled due to inventory or other issues
  • Fraud detected during manual review
  • Duplicate authorization was created by mistake
  • Payment method changed by customer to a different option

Cancellation is only possible for payments in the authorized state. Once a payment is captured, use reversal (before settlement) or refund (after settlement) instead.

API Endpoint

POST https://api.plexypay.com/v2/payments/{payment_id}/cancels

Cancelling a Payment

Full Cancellation

Cancel the entire authorized amount:

curl -X POST https://api.plexypay.com/v2/payments/pay_1234567890/cancels \
  -H "x-api-key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "merchant_id": "merchant_abc123"
  }'

Request Parameters

ParameterTypeRequiredDescription
merchant_idstringYesYour merchant identifier
referencestringNoYour internal reference for this cancellation
idempotency_keystringNoUnique key to prevent duplicate cancellations

Response

{
  "payment_id": "pay_1234567890",
  "cancel_id": "cnl_0987654321",
  "status": "cancelled",
  "merchant_id": "merchant_abc123",
  "cancelled_at": "2026-03-25T10:30:00Z",
  "original_amount": {
    "value": 10000,
    "currency": "KZT"
  }
}

Partial Cancellation

Some payment methods support partial cancellation, allowing you to reduce the authorized amount without fully cancelling.

Partial cancellation support varies by payment method and card scheme. Check the capabilities.partial_cancel_allowed field on the payment object.

Checking Partial Cancel Support

Retrieve the payment to check whether partial cancellation is supported before submitting a partial cancel request:

curl -X GET https://api.plexypay.com/v2/payments/pay_1234567890 \
  -H "x-api-key: YOUR_API_KEY"

Check the capabilities.partial_cancel_allowed field in the response. If true, proceed with a partial cancellation request.

Partial Cancellation Request

curl -X POST https://api.plexypay.com/v2/payments/pay_1234567890/cancels \
  -H "x-api-key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "amount": {
      "value": 3000,
      "currency": "KZT"
    },
    "merchant_id": "merchant_abc123"
  }'

Partial Cancellation Response

{
  "payment_id": "pay_1234567890",
  "cancel_id": "cnl_0987654321",
  "status": "partially_cancelled",
  "merchant_id": "merchant_abc123",
  "cancelled_at": "2026-03-25T10:30:00Z",
  "cancelled_amount": {
    "value": 3000,
    "currency": "KZT"
  },
  "remaining_authorization": {
    "value": 7000,
    "currency": "KZT"
  }
}

Webhook Events

CANCEL

Sent when a cancellation is successfully processed.

{
  "event_type": "CANCEL",
  "event_id": "evt_abc123",
  "created_at": "2026-03-25T10:30:00Z",
  "data": {
    "payment_id": "pay_1234567890",
    "cancel_id": "cnl_0987654321",
    "merchant_id": "merchant_abc123",
    "status": "cancelled",
    "cancelled_amount": {
      "value": 10000,
      "currency": "KZT"
    },
    "cancelled_at": "2026-03-25T10:30:00Z"
  }
}

CANCEL_FAILED

Sent when a cancellation attempt fails.

{
  "event_type": "CANCEL_FAILED",
  "event_id": "evt_def456",
  "created_at": "2026-03-25T10:30:00Z",
  "data": {
    "payment_id": "pay_1234567890",
    "merchant_id": "merchant_abc123",
    "error": {
      "code": "INVALID_PAYMENT_STATE",
      "message": "Payment has already been captured and cannot be cancelled"
    }
  }
}

Error Handling

Error CodeDescriptionResolution
PAYMENT_NOT_FOUNDPayment ID does not existVerify the payment_id
INVALID_PAYMENT_STATEPayment not in authorized stateUse refund if captured
AUTHORIZATION_EXPIREDAuthorization already expiredNo action needed, funds already released
PARTIAL_CANCEL_NOT_SUPPORTEDPayment method doesn't support partial cancelCancel full amount or proceed to capture
AMOUNT_EXCEEDS_AUTHORIZATIONCancel amount exceeds remaining authorizationReduce the cancel amount

Example Error Handling

If cancellation returns INVALID_PAYMENT_STATE, retrieve the payment to check its current status:

curl -X GET https://api.plexypay.com/v2/payments/pay_1234567890 \
  -H "x-api-key: YOUR_API_KEY"

If the payment status is captured, issue a refund instead:

curl -X POST https://api.plexypay.com/v2/payments/pay_1234567890/refunds \
  -H "x-api-key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "merchant_id": "merchant_abc123",
    "reason": "CUSTOMER_REQUEST"
  }'

If the error is AUTHORIZATION_EXPIRED, no action is needed — the funds have already been released.

Cancel vs Other Modifications

ScenarioAction
Payment authorized, not capturedCancel
Payment captured, before settlementReversal
Payment captured, after settlementRefund

Best Practices

Don't leave unused authorizations open. Cancel as soon as you know you won't fulfill the order.

Prevent duplicate cancellations from retry attempts.

Sync your order management system when cancellation succeeds.

Inform customers that the hold on their funds has been released.

Listen for CANCEL and CANCEL_FAILED webhooks to ensure your systems stay in sync.

Automatic Cancellation

Authorizations that are not captured within their validity period are automatically cancelled by the card network. You'll receive a webhook notification:

{
  "event_type": "AUTHORIZATION_EXPIRED",
  "event_id": "evt_xyz789",
  "created_at": "2026-03-25T10:30:00Z",
  "data": {
    "payment_id": "pay_1234567890",
    "merchant_id": "merchant_abc123",
    "expired_at": "2026-03-25T10:30:00Z",
    "original_amount": {
      "value": 10000,
      "currency": "KZT"
    }
  }
}

Even though expired authorizations are automatically released, it's best practice to explicitly cancel payments you don't intend to capture. This releases the hold on the customer's funds immediately rather than waiting for expiry.

Viewing Cancellations in Plexy Dashboard

View and manage cancellations in the Plexy Dashboard:

  1. Navigate to Payments
  2. Filter by Status: Cancelled
  3. Click on a payment to view cancellation details

The dashboard shows:

  • Original authorization amount
  • Cancellation timestamp
  • Who initiated the cancellation (API, Dashboard, or automatic)
  • Any partial cancellation history

On this page