---
title: Testing Collections
slug: testing-collections
docTags: 
createdAt: 2024-06-05T14:14:31.560Z
---

These scenarios do not include 3D Secure 2 authentication testing.
See [Testing 3D Secure 2 Flows](docId\:BdCGiYQDm3mlE-UBxp1yR) for 3D Secure 2 authentication testing for your app.

## Card Collections Scenarios (Positive Flow)

Collect funds previously reserved using the [Testing Card PreAuths](docId\:gwWUVrKwOnC5YVk6qhMMi) request.

### Important to Consider

- Ensure you have the correc&#x74;**&#x20;receiptId** for the original pre authorisation.
  - This is required for you to process the collection.
- The expiry time of the reserved pre authorised funds differs across acquirers. If not collected, the reserved funds are released and the collection request will be declined.
  - To request the funds, attempt a `/transactions/payments` request instead.
- You can collect **partial&#x20;**&#x61;mounts or **multiple partial** amounts, as long as the&#x79;**&#x20;do not exceed** the amount of the original pre authorisation.
- Ensure the currency in the collection request matches the currency from the original pre authorisation.

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

| **Suggested Test Scenario**                                 | **Expected Outcome** | **Tip**                                                                                                                                                                                       |
| ----------------------------------------------------------- | -------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Process a collection on the full preAuth amount.            | 200<br />Successful  | Ensure you have the correct **receiptId** for the original pre authorisation.                                                                                                                 |
| Process a partial collection on the preAuth amount.         | 200<br />Successful  | Ensure you have the correct **receiptId** for the original pre authorisation.                                                                                                                 |
| Process multiple partial collections on the preAuth amount. | 200<br />Successful  | Ensure you have the correct **receiptId** for the original pre authorisation.<br />Ensure the total multiple partial collections, do not exceed the amount of the original pre authorisation. |

***

### Request Parameters

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

HTTP Method: **POST**

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

**&#x20;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 collected.                                                                                                                                                       |
| `amount`<br />Decimal<br /><font color="#ef5b2e">Required</font>                         | The amount to collect must not exceed the amount of the original pre authorisation.<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 collection.<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
Collection 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": "937657990037798912",
    "originalReceiptId": "937657941614559232",
    "yourPaymentReference": "aa648425-2230-4e4e-8a61-27f06df54542",
    "type": "Collection",
    "createdAt": "2023-01-31T10:38:05.6451+00:00",
    "result": "Success",
    "message": "AuthCode: ",
    "judoId": 100042597,
    "merchantName": "Shodan - Ai Routing",
    "appearsOnStatementAs": "APL*/ShodanAiRouting    ",
    "originalAmount": "10.99",
    "netAmount": "10.99",
    "amount": "10.99",
    "currency": "GBP",
    "acquirerTransactionId": "64012420784005660136",
    "externalBankResponseCode": "",
    "authCode": "574623",
    "cardDetails": {
        "cardLastfour": "3436",
        "endDate": "1230",
        "cardToken": "SOF-KM2rtbUVRP2NWvrBWsvJOQ",
        "cardType": 11,
        "cardScheme": "VISA",
        "cardFunding": "Debit",
        "cardCategory": "",
        "cardCountry": "FR",
        "bank": "CREDIT INDUSTREIL ET COMMERCIAL"
    },
    "consumer": {
        "yourConsumerReference": "collection test"
    },
    "threeDSecure": {
        "attempted": false
    }
}
```
:::

***

## Card Collections 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 to collect a preAuth that has already been collected.              | 65                      | Sorry, but the collection request you've specified is not valid. Please check your details and try again.                              |
| Attempt to collect an amount that is greater than the preAuth amount.      | 46                      | Sorry, but the amount you're trying to collect is greater than the pre-auth.                                                           |
| Attempt to collect an expired preAuth.                                     | 42                      | Sorry, it looks like the PreAuth you are referencing has expired.                                                                      |
| Attempt to collect using the receiptId for a payment instead of a preAuth. | 43                      | Sorry, it looks like you're trying to make a collection on an invalid transaction type. Collections can only be performed on PreAuths. |
| Attempt to collect a preAuth that has already been voided.                 | 45                      | Sorry, this transaction has been voided. You cannot perform a collection on a voided transaction.                                      |

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

