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

# Fetch and store payment tokens

> Retrieve a Dintero payment token after the customer completes card entry by polling the transaction with the includes query parameter and persist it securely.

When the customer has completed filling in their card info, the `return_url` and `callback_url` will receive a request.

When you get this request, the payment token will be stored on the transaction.
Use [get transaction details] to retrieve the transaction, with the query-param `includes`
to include the cards tokens

**example**:

* `?includes=card.payment_token`
* `?includes=card.recurrence_token`

The token will then be included in the card details, e.g. `card.payment_token`.

The card data contains `expiry_date` (format `MM/YYYY`). When tokenization is used, `card.expiry_date` will be the expiration date of the card itself if available.
If the card’s expiration date is unavailable, `card.expiry_date` will fall back to the token’s expiration date.

<Info>
  Store the token internally in a secure manner.
</Info>

## Fetching a card token

You can look up a stored token directly with [get card token], which returns the token's current status and card details without needing to go through a transaction.

### Token status

A card token has one of the following statuses:

| Status      | Description                                                                                                        |
| ----------- | ------------------------------------------------------------------------------------------------------------------ |
| `ACTIVE`    | The card is active and can be used for payment.                                                                    |
| `INACTIVE`  | The card has not been activated for payment yet.                                                                   |
| `SUSPENDED` | The card has been deactivated, for example if it's blocked. It can be reactivated later.                           |
| `DELETED`   | The card has been deleted. It can never become active again.                                                       |
| `CANCELLED` | The token has been deleted by the card issuer and can no longer be used to transact, per the card network's rules. |

### Attempting payment with a token

A newly created token isn't synced immediately, so [get card token] can return a `404` for a token that was just created even though the token itself is valid.

### External references for imported tokens

When importing cards from another PSP/acquirer, we store the reference you used there as an external token reference.
You can use this reference the same way you'd use a Dintero-issued token:

* Pass it as `token_id` to [get card token] to look up the token using the old PSP's reference.
* Pass it as the `payment_token` or `recurrence_token` value when creating a payment, instead of the Dintero-issued token — see [use a stored card token].

Note that if the same card appeared multiple times in the imported cards, these will refer to a single payment token within our system.
It is also recommended to switch to using the token's actual ID and payment token values instead of the old reference.

[get transaction details]: /api-reference/transactions/transactions_id_get

[get card token]: /api-reference/card-tokens/card_tokens_token_id_get

[use a stored card token]: /docs/checkout/tokenization-use-token
