Receipt Generation
Basics
A complete example of generating a receipt is demonstrated in the following file:
./examples/document/receipt/create_receipt_with_custom_data.php
To generate a receipt, the following steps are required:
// 1. Creating a receipt
// (issuing a receipt in Hungarian language (Ft) paid in cash)
$receipt = new Receipt();
// 2. Initializing the header
$receipt->setHeader(new ReceiptHeader());
// 3. Setting the prefix
$receipt->getHeader()->setPrefix('RECEIPT');
// 4. Order number (optional) – typically a webshop order ID
$receipt->getHeader()->setOrderNumber('ORD-2026-0042');
// 5. Composing the receipt item with default data
// (1 sales item with 27% VAT content)
$item = new ReceiptItem('Sales item', 10000.0);
// a) Setting the net price of the item
$item->setNetPrice(10000.0);
// b) Setting the VAT amount of the item
$item->setVatAmount(2700.0);
// c) Setting the gross amount of the item
$item->setGrossAmount(12700.0);
// d) Adding item data to the receipt
$receipt->addItem($item);
// 6. Creating the receipt (generating)
$result = $agent->generateReceipt($receipt);
If you set an order number when generating (setOrderNumber), you can later retrieve the receipt data and PDF using the same identifier: Querying receipt data, Receipt PDF download.
info
The order number in the receipt header has been available since version 2.12.1. Querying receipt data and PDF by order number requires 2.12.2 or newer (see the changelog).
Expected and Optional Inputs
Receipt Header Data
| Description | Field | Type | Required | Default Value |
|---|---|---|---|---|
| Call ID | callId | string | ||
| Prefix | prefix | string | yes | |
| Payment Method | paymentMethod | string | yes | cash |
| Currency | currency | string | yes | Ft |
| Exchange Bank | exchangeBank | string | ||
| Exchange Rate | exchangeRate | string | ||
| Comment | comment | string | ||
| PDF Template | pdfTemplate | string | ||
| Buyer Ledger ID | buyerLedgerId | string | ||
| Order number | orderNumber | string |
Receipt Item Data
| Description | Field | Type | Required | Default Value |
|---|---|---|---|---|
| ID | id | string | ||
| Quantity | quantity | double | yes | |
| Quantity Unit | quantityUnit | string | yes | |
| Net Unit Price | netUnitPrice | double | yes | |
| VAT Rate | vat | string | yes | |
| Net Price | netPrice | double | yes | |
| VAT Amount | vatAmount | double | yes | |
| Gross Amount | grossAmount | double | yes | |
| Ledger Data | ledgerData | ReceiptItemLedger | ||
| Comment | comment | string | ||
| Count of Data eraser code | dataDeletionCode | integer |
Receipt Item Ledger Data
| Description | Field | Type | Required | Default Value |
|---|---|---|---|---|
| Revenue Ledger Number | revenueLedgerNumber | string | ||
| VAT Ledger Number | vatLedgerNumber | string |
Credit Note Data (Payment)
| Description | Field | Type | Required | Default Value |
|---|---|---|---|---|
| Payment Method | paymentMethod | string | yes | cash |
| Amount | amount | double | yes | |
| Description | description | string |