Skip to content

Simulate an embedded payment

View as Markdown

Sandbox only. Used by the checkout script to test the customer’s payment with a test card or a QR scan, without moving real money.

Changes in 2026-09-27

POST /api/checkout/embedded/sessions/{id}/sandbox/simulate

Authentication

Publishable key + X-Client-Secret

Headers

NameTypeRequiredValuesDescription
X-Client-Secretstringyes

Path parameters

NameTypeRequiredValuesDescription
idstring (uuid)yes

Request body

NameTypeRequiredValuesDescription
channelstringyesQPAY, NODE_QR, WECHAT, CARD, R2P
outcomestringnoSUCCEEDED, DECLINED, TIMEOUT
cardobjectno
card.panstringyes
card.expirystringyes
card.cvvstringyes
consentbooleanno

Response 201

NameTypeRequiredValuesDescription
successbooleanyestrue
dataobjectyes
data.paymentobjectyes
data.payment.idstringyes
data.payment.statusstringyes
data.payment.failureCodestring | nullyes

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-010422The requested payment channel is not available for this payment.
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.
SET-002400A required platform setting is missing or unknown.
FSC-013500The fee could not be calculated because the destination cannot be resolved.
EVT-201403This operation is not available for the key environment: sandbox-only operations need a sandbox key, and the others need a production key.
EVT-202422The test card number is not a known sandbox test card.
EVT-203409The payment intent is not open, so it cannot be simulated.
EVT-205422The channel is not available in the sandbox.
AFP-001409The payment intent is locked by another operation.
PSP-003422The provider terminal required for this payment is not configured.
PRE-005409The payment is not a pre-authorization.
curl -sS -X POST "https://api.tappay.mn/api/checkout/embedded/sessions/SESSION_ID/sandbox/simulate" \
  -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","card":{"pan":"4242424242424242","expiry":"12/30","cvv":"123"},"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/sandbox/simulate', {
  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',
    card: {
      pan: '4242424242424242',
      expiry: '12/30',
      cvv: '123',
    },
    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',
    'card' => [
        'pan' => '4242424242424242',
        'expiry' => '12/30',
        'cvv' => '123',
    ],
    'consent' => true,
]);
$ch = curl_init('https://api.tappay.mn/api/checkout/embedded/sessions/SESSION_ID/sandbox/simulate');
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/sandbox/simulate',
    data=json.dumps({
        'channel': 'CARD',
        'card': {
            'pan': '4242424242424242',
            'expiry': '12/30',
            'cvv': '123',
        },
        '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": {
    "payment": {
      "id": "0192f8a4-1b2c-7d3e-8f40-5a6b7c8d9e04",
      "status": "SUCCEEDED",
      "failureCode": null
    }
  }
}

For the full flow, read the guide.