Skip to content

Accept QR payments

View as Markdown

Overview

A QR payment lets your customer scan a code with a wallet or banking app. You create an invoice for the amount and show its QR code. TapPay tells you when the payment succeeds.

Before you begin

Your key needs the payments:write scope, and you use your secret key, shown below as sk_test_YOUR_SECRET_KEY. Use a sandbox key while you build, because sandbox payments move no money. You send no line items, so TapPay adds one line for the whole amount.

Steps

Create the invoice

Send the amount, a description and your own orderId. With a merchant-level key the terminalId is required; with a terminal-level key it is not. The response has the invoiceId, the intentId of the first payment intent and a stable deeplink for the customer.

curl -sS -X POST "https://api.tappay.mn/api/v1/invoices" \
  -H "Authorization: Bearer sk_test_YOUR_SECRET_KEY" \
  -H "TapPay-Version: 2026-09-27" \
  -H "Idempotency-Key: $(openssl rand -hex 16)" \
  -H "Content-Type: application/json" \
  -d '{"terminalId":"YOUR_TERMINAL_ID","amount":1000,"description":"Order 1","orderId":"order-'"$(uuidgen)"'"}'
import { TapPay } from '@tappay-mn/node';

const tappay = new TapPay({ apiKey: 'sk_test_YOUR_SECRET_KEY' });
const invoice = await tappay.invoices.create({
  body: {
    terminalId: 'YOUR_TERMINAL_ID',
    amount: 1000,
    description: 'Order 1',
    orderId: `order-${crypto.randomUUID()}`,
  },
});
console.log(JSON.stringify(invoice));
<?php
require 'vendor/autoload.php';

use TapPay\TapPay;

$tappay = new TapPay(['apiKey' => 'sk_test_YOUR_SECRET_KEY']);
$invoice = $tappay->invoices->create([
    'body' => [
        'terminalId' => 'YOUR_TERMINAL_ID',
        'amount' => 1000,
        'description' => 'Order 1',
        'orderId' => 'order-' . vsprintf('%s%s-%s-%s-%s-%s%s%s', str_split(bin2hex(random_bytes(16)), 4)) . '',
    ],
]);
echo json_encode($invoice);
import json
import uuid
import tappay

client = tappay.TapPay("sk_test_YOUR_SECRET_KEY")
invoice = client.invoices.create({
    "body": {
        "terminalId": "YOUR_TERMINAL_ID",
        "amount": 1000,
        "description": "Order 1",
        "orderId": "order-" + str(uuid.uuid4()) + "",
    },
})
print(json.dumps(invoice))

Show the QR code

Present the intent on the NODE_QR channel. The response has a qrText value, which you draw as a QR code on your screen or on paper. Use QPAY instead of NODE_QR to get a QPay QR code and bank app links.

curl -sS -X POST "https://api.tappay.mn/api/v1/intents/INTENT_ID/present" \
  -H "Authorization: Bearer sk_test_YOUR_SECRET_KEY" \
  -H "TapPay-Version: 2026-09-27" \
  -H "Idempotency-Key: $(openssl rand -hex 16)" \
  -H "Content-Type: application/json" \
  -d '{"channel":"NODE_QR"}'
import { TapPay } from '@tappay-mn/node';

const tappay = new TapPay({ apiKey: 'sk_test_YOUR_SECRET_KEY' });
const intent = await tappay.intents.present({ id: 'INTENT_ID', body: { channel: 'NODE_QR' } });
console.log(JSON.stringify(intent));
<?php
require 'vendor/autoload.php';

use TapPay\TapPay;

$tappay = new TapPay(['apiKey' => 'sk_test_YOUR_SECRET_KEY']);
$intent = $tappay->intents->present(['id' => 'INTENT_ID', 'body' => ['channel' => 'NODE_QR']]);
echo json_encode($intent);
import json
import tappay

client = tappay.TapPay("sk_test_YOUR_SECRET_KEY")
intent = client.intents.present({"id": "INTENT_ID", "body": {"channel": "NODE_QR"}})
print(json.dumps(intent))

A dynamic QR code carries the amount and works for one payment. A static QR code is printed, has no amount, and TapPay creates a new invoice each time a customer scans it.

Pay in the sandbox

Let the simulator act as the customer who scans the code. It works only with a sandbox key. The outcome can be SUCCEEDED, DECLINED or TIMEOUT, and the response has the payment id.

curl -sS -X POST "https://api.tappay.mn/api/v1/sandbox/intents/INTENT_ID/simulate" \
  -H "Authorization: Bearer sk_test_YOUR_SECRET_KEY" \
  -H "TapPay-Version: 2026-09-27" \
  -H "Idempotency-Key: $(openssl rand -hex 16)" \
  -H "Content-Type: application/json" \
  -d '{"channel":"QR","outcome":"SUCCEEDED"}'
import { TapPay } from '@tappay-mn/node';

const tappay = new TapPay({ apiKey: 'sk_test_YOUR_SECRET_KEY' });
const result = await tappay.sandbox.simulateIntent({ id: 'INTENT_ID', body: { channel: 'QR', outcome: 'SUCCEEDED' } });
console.log(JSON.stringify(result));
<?php
require 'vendor/autoload.php';

use TapPay\TapPay;

$tappay = new TapPay(['apiKey' => 'sk_test_YOUR_SECRET_KEY']);
$result = $tappay->sandbox->simulateIntent(['id' => 'INTENT_ID', 'body' => ['channel' => 'QR', 'outcome' => 'SUCCEEDED']]);
echo json_encode($result);
import json
import tappay

client = tappay.TapPay("sk_test_YOUR_SECRET_KEY")
result = client.sandbox.simulate_intent({"id": "INTENT_ID", "body": {"channel": "QR", "outcome": "SUCCEEDED"}})
print(json.dumps(result))

Confirm the payment

Read the payment from your server and check that its status is SUCCEEDED. Mark the order as paid only after that, and never because the customer says the QR code was scanned.

curl -sS "https://api.tappay.mn/api/v1/payments/PAYMENT_ID" \
  -H "Authorization: Bearer sk_test_YOUR_SECRET_KEY" \
  -H "TapPay-Version: 2026-09-27"
import { TapPay } from '@tappay-mn/node';

const tappay = new TapPay({ apiKey: 'sk_test_YOUR_SECRET_KEY' });
const payment = await tappay.payments.retrieve({ id: 'PAYMENT_ID' });
console.log(JSON.stringify(payment));
<?php
require 'vendor/autoload.php';

use TapPay\TapPay;

$tappay = new TapPay(['apiKey' => 'sk_test_YOUR_SECRET_KEY']);
$payment = $tappay->payments->retrieve(['id' => 'PAYMENT_ID']);
echo json_encode($payment);
import json
import tappay

client = tappay.TapPay("sk_test_YOUR_SECRET_KEY")
payment = client.payments.retrieve({"id": "PAYMENT_ID"})
print(json.dumps(payment))

Verify

When the payment succeeds, TapPay sends the payment.succeeded event to your webhook endpoint. Handle it as described in the webhooks guide, then read the payment with the request above. The invoice status becomes PAID, and TapPay also sends invoice.paid.

Common mistakes

  • Letting two customers pay the same dynamic QR code. The second payment gets the OVERPAID status, and TapPay refunds it automatically, without a fee.
  • Reusing a dynamic QR code. It is single use: after a payment its qrStatus is USED, so create a new intent for the next payment.
  • Treating a static QR code like a dynamic one. Its code starts with SQR, has no amount, and each scan makes a new invoice.
  • Marking an order as paid while the status is PROCESSING. Wait for SUCCEEDED or the payment.succeeded event.
  • Sending the same orderId twice for one terminal. TapPay rejects the second invoice as a duplicate, even with a new Idempotency-Key.

Next steps

Listen for payments with the webhooks guide. Break an order into lines with the orders guide, and offer more ways to pay with the channels guide. To show the amount on the sticker at your till, see the stickers guide. To accept QR payments without code, see QR payments in the portal. See every field in Create an invoice, Present a payment intent and Retrieve a payment.