Skip to main content

Querying Receipt Data

Basics

The data of an existing receipt can be queried by receipt number or order number. The downloadable package includes ./examples/document/receipt/get_receipt_data.php for the receipt-number case; see the code sample below for the order-number call.

tip

When querying by order number, the API returns the document associated with that order number (same “last matching document” behaviour as invoice queries).

Example:

use SzamlaAgent\Document\Receipt\Receipt;

// Receipt number (default type – Receipt::FROM_DOCUMENT_NUMBER):
$agent->getReceiptData('NYGTA-2021-001');
// or explicitly:
$agent->getReceiptData('NYGTA-2021-001', Receipt::FROM_DOCUMENT_NUMBER);

// Order number:
$agent->getReceiptData('ORD-2026-0042', Receipt::FROM_ORDER_NUMBER);
// Document::FROM_ORDER_NUMBER is the same value.

// Object holding the receipt data for further processing:
$result->getDataObj();

For setting the order number at generation time, see Receipt generation. For PDF download, see Receipt PDF download.

Expected and Optional Inputs

DescriptionFieldTypeRequiredDefault
Receipt numberreceiptNumberstringyes*
Order numberorderNumberstringyes*
PDF templatepdfTemplatestring

* Provide exactly one of receiptNumber or orderNumber per call: either pass the receipt number as the first argument with the default type, or pass the order number as the first argument with Receipt::FROM_ORDER_NUMBER as the second (same as Document::FROM_ORDER_NUMBER).