> **Description:** Generate one-time QR codes for secure in-store payments, allowing customers to complete transactions by scanning with their Vipps or MobilePay app.

> **AI agent:** Read [https://developer.vippsmobilepay.com/docs/knowledge-base/ai-tools.md](https://developer.vippsmobilepay.com/docs/knowledge-base/ai-tools.md) first. It covers keeping API keys and secrets out of generated code.

> **Full site overview:** For an overview of the entire site, read [https://developer.vippsmobilepay.com/llms.txt](https://developer.vippsmobilepay.com/llms.txt).

# One-time payment QR

Generate one-time QR codes for in-store payments. Scanning opens the Vipps or MobilePay app for instant approval--no phone number needed.

When using the ePayment API, the QR code comes back from the payment request itself, so there is no call to the
[QR API](https://developer.vippsmobilepay.com/docs/APIs/qr-api/README.md). The QR API is only needed for the
[Recurring API](https://developer.vippsmobilepay.com/docs/APIs/recurring-api/README.md) or the legacy eCom API, or when you need a printed code that is not tied to
a single payment.

**TIP**

For a visual walkthrough of the customer's experience with one-time payment QR codes, see [How it works with QR codes](https://developer.vippsmobilepay.com/docs/APIs/epayment-api/how-it-works/qr.md).

## Scenario

Generate the payment request with the
[`POST:/epayment/v1/payments`](https://developer.vippsmobilepay.com/redocusaurus/epayment-swagger-id.yaml) endpoint with:

* `"userFlow": "QR"`.
* (Optional) `qrFormat` and `size` for the QR

Image: A one-time payment QR code displayed on a merchant screen for a customer to scan with their Vipps or MobilePay app.

Since the customer will scan from their phone, you don't need their phone number.
This payment command can do an app-switch and open their Vipps or MobilePay app with the payment request.

## 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.

## Request

Generate the payment request with dynamic QR:

```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 '{
  "userFlow": "QR",
  "qrFormat": {
    "format": "IMAGE/SVG+XML"
  },
  "amount": {
    "value": 42924,
    "currency": "NOK"
  },
  "paymentMethod": {
    "type": "WALLET"
  },
  "customerInteraction": "CUSTOMER_PRESENT",
  "receipt":{
    "orderLines": [
      {
        "name": "Ear buds",
        "id": "21231211",
        "totalAmount": 42924,
        "totalAmountExcludingTax": 34339,
        "totalTaxAmount": 8585,
        "taxRate": 2500
      }
    ],
    "bottomLine": {
      "currency": "NOK",
      "posId": "vending_machine_12345",
      "receiptNumber": "0527013501"
    }
  },
  "reference": "2486791679658155992",
  "returnUrl": "http://example.com/redirect?reference=2486791679658155992",
  "paymentDescription": "Ear buds"
}'
```

Specify `"customerInteraction": "CUSTOMER_PRESENT"`, since the customer is present.
You can also specify the order details at this time.

Display the dynamic QR on a screen facing the customer.

When the customer scans the QR code and is directed to the Vipps or MobilePay app,
the payment screen is presented and they click *Pay*.

Once the payment is approved, update the status in your system.
To determine that the user has authorized the payment, you can
get notifications via the [Webhooks API](https://developer.vippsmobilepay.com/docs/APIs/webhooks-api/api-guide.md) and/or poll for the status.

The result of this request will contain a `redirectUrl` pointing to a link where you can download the QR image.

## Sequence diagram

Dynamic QR directing to the app

```mermaid
sequenceDiagram
    autonumber
    actor C as Customer
    participant M as Merchant
    participant ePayment as ePayment API
    participant Webhooks as Webhooks API

    C->>M: Select the products
    M->>ePayment: Request a payment with userFlow QR
    ePayment-->>M: Return the one-time payment QR
    M->>C: Display the one-time QR on a screen facing the customer
    C->>ePayment: Scan the QR, select a card, and confirm the payment
    Webhooks-->>M: Webhook: the payment was authorized, aborted, or expired
    M->>ePayment: Poll for payment info, as a backup if the webhook is delayed or missed
    ePayment-->>M: Current state of the payment
    alt The payment was aborted or expired
        M->>M: Remove the QR and return the customer to the checkout screen
    else The payment was authorized
        M->>ePayment: Capture payment
        ePayment-->>M: Status of capture
        M->>M: Verify status of POS matches capture
    end
```

  Customer selects the products.
  Merchant requests a payment with a QR user flow via the ePayment API.
  ePayment API returns the one-time payment QR to the merchant.
  Merchant displays the one-time QR on a screen facing the customer.
  Customer scans the QR, selects a card, and confirms the payment.
  Webhooks API sends the merchant an authorized, aborted, or expired event.
  Merchant gets the payment from the ePayment API, as a backup if the webhook is delayed or missed.
  ePayment API returns the current state of the payment.
  If the payment was aborted or expired, the merchant removes the QR and returns the customer to the checkout screen, and
  the flow ends.
  If the payment was authorized, the merchant captures the payment via the ePayment API.
  ePayment API returns the status of the capture.
  Merchant verifies that the POS status matches the capture.

## Related pages

* [How it works guide for one-time payment QRs](https://developer.vippsmobilepay.com/docs/APIs/epayment-api/how-it-works/qr.md)
* [Recommended flows: Dynamic QR directing to the app for payment](https://developer.vippsmobilepay.com/docs/recommended-flows/vending-machines/one-time-payment.md)
