mirror of
https://git.yoomoney.ru/scm/sdk/yookassa-sdk-php.git
synced 2026-08-17 15:42:01 +00:00
Исправлены некоторые ошибки. Добавлены примеры работы с выплатами
This commit is contained in:
+1
-1
@@ -122,7 +122,7 @@ class Client extends BaseClient
|
||||
/**
|
||||
* Текущая версия библиотеки
|
||||
*/
|
||||
const SDK_VERSION = '2.8.0';
|
||||
const SDK_VERSION = '2.8.1';
|
||||
|
||||
/**
|
||||
* Получить список платежей магазина
|
||||
|
||||
@@ -27,8 +27,10 @@
|
||||
namespace YooKassa\Common;
|
||||
|
||||
use YooKassa\Common\Exceptions\InvalidPropertyValueTypeException;
|
||||
use YooKassa\Model\Airline;
|
||||
use YooKassa\Model\AirlineInterface;
|
||||
use YooKassa\Model\AmountInterface;
|
||||
use YooKassa\Model\Deal\PaymentDealInfo;
|
||||
use YooKassa\Model\MonetaryAmount;
|
||||
use YooKassa\Model\Receipt;
|
||||
use YooKassa\Model\ReceiptInterface;
|
||||
use YooKassa\Model\Transfer;
|
||||
@@ -40,6 +42,7 @@ use YooKassa\Model\TransferInterface;
|
||||
* @property AmountInterface $amount Сумма
|
||||
* @property ReceiptInterface $receipt Данные фискального чека 54-ФЗ
|
||||
* @property TransferInterface[] $transfers Данные о распределении платежа между магазинами
|
||||
* @property AirlineInterface $airline Данные фискального чека 54-ФЗ
|
||||
*
|
||||
* @since 1.0.18
|
||||
*/
|
||||
@@ -60,6 +63,11 @@ class AbstractPaymentRequest extends AbstractRequest
|
||||
*/
|
||||
private $_transfers = array();
|
||||
|
||||
/**
|
||||
* @var AirlineInterface Объект с данными для продажи авиабилетов
|
||||
*/
|
||||
private $_airline;
|
||||
|
||||
/**
|
||||
* Возвращает сумму оплаты
|
||||
* @return AmountInterface Сумма оплаты
|
||||
@@ -79,12 +87,28 @@ class AbstractPaymentRequest extends AbstractRequest
|
||||
}
|
||||
|
||||
/**
|
||||
* Устанавливает сумму оплаты
|
||||
* @param AmountInterface $value Сумма оплаты
|
||||
* Устанавливает сумму
|
||||
*
|
||||
* @param AmountInterface|array|string $value Сумма оплаты
|
||||
*
|
||||
* @return AbstractPaymentRequest Инстанс билдера запросов
|
||||
*/
|
||||
public function setAmount(AmountInterface $value)
|
||||
public function setAmount($value)
|
||||
{
|
||||
$this->_amount = $value;
|
||||
$this->_amount = new MonetaryAmount();
|
||||
if ($value === null || $value === '') {
|
||||
return $this;
|
||||
}
|
||||
|
||||
if ($value instanceof AmountInterface) {
|
||||
$this->_amount = $value;
|
||||
} elseif (is_array($value)) {
|
||||
$this->_amount->fromArray($value);
|
||||
} else {
|
||||
$this->_amount->setValue($value);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -98,15 +122,19 @@ class AbstractPaymentRequest extends AbstractRequest
|
||||
|
||||
/**
|
||||
* Устанавливает чек
|
||||
* @param ReceiptInterface|null $value Инстанс чека или null для удаления информации о чеке
|
||||
* @param ReceiptInterface|array|null $value Инстанс чека или null для удаления информации о чеке
|
||||
* @throws InvalidPropertyValueTypeException Выбрасывается если передан не инстанс класса чека и не null
|
||||
*/
|
||||
public function setReceipt($value)
|
||||
{
|
||||
if ($value === null || $value instanceof ReceiptInterface) {
|
||||
if ($value === null) {
|
||||
$this->_receipt = null;
|
||||
} elseif (is_array($value)) {
|
||||
$this->_receipt = new Receipt($value);
|
||||
} elseif ($value instanceof ReceiptInterface) {
|
||||
$this->_receipt = $value;
|
||||
} else {
|
||||
throw new InvalidPropertyValueTypeException('Invalid receipt in Refund', 0, 'Refund.receipt', $value);
|
||||
throw new InvalidPropertyValueTypeException('Invalid receipt in Payment', 0, 'Payment.receipt', $value);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -178,6 +206,45 @@ class AbstractPaymentRequest extends AbstractRequest
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Возвращает данные авиабилетов
|
||||
* @return AirlineInterface Данные авиабилетов
|
||||
*/
|
||||
public function getAirline()
|
||||
{
|
||||
return $this->_airline;
|
||||
}
|
||||
|
||||
/**
|
||||
* Проверяет, были ли установлены данные авиабилетов
|
||||
* @return bool
|
||||
*/
|
||||
public function hasAirline()
|
||||
{
|
||||
return $this->_airline !== null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Устанавливает информацию об авиабилетах
|
||||
* @param AirlineInterface|array|null $value Объект данных длинной записи или ассоциативный массив с данными
|
||||
*
|
||||
* @return AbstractPaymentRequest
|
||||
*/
|
||||
public function setAirline($value)
|
||||
{
|
||||
if ($value === null) {
|
||||
$this->_airline = null;
|
||||
} elseif (is_array($value)) {
|
||||
$this->_airline = new Airline($value);
|
||||
} elseif ($value instanceof AirlineInterface) {
|
||||
$this->_airline = $value;
|
||||
} else {
|
||||
throw new InvalidPropertyValueTypeException('Invalid airline value type', 0, 'airline', $value);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Валидирует объект запроса
|
||||
* @return bool True если запрос валиден и его можно отправить в API, false если нет
|
||||
|
||||
@@ -29,7 +29,6 @@ namespace YooKassa\Common;
|
||||
use YooKassa\Common\Exceptions\InvalidPropertyValueException;
|
||||
use YooKassa\Common\Exceptions\InvalidPropertyValueTypeException;
|
||||
use YooKassa\Model\AmountInterface;
|
||||
use YooKassa\Model\Deal\PaymentDealInfo;
|
||||
use YooKassa\Model\MonetaryAmount;
|
||||
use YooKassa\Model\Receipt;
|
||||
use YooKassa\Model\Receipt\ReceiptItemAmount;
|
||||
@@ -195,11 +194,19 @@ abstract class AbstractPaymentRequestBuilder extends AbstractRequestBuilder
|
||||
throw new InvalidPropertyValueException(
|
||||
'Item#' . $index . ' title or description not specified',
|
||||
0,
|
||||
'AbstractPaymentRequestBuilder.items[' . $index . '].title',
|
||||
'AbstractPaymentRequestBuilder.items[' . $index . '].description',
|
||||
json_encode($item)
|
||||
);
|
||||
}
|
||||
foreach (array('price', 'quantity', 'vatCode') as $property) {
|
||||
if (empty($item['price']) && empty($item['amount'])) {
|
||||
throw new InvalidPropertyValueException(
|
||||
'Item#' . $index . ' amount or price not specified',
|
||||
0,
|
||||
'AbstractPaymentRequestBuilder.items[' . $index . '].amount',
|
||||
json_encode($item)
|
||||
);
|
||||
}
|
||||
foreach (array('quantity', 'vatCode') as $property) {
|
||||
if (empty($item[$property])) {
|
||||
throw new InvalidPropertyValueException(
|
||||
'Item#' . $index . ' ' . $property . ' not specified',
|
||||
@@ -209,18 +216,13 @@ abstract class AbstractPaymentRequestBuilder extends AbstractRequestBuilder
|
||||
);
|
||||
}
|
||||
}
|
||||
$this->addReceiptItem(
|
||||
empty($item['title']) ? $item['description'] : $item['title'],
|
||||
$item['price'],
|
||||
$item['quantity'],
|
||||
$item['vatCode'],
|
||||
isset($item['payment_mode']) ? $item['payment_mode'] : null,
|
||||
isset($item['payment_subject']) ? $item['payment_subject'] : null,
|
||||
isset($item['product_code']) ? $item['product_code'] : null,
|
||||
isset($item['country_of_origin_code']) ? $item['country_of_origin_code'] : null,
|
||||
isset($item['customs_declaration_number']) ? $item['customs_declaration_number'] : null,
|
||||
isset($item['excise']) ? $item['excise'] : null
|
||||
|
||||
$item['description'] = empty($item['title']) ? $item['description'] : $item['title'];
|
||||
$item['amount'] = array(
|
||||
'value' => !empty($item['amount']['value']) ? $item['amount']['value'] : $item['price'],
|
||||
'currency' => !empty($item['amount']['currency']) ? $item['amount']['currency'] : $this->amount->getCurrency(),
|
||||
);
|
||||
$this->receipt->addItem(new ReceiptItem($item));
|
||||
}
|
||||
$index++;
|
||||
}
|
||||
|
||||
@@ -604,9 +604,36 @@ class Receipt extends AbstractObject implements ReceiptInterface
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($sourceArray['receipt_industry_details'])) {
|
||||
foreach ($sourceArray['receipt_industry_details'] as $i => $itemArray) {
|
||||
if (is_array($itemArray)) {
|
||||
$sourceArray['receipt_industry_details'][$i] = new IndustryDetails($itemArray);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($sourceArray['receipt_operational_details'])) {
|
||||
$sourceArray['receipt_operational_details'] = new OperationalDetails($sourceArray['receipt_operational_details']);
|
||||
}
|
||||
|
||||
parent::fromArray($sourceArray);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function jsonSerialize()
|
||||
{
|
||||
$result = parent::jsonSerialize();
|
||||
unset($result['email'], $result['phone'], $result['amount_value'], $result['shipping_amount_value']);
|
||||
if (empty($result['settlements'])) {
|
||||
unset($result['settlements']);
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Возвращает Id объекта чека
|
||||
*
|
||||
|
||||
@@ -42,8 +42,8 @@ use YooKassa\Helpers\TypeCast;
|
||||
*
|
||||
* @property string $federalId Идентификатор федерального органа исполнительной власти (тег в 54 ФЗ — 1262)
|
||||
* @property string $federal_id Идентификатор федерального органа исполнительной власти (тег в 54 ФЗ — 1262)
|
||||
* @property Datetime $documentDate Дата документа основания (тег в 54 ФЗ — 1263)
|
||||
* @property Datetime $document_date Дата документа основания (тег в 54 ФЗ — 1263)
|
||||
* @property DateTime $documentDate Дата документа основания (тег в 54 ФЗ — 1263)
|
||||
* @property DateTime $document_date Дата документа основания (тег в 54 ФЗ — 1263)
|
||||
* @property string $documentNumber Номер нормативного акта федерального органа исполнительной власти (тег в 54 ФЗ — 1264)
|
||||
* @property string $document_number Номер нормативного акта федерального органа исполнительной власти (тег в 54 ФЗ — 1264)
|
||||
* @property string $value Значение отраслевого реквизита (тег в 54 ФЗ — 1265)
|
||||
@@ -63,7 +63,7 @@ class IndustryDetails extends AbstractObject
|
||||
private $_federalId;
|
||||
|
||||
/**
|
||||
* @var Datetime Дата документа основания (тег в 54 ФЗ — 1263). Передается в формате [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601)
|
||||
* @var DateTime Дата документа основания (тег в 54 ФЗ — 1263). Передается в формате [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601)
|
||||
*/
|
||||
private $_documentDate;
|
||||
|
||||
@@ -106,7 +106,7 @@ class IndustryDetails extends AbstractObject
|
||||
|
||||
/**
|
||||
* Возвращает дату документа основания
|
||||
* @return Datetime Дата документа основания
|
||||
* @return DateTime Дата документа основания
|
||||
*/
|
||||
public function getDocumentDate()
|
||||
{
|
||||
@@ -115,7 +115,7 @@ class IndustryDetails extends AbstractObject
|
||||
|
||||
/**
|
||||
* Устанавливает дату документа основания
|
||||
* @param string|Datetime $value Дата документа основания
|
||||
* @param string|DateTime $value Дата документа основания
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function setDocumentDate($value)
|
||||
|
||||
@@ -43,8 +43,8 @@ use YooKassa\Helpers\TypeCast;
|
||||
*
|
||||
* @property string $operationId Идентификатор операции (тег в 54 ФЗ — 1271)
|
||||
* @property string $operation_id Идентификатор операции (тег в 54 ФЗ — 1271)
|
||||
* @property Datetime $createdAt Время создания операции (тег в 54 ФЗ — 1273)
|
||||
* @property Datetime $created_at Время создания операции (тег в 54 ФЗ — 1273)
|
||||
* @property DateTime $createdAt Время создания операции (тег в 54 ФЗ — 1273)
|
||||
* @property DateTime $created_at Время создания операции (тег в 54 ФЗ — 1273)
|
||||
* @property string $value Данные операции (тег в 54 ФЗ — 1272)
|
||||
*/
|
||||
class OperationalDetails extends AbstractObject
|
||||
@@ -60,7 +60,7 @@ class OperationalDetails extends AbstractObject
|
||||
private $_operationId;
|
||||
|
||||
/**
|
||||
* @var Datetime Время создания операции (тег в 54 ФЗ — 1273).
|
||||
* @var DateTime Время создания операции (тег в 54 ФЗ — 1273).
|
||||
* Указывается по [UTC](https://ru.wikipedia.org/wiki/Всемирное_координированное_время) и передается в формате [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601).
|
||||
*/
|
||||
private $_createdAt;
|
||||
@@ -102,7 +102,7 @@ class OperationalDetails extends AbstractObject
|
||||
|
||||
/**
|
||||
* Возвращает время создания операции
|
||||
* @return Datetime Время создания операции
|
||||
* @return DateTime Время создания операции
|
||||
*/
|
||||
public function getCreatedAt()
|
||||
{
|
||||
@@ -111,7 +111,7 @@ class OperationalDetails extends AbstractObject
|
||||
|
||||
/**
|
||||
* Устанавливает время создания операции
|
||||
* @param string|Datetime $value Время создания операции
|
||||
* @param string|DateTime $value Время создания операции
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function setCreatedAt($value)
|
||||
|
||||
@@ -121,11 +121,6 @@ class CreatePaymentRequest extends AbstractPaymentRequest implements CreatePayme
|
||||
*/
|
||||
private $_clientIp;
|
||||
|
||||
/**
|
||||
* @var AirlineInterface Объект с данными для продажи авиабилетов
|
||||
*/
|
||||
private $_airline;
|
||||
|
||||
/**
|
||||
* @var Metadata Метаданные привязанные к платежу
|
||||
*/
|
||||
@@ -524,33 +519,6 @@ class CreatePaymentRequest extends AbstractPaymentRequest implements CreatePayme
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Возвращает данные авиабилетов
|
||||
* @return AirlineInterface Данные авиабилетов
|
||||
*/
|
||||
public function getAirline()
|
||||
{
|
||||
return $this->_airline;
|
||||
}
|
||||
|
||||
/**
|
||||
* Проверяет, были ли установлены данные авиабилетов
|
||||
* @return bool
|
||||
*/
|
||||
public function hasAirline()
|
||||
{
|
||||
return $this->_airline !== null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Устанавливает данные авиабилетов
|
||||
* @param AirlineInterface $value Данные авиабилетов
|
||||
*/
|
||||
public function setAirline($value)
|
||||
{
|
||||
$this->_airline = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Возвращает данные оплаты установленные мерчантом
|
||||
* @return Metadata Метаданные, привязанные к платежу
|
||||
|
||||
@@ -80,7 +80,7 @@ class CreatePaymentRequestBuilder extends AbstractPaymentRequestBuilder
|
||||
private $confirmationFactory;
|
||||
|
||||
/**
|
||||
* @var Airline Длинная запись
|
||||
* @var AirlineInterface Объект с данными для продажи авиабилетов
|
||||
*/
|
||||
private $airline;
|
||||
|
||||
@@ -172,10 +172,9 @@ class CreatePaymentRequestBuilder extends AbstractPaymentRequestBuilder
|
||||
} elseif ($value instanceof AirlineInterface) {
|
||||
$this->airline = clone $value;
|
||||
} else {
|
||||
throw new InvalidPropertyValueTypeException('Invalid receipt value type', 0, 'receipt', $value);
|
||||
throw new InvalidPropertyValueTypeException('Invalid airline value type', 0, 'airline', $value);
|
||||
}
|
||||
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
@@ -90,23 +90,17 @@ class CreatePaymentRequestSerializer
|
||||
if ($request->getAmount()->getValue() > 0) {
|
||||
$result['amount'] = $this->serializeAmount($request->getAmount());
|
||||
}
|
||||
|
||||
if ($request->hasTransfers()) {
|
||||
$result['transfers'] = $this->serializeTransfers($request->getTransfers());
|
||||
}
|
||||
|
||||
if ($request->hasDescription()) {
|
||||
$result['description'] = $request->getDescription();
|
||||
}
|
||||
if ($request->hasReceipt()) {
|
||||
$receipt = $request->getReceipt();
|
||||
if ($receipt->notEmpty()) {
|
||||
$result['receipt'] = $this->serializeReceipt($receipt);
|
||||
}
|
||||
if ($request->hasReceipt() && $request->getReceipt()->notEmpty()) {
|
||||
$result['receipt'] = $request->getReceipt()->toArray();
|
||||
}
|
||||
if ($request->hasRecipient()) {
|
||||
$result['recipient']['account_id'] = $request->getRecipient()->getAccountId();
|
||||
$result['recipient']['gateway_id'] = $request->getRecipient()->getGatewayId();
|
||||
$result['recipient'] = $request->getRecipient()->toArray();
|
||||
}
|
||||
if ($request->hasPaymentMethodData()) {
|
||||
$method = self::$paymentDataSerializerMap[$request->getPaymentMethodData()->getType()];
|
||||
@@ -126,34 +120,8 @@ class CreatePaymentRequestSerializer
|
||||
$result['save_payment_method'] = $request->getSavePaymentMethod();
|
||||
}
|
||||
if ($request->hasAirline()) {
|
||||
$airline = $request->getAirline();
|
||||
$result['airline'] = array();
|
||||
|
||||
$ticketNumber = $airline->getTicketNumber();
|
||||
if (!empty($ticketNumber)) {
|
||||
$result['airline']['ticket_number'] = $ticketNumber;
|
||||
}
|
||||
$bookingReference = $airline->getBookingReference();
|
||||
if (!empty($bookingReference)) {
|
||||
$result['airline']['booking_reference'] = $bookingReference;
|
||||
}
|
||||
|
||||
foreach ($airline->getPassengers() as $passenger) {
|
||||
$result['airline']['passengers'][] = array(
|
||||
'first_name' => $passenger->getFirstName(),
|
||||
'last_name' => $passenger->getLastName(),
|
||||
);
|
||||
}
|
||||
|
||||
foreach ($airline->getLegs() as $leg) {
|
||||
$result['airline']['legs'][] = array(
|
||||
'departure_airport' => $leg->getDepartureAirport(),
|
||||
'destination_airport' => $leg->getDestinationAirport(),
|
||||
'departure_date' => $leg->getDepartureDate(),
|
||||
);
|
||||
}
|
||||
$result['airline'] = $request->getAirline()->toArray();
|
||||
}
|
||||
|
||||
if ($request->hasDeal()) {
|
||||
$result['deal'] = $request->getDeal()->toArray();
|
||||
}
|
||||
@@ -190,28 +158,6 @@ class CreatePaymentRequestSerializer
|
||||
return $result;
|
||||
}
|
||||
|
||||
private function serializeReceipt(ReceiptInterface $receipt)
|
||||
{
|
||||
$result = array();
|
||||
|
||||
/** @var ReceiptItem $item */
|
||||
foreach ($receipt->getItems() as $item) {
|
||||
$result['items'][] = $item->jsonSerialize();
|
||||
}
|
||||
|
||||
$customer = $receipt->getCustomer();
|
||||
if ($customer !== null) {
|
||||
$result['customer'] = $customer->jsonSerialize();
|
||||
}
|
||||
|
||||
$value = $receipt->getTaxSystemCode();
|
||||
if (!empty($value)) {
|
||||
$result['tax_system_code'] = $value;
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
private function serializeAmount(AmountInterface $amount)
|
||||
{
|
||||
return array(
|
||||
|
||||
@@ -31,6 +31,7 @@ use YooKassa\Common\AbstractRequest;
|
||||
use YooKassa\Common\Exceptions\InvalidPropertyException;
|
||||
use YooKassa\Common\Exceptions\InvalidPropertyValueTypeException;
|
||||
use YooKassa\Common\Exceptions\InvalidRequestException;
|
||||
use YooKassa\Model\AirlineInterface;
|
||||
use YooKassa\Model\Deal\CaptureDealData;
|
||||
|
||||
class CreateCaptureRequestBuilder extends AbstractPaymentRequestBuilder
|
||||
@@ -79,12 +80,23 @@ class CreateCaptureRequestBuilder extends AbstractPaymentRequestBuilder
|
||||
if ($this->receipt->notEmpty()) {
|
||||
$this->currentObject->setReceipt($this->receipt);
|
||||
}
|
||||
if ($this->deal) {
|
||||
$this->currentObject->setDeal($this->deal);
|
||||
}
|
||||
|
||||
return parent::build();
|
||||
}
|
||||
|
||||
/**
|
||||
* Устанавливает информацию об авиабилетах
|
||||
* @param AirlineInterface|array $value Объект данных длинной записи или ассоциативный массив с данными
|
||||
*
|
||||
* @return CreateCaptureRequestBuilder
|
||||
*/
|
||||
public function setAirline($value)
|
||||
{
|
||||
$this->currentObject->setAirline($value);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Устанавливает сделку
|
||||
* @param CaptureDealData|array|null $value Данные о сделке, в составе подтверждения оплаты
|
||||
@@ -94,21 +106,7 @@ class CreateCaptureRequestBuilder extends AbstractPaymentRequestBuilder
|
||||
*/
|
||||
public function setDeal($value)
|
||||
{
|
||||
if ($value === null) {
|
||||
return $this;
|
||||
}
|
||||
if ($value instanceof CaptureDealData) {
|
||||
$this->deal = $value;
|
||||
} elseif (is_array($value)) {
|
||||
$this->deal = new CaptureDealData($value);
|
||||
} else {
|
||||
throw new InvalidPropertyValueTypeException(
|
||||
'Invalid deal value type in CreateCaptureRequest',
|
||||
0,
|
||||
'CreateCaptureRequest.deal',
|
||||
$value
|
||||
);
|
||||
}
|
||||
$this->currentObject->setDeal($value);
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -57,9 +57,9 @@ interface CreateCaptureRequestInterface
|
||||
|
||||
/**
|
||||
* Устанавливает сумму оплаты
|
||||
* @param AmountInterface $value Сумма оплаты
|
||||
* @param AmountInterface|array|string $value Сумма оплаты
|
||||
*/
|
||||
public function setAmount(AmountInterface $value);
|
||||
public function setAmount($value);
|
||||
|
||||
/**
|
||||
* Возвращает чек, если он есть
|
||||
|
||||
@@ -53,75 +53,11 @@ class CreateCaptureRequestSerializer
|
||||
if ($request->hasTransfers()) {
|
||||
$result['transfers'] = $this->serializeTransfers($request->getTransfers());
|
||||
}
|
||||
if ($request->hasReceipt()) {
|
||||
$receipt = $request->getReceipt();
|
||||
if ($receipt->notEmpty()) {
|
||||
$result['receipt'] = array();
|
||||
/** @var ReceiptItem $item */
|
||||
foreach ($receipt->getItems() as $item) {
|
||||
$itemArray = array(
|
||||
'description' => $item->getDescription(),
|
||||
'amount' => array(
|
||||
'value' => $item->getPrice()->getValue(),
|
||||
'currency' => $item->getPrice()->getCurrency(),
|
||||
),
|
||||
'quantity' => $item->getQuantity(),
|
||||
'vat_code' => $item->getVatCode(),
|
||||
);
|
||||
|
||||
if ($value = $item->getPaymentSubject()) {
|
||||
$itemArray['payment_subject'] = $value;
|
||||
}
|
||||
|
||||
if ($value = $item->getPaymentMode()) {
|
||||
$itemArray['payment_mode'] = $value;
|
||||
}
|
||||
|
||||
if ($value = $item->getProductCode()) {
|
||||
$itemArray['product_code'] = $value;
|
||||
}
|
||||
|
||||
if ($value = $item->getCountryOfOriginCode()) {
|
||||
$itemArray['country_of_origin_code'] = $value;
|
||||
}
|
||||
|
||||
if ($value = $item->getCustomsDeclarationNumber()) {
|
||||
$itemArray['customs_declaration_number'] = $value;
|
||||
}
|
||||
|
||||
if ($value = $item->getExcise()) {
|
||||
$itemArray['excise'] = $value;
|
||||
}
|
||||
|
||||
$result['receipt']['items'][] = $itemArray;
|
||||
}
|
||||
|
||||
if ($customer = $receipt->getCustomer()) {
|
||||
$customerArray = array();
|
||||
|
||||
if ($value = $customer->getEmail()) {
|
||||
$customerArray['email'] = $value;
|
||||
}
|
||||
|
||||
if ($value = $customer->getPhone()) {
|
||||
$customerArray['phone'] = $value;
|
||||
}
|
||||
|
||||
if ($value = $customer->getFullName()) {
|
||||
$customerArray['full_name'] = $value;
|
||||
}
|
||||
|
||||
if ($value = $customer->getInn()) {
|
||||
$customerArray['inn'] = $value;
|
||||
}
|
||||
|
||||
$result['receipt']['customer'] = $customerArray;
|
||||
}
|
||||
|
||||
if ($value = $receipt->getTaxSystemCode()) {
|
||||
$result['receipt']['tax_system_code'] = $value;
|
||||
}
|
||||
}
|
||||
if ($request->hasReceipt() && $request->getReceipt()->notEmpty()) {
|
||||
$result['receipt'] = $request->getReceipt()->toArray();
|
||||
}
|
||||
if ($request->hasAirline()) {
|
||||
$result['airline'] = $request->getAirline()->toArray();
|
||||
}
|
||||
if ($request->hasDeal()) {
|
||||
$result['deal'] = $request->getDeal()->toArray();
|
||||
|
||||
Reference in New Issue
Block a user