# Payer token
source: https://developer.mastercard.com/open-finance-europe/documentation/licensed/aiia-enterprise/payments/payer-token/index.md

Aiia Enterprise provides for a `payerToken` to be generated as part of a [Payment Request](https://developer.mastercard.com/open-finance-europe/documentation/licensed/aiia-enterprise/payments/requesting-payments/index.md) where Payment Service Users (PSU's) perform multiple transactions with a TPP. The `payerToken` can streamline the PSU's account selection journey, by skipping steps where the PSU chooses their account.

Please note however that this is dependent on the individual ASPSP's implementation. Some banks will still present an account selector screen to the PSU, even when the source account is specified in the request. Therefore, using a `payerToken` does not guarantee that the requested source account will be used to make the payment.
Note: TPPs should only send a `payerToken` if the PSU has confirmed that they want to use the source account they used previously.

### How it works {#how-it-works}

1. A PSU initiates a transaction from their account through the TPP.
2. The TPP submits a payment request to Aiia Enterprise.
3. The PSU authorizes the payment.
4. The TPP submits a request to Aiia Enterprise to generate a `payerToken`, which contains information about the source account used for the transaction.
5. Aiia Enterprise generates an encrypted `payerToken` and sends it to the TPP.
6. The TPP stores the `payerToken`.
7. When the PSU initiates a subsequent payment, the TPP includes the `payerToken` within their payment request to Aiia Enterprise.
8. Aiia Enterprise uses the `payerToken` to pre-populate the source account in the payment request to the bank.

### To link a payment account for the first time {#to-link-a-payment-account-for-the-first-time}

A request to create a `payerToken` is made using the `issuerPayerToken` parameter within the [Payment Request](https://developer.mastercard.com/open-finance-europe/documentation/licensed/aiia-enterprise/payments/requesting-payments/index.md).

|      **Name**      | **Type** |                                           **Description**                                           |
|--------------------|----------|-----------------------------------------------------------------------------------------------------|
| `issuerPayerToken` | boolean  | A `true` or `false` value to indicate that a `payerToken` will be created for this payment account. |

##### Example {#example}

Set `issuePayerToken` to `true` to request a `payerToken`:

```json
{
  "issuePayerToken": true,
  "payerToken": "<payer-token>",
  "providerId": "DemoBank",
  "providers": [ "DK" ],
}
```

#### Response {#response}

The returned `payerToken` can be located by calling **/v1/payments/{paymentId}/payer-token**.

```json
{
  "providerId": "DemoBank",
  "redactedAccountNumber": "1234 *******890",
  "expires": "2023-08-24T14:15:22.223+00:00",
  "payerToken": "<payer-token>"
}
```

The following sequence diagram shows the flow for requesting a `payerToken`.
Diagram link-payer-token

#### Subsequent times {#subsequent-times}

For subsequent requests, the `payerToken` is used to pre-populate the source account in the payment request to the bank.

|  **Name**  | **Type** |                                                    **Description**                                                     |
|------------|----------|------------------------------------------------------------------------------------------------------------------------|
| payerToken | `string` | Contains encrypted values about the source account. Used to pre-set values on the payment to shorten the payment flow. |

##### Example {#example-1}

Set `issuePayerToken` to `true` to request a `payerToken`:

```json
{
  "issuePayerToken": true,
  "payerToken": "<payer-token>",
  "providerId": "DemoBank",
  "providers": [ "DK" ],
}
```

The following sequence diagram shows the flow for subsequent calls using `payerToken`.
Diagram subsequent-payer-token
