Cancel or Refund a Payment with Transaction

Do not execute a refund while another is in progress. Wait for the current operation to complete before starting a new one.

This service allows you to cancel or refund an existing payment. Our system will identify if a cancellation or a refund is necessary based on the transaction status related to the transaction_id provided on the request. This is for certain scenarios where you want to be more specific about the actions taken on the payments lifecycle. This service performs the following functions based on the status of the transaction:

  • Cancels the payment if it has not been captured.
  • Refunds the payment if it has been captured.

Refunds

If you fill out the amount field, the refund will be partial. Otherwise, it will create a complete refund. The funds will be refunded to the payment method that was originally charged.

Note that this request requires an X-Idempotency-Key. Check the Authentication page for more information.

POST/payments/{payment_id}/transactions/{transaction_id}/cancel-or-refund

Path Parameters

payment_idstringrequired

The unique identifier of the payment (UUID, 36 chars).

transaction_idstringrequired

The unique identifier of the transaction (UUID, 36 chars).

Body application/json

descriptionstring

Description of the cancellation or refund. (MAX 255; MIN 3).

reason"DUPLICATE" | "FRAUDULENT" | "REQUESTED_BY_CUSTOMER" | "REVERSE"

Indicating the reason for the cancellation or refund. If set, possible values are DUPLICATE, FRAUDULENT, REQUESTED_BY_CUSTOMER, and REVERSE. Use REVERSE to request an automatic reverse of the recipient funds when a recipient is involved in the transaction.

merchant_referencestring

Identification of the payment transaction defined by the merchant. If no merchant_reference is defined, the merchant_order_id of the payment will be associated to the transaction. (MAX 255; MIN 3).

amountobject

Specifies the amount object for refund.

Show amount properties
currencystring

The currency used to make the payment. For a full list of currency codes, see Country reference (MAX 3; MIN 3; ISO 4217).

valuenumber<float>

The payment amount (multiple of 0.0001).

split_marketplaceobject[]

Split marketplace array of objects

Show split_marketplace properties
recipient_idstring

The unique identifier of the recipient in the WHITELABEL system.
You must provide the recipient_id (WHITELABEL-generated) or the provider_recipient_id (external provider’s ID) when creating a payment.

provider_recipient_idstring

The recipient ID provided by the external payment provider, if applicable.
You must provide the provider_recipient_id or the recipient_id (WHITELABEL-generated) when creating a payment.

descriptionstring

Description for the split. (MAX 255; MIN 3).

type"PURCHASE" | "PAYMENTFEE" | "VAT" | "COMMISSION" | "MARKETPLACE" | "SHIPPING"required

The type of split. recipient_id is mandatory for PURCHASE and MARKETPLACE.

merchant_referencestring

Optional unique identifier for the split transaction (MAX 255; MIN 3).

recipient_type"MEAL" | "FOOD" | "MULTI_BENEFITS" | "FLEET"

The type of recipient for the provider.

amountobject

Defines the amount of the split.

Show amount properties
valuenumber<float>required

The split amount (multiple of 0.0001).

currencystringrequired

The currency used to make the payment. For a full list of currency codes, see Country reference (MAX 3; MIN 3; ISO 4217).

liabilityobject

Optional information regarding the recipient’s liability for fees and chargebacks.

Show liability properties
processing_fee"MERCHANT" | "RECIPIENT" | "SHARED"

Indicates who will be charged the transaction fee.

chargebacksboolean

The recipient is responsible in case of a chargeback.

simplified_modeboolean

Indicates if we should try to refund a payment after an error/declined on the first try. It is false by default. For more information, access the guide.

response_additional_dataobject

Specifies additional data for required the transaction response

Show response_additional_data properties
receiptboolean

Indicates if a receipt is necessary for the transaction response

receipt_language"ES" | "EN" | "PT"

Indicates the language of the receipt to be generated

customer_payerobject

Specifies customer object for payments.

Show customer_payer properties
first_namestring

The customer’s first name (MAX 255; MIN 3).

last_namestring

The customer’s last name (MAX 255; MIN 3).

gender"M" | "F" | "NB" | "NA" | "NK" | "U"

The customer’s gender (MAX 2; MIN 1).
- M=Male
- F=Female
- NB=Non Binary
- NA=Not applicable
- NK=Not Known
- U=Undefined.

date_of_birthstring

The customer’s date of birth in the YYYY-MM-DD format (Length: 10).

emailstring

The customer’s e-mail (MAX 255; MIN 3).

nationalitystring

The customer’s nationality (MAX 2; MIN 2; ISO 3166-1).

documentobject

Specifies the customer’s document object, including its number and type.

Show document properties
document_numberstring

Document number for customer (MAX 40; MIN 3)

document_type"DNI" | "CI" | "LC" | "LE" | "CUIT" | "CUIL" | "PAS" | "CPF" | "RG" | "CNH" | "CNPJ" | "RUT" | "RUN" | "CC" | "CE" | "NIT" | "DUI" | "PIC" | "DPI" | "IFR" | "INE" | "CP" | "RFC" | "CURP" | "CIP" | "CIC" | "CUI" | "RUC"

The customer’s document type (MAX 6, MIN 2). Access Document Type List for more details.

phoneobject

Specifies the customer’s phone object.

Show phone properties
country_codestring

The country code of the customer’s phone (MAX 3; MIN 1).

numberstring

The customer’s phone number, without the country code (MAX 32; MIN 1).

billing_addressobject

Specifies the customer’s billing address object.

Show billing_address properties
address_line_1string

The primary billing address line of the customer (MAX 255; MIN 3).

address_line_2string

The secondary billing address line of the customer (MAX 255; MIN 3).

citystring

The city considered for the billing address (MAX 255; MIN 3).

country"AR" | "BO" | "BR" | "CL" | "CO" | "CR" | "EC" | "SV" | "GT" | "HN" | "MX" | "NI" | "PA" | "PY" | "PE" | "US" | "UY"

The country considered for the billing address (MAX 2; MIN 2; ISO 3166-1).

statestring

The state considered for the billing address (MAX 255; MIN 3).

zip_codestring

The zipcode considered for the billing address (MAX 10; MIN 5).

shipping_addressobject

Specifies the customer’s shipping address object.

Show shipping_address properties
address_line_1string

The primary shipping address line of the customer (MAX 255; MIN 3).

address_line_2string

The secondary shipping address line of the customer (MAX 255; MIN 3).

citystring

The city considered for the shipping address (MAX 255; MIN 3).

country"AR" | "BO" | "BR" | "CL" | "CO" | "CR" | "EC" | "SV" | "GT" | "HN" | "MX" | "NI" | "PA" | "PY" | "PE" | "US" | "UY"

The country considered for the shipping address (MAX 2; MIN 2; ISO 3166-1).

statestring

The state considered for the shipping address (MAX 255; MIN 3).

zip_codestring

The zipcode considered for the shipping address (MAX 10; MIN 5).

payment_methodobject

Specifies payment method object for payments.

Show payment_method properties
detailobject

Specifies the payment method detail object.

Show detail properties
bank_transferobject

Specifies bank transfer payment method details.

Show bank_transfer properties
account_type"CHECKINGS" | "SAVINGS"

Type of bank account (MAX 255; MIN 3)

bank_namestring

Name of the bank (MAX 255; MIN 3)

bank_idstring

ID of the bank (MAX 255; MIN 3)

beneficiary_namestring

Name of the account holder (MAX 255; MIN 3)

bank_accountstring

Bank account number (MAX 255; MIN 3)

beneficiary_document_typestring

Document type of the account holder (MAX 255; MIN 3)

beneficiary_documentstring

Document number of the account holder (MAX 255; MIN 3)

referencestring

Reference code for the user (MAX 255; MIN 1)

bank_account_mask_numberstring

Masked bank account number associated with the bank transfer (for example, ****6789). This is account data, not mandate data.

mandateobject

Direct debit mandate details, for bank transfer methods that operate with mandates (for example, ACH, SEPA, BACS, PAD).

Show mandate properties
idstring

Mandate identifier, as provided by the payment provider.

infostring

Free-text mandate information.

received_statusstring

Provider status indicating whether the mandate was received. Forwarded as provided by the payment provider.

existing_statusstring

Provider status of the existing mandate. Forwarded as provided by the payment provider.

created_atstring<date-time>

Date and time when the mandate was created (ISO 8601).

updated_atstring<date-time>

Date and time when the mandate was last updated (ISO 8601).

Response

201

idstring
typestring
statusstring
categorystring
amountobject
Show amount properties
capturedinteger
currencystring
refundedinteger
valueinteger
merchant_referencestring
created_atstring
updated_atstring
provider_dataobject
Show provider_data properties
idstring
transaction_idstring
account_idstring
statusstring
status_detailstring
response_messageany
response_codestring
iso8583_response_codestring
iso8583_response_messagestring
raw_requestobject

Obfuscated copy of the request WHITELABEL sent to the provider. Only returned for allowlisted organizations.

raw_responseany
third_party_transaction_idany
third_party_account_idany
connection_dataobject
Show connection_data properties
idstring
namestring
response_codestring
response_messagestring
paymentobject
Show payment properties
idstring
account_idstring
descriptionstring
countrystring
statusstring
sub_statusstring
merchant_order_idstring
created_atstring
updated_atstring
amountobject
Show amount properties
capturedinteger
currencystring
refundedinteger
valueinteger
additional_dataobject
Show additional_data properties
airlineobject
Show airline properties
pnrstring
legsobject[]
Show legs properties
departure_airportstring
departure_datetimestring
departure_airport_timezonestring
arrival_airportstring
arrival_airport_timezonestring
arrival_datetimestring
carrier_codestring
carrier_namestring
flight_numberstring
fare_basis_codestring
fare_class_codestring
base_fareinteger
base_fare_currencystring
stopover_codestring
passengersobject[]
Show passengers properties
first_namestring
last_namestring
middle_namestring
typestring
date_of_birthstring
nationalitystring
documentobject
Show document properties
document_typestring
document_numberstring
countrystring
loyalty_numberstring
loyalty_tierstring
emailany
phoneany
ticketany
ticketsobject[]
Show tickets properties
ticket_numberstring
e_ticketboolean
restrictedboolean
total_fare_amountinteger
total_tax_amountinteger
total_fee_amountinteger
issueany
orderobject
Show order properties
fee_amountinteger
shipping_amountinteger
tip_amountany
itemsobject[]
Show items properties
idstring
namestring
quantityinteger
unit_amountinteger
categorystring
brandstring
sku_codestring
manufacture_part_numberstring
seller_detailsany

400

codestring
messagesstring[]

401

codestring
messagesstring[]

403

codestring
messagesstring[]
Request
curl -X POST "https://api-sandbox.whitelabel.com/v1/payments/<payment_id>/transactions/<transaction_id>/cancel-or-refund" \
  -H "Content-Type: application/json" \
  -H "public-api-key: <public-api-key>" \
  -H "private-secret-key: <private-secret-key>" \
  -H "X-Idempotency-Key: <X-Idempotency-Key>" \
  -d '{
  "description": "string",
  "reason": "DUPLICATE",
  "merchant_reference": "string",
  "amount": {
    "currency": "string",
    "value": 0
  },
  "split_marketplace": [
    {
      "recipient_id": "string",
      "provider_recipient_id": "string",
      "description": "string",
      "type": "PURCHASE",
      "merchant_reference": "string",
      "recipient_type": "MEAL",
      "amount": {
        "value": 0,
        "currency": "string"
      },
      "liability": {
        "processing_fee": "MERCHANT",
        "chargebacks": true
      }
    }
  ],
  "simplified_mode": false,
  "response_additional_data": {
    "receipt": true,
    "receipt_language": "ES"
  },
  "customer_payer": {
    "first_name": "string",
    "last_name": "string",
    "gender": "M",
    "date_of_birth": "string",
    "email": "string",
    "nationality": "string",
    "document": {
      "document_number": "string",
      "document_type": "DNI"
    },
    "phone": {
      "country_code": "string",
      "number": "string"
    },
    "billing_address": {
      "address_line_1": "string",
      "address_line_2": "string",
      "city": "string",
      "country": "AR",
      "state": "string",
      "zip_code": "string"
    },
    "shipping_address": {
      "address_line_1": "string",
      "address_line_2": "string",
      "city": "string",
      "country": "AR",
      "state": "string",
      "zip_code": "string"
    }
  },
  "payment_method": {
    "detail": {
      "bank_transfer": {
        "account_type": "CHECKINGS",
        "bank_name": "string",
        "bank_id": "string",
        "beneficiary_name": "string",
        "bank_account": "string",
        "beneficiary_document_type": "string",
        "beneficiary_document": "string",
        "reference": "string",
        "bank_account_mask_number": "string",
        "mandate": {
          "id": "string",
          "info": "string",
          "received_status": "string",
          "existing_status": "string",
          "created_at": "1970-01-01T00:00:00.000Z",
          "updated_at": "1970-01-01T00:00:00.000Z"
        }
      }
    }
  }
}'
Response
{
  "id": "7fd485f3-bd72-45eb-a3fb-774daa3d79b6",
  "type": "REFUND",
  "status": "REFUNDED",
  "category": "CARD",
  "amount": {
    "captured": 0,
    "currency": "COP",
    "refunded": 0,
    "value": 30000
  },
  "merchant_reference": "0000023",
  "created_at": "2024-06-06T14:06:06.284443Z",
  "updated_at": "2024-06-06T14:06:37.984065Z",
  "provider_data": {
    "id": "YUNO_TEST_PAYMENT_GW",
    "transaction_id": "",
    "account_id": "493e9374-510a-4201-9e09-de669d75f256",
    "status": "",
    "status_detail": "",
    "response_message": null,
    "response_code": "SUCCEEDED",
    "iso8583_response_code": "00",
    "iso8583_response_message": "Approved or completed successfully",
    "raw_request": {},
    "raw_response": null,
    "third_party_transaction_id": null,
    "third_party_account_id": null
  },
  "connection_data": {
    "id": "58cc35f4-faef-4107-8e09-d18d60121d38",
    "name": "Connection name"
  },
  "response_code": "SUCCEEDED",
  "response_message": "Transaction successful",
  "payment": {
    "id": "c3583c27-0478-4e02-8827-4d8f2121c670",
    "account_id": "",
    "description": "Test",
    "country": "CO",
    "status": "REFUNDED",
    "sub_status": "REFUNDED",
    "merchant_order_id": "0000023",
    "created_at": "2024-06-06T14:06:06.284443Z",
    "updated_at": "2024-06-06T14:06:06.284443Z",
    "amount": {
      "captured": 0,
      "currency": "COP",
      "refunded": 30000,
      "value": 30000
    },
    "additional_data": {
      "airline": {
        "pnr": "1P-2UUGJW",
        "legs": [
          {
            "departure_airport": "EZE",
            "departure_datetime": "2014-05-12 13:05:00",
            "departure_airport_timezone": "-03:00",
            "arrival_airport": "AMS",
            "arrival_airport_timezone": "+00:00",
            "arrival_datetime": "",
            "carrier_code": "KL",
            "carrier_name": "KLM Royal Dutch Airlines",
            "flight_number": "842",
            "fare_basis_code": "HL7LNR",
            "fare_class_code": "FR",
            "base_fare": 200,
            "base_fare_currency": "BRL",
            "stopover_code": "s"
          }
        ],
        "passengers": [
          {
            "first_name": "string",
            "last_name": "string",
            "middle_name": "string",
            "type": "s",
            "date_of_birth": "stringstri",
            "nationality": "st",
            "document": {
              "document_type": "CPF",
              "document_number": "351.040.753-97"
            },
            "country": "st",
            "loyalty_number": "string",
            "loyalty_tier": "strin",
            "email": null,
            "phone": null
          }
        ],
        "ticket": null,
        "tickets": [
          {
            "ticket_number": "123456",
            "e_ticket": false,
            "restricted": false,
            "total_fare_amount": 80,
            "total_tax_amount": 22,
            "total_fee_amount": 14,
            "issue": null
          }
        ]
      },
      "order": {
        "fee_amount": 100,
        "shipping_amount": 100,
        "tip_amount": null,
        "items": [
          {
            "id": "123AD",
            "name": "Skirt",
            "quantity": 1,
            "unit_amount": 29800,
            "category": "Clothes",
            "brand": "XYZ",
            "sku_code": "8765432109",
            "manufacture_part_number": "XYZ123456"
          }
        ]
      },
      "seller_details": null
    }
  }
}