---
title: Testing Refunds
slug: testing-refunds
docTags: 
createdAt: 2024-06-05T13:53:05.835Z
---

## Card Refund Scenarios (Positive Flow)

### Important to Consider

- Ensure the **Refund Payments** permission is enabled on your API credentials.
- Ensure you have the correc&#x74;**&#x20;receiptId** for the original payment or collection.
  - This is required for you to process the refund.
- You can make **multiple partial refund** requests, up to the original transaction amount.
- These scenarios can be used on:
  - Card
  - Apple Pay™
  - Google Pay™
    test transactions.

To simulate a **full or partial refund** on the original transaction amount:

| **Suggested Test Scenario**                                                                                         | **Expected Outcome** | **Tip**                                                                                                                                                                                                                                                          |
| ------------------------------------------------------------------------------------------------------------------- | -------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Process a **partial&#x20;**&#x72;efund.<br />You can also make **multiple&#x20;**&#x74;est partial refund requests. | 200<br />Successful  | Ensure you have the correct **receiptId&#x20;**&#x66;or the original payment or collection, to process the partial refund.<br />If you are testing multiple partial refund requests, ensure the combined requests do not exceed the original transaction amount. |
| Process a **full&#x20;**&#x72;efund.<br />                                                                          | 200<br />Successful  | Ensure you have the correct **receiptId&#x20;**&#x66;or the original payment or collection, to process the full refund.                                                                                                                                          |

***

### Request Parameters

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

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:**

:::hint{type="info"}
Ensure you have the correct **receiptId&#x20;**&#x66;or the original transaction to process the full or partial refund.
:::

**Configuration Property Descriptions**

| **Parameter**                                                                            | **Description**                                                                                                                                                                                                  |
| ---------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `receiptId`<br />String<br /><font color="#ef5b2e">Required</font>                       | Judopay's reference for the transaction that is to be refunded.                                                                                                                                                  |
| `amount`<br />Decimal<br /><font color="#ef5b2e">Required</font>                         | The amount to refund.<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 transaction.<br />If not specified, the currency of the original transaction 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 refund.<br />Format:<br />* Maximum length 50 characters.<br />**This is not the yourPaymentReference of the original transaction**.                                              |

:::CodeblockTabs
Refund Request Example

```json
{
  "receiptId": "675014982672486400",
  "amount": 10.99,
  "currency": "GBP",
  "yourPaymentReference": "6482c678-cad3-4efd-b081-aeae7a89a134"
}
```

Response Example

```json
{
    "receiptId": "914572343442046976",
    "originalReceiptId": "914572313402441728",
    "yourPaymentReference": "9b3855ae-cae6-4342-a503-2908e3a1593f",
    "type": "Refund",
    "createdAt": "2022-11-28T17:43:58.9941+00:00",
    "result": "Success",
    "message": "Refund successful",
    "judoId": 100502814,
    "merchantName": "Shodan - Cybersource Routing",
    "appearsOnStatementAs": "APL*/ShodanCybersourceRo",
    "originalAmount": "5.00",
    "netAmount": "0.00",
    "amount": "5.00",
    "currency": "GBP",
    "acquirerTransactionId": "7016975398",
    "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 Refund 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**<br />                                                                                                                                                                                     |
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ----------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Attempt a refund on a preAuth that has not yet been collected.<br />For a preAuth that has not yet been collected, follow the [void scenarios](docId\:DMBAKsKJll551SuxQIPuM).                                      | 67                      | Sorry, but your refund request was not valid.<br />Please check that the original transaction was a Sale or Collection, has not previously been refunded, was not for a lesser amount than your refund request. |
| Attempt a refund on a preAuth that has already been voided.                                                                                                                                                        | 48                      | Sorry, this transaction has been voided. You cannot perform a refund on a voided transaction.                                                                                                                   |
| Attempt a larger refund amount than the original transaction amount.                                                                                                                                               | 49                      | Sorry, but the amount you're trying to refund is greater than the original transaction.                                                                                                                         |
| Attempt a refund using the incorrect receiptId.<br />Use the **preAuth receiptId** to simulate the error.<br /><br />(For a positive flow, the correct receiptId would be for the original payment or collection). | 47                      | Sorry, but it looks like the transaction you are trying to refund is invalid.<br />Refunds can only be performed on Sales and Collections.                                                                      |

:::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).

