> **Description:** This flow uses a Merchant Callback QR to verify customer age at vending machines before allowing purchase.

# Age check

Customer scans a QR code on a vending machine, completes the steps in our app, and the merchant verifies that the customer meets the minimum age requirement before allowing the purchase.

Four-screen age check flow in the app (Vipps or MobilePay): (1) Phone camera showing a QR code to scan. (2) "Start age check?" screen asking to confirm sharing age information, with a Continue button. (3) "Verifying age..." screen showing verification in progress. (4) "Over 18 years" confirmation screen with an OK button.

## One-time merchant setup

**Register webhook** - Register a webhook for the `user.checked-in.v1` event. This is the URL where Vipps MobilePay sends events whenever a customer scans one of your Callback QRs. This only needs to be done once per merchant. See [Register a webhook](https://developer.vippsmobilepay.com/docs/APIs/qr-api/api-guide/webhooks.md#user-checked-in-event).

## Per vending machine setup

**Create Callback QR** - For each vending machine, create a [Merchant Callback QR](https://developer.vippsmobilepay.com/redocusaurus/qr-swagger-id.yaml) with a `merchantQrId` and set `category` to `AGE_CHECK`. Display the QR image on the vending machine and store the `merchantQrId` in your system to identify which vending machine the customer is at.

## Per customer interaction flow

1. **Customer scans QR** - The customer scans the Callback QR on the vending machine using their phone camera or through the Vipps MobilePay app.
2. **Vipps MobilePay app opens** - The app opens automatically and starts an age-check flow for the customer.
3. **Receive webhook** - Vipps MobilePay sends a `user.checked-in.v1` webhook containing the `customerToken` and `merchantQrId` (used to identify which vending machine is being used).
4. **Perform age check** - Call the [Age Check endpoint](https://developer.vippsmobilepay.com/redocusaurus/qr-swagger-id.yaml) with the `customerToken` (nested under `customer`) and the required `minAge` (e.g., 16).
5. **Receive result** - Vipps MobilePay responds with `ageCheck: true` (allow purchase) or `ageCheck: false` (block purchase).

View sequence diagram

Age check at vending machine

```mermaid
sequenceDiagram
    autonumber
    actor C as Customer
    participant M as Merchant
    participant Vipps as Vipps MobilePay API

    Note over M,Vipps: One-time setup
    M->>Vipps: Register Webhook (user.checked-in.v1)

    Note over M,Vipps: Per vending machine setup
    M->>Vipps: Create Vipps MobilePay Callback QR (merchantQrId, msn, category=AGE_CHECK)

    Note over C,Vipps: Customer flow
    C->>Vipps: Customer scans QR with camera or Vipps MobilePay app
    C->>C: Vipps MobilePay app opens and user completes age check
    Vipps-->>M: Webhook: user.checked-in.v1 (customerToken, msn, merchantQrId)
    M->>Vipps: Age check endpoint (customer.customerToken, minAge = 16)
    Vipps-->>M: Response (ageCheck: true)
```

  One-time setup: Merchant registers a webhook for the user.checked-in.v1 event with Vipps MobilePay.
  Per-machine setup: Merchant creates a Vipps MobilePay Callback QR code with a merchantQrId, MSN, and category set to AGE_CHECK.
  Customer scans the QR code using their phone camera or the Vipps MobilePay app.
  Vipps MobilePay app opens and the user completes the age check.
  Vipps MobilePay sends the merchant a user.checked-in.v1 webhook with a customerToken, MSN, and merchantQrId.
  Merchant calls the age check endpoint with the customerToken and a minimum age of 16.
  Vipps MobilePay returns the age check result (ageCheck: true).

## Technical details

- [QR API guide](https://developer.vippsmobilepay.com/docs/APIs/qr-api/README.md) - Overview of the QR API
- [Merchant Callback QR](https://developer.vippsmobilepay.com/docs/APIs/qr-api/api-guide/merchant-callback.md#callback-from-qr) - How to set up callback QR codes
- [Webhooks API](https://developer.vippsmobilepay.com/docs/APIs/webhooks-api/README.md) - How to register and manage webhooks

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