23 KiB
YooKassa API SDK
Class: \YooKassa\Request\Receipts\CreatePostReceiptRequestBuilder
Namespace: \YooKassa\Request\Receipts
Summary:
Класс билдера объектов запросов к API на создание чека.
Examples
Пример использования билдера
try {
$receiptBuilder = \YooKassa\Request\Receipts\CreatePostReceiptRequest::builder();
$receiptBuilder->setType(\YooKassa\Model\Receipt\ReceiptType::PAYMENT)
->setObjectId('24b94598-000f-5000-9000-1b68e7b15f3f', \YooKassa\Model\Receipt\ReceiptType::PAYMENT) // payment_id
->setCustomer([
'email' => 'john.doe@merchant.com',
'phone' => '71111111111',
])
->setItems([
[
'description' => 'Платок Gucci',
'quantity' => '1.00',
'amount' => [
'value' => '3000.00',
'currency' => 'RUB',
],
'vat_code' => 2,
'payment_mode' => 'full_payment',
'payment_subject' => 'commodity',
],
])
->addSettlement([
[
'type' => 'prepayment',
'amount' => [
'value' => 100.00,
'currency' => 'RUB',
],
],
])
->setSend(true)
;
// Создаем объект запроса
$request = $receiptBuilder->build();
// Можно изменить данные, если нужно
$request->setOnBehalfOf('159753');
$request->getitems()->add(new \YooKassa\Model\Receipt\ReceiptItem([
'description' => 'Платок Gucci Новый',
'quantity' => '1.00',
'amount' => [
'value' => '3500.00',
'currency' => 'RUB',
],
'vat_code' => 2,
'payment_mode' => 'full_payment',
'payment_subject' => 'commodity',
]));
$idempotenceKey = uniqid('', true);
$response = $client->createReceipt($request, $idempotenceKey);
} catch (Exception $e) {
$response = $e;
}
var_dump($response);
Constants
- No constants found
Properties
| Visibility | Name | Flag | Summary |
|---|---|---|---|
| protected | $currentObject | Собираемый объект запроса. |
Methods
| Visibility | Name | Flag | Summary |
|---|---|---|---|
| public | __construct() | Конструктор, инициализирует пустой запрос, который в будущем начнём собирать. | |
| public | addItem() | Добавляет товар в чек. | |
| public | addReceiptIndustryDetails() | Добавляет отраслевой реквизит чека. | |
| public | addSettlement() | Добавляет оплату в перечень совершенных расчетов. | |
| public | build() | Строит и возвращает объект запроса для отправки в API ЮKassa. | |
| public | setAdditionalUserProps() | Устанавливает дополнительный реквизит пользователя. | |
| public | setCurrency() | Устанавливает валюту в которой будет происходить подтверждение оплаты заказа. | |
| public | setCustomer() | Устанавливает информацию о пользователе. | |
| public | setItems() | Устанавливает список товаров чека. | |
| public | setObjectId() | Устанавливает Id объекта чека. | |
| public | setObjectType() | Устанавливает тип объекта чека. | |
| public | setOnBehalfOf() | Устанавливает идентификатор магазина, от имени которого нужно отправить чек. | |
| public | setOptions() | Устанавливает свойства запроса из массива. | |
| public | setReceiptIndustryDetails() | Устанавливает отраслевой реквизит чека. | |
| public | setReceiptOperationalDetails() | Устанавливает операционный реквизит чека. | |
| public | setSend() | Устанавливает признак отложенной отправки чека. | |
| public | setSettlements() | Устанавливает массив оплат, обеспечивающих выдачу товара. | |
| public | setTaxSystemCode() | Устанавливает код системы налогообложения. | |
| public | setType() | Устанавливает тип чека в онлайн-кассе. | |
| protected | initCurrentObject() | Инициализирует объект запроса, который в дальнейшем будет собираться билдером |
Details
- File: lib/Request/Receipts/CreatePostReceiptRequestBuilder.php
- Package: Default
- Class Hierarchy:
- \YooKassa\Common\AbstractRequestBuilder
- \YooKassa\Request\Receipts\CreatePostReceiptRequestBuilder
Properties
protected $currentObject : ?\YooKassa\Common\AbstractRequestInterface
Summary
Собираемый объект запроса.
Type: AbstractRequestInterface
Details:
Methods
public __construct() : mixed
public __construct() : mixed
Summary
Конструктор, инициализирует пустой запрос, который в будущем начнём собирать.
Details:
- Inherited From: \YooKassa\Common\AbstractRequestBuilder
Returns: mixed -
public addItem() : self
public addItem(array|\YooKassa\Model\Receipt\ReceiptItemInterface|null $value) : self
Summary
Добавляет товар в чек.
Details:
- Inherited From: \YooKassa\Request\Receipts\CreatePostReceiptRequestBuilder
Parameters:
| Type | Name | Description |
|---|---|---|
array OR \YooKassa\Model\Receipt\ReceiptItemInterface OR null |
value | Информация о товаре |
Returns: self - Инстанс билдера запросов
public addReceiptIndustryDetails() : self
public addReceiptIndustryDetails(array|\YooKassa\Model\Receipt\IndustryDetails|null $value) : self
Summary
Добавляет отраслевой реквизит чека.
Details:
- Inherited From: \YooKassa\Request\Receipts\CreatePostReceiptRequestBuilder
Parameters:
| Type | Name | Description |
|---|---|---|
array OR \YooKassa\Model\Receipt\IndustryDetails OR null |
value | Отраслевой реквизит чека |
Returns: self - Инстанс билдера запросов
public addSettlement() : self
public addSettlement(array|\YooKassa\Model\Receipt\SettlementInterface|null $value) : self
Summary
Добавляет оплату в перечень совершенных расчетов.
Details:
- Inherited From: \YooKassa\Request\Receipts\CreatePostReceiptRequestBuilder
Parameters:
| Type | Name | Description |
|---|---|---|
array OR \YooKassa\Model\Receipt\SettlementInterface OR null |
value | Информация об оплате |
Returns: self - Инстанс билдера запросов
public build() : \YooKassa\Request\Receipts\CreatePostReceiptRequest
public build(null|array $options = null) : \YooKassa\Request\Receipts\CreatePostReceiptRequest
Summary
Строит и возвращает объект запроса для отправки в API ЮKassa.
Details:
- Inherited From: \YooKassa\Request\Receipts\CreatePostReceiptRequestBuilder
Parameters:
| Type | Name | Description |
|---|---|---|
null OR array |
options | Массив параметров для установки в объект запроса |
Throws:
| Type | Description |
|---|---|
| \YooKassa\Common\Exceptions\InvalidRequestException | Выбрасывается если собрать объект запроса не удалось |
Returns: \YooKassa\Request\Receipts\CreatePostReceiptRequest - Инстанс объекта запроса
public setAdditionalUserProps() : self
public setAdditionalUserProps(\YooKassa\Model\Receipt\AdditionalUserProps|array|null $value) : self
Summary
Устанавливает дополнительный реквизит пользователя.
Details:
- Inherited From: \YooKassa\Request\Receipts\CreatePostReceiptRequestBuilder
Parameters:
| Type | Name | Description |
|---|---|---|
\YooKassa\Model\Receipt\AdditionalUserProps OR array OR null |
value | Дополнительный реквизит пользователя |
Returns: self - Инстанс билдера запросов
public setCurrency() : self
public setCurrency(string $value) : self
Summary
Устанавливает валюту в которой будет происходить подтверждение оплаты заказа.
Details:
- Inherited From: \YooKassa\Request\Receipts\CreatePostReceiptRequestBuilder
Parameters:
| Type | Name | Description |
|---|---|---|
string |
value | Валюта в которой подтверждается оплата |
Returns: self - Инстанс билдера запросов
public setCustomer() : self
public setCustomer(array|\YooKassa\Model\Receipt\ReceiptCustomerInterface $value) : self
Summary
Устанавливает информацию о пользователе.
Details:
- Inherited From: \YooKassa\Request\Receipts\CreatePostReceiptRequestBuilder
Parameters:
| Type | Name | Description |
|---|---|---|
array OR \YooKassa\Model\Receipt\ReceiptCustomerInterface |
value | Информация о плательщике |
Returns: self - Инстанс билдера запросов
public setItems() : self
public setItems(array|\YooKassa\Model\Receipt\ReceiptItemInterface[]|null $value) : self
Summary
Устанавливает список товаров чека.
Details:
- Inherited From: \YooKassa\Request\Receipts\CreatePostReceiptRequestBuilder
Parameters:
| Type | Name | Description |
|---|---|---|
array OR \YooKassa\Model\Receipt\ReceiptItemInterface[] OR null |
value | Список товаров чека |
Returns: self - Инстанс билдера запросов
public setObjectId() : self
public setObjectId(string $value, null|string $type = null) : self
Summary
Устанавливает Id объекта чека.
Details:
- Inherited From: \YooKassa\Request\Receipts\CreatePostReceiptRequestBuilder
Parameters:
| Type | Name | Description |
|---|---|---|
string |
value | Id объекта чека |
null OR string |
type | Тип объекта чека |
Returns: self - Инстанс билдера запросов
public setObjectType() : self
public setObjectType(string|null $value) : self
Summary
Устанавливает тип объекта чека.
Details:
- Inherited From: \YooKassa\Request\Receipts\CreatePostReceiptRequestBuilder
Parameters:
| Type | Name | Description |
|---|---|---|
string OR null |
value | Тип объекта чека |
Returns: self - Инстанс билдера запросов
public setOnBehalfOf() : self
public setOnBehalfOf(string|null $value) : self
Summary
Устанавливает идентификатор магазина, от имени которого нужно отправить чек.
Description
Выдается ЮKassa, отображается в разделе Продавцы личного кабинета (столбец shopId). Необходимо передавать, если вы используете решение ЮKassa для платформ.
Details:
- Inherited From: \YooKassa\Request\Receipts\CreatePostReceiptRequestBuilder
Parameters:
| Type | Name | Description |
|---|---|---|
string OR null |
value | Идентификатор магазина, от имени которого нужно отправить чек |
Returns: self - Инстанс билдера запросов
public setOptions() : \YooKassa\Common\AbstractRequestBuilder
public setOptions(iterable|null $options) : \YooKassa\Common\AbstractRequestBuilder
Summary
Устанавливает свойства запроса из массива.
Details:
- Inherited From: \YooKassa\Common\AbstractRequestBuilder
Parameters:
| Type | Name | Description |
|---|---|---|
iterable OR null |
options | Массив свойств запроса |
Throws:
| Type | Description |
|---|---|
| \InvalidArgumentException | Выбрасывается если аргумент не массив и не итерируемый объект |
| \YooKassa\Common\Exceptions\InvalidPropertyException | Выбрасывается если не удалось установить один из параметров, переданных в массиве настроек |
Returns: \YooKassa\Common\AbstractRequestBuilder - Инстанс текущего билдера запросов
public setReceiptIndustryDetails() : self
public setReceiptIndustryDetails(array|\YooKassa\Model\Receipt\IndustryDetails[]|null $value) : self
Summary
Устанавливает отраслевой реквизит чека.
Details:
- Inherited From: \YooKassa\Request\Receipts\CreatePostReceiptRequestBuilder
Parameters:
| Type | Name | Description |
|---|---|---|
array OR \YooKassa\Model\Receipt\IndustryDetails[] OR null |
value | Отраслевой реквизит чека |
Returns: self - Инстанс билдера запросов
public setReceiptOperationalDetails() : self
public setReceiptOperationalDetails(array|\YooKassa\Model\Receipt\OperationalDetails|null $value) : self
Summary
Устанавливает операционный реквизит чека.
Details:
- Inherited From: \YooKassa\Request\Receipts\CreatePostReceiptRequestBuilder
Parameters:
| Type | Name | Description |
|---|---|---|
array OR \YooKassa\Model\Receipt\OperationalDetails OR null |
value | Операционный реквизит чека |
Returns: self - Инстанс билдера запросов
public setSend() : self
public setSend(bool $value) : self
Summary
Устанавливает признак отложенной отправки чека.
Details:
- Inherited From: \YooKassa\Request\Receipts\CreatePostReceiptRequestBuilder
Parameters:
| Type | Name | Description |
|---|---|---|
bool |
value | Признак отложенной отправки чека |
Returns: self - Инстанс билдера запросов
public setSettlements() : self
public setSettlements(array|\YooKassa\Model\Receipt\SettlementInterface[]|null $value) : self
Summary
Устанавливает массив оплат, обеспечивающих выдачу товара.
Details:
- Inherited From: \YooKassa\Request\Receipts\CreatePostReceiptRequestBuilder
Parameters:
| Type | Name | Description |
|---|---|---|
array OR \YooKassa\Model\Receipt\SettlementInterface[] OR null |
value | Массив оплат, обеспечивающих выдачу товара |
Returns: self - Инстанс билдера запросов
public setTaxSystemCode() : self
public setTaxSystemCode(int|null $value) : self
Summary
Устанавливает код системы налогообложения.
Details:
- Inherited From: \YooKassa\Request\Receipts\CreatePostReceiptRequestBuilder
Parameters:
| Type | Name | Description |
|---|---|---|
int OR null |
value | Код системы налогообложения. Число 1-6. |
Returns: self - Инстанс билдера запросов
public setType() : self
public setType(string|null $value) : self
Summary
Устанавливает тип чека в онлайн-кассе.
Details:
- Inherited From: \YooKassa\Request\Receipts\CreatePostReceiptRequestBuilder
Parameters:
| Type | Name | Description |
|---|---|---|
string OR null |
value | Тип чека в онлайн-кассе: приход "payment" или возврат "refund" |
Returns: self - Инстанс билдера запросов
protected initCurrentObject() : \YooKassa\Request\Receipts\CreatePostReceiptRequest
protected initCurrentObject() : \YooKassa\Request\Receipts\CreatePostReceiptRequest
Summary
Инициализирует объект запроса, который в дальнейшем будет собираться билдером
Details:
- Inherited From: \YooKassa\Request\Receipts\CreatePostReceiptRequestBuilder
Returns: \YooKassa\Request\Receipts\CreatePostReceiptRequest - Инстанс собираемого объекта запроса к API
Top Namespaces
Reports
This document was automatically generated from source code comments on 2023-06-16 using phpDocumentor
© 2023 YooMoney