---
title: Testing Voids
slug: testing-voids
docTags: 
createdAt: 2024-06-05T14:36:14.881Z
---

:::hint{type="info"}
Voids cannot be performed on pre authorisations that have been collected (partial or full).
:::

## Card Void Scenarios (Positive Flow)

### Important to Consider

- Ensure the **Preauth Transactions** permission is enabled on your API credentials.
- Ensure you have the correc&#x74;**&#x20;receiptId** for the original pre authorisation.
  - This is required for you to process the void.
- Voids cannot be performed on pre authorisations that have expired, or been collected (partial or full).

To simulate voiding a [pre authorised transaction](docId\:gwWUVrKwOnC5YVk6qhMMi):

| **Suggested Test Scenario**                      | **Expected Outcome** | **Tip**                                                                       |
| ------------------------------------------------ | -------------------- | ----------------------------------------------------------------------------- |
| Process a void on the full preAuth amount.<br /> | 200<br />Successful  | Ensure you have the correct **receiptId** for the original pre authorisation. |

***

### Request Parameters

Sandbox endpoint:
`https://api-sandbox.judopay.com/transactions/voids`

HTTP Method: **POST**

**Header Parameters**:

For more information, see [Authentication Methods](docId\:ylKW5coh5NQnfQ3j_Wjk2).

| API-Version:                                   | 6.26<br />For the latest version of the Judopay Transaction API, see [Latest Version](docId\:bcXNM5keOk-nlNrZTafUT).                                                                                                                                                                                                                                                                                                                                                                                                                                         |
| ---------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| Content-Type:                                  | application/json                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             |
| Accept:                                        | application/json                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             |
| **Authorization Method**:<br />TokenSecretAuth | In the Authorization Header:<br />* Supply: **Basic** \{`authstring`}<br />Example:<br />**Basic**`TXpFdPdRSzWmSGk4djhxeTpjBTS4YjQ5OTdkZmO7CTk1YTE0OWEyMDg1MmY3YWYyZWEyZTcwYmQyZGY3O`<br />Replace \{`authstring`} with **base64 encoding** of:<br />* <font color="#6a4ee1">**API Token**</font> (username)
* <font color="#ef5b2e">**Colon**</font>
* **API Secret** (password)<br />Example:<br /><font color="#6a4ee1">**MzPdkQK1mGi8v3ky**</font><font color="#ef5b2e">**:**</font>**y158n4732dfc7595a149a20381f7af2ea2e70gr6df794b8rnwc019cc5f799kk3** |

***

**Body Parameters**:

**Configuration Property Descriptions**

| **Parameter**                                                                            | **Description**                                                                                                                                                                                                              |
| ---------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `receiptId`<br />String&#xD;<br />&#xD;<font color="#ef5b2e">Required</font>             | Judopay's reference for the pre authorisation that is to be voided.                                                                                                                                                          |
| `amount`<br />Decimal<br /><font color="#ef5b2e">Required</font>                         | The amount to void.<br />Format:<br />* Two decimal places<br />For currencies using a different structure please contact Judopay for support.                                                                               |
| `currency`<br />String<br /><font color="#ef5b2e">Required</font>                        | If specified, the currency must match the original pre authorisation.<br />If not specified, the currency of the original pre authorisation will be used.<br />Any ISO 4217 alphabetic currency code:<br />* GBP
* USD
* EUR |
| `yourPaymentReference`<br />String&#xD;<br />&#xD;<font color="#ef5b2e">Required</font> | Your unique reference for this void.<br />Format:<br />* Maximum length 50 characters.<br />**This is not the yourPaymentReference of the original pre authorisation**.                                                      |
| `yourPaymentMetaData`<br />String<br /><font color="#42cbd4">Optional</font><br />       | Key-value map for additional metadata associated with this transaction.<br />Will be stored but not processed or passed to gateways.<br />Do not include sensitive information like card numbers.                            |

:::CodeblockTabs
Void Request Example

```json
{
  "receiptId": "675014982672486400",
  "amount": 10.99,
  "currency": "GBP",
  "yourPaymentMetaData": {
    "internalLocationRef": "Example",
    "internalId": 99
  },
  "yourPaymentReference": "aa648425-2230-4e4e-8a61-27f06df54542",
 }
```

Response Example

```json
{
    "receiptId": "914571470754189312",
    "originalReceiptId": "914571434016280576",
    "yourPaymentReference": "e61b5555-31fe-41f3-843a-905a28c552f0",
    "type": "VOID",
    "createdAt": "2022-11-28T17:40:31.4741+00:00",
    "result": "Success",
    "message": "Void successful",
    "judoId": 100502814,
    "merchantName": "Shodan - Cybersource Routing",
    "appearsOnStatementAs": "APL*/ShodanCybersourceRo",
    "originalAmount": "5.00",
    "amountCollected": "0.00",
    "netAmount": "5.00",
    "amount": "5.00",
    "currency": "GBP",
    "externalBankResponseCode": "",
    "cardDetails": {
        "cardLastfour": "1111",
        "endDate": "1230",
        "cardToken": "EndpeR5KPgLAweDhdj3lzKj5ZEcqpr4s",
        "cardType": 1,
        "cardScheme": "VISA",
        "cardFunding": "Credit",
        "cardCategory": "",
        "cardCountry": "US",
        "bank": "JPMORGAN CHASE BANK, N.A."
    },
    "consumer": {
        "yourConsumerReference": "CardsWithMultipleConsumers2"
    }
}
```
:::

***

## Card Void Scenarios (Negative Flow)

Declines can occur for various reasons, it can be impossible to simulate all the negative flows in a sandbox environment.

### Important to Consider

- How your app handles negative flows
- Your customer's experience should a negative flow occur:
  - Logic to communicate error messages
  - Customise how your app responds
- How to maintain application consistency

Follow our suggested guidelines to simulate negative scenarios, to test your app’s error handling:

| **Suggested Negative Test Scenario**                                    | **Expected Error Code** | **Error Description**                                                                                            |
| ----------------------------------------------------------------------- | ----------------------- | ---------------------------------------------------------------------------------------------------------------- |
| Attempt to void a preAuth that has already been voided.                 | 51                      | Sorry, but it looks like the transaction you are trying to void has already been voided.                         |
| Attempt to void a preAuth that has already been collected.              | 52                      | Sorry, but it looks like the transaction you are trying to void has already been collected.                      |
| Attempt to void an amount that is different to the preAuth amount.      | 53                      | Sorry, but it looks like the void you are trying to process is for a different amount than the original preauth. |
| Attempt to void an expired preAuth .                                    | 42                      | Sorry, it looks like the PreAuth you are referencing has expired.                                                |
| Attempt to void using the receiptId for a payment instead of a preAuth. | 68                      | Sorry, but your void request is not valid. Please check your details and try again.                              |

:::hint{type="warning"}
Where the codes remain fixed, the descriptions may change.&#x20;
You **should not&#x20;**&#x62;uild any error handling logic based on these descriptions.
:::

For a list of possible error codes, types and descriptions, see  [Error Codes and Descriptions](docId:_zrsihomUEW-XnRQ4PBtJ).

