Files
yookassa-sdk-php/docs/classes/YooKassa-Request-Receipts-CreatePostReceiptRequestBuilder.md
T

20 KiB
Raw Blame History

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\ReceiptType::PAYMENT)
        ->setObjectId('24b94598-000f-5000-9000-1b68e7b15f3f')
        ->setCustomer(array(
            'email' => 'john.doe@merchant.com',
            'phone' => '71111111111',
        ))
        ->setItems(array(
            array(
                'description' => 'Платок Gucci',
                'quantity' => '1.00',
                'amount' => array(
                    'value' => '3000.00',
                    'currency' => 'RUB',
                ),
                'vat_code' => 2,
                'payment_mode' => 'full_payment',
                'payment_subject' => 'commodity',
            ),
        ))
        ->setSettlements(array(
            array(
                'type' => 'prepayment',
                'amount' => array(
                    'value' => 100.00,
                    'currency' => 'RUB',
                ),
            ),
        ))
        ->setSend(true);

    // Создаем объект запроса
    $request = $receiptBuilder->build();

    // Можно изменить данные, если нужно
    $request->setOnBehalfOf('159753');
    $request->addItem(new \YooKassa\Model\ReceiptItem(array(
        'description' => 'Платок Gucci Новый',
        'quantity' => '1.00',
        'amount' => array(
            '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 $amount Сумма чека
protected $currentObject Собираемый объект запроса
protected $customer Информация о плательщике

Methods

Visibility Name Flag Summary
public __construct() Конструктор, инициализирует пустой запрос, который в будущем начнём собирать
public addItem() Добавляет товар в чек
public build() Строит и возвращает объект запроса для отправки в API ЮKassa
public setAmount() Устанавливает сумму
public setCurrency() Устанавливает валюту в которой будет происходить подтверждение оплаты заказа
public setCustomer() Устанавливает информацию о пользователе
public setItems() Устанавливает список товаров чека
public setObjectId() Устанавливает Id объекта чека
public setOnBehalfOf() Устанавливает идентификатор магазина, от имени которого нужно отправить чек.
public setOptions() Устанавливает свойства запроса из массива
public setSend() Устанавливает признак отложенной отправки чека.
public setSettlements() Устанавливает массив оплат, обеспечивающих выдачу товара.
public setTaxSystemCode() Устанавливает код системы налогообложения
public setType() Устанавливает тип чека в онлайн-кассе
protected initCurrentObject() Инициализирует объект запроса, который в дальнейшем будет собираться билдером

Details


Properties

protected $amount : \YooKassa\Model\AmountInterface


Summary

Сумма чека

Type: AmountInterface

Details:

protected $currentObject : \YooKassa\Request\Receipts\CreatePostReceiptRequest


Summary

Собираемый объект запроса

Type: CreatePostReceiptRequest

Details:

protected $customer : \YooKassa\Model\ReceiptCustomer


Summary

Информация о плательщике

Type: ReceiptCustomer

Details:


Methods

public __construct() : mixed

public __construct() : mixed

Summary

Конструктор, инициализирует пустой запрос, который в будущем начнём собирать

Details:

Returns: mixed -

public addItem() : \YooKassa\Request\Receipts\CreatePostReceiptRequestBuilder

public addItem(\YooKassa\Model\ReceiptItemInterface|array $value) : \YooKassa\Request\Receipts\CreatePostReceiptRequestBuilder

Summary

Добавляет товар в чек

Details:

Parameters:
Type Name Description
\YooKassa\Model\ReceiptItemInterface OR array value Информация о товаре

Returns: \YooKassa\Request\Receipts\CreatePostReceiptRequestBuilder -

public build() : \YooKassa\Request\Receipts\CreatePostReceiptRequest|\YooKassa\Common\AbstractRequest

public build(array|null $options = null) : \YooKassa\Request\Receipts\CreatePostReceiptRequest|\YooKassa\Common\AbstractRequest

Summary

Строит и возвращает объект запроса для отправки в API ЮKassa

Details:

Parameters:
Type Name Description
array OR null options Массив параметров для установки в объект запроса
Throws:
Type Description
\YooKassa\Common\Exceptions\InvalidRequestException Выбрасывается если собрать объект запроса не удалось

Returns: \YooKassa\Request\Receipts\CreatePostReceiptRequest|\YooKassa\Common\AbstractRequest - Инстанс объекта запроса

public setAmount() : self

public setAmount(\YooKassa\Model\AmountInterface|array|string $value) : self

Summary

Устанавливает сумму

Details:

Parameters:
Type Name Description
\YooKassa\Model\AmountInterface OR array OR string value Сумма оплаты

Returns: self - Инстанс билдера запросов

public setCurrency() : self

public setCurrency(string $value) : self

Summary

Устанавливает валюту в которой будет происходить подтверждение оплаты заказа

Details:

Parameters:
Type Name Description
string value Валюта в которой подтверждается оплата

Returns: self - Инстанс билдера запросов

public setCustomer() : self

public setCustomer(\YooKassa\Model\ReceiptCustomerInterface|array $value) : self

Summary

Устанавливает информацию о пользователе

Details:

Parameters:
Type Name Description
\YooKassa\Model\ReceiptCustomerInterface OR array value Информация о плательщике

Returns: self - Инстанс билдера запросов

public setItems() : \YooKassa\Request\Receipts\CreatePostReceiptRequestBuilder

public setItems(\YooKassa\Model\ReceiptItemInterface[]|array $value) : \YooKassa\Request\Receipts\CreatePostReceiptRequestBuilder

Summary

Устанавливает список товаров чека

Details:

Parameters:
Type Name Description
\YooKassa\Model\ReceiptItemInterface[] OR array value Список товаров чека

Returns: \YooKassa\Request\Receipts\CreatePostReceiptRequestBuilder -

public setObjectId() : \YooKassa\Request\Receipts\CreatePostReceiptRequestBuilder

public setObjectId(string $value) : \YooKassa\Request\Receipts\CreatePostReceiptRequestBuilder

Summary

Устанавливает Id объекта чека

Details:

Parameters:
Type Name Description
string value Id объекта чека

Returns: \YooKassa\Request\Receipts\CreatePostReceiptRequestBuilder -

public setOnBehalfOf() : \YooKassa\Request\Receipts\CreatePostReceiptRequestBuilder

public setOnBehalfOf(string $value) : \YooKassa\Request\Receipts\CreatePostReceiptRequestBuilder

Summary

Устанавливает идентификатор магазина, от имени которого нужно отправить чек.

Description

Выдается ЮKassa, отображается в разделе Продавцы личного кабинета (столбец shopId). Необходимо передавать, если вы используете решение ЮKassa для платформ.

Details:

Parameters:
Type Name Description
string value Идентификатор магазина, от имени которого нужно отправить чек

Returns: \YooKassa\Request\Receipts\CreatePostReceiptRequestBuilder -

public setOptions() : \YooKassa\Common\AbstractRequestBuilder

public setOptions(array|\Traversable $options) : \YooKassa\Common\AbstractRequestBuilder

Summary

Устанавливает свойства запроса из массива

Details:

Parameters:
Type Name Description
array OR \Traversable options Массив свойств запроса
Throws:
Type Description
\InvalidArgumentException Выбрасывается если аргумент не массив и не итерируемый объект
\YooKassa\Common\Exceptions\InvalidPropertyException Выбрасывается если не удалось установить один из параметров, переданныч в массиве настроек

Returns: \YooKassa\Common\AbstractRequestBuilder - Инстанс текущего билдера запросов

public setSend() : \YooKassa\Request\Receipts\CreatePostReceiptRequestBuilder

public setSend(bool $value) : \YooKassa\Request\Receipts\CreatePostReceiptRequestBuilder

Summary

Устанавливает признак отложенной отправки чека.

Details:

Parameters:
Type Name Description
bool value Признак отложенной отправки чека.

Returns: \YooKassa\Request\Receipts\CreatePostReceiptRequestBuilder -

public setSettlements() : \YooKassa\Request\Receipts\CreatePostReceiptRequestBuilder

public setSettlements(\YooKassa\Model\SettlementInterface[]|array $value) : \YooKassa\Request\Receipts\CreatePostReceiptRequestBuilder

Summary

Устанавливает массив оплат, обеспечивающих выдачу товара.

Details:

Parameters:
Type Name Description
\YooKassa\Model\SettlementInterface[] OR array value Массив оплат, обеспечивающих выдачу товара

Returns: \YooKassa\Request\Receipts\CreatePostReceiptRequestBuilder -

public setTaxSystemCode() : \YooKassa\Request\Receipts\CreatePostReceiptRequestBuilder

public setTaxSystemCode(int $value) : \YooKassa\Request\Receipts\CreatePostReceiptRequestBuilder

Summary

Устанавливает код системы налогообложения

Details:

Parameters:
Type Name Description
int value Код системы налогообложения. Число 1-6.

Returns: \YooKassa\Request\Receipts\CreatePostReceiptRequestBuilder -

public setType() : \YooKassa\Request\Receipts\CreatePostReceiptRequestBuilder

public setType(string $value) : \YooKassa\Request\Receipts\CreatePostReceiptRequestBuilder

Summary

Устанавливает тип чека в онлайн-кассе

Details:

Parameters:
Type Name Description
string value Тип чека в онлайн-кассе: приход "payment" или возврат "refund".

Returns: \YooKassa\Request\Receipts\CreatePostReceiptRequestBuilder -

protected initCurrentObject() : \YooKassa\Request\Receipts\CreatePostReceiptRequest

protected initCurrentObject() : \YooKassa\Request\Receipts\CreatePostReceiptRequest

Summary

Инициализирует объект запроса, который в дальнейшем будет собираться билдером

Details:

Returns: \YooKassa\Request\Receipts\CreatePostReceiptRequest - Инстанс собираемого объекта запроса к API


Top Namespaces


Reports


This document was automatically generated from source code comments on 2021-12-09 using phpDocumentor

© 2021 YooMoney