# Reversals via API

In cases where the outcome of a transaction is unclear due to a disconnection or timeout, you can perform a reversal. This allows you to attempt another transaction and avoid duplicating the amount authorized against the cardholder.&#x20;

**Cases where initiating a reversal is advised:**&#x20;

* You receive a 504 HTTP Gateway timeout response.&#x20;
* You don’t receive a response within an expected window of time and wish to cancel the request.&#x20;

## Availability <a href="#availability" id="availability"></a>

Reversal is available to all merchants.

## How it works <a href="#how-it-works" id="how-it-works"></a>

### Step 1: Include the reversal ID in your initial payment request <a href="#step-1__003a-include-the-reversal-id-in-your-initial-payment-request" id="step-1__003a-include-the-reversal-id-in-your-initial-payment-request"></a>

To perform a reversal at a later stage, the initial payment request **must** include a unique identifier generated by you, so that Verifone can identify the payment you wish to reverse later.&#x20;

Verifone accepts this unique identifier in a [UUID](https://www.rfc-editor.org/rfc/rfc4122.html) format, as a header in your payment request with the key name: **x-vfi-api-idempotencykey**&#x20;

#### Example

**API Reference**: <https://verifone.cloud/api-catalog/verifone-ecommerce-api#tag/Ecom-Payments/operation/saleTransaction> &#x20;

**Request Method:** POST&#x20;

**URL:** <https://cst.test-gsc.vfims.com/oidc/api/v2/transactions/card> &#x20;

**Header**: x-vfi-api-idempotencykey: a38b85b2-b835-4c37-adec-4b91c3ed0dfb&#x20;

#### Request body

```javascript
{ 
    
        "entity_id": "{{entity_id}}", 
    
        "currency_code": "{{currency}}", 
    
        "amount": 1000, 
    
        "merchant_reference": "Payment 123", 
    
        "payment_provider_contract": "{{ppc}}", 
    
        "stored_credential": { 
    
            "stored_credential_type": "CHARGE", 
    
            "reference": "e03c516d-3ef2-4646-8533-de23575be882", 
    
            "processing_model_details": { 
    
                "processing_model": "UNSCHEDULED_CREDENTIAL_ON_FILE" 
    
            } 
    
        } 
    
    } 
```

### Step 2: Perform a Reversal  <a href="#step-2__003a-perform-a-reversal__00a0" id="step-2__003a-perform-a-reversal__00a0"></a>

Now, in case you were not able to retrieve the result from the transaction in step one, the x-vfi-api-idempotencykey can be used again to reverse it.&#x20;

#### Example

**API Reference:** <https://verifone.cloud/api-catalog/verifone-ecommerce-api#tag/Payment-Modifications/operation/reverseTransaction> &#x20;

**Request Method:** POST

**URL**: <https://cst.test-gsc.vfims.com/oidc/api/v2/transactions/reverse> &#x20;

**Header**:  x-vfi-api-idempotencykey: a38b85b2-b835-4c37-adec-4b91c3ed0dfb&#x20;

#### Body

N/A&#x20;

#### Response

```javascript
{ 

"id": "6c6564dd-1b53-4c60-82f8-3c0cb8cc36aa", 

"payment_provider_contract": "{{ppc}}", 

"amount": 1000, 

"merchant_reference": "Payment 123", 

"status": "AUTHORIZED", 

"status_reason": "Approved", 

"arn": "SIMULATORN54NC6B2IGGCRH71KJDY", 

"cvv_result": "0", 

"details": { 

"auto_capture": false 

}, 

"reason_code": "0000", 

"shopper_interaction": "ECOMMERCE", 

"stan": "123456", 

"threed_authentication": { 

"reversal_status": "NONE", 

"additional_data": { 

"initiator_trace_id": "123456" 

}, 

"balance_amount": 0 

} 
```

From the transaction response, you can see that the reversal attempt was AUTHORISED, the initial payment has now been successfully canceled.&#x20;

## Additional Steps  <a href="#additional-steps__00a0" id="additional-steps__00a0"></a>

### Query the transaction result  <a href="#query-the-transaction-result__00a0" id="query-the-transaction-result__00a0"></a>

Use the **Read Transaction** endpoint to check the initial transaction ID and observe the reversal being applied. \
&#x20;\
**API Reference:** <https://verifone.cloud/api-catalog/verifone-ecommerce-api#tag/Transaction/operation/readTransaction>&#x20;

**Request Method:** GET

**URL**: [https://cst.test-gsc.vfims.com/oidc/api/v2/transaction/{id}](https://cst.test-gsc.vfims.com/oidc/api/v2/transaction/%7bid%7d) &#x20;

**Header**: &#x20;

N/A&#x20;

**Body**:&#x20;

N/A&#x20;

**Response**:

```javascript
{ 

…….. 

"merchant_reference": "Payment 123", 

"payment_product": "CARD", 

"payment_product_type": "VISA", 

"status": "CANCEL AUTHORISED", 

………. 

} 
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.verifone.com/online-payments/api-integration/reversals-via-api.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
