> ## Documentation Index
> Fetch the complete documentation index at: https://primer.io/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Testing Network Tokens

> [!NOTE]
>
> Before testing network tokens in sandbox, make sure your account is fully enrolled to network tokenization.
>
> Speak to your Customer Success Manager or raise a ticket on our [Support Portal](https://portal.support.primer.io/servicedesk/customer/portal/11).  If you don't have access, please contact your account administrator for assistance.

> [!WARNING]
>
> Visa's testing environment is frequently reset, which makes testing Visa network tokens extremely unreliable.
>
> As a result, testing Visa network tokenization is not available on Primer sandbox. We encourage you to only test Mastercard network tokenization in sandbox, and to test Visa network tokenization in production.

### Provisioning network tokens

> [!NOTE]
>
> On sandbox, Primer attempts to provision a network token whenever a card is added to the vault of a customer ID starting with `primer-nt-testing`.

The best way to vault a card is to use Universal Checkout. Make sure to call POST with a ["customerId"](https://primer.io/docs/api-reference/v2.4/api-reference/client-session-api/create-a-client-session.md#body-customer-id) and ["vaultOnSuccess"](https://primer.io/docs/api-reference/v2.4/api-reference/client-session-api/create-a-client-session.md#response-payment-method-vault-on-success) set to `true`. This automatically vaults the card if the payment is successfully authorized.

This first payment is processed using the raw card data. Once vaulted, it usually takes a few seconds for the network token to be provisioned and available for subsequent payments.

Use the following test cards to simulate scenarios:

| Scenario | Card Network | Card Number | CVV | Expiry date |
| - | - | - | - | - |
| Eligible card | Mastercard | 2222 6904 2006 4590 | Any 3 digit number | Any future expiry date |
| Eligible card | Mastercard | 2222 6904 2006 4574 | Any 3 digit number | Any future expiry date |
| Eligible card | Mastercard | 2222 6904 2006 4590 | Any 3 digit number | Any future expiry date |
| Eligible card | Mastercard | 5120 3501 0006 4594 | Any 3 digit number | Any future expiry date |
| Non-eligible card | Mastercard | 5460 1261 2820 0800 | Any 3 digit number | Any future expiry date |

To validate that the card was properly network tokenized, call GET to list the saved payment methods for a specific `customerId`. The field ["paymentMethod.isNetworkTokenized"](https://primer.io/docs/api-reference/v2.4/api-reference/payment-methods-api/list-saved-payment-methods.md#response.body.data.paymentMethodData.Payment%20Card%20Token%20API%20Schema.isNetworkTokenized) is set to `true` when the network token was successfully provisioned and attached to the vaulted card.

### Processing payments with network tokens

When a payment is created with a vaulted card that has been network tokenized, Primer automatically attempts to pass the network token to the processor, if the processor is supported.

You can test this by creating a payment with:

* the Payments API by following this [guide](https://primer.io/docs/payment-services/save-payment-methods.md#create-merchant-initiated-payments)
* or with the vault section of Universal Checkout, by selecting a vaulted card that was network tokenized

To validate that the payment used a network token, call GET with the payment ID to retrieve the payment object. The field ["cardTokenType"](https://primer.io/docs/api-reference/v2.4/api-reference/payments-api/get-a-payment.md#response.body.cardTokenType) is set to:

* `NETWORK_TOKEN` if the payment was processed with a network token
* `CARD_PAN` if the payment was processed with the raw credentials


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.