# Төлбөрийн баримт илгээх

> Таны баримтыг ebarimt бүртгэлтэй эсвэл бүртгэлгүйгээр төлбөрт хавсаргана.

Эх: https://docs.tappay.mn/mn/reference/receipts/submit/

Таны баримтыг ebarimt бүртгэлтэй эсвэл бүртгэлгүйгээр [төлбөрт](https://docs.tappay.mn/mn/glossary.md#payment) хавсаргана. Баримтын `amount`-ыг, ebarimt гаргасан бол түүний `ddtd`, сугалааны дугаарыг илгээнэ.

`POST /api/v1/payments/{id}/receipt` Хувилбар 2026-09-27

### Нэвтрэлт

Secret key (Bearer)

### Header

| Нэр | Төрөл | Заавал | Утга | Тайлбар |
| - | - | - | - | - |
| `TapPay-Version` | string | үгүй | | |
| `TapPay-Timestamp` | string | үгүй | | |
| `TapPay-Nonce` | string | үгүй | | |
| `TapPay-Signature` | string | үгүй | | |
| `Idempotency-Key` | string | тийм | | |

### Замын параметр

| Нэр | Төрөл | Заавал | Утга | Тайлбар |
| - | - | - | - | - |
| `id` | string (uuid) | тийм | | |

### Хүсэлтийн бие

| Нэр | Төрөл | Заавал | Утга | Тайлбар |
| - | - | - | - | - |
| `receiptKind` | string | тийм | `WITH_EBARIMT`, `WITHOUT_EBARIMT` | |
| `receiptType` | string | үгүй | `B2C`, `B2B`, `SALES` | |
| `ddtd` | string | үгүй | | |
| `lottery` | string | үгүй | | |
| `qrData` | string | үгүй | | |
| `url` | string | үгүй | | |
| `merchantReceiptNo` | string | үгүй | | |
| `amount` | string | тийм | | |
| `vat` | string | үгүй | | |
| `cityTax` | string | үгүй | | |
| `issuedAt` | string | тийм | | |
| `lines` | array\<object> | үгүй | | |
| `lines[].name` | string | тийм | | |
| `lines[].quantity` | string | тийм | | |
| `lines[].unitPrice` | string | тийм | | |
| `lines[].totalAmount` | string | тийм | | |
| `lines[].classificationCode` | string | үгүй | | |
| `lines[].measureUnit` | string | үгүй | | |
| `lines[].taxProductCode` | string | үгүй | | |
| `lines[].barCode` | string | үгүй | | |
| `lines[].barCodeType` | string | үгүй | `GS1`, `ISBN`, `UNDEFINED` | |

### Хариу 201

| Нэр | Төрөл | Заавал | Утга | Тайлбар |
| - | - | - | - | - |
| `success` | boolean | тийм | `true` | |
| `data` | object | тийм | | |
| `data.receipt` | object | тийм | | |
| `data.receipt.id` | string (uuid) | тийм | | |
| `data.receipt.status` | string | тийм | `PENDING`, `REGISTERED`, `FAILED`, `RETURNED` | |
| `data.receipt.issuer` | string | тийм | `MERCHANT`, `NODE` | |
| `data.receipt.receiptType` | string \| null | тийм | `B2C`, `B2B`, `SALES`, `null` | |
| `data.receipt.ddtd` | string \| null | тийм | | |
| `data.receipt.lottery` | string \| null | тийм | | |
| `data.receipt.qrData` | string \| null | тийм | | |
| `data.receipt.url` | string \| null | тийм | | |
| `data.receipt.merchantReceiptNo` | string \| null | тийм | | |
| `data.receipt.amount` | string \| null | тийм | | |
| `data.receipt.vat` | string \| null | тийм | | |
| `data.receipt.cityTax` | string \| null | тийм | | |
| `data.receipt.issuedAt` | string \| null | тийм | | |
| `data.receipt.returnedAt` | string \| null | тийм | | |
| `data.receipt.failureReason` | string \| null | тийм | | |
| `data.receipt.lines` | array \| null | тийм | | |
| `data.receipt.attempts` | integer | тийм | | |
| `data.receipt.nextAttemptAt` | string \| null | тийм | | |
| `data.receipt.recipientFallback` | boolean | тийм | | |
| `data.receipt.parts` | array \| null | тийм | | |
| `data.history` | array\<object> | тийм | | |
| `data.history[].id` | string (uuid) | тийм | | |
| `data.history[].status` | string | тийм | `PENDING`, `REGISTERED`, `FAILED`, `RETURNED` | |
| `data.history[].issuer` | string | тийм | `MERCHANT`, `NODE` | |
| `data.history[].receiptType` | string \| null | тийм | `B2C`, `B2B`, `SALES`, `null` | |
| `data.history[].ddtd` | string \| null | тийм | | |
| `data.history[].lottery` | string \| null | тийм | | |
| `data.history[].qrData` | string \| null | тийм | | |
| `data.history[].url` | string \| null | тийм | | |
| `data.history[].merchantReceiptNo` | string \| null | тийм | | |
| `data.history[].amount` | string \| null | тийм | | |
| `data.history[].vat` | string \| null | тийм | | |
| `data.history[].cityTax` | string \| null | тийм | | |
| `data.history[].issuedAt` | string \| null | тийм | | |
| `data.history[].returnedAt` | string \| null | тийм | | |
| `data.history[].failureReason` | string \| null | тийм | | |
| `data.history[].lines` | array \| null | тийм | | |
| `data.history[].attempts` | integer | тийм | | |
| `data.history[].nextAttemptAt` | string \| null | тийм | | |
| `data.history[].recipientFallback` | boolean | тийм | | |
| `data.history[].parts` | array \| null | тийм | | |

### Алдаа

| Код | Status | Мессеж |
| - | - | - |
| [`AUTH-001`](https://docs.tappay.mn/mn/errors.md#AUTH-001) | 401 | API key байхгүй, буруу эсвэл хүчингүй болсон байна. |
| [`EVT-206`](https://docs.tappay.mn/mn/errors.md#EVT-206) | 401 | Production key sandbox-д хүлээн авахгүй. Sandbox key (sk_test\_/pk_test\_) ашиглана уу. |
| [`EVT-207`](https://docs.tappay.mn/mn/errors.md#EVT-207) | 401 | Sandbox key production-д хүлээн авахгүй. Production key (sk_live\_/pk_live\_) ашиглана уу. |
| [`AUTH-018`](https://docs.tappay.mn/mn/errors.md#AUTH-018) | 403 | Хүсэлт түлхүүрийн зөвшөөрөгдсөн IP жагсаалтад ороогүй хаягаас ирсэн. |
| [`AUTH-058`](https://docs.tappay.mn/mn/errors.md#AUTH-058) | 403 | API key-д энэ үйлдэлд шаардлагатай scope байхгүй байна. |
| [`SIG-002`](https://docs.tappay.mn/mn/errors.md#SIG-002) | 401 | Хүсэлтийн цагийн тэмдэг зөвшөөрөгдсөн хугацааны гадна байна. |
| [`SIG-003`](https://docs.tappay.mn/mn/errors.md#SIG-003) | 401 | Хүсэлтийн гарын үсэг байхгүй эсвэл таарахгүй байна. |
| [`SIG-005`](https://docs.tappay.mn/mn/errors.md#SIG-005) | 409 | Энэ хүсэлтийн nonce өмнө нь ашиглагдсан байна. |
| [`VAL-014`](https://docs.tappay.mn/mn/errors.md#VAL-014) | 400 | TapPay-Version header нь мэдэгдэх API хувилбар биш байна. |
| [`BIZ-004`](https://docs.tappay.mn/mn/errors.md#BIZ-004) | 403 | Terminal идэвхгүй байна. |
| [`BIZ-005`](https://docs.tappay.mn/mn/errors.md#BIZ-005) | 403 | Мерчантын данс энэ хүсэлтийг зөвшөөрөх төлөвт байхгүй байна. |
| [`VAL-002`](https://docs.tappay.mn/mn/errors.md#VAL-002) | 400 | Заавал байх талбар эсвэл header дутуу байна. |
| [`VAL-010`](https://docs.tappay.mn/mn/errors.md#VAL-010) | 409 | Энэ Idempotency-Key өөр хүсэлтийн биетэй өмнө нь ашиглагдсан байна. |
| [`VAL-013`](https://docs.tappay.mn/mn/errors.md#VAL-013) | 409 | Энэ Idempotency-Key-тэй хүсэлт боловсруулагдаж байна. |
| [`VAL-001`](https://docs.tappay.mn/mn/errors.md#VAL-001) | 400 | Хүсэлт шалгалтад тэнцсэнгүй. |

Playground-д туршиж үзэх: https://docs.tappay.mn/mn/reference/receipts/submit/

```bash title="curl"
curl -sS -X POST "https://api.tappay.mn/api/v1/payments/PAYMENT_ID/receipt" \
  -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 '{"receiptKind":"WITH_EBARIMT","receiptType":"B2C","ddtd":"DDTD-EXAMPLE-0001","merchantReceiptNo":"rcpt-'"$(uuidgen)"'","amount":"1000","vat":"90.91","issuedAt":"2026-10-03T10:00:00Z","lines":[{"name":"Order 1","quantity":"1","unitPrice":"1000","totalAmount":"1000"}]}'
```

```js title="Node.js"
import { TapPay } from '@tappay-mn/node';

const tappay = new TapPay({ apiKey: 'sk_test_YOUR_SECRET_KEY' });
const receipt = await tappay.receipts.submit({
  id: 'PAYMENT_ID',
  body: {
    receiptKind: 'WITH_EBARIMT',
    receiptType: 'B2C',
    ddtd: 'DDTD-EXAMPLE-0001',
    merchantReceiptNo: `rcpt-${crypto.randomUUID()}`,
    amount: '1000',
    vat: '90.91',
    issuedAt: '2026-10-03T10:00:00Z',
    lines: [
      {
        name: 'Order 1',
        quantity: '1',
        unitPrice: '1000',
        totalAmount: '1000',
      },
    ],
  },
});
console.log(JSON.stringify(receipt));
```

```php title="PHP"
<?php
require 'vendor/autoload.php';

use TapPay\TapPay;

$tappay = new TapPay(['apiKey' => 'sk_test_YOUR_SECRET_KEY']);
$receipt = $tappay->receipts->submit([
    'id' => 'PAYMENT_ID',
    'body' => [
        'receiptKind' => 'WITH_EBARIMT',
        'receiptType' => 'B2C',
        'ddtd' => 'DDTD-EXAMPLE-0001',
        'merchantReceiptNo' => 'rcpt-' . vsprintf('%s%s-%s-%s-%s-%s%s%s', str_split(bin2hex(random_bytes(16)), 4)) . '',
        'amount' => '1000',
        'vat' => '90.91',
        'issuedAt' => '2026-10-03T10:00:00Z',
        'lines' => [
            [
                'name' => 'Order 1',
                'quantity' => '1',
                'unitPrice' => '1000',
                'totalAmount' => '1000',
            ],
        ],
    ],
]);
echo json_encode($receipt);
```

```python title="Python"
import json
import uuid
import tappay

client = tappay.TapPay("sk_test_YOUR_SECRET_KEY")
receipt = client.receipts.submit({
    "id": "PAYMENT_ID",
    "body": {
        "receiptKind": "WITH_EBARIMT",
        "receiptType": "B2C",
        "ddtd": "DDTD-EXAMPLE-0001",
        "merchantReceiptNo": "rcpt-" + str(uuid.uuid4()) + "",
        "amount": "1000",
        "vat": "90.91",
        "issuedAt": "2026-10-03T10:00:00Z",
        "lines": [
            {
                "name": "Order 1",
                "quantity": "1",
                "unitPrice": "1000",
                "totalAmount": "1000",
            },
        ],
    },
})
print(json.dumps(receipt))
```

```json title="Response"
{
  "success": true,
  "data": {
    "receipt": {
      "id": "0192f8a4-1b2c-7d3e-8f40-5a6b7c8d9e07",
      "status": "REGISTERED",
      "issuer": "MERCHANT",
      "receiptType": "B2C",
      "ddtd": "DDTD-EXAMPLE-0001",
      "lottery": null,
      "qrData": null,
      "url": null,
      "merchantReceiptNo": "rcpt-4f2a9c1b7e30",
      "amount": "1000",
      "vat": "90.91",
      "cityTax": null,
      "issuedAt": "2026-10-03T10:00:00.000Z",
      "returnedAt": null,
      "failureReason": null,
      "lines": [
        {
          "name": "Order 1",
          "quantity": "1",
          "unitPrice": "1000",
          "totalAmount": "1000"
        }
      ],
      "attempts": 0,
      "nextAttemptAt": null,
      "recipientFallback": false,
      "parts": null
    },
    "history": []
  }
}
```

> **Сануулга:** **Цагтаа илгээ**
>
> `ebarimt_merchant_timeout`, 24 цаг, дуусахаас өмнө баримтыг илгээ. Үүний дараа баримт `FAILED` болж `MERCHANT_TIMEOUT` авна.

Бүтэн урсгалыг [гарын авлагаас](https://docs.tappay.mn/mn/guides/receipts.md) үзнэ үү.
