Skip to content

Present an embedded session

View as Markdown

Used by the TapPay checkout script when the customer picks a payment channel. It returns what the customer needs to pay and records the customer’s consent.

Changes in 2026-09-27

POST /api/checkout/embedded/sessions/{id}/present

Authentication

Publishable key + X-Client-Secret

Headers

NameTypeRequiredValuesDescription
X-Client-Secretstringyes
Idempotency-Keystringyes

Path parameters

NameTypeRequiredValuesDescription
idstring (uuid)yes

Request body

NameTypeRequiredValuesDescription
channelstringyesQPAY, NODE_QR, WECHAT, CARD, R2P
consentbooleanno

Response 201

NameTypeRequiredValuesDescription
successbooleanyestrue
dataobjectyes
data.kindstringyesCARD, PRESENTATION
data.attemptTokenstringno
data.presentationobjectno
data.presentation.channelstringyesQPAY, NODE_QR, WECHAT, CARD, R2P
data.presentation.displaystringyesCARD_FORM, QR, WALLET_REQUEST
data.presentation.qrTextstring | nullyes
data.presentation.linksarray<object>yes
data.presentation.links[].labelstringyes
data.presentation.links[].logoUrlstring | nullyes
data.presentation.links[].urlstringyes
data.presentation.expiresAtstringyes

Errors

CodeStatusMessage
VAL-002400A required field or header is missing.
VAL-010409This Idempotency-Key was already used with a different request body.
VAL-013409A request with this Idempotency-Key is still being processed.
VAL-014400The TapPay-Version header is not a known API version.
AUTH-001401The API key is missing, invalid or revoked.
AUTH-058403The API key does not have the scope this operation requires.
PAY-001404The invoice was not found.
PAY-010422The requested payment channel is not available for this payment.
PAY-012409The payment intent is no longer open.
PAY-033409The checkout session is not open.
PAY-034404The checkout session was not found, or the client secret does not match.
PAY-035422The payer's consent is required for this payment.
BIZ-004403The terminal is not active.
BIZ-005403The merchant account is not in a state that allows this request.
AFP-003410The payment intent has expired.
PSP-003422The provider terminal required for this payment is not configured.
curl -sS -X POST "https://api.tappay.mn/api/checkout/embedded/sessions/SESSION_ID/present" \
  -H "Authorization: Bearer pk_test_YOUR_PUBLISHABLE_KEY" \
  -H "X-Client-Secret: CLIENT_SECRET" \
  -H "TapPay-Version: 2026-09-27" \
  -H "Idempotency-Key: $(openssl rand -hex 16)" \
  -H "Content-Type: application/json" \
  -d '{"channel":"CARD","consent":true}'

The SDKs do not cover this API (browser checkout script) — the example calls HTTP directly.

const res = await fetch('https://api.tappay.mn/api/checkout/embedded/sessions/SESSION_ID/present', {
  method: 'POST',
  headers: {
    Authorization: 'Bearer pk_test_YOUR_PUBLISHABLE_KEY',
    'X-Client-Secret': 'CLIENT_SECRET',
    'TapPay-Version': '2026-09-27',
    'Idempotency-Key': crypto.randomUUID(),
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    channel: 'CARD',
    consent: true,
  }),
});
console.log(await res.text());

The SDKs do not cover this API (browser checkout script) — the example calls HTTP directly.

<?php
$body = json_encode([
    'channel' => 'CARD',
    'consent' => true,
]);
$ch = curl_init('https://api.tappay.mn/api/checkout/embedded/sessions/SESSION_ID/present');
curl_setopt_array($ch, [
    CURLOPT_CUSTOMREQUEST => 'POST',
    CURLOPT_POSTFIELDS => $body,
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_HTTPHEADER => [
        'Authorization: Bearer pk_test_YOUR_PUBLISHABLE_KEY',
        'X-Client-Secret: CLIENT_SECRET',
        'TapPay-Version: 2026-09-27',
        'Idempotency-Key: ' . bin2hex(random_bytes(16)),
        'Content-Type: application/json',
    ],
]);
echo curl_exec($ch);

The SDKs do not cover this API (browser checkout script) — the example calls HTTP directly.

import json, urllib.request, uuid

req = urllib.request.Request(
    'https://api.tappay.mn/api/checkout/embedded/sessions/SESSION_ID/present',
    data=json.dumps({
        'channel': 'CARD',
        'consent': True,
    }).encode(),
    method='POST',
    headers={
        'Authorization': 'Bearer pk_test_YOUR_PUBLISHABLE_KEY',
        'X-Client-Secret': 'CLIENT_SECRET',
        'TapPay-Version': '2026-09-27',
        'Idempotency-Key': str(uuid.uuid4()),
        'Content-Type': 'application/json',
    },
)
print(urllib.request.urlopen(req).read().decode())
{
  "success": true,
  "data": {
    "kind": "CARD",
    "attemptToken": "att_7f3a91c2d4e8"
  }
}

For the full flow, read the guide.