Singapay Home Page
Logo Icon
  1. Card (Money In)
  2. Cancel Transaction

Information

MethodPathFormatAuthentication
PATCH/api/v2.0/card/{account_id}/cancel/{id}jsonOAuth 2.0 with Access Token

Overview

The Cancel endpoint performs either a void or refund depending on the current transaction status:

  • Void: For transactions with status registered, pending, or processing (payment not yet captured).
  • Refund: For transactions with status success (payment already captured).

Both void and refund return status: "success". Use cancel_type to distinguish between them.


Request Details

Headers Structure

FieldValueTypeMandatoryDescriptionExample
AuthorizationBearer {access_token}AlphanumericMandatoryBearer token obtained from the access token endpoint.Bearer eyJ0eXAiOiJKV1{…}

Path Parameters

ParameterTypeMandatoryDescriptionExample
account_idStringRequiredMerchant Account ULID01K5G4FZZ18DMK0M5QTR8Y9QY9
idStringRequiredTransaction ID9901JAB3CD4E5F6G7H8J9K0M1N2

Request Example

PATCH /api/v2.0/card/01K5G4FZZ18DMK0M5QTR8Y9QY9/cancel/9901JAB3CD4E5F6G7H8J9K0M1N2

cURL Example:

curl -X PATCH "https://your-domain.com/api/v2.0/card/01K5G4FZZ18DMK0M5QTR8Y9QY9/cancel/9901JAB3CD4E5F6G7H8J9K0M1N2" \
  -H "X-PARTNER-ID: {api_key}" \
  -H "Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGc..."

Response Details

Response Structure

FieldTypeMandatoryDescriptionExample
response_codeStringMandatoryResponse codeSP000
response_messageStringMandatoryHuman-readable response messageSuccessfully
dataObjectMandatoryResponse data-
> transaction_idStringMandatoryTransaction ID9901JAB3CD4E5F6G7H8J9K0M1N2
> reference_noStringMandatoryMerchant order reference numberORD-20260225-001
> statusStringMandatoryAlways success for both void and refundsuccess
> cancel_typeStringMandatoryType of cancellation performed (void or refund)void

Response Example — Void (HTTP 200)

When voiding a transaction that has not been captured:

Success: Transaction voided.

{
    "response_code": "SP000",
    "response_message": "Successfully",
    "data": {
        "transaction_id": "9901JAB3CD4E5F6G7H8J9K0M1N2",
        "reference_no": "ORD-20260225-001",
        "status": "success",
        "cancel_type": "void"
    }
}

Response Example — Refund (HTTP 200)

When refunding a captured/successful transaction:

Success: Transaction refunded.

{
    "response_code": "SP000",
    "response_message": "Successfully",
    "data": {
        "transaction_id": "9901JAB3CD4E5F6G7H8J9K0M1N2",
        "reference_no": "ORD-20260225-001",
        "status": "success",
        "cancel_type": "refund"
    }
}

Error Response (HTTP 400)

Error: Cannot cancel the transaction.

{
    "response_code": "SP012",
    "response_message": "Cannot cancel: transaction status is success",
    "data": {
        "transaction_id": "9901JAB3CD4E5F6G7H8J9K0M1N2"
    }
}

Cancellable Statuses

Current StatusCancel TypeResulting Status
registeredVoidsuccess
pendingVoidsuccess
processingVoidsuccess
successRefundsuccess

Important Notes

  • Status Field: Both void and refund return status: "success". Use the cancel_type field to distinguish whether the operation was a void or refund.
  • Void vs Refund: The system automatically determines whether to void or refund based on the current transaction status. Void is used before capture, refund after.
  • Non-cancellable statuses: Transactions that are already cancelled, refunded, or failed cannot be cancelled again.
  • Irreversible: Once a transaction is voided or refunded, the action cannot be undone via the API.
  • Transaction ID: Use the transaction_id returned from the payment response as the {id} path parameter.