> For the complete documentation index, see [llms.txt](https://docs.payments.thalescloud.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.payments.thalescloud.io/merchant-tokenization/es/entornos/sandbox-environment.md).

# Entorno sandbox

Use the Sandbox Environment to test and validate your Thales API integration during the project. You can also use the Sandbox Environment anytime to reproduce Merchant Tokenization use cases.

Set up the configuration (URL, certificate, API keys, and so on) before connecting to the Sandbox Environment.

<figure><img src="/spaces/O4Alaz7Oc1lNUVi3QiVW/files/JaR8HmkbhnbFvkS7o0NK" alt=""><figcaption><p>Example Sandbox Environment configuration.</p></figcaption></figure>

## How does it work ? <a href="#tests-description" id="tests-description"></a>

### Merchant onboarding <a href="#merchant-onboarding" id="merchant-onboarding"></a>

The Sandbox Environment accepts 10 predefined merchant names during onboarding: Merchant1, Merchant2, Merchant3, ..., Merchant10.

### Tokenization <a href="#tokenization" id="tokenization"></a>

You can use any PAN starting with a BIN that belongs to the payment network BIN ranges. The BIN ranges match the Production Environment. See the list below.

| Mastercard BIN                  | Visa BIN                        | Amex BIN                    |
| ------------------------------- | ------------------------------- | --------------------------- |
| start : 22200000 end : 27299999 | start : 40000000 end : 40117799 | start : 340000 end : 349999 |
| start : 50000000 end : 50599999 | start : 40118000 end : 43127399 | start : 370000 end : 379999 |
| start : 50700000 end : 50899999 | start : 43127500 end : 43893499 |                             |
| start : 51000000 end : 59999999 | start : 43893600 end : 45141599 |                             |
| start : 60000000 end : 62699999 | start : 45141700 end : 45739299 |                             |
| start : 62800000 end : 63599999 | start : 45739400 end : 45763099 |                             |
| start : 63700000 end : 64999999 | start : 45763300 end : 49999999 |                             |
| start : 65200000 end : 65499999 |                                 |                             |
| start : 65600000 end : 69999999 |                                 |                             |
| start : 97500000 end : 97599999 |                                 |                             |

Use a PAN that passes the Luhn check, except when the **Test Data** column explicitly says otherwise.

The year in the card expiry date selects the test case to run: \[XXYY]. `XX` can be any value. `YY` is the test case number.<br>

{% hint style="warning" %}
Limitations:

* The Get token use case is not available in the Sandbox Environment.
* The Sandbox Environment always returns a different `tokenId` in response to a Tokenization request. This differs from some payment networks, which may reuse the same `tokenId` depending on the inputs.
  {% endhint %}

### Token life cycle management (LCM) <a href="#token-life-cycle-management" id="token-life-cycle-management"></a>

The Sandbox Environment lets you trigger notifications sent from the TSP by setting a specific year value in the card expiry date.

### Transaction <a href="#transaction" id="transaction"></a>

The token PAN returned in the Create transaction response is a random number starting with a predefined token BIN (see the table below).

| Payment network | Token BIN |
| --------------- | --------- |
| Mastercard      | 512345    |
| Visa            | 462294    |
| Amex            | 371732    |

The token PAN has the same length as the card PAN and passes the Luhn check. The token BINs are valid payment network token BINs. The cryptogram is hardcoded to a fixed value and uses the same format as in the Production Environment. This lets you simulate a payment in your payment test environment.

Simulating payment transactions is out of scope for the Thales Sandbox Environment. Thales platform does not process payment transactions or authorization messages.

\
The Sandbox Environment also supports a user-defined token value. In Create token, set `encryptedData.accountId` to specify the token value and token expiry date returned in the Create transaction response. The token value must be 15 to 19 digits. The token expiry date must be 4 digits.

Example: encryptedData.accountId = 1234567890123456-1025

If `accountId` is missing, empty, or not in this format, the Sandbox Environment generates the token.

## Test scenarios <a href="#test-cases" id="test-cases"></a>

### Merchant onboarding scenarios

<table><thead><tr><th>Set</th><th width="100">ID</th><th>Use Case</th><th>Test Data</th><th>Description</th></tr></thead><tbody><tr><td>Merchant onboarding</td><td>#A1</td><td>Successful merchant onboarding</td><td>A predefined merchant name in the list Merchant1 to Merchant10</td><td>Call:<br>1) 'POST /merchants'<br>A <strong>merchantId</strong> is returned.<br>2) 'PUT /merchants/{<strong>merchantId</strong>}/mastercard/secure-cof'<br>'PUT /merchants/{<strong>merchantId</strong>}/visa'<br>3) Receive a 'POST /notify-merchant-update' notification for each payment network.<br><br>Use <strong>merchantId</strong> as input for the next test cases.</td></tr></tbody></table>

### Tokenization scenarios

<table><thead><tr><th>Set</th><th width="100">ID</th><th>Use Case</th><th>Test Data</th><th>Description</th></tr></thead><tbody><tr><td>Tokenization</td><td>#A10</td><td>Successful card tokenization</td><td>ANY Card / Exp Date [XX]31<br><br>merchantId from A1</td><td>Call:<br><br><strong>Synchronous Tokenization</strong><br>1) 'POST /tokens'<br><br><strong>Asynchronous Tokenization</strong><br>1) 'POST /async-tokens'<br>Then 2 seconds later, the token requestor receives a successful:<br>2) 'POST /notify-token-creation' containing the token data.<br><br>The generated token stays ACTIVE, regardless of other test cases.</td></tr><tr><td>Tokenization</td><td>#A10a</td><td>Successful Visa card tokenization with token (<strong>Visa Token for token</strong>)</td><td>ANY Token / Exp Date [XX]31<br><br>merchantId from A1</td><td>Call:<br><br><strong>Synchronous Tokenization</strong><br>1) 'POST /tokens'<br>encryptedData.token = &#x3C;token><br>source = TOKEN<br><br><strong>Asynchronous Tokenization</strong><br>Not available.<br><br>The generated token stays ACTIVE, regardless of other test cases.</td></tr><tr><td>Tokenization</td><td>#A11</td><td>Tokenization error case - The TSP rejects the Tokenization request because the card is not eligible.</td><td>ANY Card / Exp Date [XX]32<br><br>merchantId from A1</td><td>Call:<br>1) 'POST /tokens' or 'POST /async-tokens'<br><br>Error returned:<br>400 - PAN_NOT_ELIGIBLE</td></tr><tr><td>Tokenization</td><td>#A12</td><td>Tokenization error case - The Issuer declines Tokenization (for example, fraud)</td><td>ANY Card / Exp Date [XX]33<br><br>merchantId from A1</td><td>Call:<br>1) 'POST /tokens' or 'POST /async-tokens'<br><br>Error returned:<br>400 - ISSUER_DECLINED</td></tr><tr><td>Tokenization</td><td>#A13</td><td>Tokenization error case - The TSP rejects the Tokenization request because the card is not valid.</td><td>ANY Card with invalid Luhn check / ANY Exp Date<br><br>merchantId from A1</td><td>Call:<br>1) 'POST /tokens' or 'POST /async-tokens'<br><br>Error returned:<br>400 - INVALID_PAN_DATA</td></tr><tr><td>Tokenization</td><td>#A14</td><td>Tokenization error case - Unknown card</td><td>Card with a BIN outside the payment network ranges / ANY Exp Date<br><br>merchantId from A1</td><td>Call:<br>1) 'POST /tokens' or 'POST /async-tokens'<br><br>Error returned:<br>400 - UNKNOWN_CARD</td></tr><tr><td>Tokenization</td><td>#A15</td><td>Tokenization error case - Crypto error</td><td>ANY Card / ANY Exp Date, request with invalid encryption<br><br>merchantId from A1</td><td>Call:<br>1) 'POST /tokens' or 'POST /async-tokens'<br><br>Error returned:<br>400 - CRYPTO_ERROR</td></tr><tr><td>Tokenization</td><td>#A16</td><td>Tokenization error case - Unknown merchant</td><td>ANY Card / ANY Exp Date<br><br>invalid merchantId</td><td>Call:<br>1) 'POST /tokens' or 'POST /async-tokens'<br><br>Error returned:<br>400 - UNKNOWN_MERCHANT</td></tr><tr><td>Tokenization</td><td>#A17</td><td>Successful card tokenization with expired tokenExpireDate</td><td>ANY Card / Exp Date [XX]40<br><br>merchantId from A1</td><td>Call:<br><br><strong>Synchronous Tokenization</strong><br>1) 'POST /tokens'<br><br><strong>Asynchronous Tokenization</strong><br>1) 'POST /async-tokens'<br>Then 2 seconds later, the token requestor receives a successful:<br>2) 'POST /notify-token-creation' containing the token data.<br><br>Token expiry date = current month - 1 month.</td></tr></tbody></table>

### LCM scenarios

| Set                | ID   | Use Case                                                    | Test Data                                                    | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              |
| ------------------ | ---- | ----------------------------------------------------------- | ------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| Delete token       | #A20 | Successful token deletion                                   | tokenId from A10                                             | <p>Call:<br>1) 'DELETE /tokens/{tokenId}' with the tokenId to delete.</p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                |
| Lifecycle from TSP | #A22 | Successful card tokenization with token update notification | <p>ANY Card / Exp Date \[XX]34<br><br>merchantId from A1</p> | <p>Call:<br><br><strong>Synchronous Tokenization</strong><br>1) 'POST /tokens'<br><br><strong>Asynchronous Tokenization</strong><br>1) 'POST /async-tokens'<br>Then 2 seconds later, the token requestor receives a successful:<br>2) 'POST /notify-token-creation' containing the token data.<br><br>Then 3 seconds later, the token requestor receives:<br>3) 'POST /notify-token-update' with tokenState='SUSPENDED'<br><br>Then 3 seconds later, the token requestor receives:<br>4) 'POST /notify-token-update' with tokenState='ACTIVE'<br><br>Then 3 seconds later, the token requestor receives:<br>5) 'POST /notify-token-update' with tokenState='DELETED'</p> |
| Lifecycle from TSP | #A23 | Successful card tokenization with card update notification  | <p>ANY Card / Exp Date \[XX]35<br><br>merchantId from A1</p> | <p>Call:<br><br><strong>Synchronous Tokenization</strong><br>1) 'POST /tokens'<br><br><strong>Asynchronous Tokenization</strong><br>1) 'POST /async-tokens'<br>Then 2 seconds later, the token requestor receives a successful:<br>2) 'POST /notify-token-creation' containing the token data.<br><br>Then 2 seconds later, the token requestor receives:<br>3) 'POST /notify-token-update' with:</p><ul><li>new card last digits</li><li>new card expiration date</li><li>new cardDescription</li><li>new termsAndConditionsUrl</li><li>new privacyPolicyUrl</li><li>new completeCardImageId</li></ul>                                                                  |

### Transaction scenarios

| Set                         | ID   | Use Case                                                     | Test Data                                                    | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               |
| --------------------------- | ---- | ------------------------------------------------------------ | ------------------------------------------------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Transaction                 | #A30 | Successful transaction                                       | tokenId from A10                                             | <p>Call:<br>1) 'POST /transactions'<br>The flow is successful. The token and cryptogram are included in the response.</p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 |
| Tokenization + transactions | #A31 | Successful card tokenization followed by token state changes | <p>ANY Card / Exp Date \[XX]41<br><br>merchantId from A1</p> | <p>Call:<br><br><strong>Synchronous Tokenization</strong><br>1) 'POST /tokens'<br><br><strong>Asynchronous Tokenization</strong><br>1) 'POST /async-tokens'<br>Then 2 seconds later, the token requestor receives a successful:<br>2) 'POST /notify-token-creation' containing the token data.<br><br>3) Initial state: the token is ACTIVE for 5 minutes.<br>- Send 'POST /transactions'.<br>- The flow is successful. The token and cryptogram are included in the response.<br><br>4) Token state changes from ACTIVE to SUSPENDED. It stays SUSPENDED for 5 minutes.<br>- Send 'POST /transactions'.<br>- Error returned: INVALID\_TOKEN\_STATE.<br><br>5) Token state changes from SUSPENDED to ACTIVE. It stays ACTIVE for 5 minutes, then moves to DELETED.<br>- Send 'POST /transactions' when the state is DELETED.<br>- Error returned: INVALID\_TOKEN\_STATE.<br><br><strong>Note:</strong> No notification is sent between state changes.</p> |
| Transaction                 | #A32 | Successful transaction with Visa DAF enablement              | tokenId from A10                                             | <p>DAF enablement is part of the Visa CTF flow. It requires Thales SDK integration in the mobile application and API calls.<br><br>This test validates the Create transaction call with the additional parameters required to enable DAF.<br><br>Call:<br>1) 'POST /transactions' including the mandatory DAF parameters. <strong>Any properly formatted values are accepted</strong>.<br>- authentication<br>- visaSignedPayload<br>- transactionData<br>- device<br>- cardholder<br><br>The flow is successful. The token and cryptogram are included in the response. The <strong>isDAF</strong> indicator is present and set to true.</p>                                                                                                                                                                                                                                                                                                             |


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.payments.thalescloud.io/merchant-tokenization/es/entornos/sandbox-environment.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
