---
title: Testing Web SDK - Card Payments
slug: testing-web-sdk-card-payments
docTags: 
createdAt: 2024-06-10T13:52:22.352Z
---

With Judopay’s Web SDK solution, a minimal integration is all that is required to enable you to:

- Take a card payment
- Take a card preAuth
- Take a card token payment
- Take a card token preAuth
- Check the validity of a card, using checkCard

***

## Prerequisites

Before attempting Web SDK test transactions, ensure the following steps have been implemented:

- [Step One: Create a paymentSession](docId:40dWE6LBub7vdKza1QYDC)
- [Step Two: Add the Payment Form to your Website](docId:40dWE6LBub7vdKza1QYDC)
- Defined the **payment configuration**, **token configuration&#x20;**&#x61;nd **check card configuration&#x20;**&#x6F;bjects as required.

***

## Card Payment Scenarios (Positive Flow)

### Important to Consider

- **yourPaymentReference&#x20;**&#x69;s your unique reference for each transaction.
- Ensure you generate a unique **yourPaymentReference&#x20;**&#x61;nd unique **paymentSession&#x20;**&#x66;or each transaction.
  - This will avoid duplicate transactions.
- When making token payments, **yourConsumerReference&#x20;**&#x6D;ust match the original reference when the token was initially created.
- Ensure the following information in your **configuration object(s)** matches the information in the **paymentSession**:
  - judoId
  - currency
  - amount
  - yourConsumerReference
  - yourPaymentReference
    If this does not match, you will receive an **error**.

| **Suggested Test Scenario**                                                                                                                                                                                                       | **Expected Outcome** | **Tip**                                                                                                                                                                                                                                                                                                                                                                                                    |
| --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Process a successful Web SDK card checkCard request.<br />This will check the card is valid.                                                                                                                                      | 200<br />Successful  | Ensure you have defined the **check card configuration&#x20;**&#x6F;bject.<br />The checkCard response provides the:<br />- cardToken
- yourConsumerReference<br />Ensure you use the correct **cardToken** and **yourConsumerReference** to make futur&#x65;**&#x20;token payments**, otherwise they will fail.                                                                                           |
| Process a successful Web SDK card payment / preAuth request.<br />                                                                                                                                                                | 200<br />Successful  | Ensure you have defined the **payment configuration&#x20;**&#x6F;bject.<br />The payment /preAuth response provides the:<br />- cardToken
- yourConsumerReference                                                                                                                                                                                                                                          |
| Process a Web SDK card token payment / preAuth with the CV2 / CVV security code included in the request.<br />This will check the CV2 / CVV and card token are valid and match the stored card details.                           | 200<br />Successful  | The consumer will not be prompted to enter the security code.<br />Ensure you have defined the **token configuration&#x20;**&#x6F;bject. where **securityCode&#x20;**&#x69;s set and **shouldVerifySecurityCode**=**false**<br />When making token payments or preAuths, the **cardToken** and **yourConsumerReference&#x20;**&#x6D;ust match the original reference when the token was initially created. |
| Process a Web SDK card token payment prompting the consumer to enter **just&#x20;**&#x74;heir cardholder name.                                                                                                                    |                      | Set:<br />- shouldVerifyCardholderName: **true**
- shouldVerifySecurityCode: **false**<br />If **cardHolderName&#x20;**&#x69;s provided in the configuration object, it will be overwritten with the value entered here.<br />When making token payments or preAuths, the **cardToken** and **yourConsumerReference&#x20;**&#x6D;ust match the original reference when the token was initially created.    |
| Process a Web SDK card token payment prompting the consumer to enter **just&#x20;**&#x74;heir card security code.                                                                                                                 |                      | Set:<br />- shouldVerifySecurityCode: **true**
- shouldVerifyCardholderName: **false**<br />If **securityCode&#x20;**&#x69;s provided in the configuration object, it will be overwritten with the value entered here.<br />When making token payments or preauths, the **cardToken** and **yourConsumerReference&#x20;**&#x6D;ust match the original reference when the token was initially created.      |
| Process a Web SDK card token payment prompting the consumer to enter **both&#x20;**&#x74;heir cardholder name and security code.                                                                                                  |                      | Set:<br />- shouldVerifyCardholderName: **true**
- shouldVerifySecurityCode: **true**<br />When making token payments or preauths, the **cardToken** and **yourConsumerReference&#x20;**&#x6D;ust match the original reference when the token was initially created.                                                                                                                                       |
| **3D Secure 2 Flows**<br />For each 3D Secure 2 scenario, different calls are made from the front end to the back end.<br />It is advised to be aware of the different results from each flow and how your app will handle these. |                      |                                                                                                                                                                                                                                                                                                                                                                                                            |
| Process a Web SDK card payment prompting the frictionless flow.<br />[Testing 3D Secure 2 Flows (Frictionless Flow)](docId\:BdCGiYQDm3mlE-UBxp1yR)                                                                                |                      | Ensure Judopay has enabled 3D Secure 2 on your sandbox tokens.<br />If 3D Secure 2 is not enabled on your tokens, the test transaction will be successful, however it will not have followed the 3D Secure 2 verification process.                                                                                                                                                                         |
| Process a Web SDK card payment prompting the non-frictionless flows.<br />[Testing 3D Secure 2 Flows (Non-Frictionless Flow)](docId\:BdCGiYQDm3mlE-UBxp1yR)                                                                       |                      | Ensure Judopay has enabled 3D Secure 2 on your sandbox tokens.<br />If 3D Secure 2 is not enabled on your tokens, the test transaction will be successful, however it will not have followed the 3D Secure 2 verification process.                                                                                                                                                                         |

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

***

### Test Data

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

:::hint{type="info"}
To trigger specific **3D Secure 2 user journeys**, include the **cardHolderName&#x20;**&#x61;s specified in the [CardHolderName Table](docId\:BdCGiYQDm3mlE-UBxp1yR).
The **cardHolderName&#x20;**&#x69;s case sensitive and corresponds to an **expected transaction result**.
:::

***

### Request Parameters

**Taking a card payment or preAuth:**

- Define the configuration object for the **payment&#x20;**&#x6F;r **preAuth**.
  - Add the `.invokePayment` call to invoke a payment using the paymentSession and configuration object.
  - Add the `.invokePreauth`call to invoke a preAuth using the paymentSession and configuration object.

**Making a check card request:**

- Define the configuration object for the **checkCard**.
  - Add the `.invokeCheckCard` call to make a Check Card request using the paymentSession and configuration object.

**Taking a card token payment or token preAuth:**

- Define the configuration object for th&#x65;**&#x20;token payment** or **token preAuth**.
  - Add the `.invokeTokenPayment` call to invoke a payment using the paymentSession and configuration object.
  - Add the `.invokeTokenPreauth` call to invoke a preAuth using the paymentSession and configuration object.

**Header Parameters:**

These header parameters are to be used when creating the [paymentSession - (Prerequisite)](docId\:a33b4PWt6BRoFeJpgHDH2) request to our Transaction API.&#x20;

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

**Web SDK Payment / preAuth / CheckCard / Token Payment Configuration Parameter Descriptions:**

:::hint{type="warning"}
**\*Mastercard Recommends:**
These fields are recommended rather than mandatory. Transactions will continue to be processed if not supplied.&#x20;
See, [Mastercard Recommended 3D Secure 2 Fields](docId\:WpFMF662qaIGEGrpU_Mow).
:::

| **Parameter**                                                                                                                                                                                                                            | **Description**                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               |
| ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `judoId`<br />String<br /><font color="#ef5b2e">Required</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.                                                                                                                                                                                                                                                                                                                                                                                                   |
| `amount`<br />Decimal<br /><font color="#ef5b2e">Required</font><br /><br />                                                                                                                                                             | The amount to process.<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><br />                                                                                                                                                                  | The currency of the transaction.<br />Any ISO 4217 alphabetic currency code:<br />* GBP
* USD
* EUR                                                                                                                                                                                                                                                                                                                                                                                                                                                                           |
| `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.                                                                                                                                                                                                                                                                                                                                                                                                                                                        |
| `yourPaymentReference`<br />String<br /><font color="#ef5b2e">Required</font><br /><br />                                                                                                                                                | Your unique reference for this payment.<br />Format:<br />* Maximum length 50 characters.<br />This value should be unique in order to protect your customers against duplicate transactions. <br />With a server side integration, if a payment reference is not supplied, the transaction will not be processed.                                                                                                                                                                                                                                                            |
| `phoneCountryCode`<br />String<br /><font color="#ef5b2e">Recommended</font> <font color="#ef5b2e">*</font><br /><br />                                                                                                                  | The country code of the consumer's phone.<br />Format:<br />* Maximum length 3 characters.
* Only numbers allowed.
* Do not include special characters or spaces.<br />Must be set if **mobileNumber** is set.<br />If not set, default = 44                                                                                                                                                                                                                                                                                                                                  |
| `mobileNumber`<br />String<br /><font color="#ef5b2e">Recommended</font> <font color="#ef5b2e">*</font><br /><br />                                                                                                                      | Consumer’s valid mobile number.<br /><br />Mastercard recommends providing at least **one contact method** for Mastercard 3D Secure authenticated transactions.<br />Format:<br />* Maximum length 15 characters.
* Only numbers allowed.
* Do not include special characters or spaces.<br />Must be set if **phoneCountryCode** is set.                                                                                                                                                                                                                                     |
| `cardHolderName`<br />String<br /><font color="#ef5b2e">Recommended</font> <font color="#ef5b2e">*</font><br />                                                                                                                          | The card name of the consumer.<br />If the cardHolderName field is displayed to the user in the payment form (**isCardHolderNameVisible: true** is set in the iFrame config), the value entered in the payment form will overwrite this value.                                                                                                                                                                                                                                                                                                                                |
| `challengeRequestIndicator`<br />String<br /><font color="#42cbd4">Optional</font><br /><br /><br />                                                                                                                                     | Indicates the type of challenge request you wish to apply.<br />Set this to one of the following strings:<br />* `noPreference`
* `noChallenge`
  - No challenge required.
* `challengePreferred`
  - A challenge is preferred for this transaction.
* `challengeAsMandate`
  - Must challenge this transaction.<br />This **should not&#x20;**&#x62;e included in the same configuration object as **scaExemption**.                                                                                                                                                         |
| `initialRecurringPayment`<br />Boolean<br /><font color="#42cbd4">Optional</font>                                                                                                                                                        | Indicates if this initial payment is part of a recurring payment.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             |
| `billingAddress`<br />Object<br /><font color="#42cbd4">Optional</font><br /><br />                                                                                                                                                      | Card holder's billing address.<br />Properties:<br />* `address1` <font color="#ef5b2e">(</font><font color="#ef5b2e">Recommended)</font><font color="#ef5b2e">*</font>
* `address2` (optional)
* `town`
* `state`(only required if country is USA/Canada)
  - Format:
    - string
    - ISO Alpha-2 Code (e.g. California = "**CA**")
* `country`
  - Format:
    - string
    - See [here](docId\:XZE369mFK5UVOSaNzM8UO) for the list of valid **ISO 3166-1** format country codes.
    - `postCode`<br />If the billingAddress is provided, the postcode is **required**. |
| `emailAddress`<br />String<br /><font color="#ef5b2e">Recommended</font> <font color="#ef5b2e">*</font>                                                                                                                                  | Consumer’s valid email address.<br /><br />Mastercard recommends providing at least **one contact method** for Mastercard 3D Secure authenticated transactions.                                                                                                                                                                                                                                                                                                                                                                                                               |
| `primaryAccountDetails`<br />Object<br /><font color="#42cbd4">Optional</font><br /><br />                                                                                                                                               | This is <font color="#ef5b2e">**Mandatory** </font>for merchants who have an MCC code of <font color="#ef5b2e">**6012**.</font><br />Properties:<br />* `name`&#xA;**This is the surname.**
* `accountNumber`
* `postCode`
* `dateOfBirth`
  - Format: YYYY-MM-DD                                                                                                                                                                                                                                                                                                             |
| The configuration object for **token&#x20;**&#x70;ayments takes the same parameters as the **paymentConfiguration&#x20;**&#x6F;bject, along with the additional **token specific parameters&#x20;**&#x74;o be included, as listed below: |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               |
| `cardToken`<br />String<br /><font color="#ef5b2e">Required</font>                                                                                                                                                                       | A randomly generated string linked to the saved card stored in Judopay’s system.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              |
| `shouldVerifySecurityCode`<br />Boolean<br /><font color="#42cbd4">Optional</font>                                                                                                                                                       | Indicates if the consumer will be prompted to enter their security code.<br />Default value = **true**.                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |
| `securityCode`<br />String<br /><font color="#42cbd4">Optional</font>                                                                                                                                                                    | The 3/4 digit security code associated with the consumer’s saved card.<br />This value will be overwritten if the user is prompted to enter their own value: (**shouldVerifySecurityCode=true**).                                                                                                                                                                                                                                                                                                                                                                             |
| `shouldVerifyCardHolderName`<br />Boolean<br /><font color="#42cbd4">Optional</font>                                                                                                                                                     | Indicates if the consumer will be prompted to enter their card holder name.<br />If the user is prompted to enter their card holder name AND you have provided cardHolderName in the config, the config value will be overwritten.<br />Default value = **false**.                                                                                                                                                                                                                                                                                                            |

:::CodeblockTabs
Request Example

```javascript
const paymentConfiguration = {
    judoId: "yourJudoId",
    amount: 1.01,
    currency: "GBP",
    phoneCountryCode: "44",
    challengeRequestIndicator: "challengeAsMandate",
    initialRecurringPayment: false,
    yourConsumerReference: "yourConsumerReference",
    yourPaymentReference: "yourPaymentReference",
    billingAddress: {
        address1: "My house",
        address2: "My street",
        town: "My town",
        postCode: "TR14 8PA",
        country: "826"
    },
    mobileNumber: "07999999999",
    emailAddress: "contact@judopay.com",
    primaryAccountDetails: {
        name: "Doe",
        accountNumber: "9999999",
        dateOfBirth: "1989-09-19",
        postCode: "AB1 2CD"
    }
}
```

Response Example

```none
const onFulfillment = (receiptObject) => {
  const { result } = receiptObject
  //redirect to appropriate page depending on the result (success/failure/declined page)
}

const onRejection = (error) => {
  //redirect to error page and handle error
}
```
:::

***

## Card Payment 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 perform a Web SDK card payment / preAuth / checkCard request decline using the following:<br />* **cardNumber**: 4221690000004963
* **cv2**: 452
* **expiryDate**: 12/24                                                                                                                                                                                                                                                                                                                                                                                                            | Declined<br />          | Card declined.                                                                                                                                                                                                                                                                                                                                        |
| Attempt to perform a Web SDK card payment / preAuth / checkCard request gateway error<br />using the following:<br />* **cardNumber**: 4976350000006891
* **cv2**: 341
* **expiryDate**: 12/30<br />The transaction request has passed all Judopay's validation checks.<br />The next step in the payment flow is for the gateway to perform their checks.<br />A gateway error occurs when for example, the gateway verifies the request details with the issuing bank, who declines the request as there are not enough funds in the account.<br />**This response contains the receiptId.** | Declined<br />          | Card declined.                                                                                                                                                                                                                                                                                                                                        |
| Attempt a Web SDK card payment / preAuth with the Incorrect currency entered for the specified transaction.<br />**Default currency = GBP**                                                                                                                                                                                                                                                                                                                                                                                                                                                    | 72                      | Sorry, we're currently unable to route this transaction. Please check your account details and try again.<br />If this issue persists, please contact customer services.<br />This is a [processing error](docId:_zrsihomUEW-XnRQ4PBtJ).                                                                                                              |
| Attempt to perform a Web SDK card payment 3D Secure 2 challenge flow, where the user taps the cancel button on the challenge screen.<br />Ensure you have set the correct flags to control the 3D Secure 2 challenge scenarios.                                                                                                                                                                                                                                                                                                                                                                | 165                     | Unable to process transaction. Card authentication failed with 3DS Server.<br />                                                                                                                                                                                                                                                                      |
| Attempt to perform a Web SDK card payment / preAuth / checkCard request with the incorrect environment (live or sandbox) for your API Token and API Secret and configuration.                                                                                                                                                                                                                                                                                                                                                                                                                  | 7                       | Sorry, we were unable to authorize this request. Please check your details and permissions before trying again.                                                                                                                                                                                                                                       |
| Attempt to perform a duplicate transaction, re-using a **yourPaymentReference&#x20;**&#x74;hat has already been used in a previous transaction.                                                                                                                                                                                                                                                                                                                                                                                                                                                | 86                      | Sorry, this payment has been stopped as it is a duplicate transaction.                                                                                                                                                                                                                                                                                |
| Attempt to perform a Web SDK card payment / preAuth / checkCard request where the amount set in the configuration object is different to the amount set in the paymentSession.                                                                                                                                                                                                                                                                                                                                                                                                                 | 12                      | Sorry, we were unable to process your payment. Please check your details and try again.                                                                                                                                                                                                                                                               |
| Attempt to perform a Web SDK card payment / preAuth / checkCard request where the card type used, is not supported on your Judopay account.<br />For example, if AMEX is not enabled on your account, use card type = AMEX.                                                                                                                                                                                                                                                                                                                                                                    | 73                      | Sorry, but this card type is not currently supported on this account.                                                                                                                                                                                                                                                                                 |
| Attempt to perform a Web SDK card payment / preAuth / checkCard request where the card scheme used, is not defined in the iFrame configuration object.<br />For example, if AMEX is not defined, use card scheme = AMEX.<br />//An array of card schemes that are accepted by the merchant.<br />//If this field is set, an error will appear if an unsupported card scheme is entered.<br />**allowedCardSchemes: \['visa','mastercard'],**                                                                                                                                                   |                         | For the purpose of this exercise the class is named judopay-errors, and sets a style to be red. You can add any custom style you wish in your .CSS file.<br />**\<div class="judopay-errors" style="color\:red">Error Location\</div>**<br />For more information, see [Step Two: Add the Payment Form to your Website.](docId:40dWE6LBub7vdKza1QYDC) |

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

