Перейти к основному содержимому

Cancel Payment

Cancel a previously completed payment. A new payment record with transaction type CANCEL is created referencing the original payment.

POST/api/payment/{paymentId}/cancel

Path Parameters

ParameterTypeDescription
paymentIdstringUUID of the original payment to cancel.

Request Body

No request body is required.

Response

Returns an ApiPaymentResponse for the newly created cancel transaction. Check status field — SUCCESS means the cancellation was accepted.

FieldTypeDescription
paymentIdstringUnique identifier for the cancel transaction (UUID).
parentPaymentIdstringUUID of the original cancelled payment.
orderIdstringClient's tracking number for the order.
amountnumberTransaction amount.
installmentCountnumberNumber of installments.
currencystringCurrency code.
merchantCommissionnumberCommission charged to the merchant.
statusstringPayment status (e.g., SUCCESS, FAILED).
transactionTypestringTransaction type (CANCEL).
paymentDatestringDate and time (ISO format, e.g., 2023-05-01T14:30:00Z).
cardHolderNamestringName of the card holder.
panstringMasked Primary Account Number (e.g., 411111******1111).
domIntstringDomestic or International transaction (DOM/INT).
cardSchemestringCard scheme (e.g., VISA, MASTERCARD).
cardTypestringType of card (e.g., CREDIT, DEBIT).
loyaltyCodestringLoyalty program code (if applicable).
externalTransactionIdstringTransaction ID from the payment provider.
authCodestringAuthorization code from the payment provider.
resultCodestringResult code from the payment provider.
resultMessagestringResult message from the payment provider.
customerIdstringUnique identifier for the customer (if provided).

Important Notes

Same-day transactions only

Only same-day transactions can be cancelled. Transactions from previous days cannot be cancelled — use the Refund endpoint instead.

  • Only payments in SUCCESS status can be cancelled.
  • The cancel transaction will have the same amount and currency as the original payment.
  • The response includes a parentPaymentId field referencing the original payment.
  • If webhook is configured, a webhook notification will be sent upon cancellation.

Example

const cancelPayment = async (paymentId) => {
const response = await fetch(`https://api.example.com/api/payment/${paymentId}/cancel`, {
method: 'POST',
headers: {
'X-API-KEY': 'your_api_key_here',
'X-API-SECRET': 'your_api_secret_here'
}
});

if (!response.ok) {
const error = await response.json();
throw new Error(error.message);
}

const result = await response.json();
if (result.status === 'SUCCESS') {
console.log('Payment cancelled successfully');
}
return result;
};