> **Description:** Set up age verification requirements to ensure customers meet minimum age restrictions before completing their payments.

# Minimum user age

Set up age verification requirements to ensure customers meet minimum age restrictions before completing their payments.

For some purchases, it may be important to ensure that the buyer is over a legal age.
You can do this with the `minimumUserAge` parameter.

**TIP**

If you only need the payer's exact age, use the [User Info feature](https://developer.vippsmobilepay.com/docs/APIs/userinfo-api/userinfo-api-guide.md) instead.
The Vipps/MobilePay app will show a consent screen, letting the user know what information is being shared.
If you need to document that an age check was performed, you can log the payment requests for your records.

## Authorization

All ePayment API requests must include a valid Bearer token in the `Authorization` header.
See [Authorization](https://developer.vippsmobilepay.com/docs/APIs/epayment-api/api-guide/concepts.md#authorization) for how to obtain one.

## Creating a payment with minimum user age

To set the minimum age required for the customer to make the purchase,
make a
[`POST:/epayment/v1/payments`](https://developer.vippsmobilepay.com/redocusaurus/epayment-swagger-id.yaml)
request with `"minimumUserAge": <age>`.

For example:

```bash
curl -X POST https://apitest.vipps.no/epayment/v1/payments \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR-ACCESS-TOKEN" \
-H "Ocp-Apim-Subscription-Key: YOUR-SUBSCRIPTION-KEY" \
-H "Merchant-Serial-Number: YOUR-MSN" \
-H "Idempotency-Key: YOUR-IDEMPOTENCY-KEY" \
-H "Vipps-System-Name: acme" \
-H "Vipps-System-Version: 3.1.2" \
-H "Vipps-System-Plugin-Name: acme-webshop" \
-H "Vipps-System-Plugin-Version: 4.5.6" \
-d '{
   "amount":{
      "currency":"DKK",
      "value":16000
   },
   "customer":{
      "phoneNumber":"4712345678"
   },
   "minimumUserAge": 25,
   "paymentMethod":{
      "type":"WALLET"
   },
   "reference":"acme-shop-123-order123abcd",
   "paymentDescription": "Reference acme-shop-123-order123abcd. Thank you for shopping at our webshop!",
   "returnUrl":"https://example.com/redirect?reference=12345989434343",
   "userFlow":"WEB_REDIRECT"
}'
```

## User flows

If the user owning the phone number is younger than the specified age (in years), an error message will be provided.

### `QR` and app switch

This applies in the following scenarios:

* In [`WEB_REDIRECT` flow (universal links)](https://developer.vippsmobilepay.com/docs/APIs/epayment-api/api-guide/operations/create.md#web_redirect)
* In [`NATIVE_REDIRECT` flow](https://developer.vippsmobilepay.com/docs/APIs/epayment-api/api-guide/operations/create.md#native_redirect)
* In the [`QR` flow](https://developer.vippsmobilepay.com/docs/APIs/epayment-api/api-guide/operations/create.md#qr)

In these scenarios, the user's Vipps or MobilePay app will open with the payment request, but
if the user is less than the minimum age, they will see the detailed message: "Unfortunately you need to be at least `<age>` years old to pay to `<merchant's name>`".

Screenshot: The Vipps or MobilePay app showing a "Payment failed" screen with an illustration of three people, a message explaining the minimum age requirement, and an OK button at the bottom.

**TIP**

The payment is in `Created` state and eventually times out. So a relevant [webhook](https://developer.vippsmobilepay.com/docs/APIs/epayment-api/api-guide/webhooks.md) might be `epayments.payment.expired.v1`

### `WEB_REDIRECT` flow

In the `WEB_REDIRECT` flow (e.g., for apps and web shops),
the user will either get switched to the Vipps  or MobilePay  app
or go to the [landing page](https://developer.vippsmobilepay.com/docs/knowledge-base/landing-page.md).

* If the user is on a device where a Vipps or MobilePay app is installed, it will open automatically.
   If they don't meet the age requirements, they will see a detailed message, as shown for the
   [`QR` and app switch](#qr-and-app-switch) flows.

* If the user is on a device without a Vipps or MobilePay app, they will be directed to the
   [landing page](https://developer.vippsmobilepay.com/docs/knowledge-base/landing-page.md).
   There, they can enter their own phone number.
   If they don't meet the age requirements, the payment will not be sent to their app, and
   they will instead see a generic message (e.g., "You can't pay to this business").
   This message is generic for privacy reasons: Another user could use the phone number to get the age of the user.

Screenshot: The Vipps or MobilePay landing page displaying a generic error when the user does not meet the minimum age requirement.

### `PUSH_MESSAGE` flow

In the `PUSH_MESSAGE` flow (e.g., for POS), a payment request is pushed directly to a user's Vipps or MobilePay app.
However, this message is not sent if the user doesn't meet the age requirements.
Then, you will get a generic error message in the response to your API request.
The generic message protects the privacy of the individual.
We don't provide the age of customers without consent.

**NOTE**

**API error message:** &nbsp; `The phone number does not belong to a <Vipps|MobilePay> user, or the user cannot pay businesses.`

> **Full site overview:** For every page in this documentation, read [https://developer.vippsmobilepay.com/llms.txt](https://developer.vippsmobilepay.com/llms.txt).
