---
title: Testing SaveCard
slug: testing-savecard
docTags: 
createdAt: 2024-06-10T09:23:20.591Z
---

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.

## SaveCard Scenarios (Positive Flow)

Use `saveCard` If you do not want to perform a pre-authorisation check on a customer's account.&#x20;
SaveCard stores the card details and tokenises the card number into an encrypted string.

During the saveCard request flow, Judopay validates the fields in the request model before storing the card details and tokenising the card number.

If the request fails these checks, for example due to an incorrect field value, or the field has been incorrectly formatted, you will receive a model error response.
For more information, see [Model Errors](docId:_zrsihomUEW-XnRQ4PBtJ).

:::hint{type="info"}
The cardToke&#x6E;**&#x20;is not validated** by the issuer, until it is used in a payment or preAuth request.
:::

***

### Important to Consider

- SaveCard involves **storing** the following card details:
  - cardNumber
  - cardExpiryDate
  - cv2
- Tokenises the card number into an encrypted string.
- The saveCard request is not processed through the 3D Secure 2 flow and is not authenticated.
  - For a request to follow the 3D Secure 2 authentication flow, use [Testing CheckCard](docId:3ssySZe0ATrwUJRQsIqOv) instead.
- You **cannot** use the **receiptId&#x20;**&#x66;rom the saveCard response for **Merchant Initiated Transactions**.
  - This is due to the saveCard request not being validated by the issuer.
    For more information on the Merchant Initiated Transaction flow, see [Testing Merchant Initiated Transactions](docId\:gB1c-OQBH7UUW8rzUSawt).

:::hint{type="warning"}
SaveCard **does not validate** the card or account, as the reques&#x74;**&#x20;does not** go to the payment gateway.
:::

| **Suggested Field Validation Test Scenario**                                                                                                        | **Expected Outcome** | **Tip**                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               |
| --------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Process a saveCard request with the CV2/CVV security code included in the request to check the CV2/CVV field format is valid.<br />                 | 200<br />Successful  | The CV2 field validation check will be performed during the process.<br /><br /><br />                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                |
| Process a saveCard request without the CV2/CVV security code included in the request.<br />                                                         | Declined<br />       | The CV2 field validation check will not be performed during the process.<br /><br />                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |
| Process a saveCard request with the billing address information (cardAddress block) included in the request to check the fields are correct.<br />  | 200<br />Successful  | Ensure the **cardAddress** block has the correct fields:<br />* `address1`
* `address2`
* `town`
* `postCode`
  - Required
* `countryCode`
  - See [here](docId\:XZE369mFK5UVOSaNzM8UO) for the list of valid **ISO 3166-1** format country codes.<br />Example cardAddress block:<br />:::BlockQuote
"cardAddress": \{  &#xD;&#xA;    "address1": "CardHolder House",  &#xD;&#xA;    "address2": "1 CardHolder Street",  &#xD;&#xD;&#xA;    "town": "CardHolder Town",  &#xD;&#xA;    "postCode": "AB1 2CD",  &#xD;&#xA;    "countryCode": 826,  &#xD;&#xA;    "state": "FL", &#xD;&#xA;},
:::<br />To validate the card is registered to the correct post code, ensure the following permission on your sandbox API Credentials is enabled:<br />* **Enforce AVS checks**.<br />**The default setting = disabled**. |
| Process a saveCard request without the billing address information (cardAddress block) included in the request.                                     | 200<br />Successful  |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |

For more information on API credentials and permissions, see [Permissions](docId\:S_8hOAMytkgY13t0P657-).

***

### Test Card Data

To simulate a successful saveCard request use the [Test Cards](docId:_OBafnuC1Umhk-vIhHs5D).

***

### SaveCard Request Parameters

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

HTTP Method: **POST**

**Header Parameters:**

Depending on how you integrate with Judopay, you can authenticate requests by:

- `/paymentsession`, or
- TokenSecretAuth
  - The token and secret pair

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** |
| **Authorization Method**:<br />PaymentSessionAuthToken<br />     | **For Payment Session authentication**<br />In the Api-Token header:<br />* Supply the token used to authenticate the call to generate a payment session<br />Th&#x65;**&#x20;Payment-Session header** value must also be supplied.                                                                                                                                                                                                                                                                                                                          |
| **Authorization Method**:<br />PaymentSessionAuthReference<br /> | **For Payment Session authentication**<br />In the Payment-Session header:<br />* Supply the reference returned in the create payment session response<br />Th&#x65;**&#x20;Api-Token header** value must also be supplied.                                                                                                                                                                                                                                                                                                                                  |

***

**Body Parameters**:

**Configuration Property Descriptions**

| **Parameter**                                                                  | **Description**                                                                                                                                                             |
| ------------------------------------------------------------------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `judoId`<br />String<br /><font color="#42cbd4">Optional</font><br /><br />    | Unique ID supplied by Judopay.<br />Specific to a merchant and/or location.<br />Format:<br />* 100100100
* Maximum length 9 characters.
* Do not include spaces or dashes. |
| `cardNumber`<br />String<br /><font color="#ef5b2e">Required</font>            | The unique number printed on the card (13 to 19 digits depending on card type).<br />Submitted without whitespace or non-numeric characters.                                |
| `expiryDate`<br />String<br /><font color="#ef5b2e">Required</font>            | The expiry date of the card.<br />Format:<br />* MM/YY                                                                                                                      |
| `cv2`<br />String<br /><font color="#42cbd4">Optional</font>                   | The 3 or 4 digit number on the back of the card.<br />Also known as the card verification value (CVV) or security code.                                                     |
| `yourConsumerReference`<br />String<br /><font color="#ef5b2e">Required</font> | Unique reference to anonymously identify your customer.<br />Advisable to use GUIDs.<br />Must be below 40 characters.                                                      |
| `cardHolderName`<br />String<br /><font color="#42cbd4">Optional</font>        | The full name of the card holder.                                                                                                                                           |

:::CodeblockTabs
SaveCard Request Example

```json
{
    "cardNumber": "4976000000003436",
    "expiryDate": "12/30",
    "cv2": "452",
    "yourConsumerReference": "Carlie1656@example.com",
    "cardHolderName": "Brenda Quigley",
    "judoId": "100078697"
}
```

Response Example

```json
{
    "receiptId": "9551393333331152",
    "yourPaymentReference": "Judo_RegisterCard_638149261737657931",
    "type": "Save",
    "createdAt": "2023-03-20T16:22:53.7970+00:00",
    "result": "Success",
    "message": "Register Card",
    "judoId": 100042597,
    "merchantName": "Shodan - Ai Routing",
    "appearsOnStatementAs": "APL*/ShodanAiRouting    ",
    "originalAmount": "0.00",
    "netAmount": "0.00",
    "amount": "0.00",
    "currency": "GBP",
    "acquirerTransactionId": "123456",
    "externalBankResponseCode": "",
    "authCode": "",
    "cardDetails": {
        "cardLastfour": "3436",
        "endDate": "1230",
        "cardToken": "SOF-OBcPH1avSuGSJ8UF9Wnt7A",
        "cardType": 11,
        "cardScheme": "VISA",
        "cardFunding": "Debit",
        "cardCategory": "Classic",
        "cardCountry": "FR",
        "bank": "CREDIT INDUSTRIEL ET COMMERCIAL",
        "cardHolderName": "Brenda Quigley"
    },
    "consumer": {
        "yourConsumerReference": "Carlie1656@example.com",
    },
    "threeDSecure": {
        "attempted": false
    },
    "risks": {
        "postCodeCheck": "UNKNOWN",
        "cv2Check": "PASSED",
        "merchantSuggestion": "Allow"
    }
}
```
:::

***

## SaveCard Scenarios (Negative Flow)

Field and formatting errors can occur for various reasons, it can be impossible to simulate all the model errors 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 model errors, to test your app’s error handling:

| **Suggested Field Validation Negative Scenario**                                                                                               | **Expected Error Code** | **Model Error Description**                                                                                                                                                                                                                                          |
| ---------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Attempt to perform a saveCard request using an invalid/expired card expiry date.                                                               | 46                      | :::BlockQuote
\{&#xD;&#xA;  "details": \[&#xD;&#xA;   \{&#xD;&#xA;     "code": 46,&#xD;&#xA;     "fieldName": "ExpiryDate",&#xD;&#xA;     "message": "Sorry, but the expiry date entered is in the past. Please check your details and try again."&#xD;&#xA;   }
::: |
| Attempt to perform a saveCard request using an invalid card number.<br />For example use 13 digits for the card number.                        | 30                      | :::BlockQuote
\{&#xA; "details": \[&#xA;  \{&#xA;    "code": 30,&#xA;    "fieldName": "CardNumber",&#xA;    "message": "Sorry, it looks like the card number entered is invalid. Please check your details and try again."&#xA; }
:::                                |
| Attempt to perform a saveCard request with an invalid CV2 field format.<br />For example "ABC123".                                             | 1                       | :::BlockQuote
\{&#xA; "details": \[&#xA; \{&#xA;   "message": "Sorry, we're unable&#xA;    to process your request. Please &#xA;    check your details and try&#xA;    again.",&#xA; "code": 1,&#xA; "category": 2&#xA;}
:::                                         |
| Attempt to perform a saveCard request with a missing CV2.<br />The sandbox token has cv2 enabled, the saveCard request has an empty cv2 field. | 31                      | :::BlockQuote
\{&#xA; "details": \[&#xA; \{&#xA;    "code": 31,&#xA;    "fieldName": "Cv2",&#xA;    "message": "Sorry, you've not supplied the 3-digit card security code. Please check your details and try again."&#xA; }
:::                                      |

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

***

### Next Steps

Using the **cardToken&#x20;**&#x66;rom the `saveCard` response, you can test the following scenarios:

- [Testing Card PreAuths](docId\:gwWUVrKwOnC5YVk6qhMMi)
- [Testing Card Payments](docId\:NQ7C98PanEmfgukhbPucB)

