mirror of
https://git.yoomoney.ru/scm/sdk/yookassa-sdk-php.git
synced 2026-08-17 14:51:19 +00:00
Добавлен прием платежей через Alfa Pay. Добавлен новый тип ошибки RuleViolationError
Добавлены нулевые привязки по СБП Добавлена причина отмены возвратов `payment_expired`
This commit is contained in:
+7
-6
@@ -71,7 +71,8 @@ use YooKassa\Request\Invoices\InvoiceResponse;
|
||||
use YooKassa\Request\PaymentMethods\CreatePaymentMethodRequest;
|
||||
use YooKassa\Request\PaymentMethods\CreatePaymentMethodRequestInterface;
|
||||
use YooKassa\Request\PaymentMethods\CreatePaymentMethodRequestSerializer;
|
||||
use YooKassa\Request\PaymentMethods\PaymentMethodResponse;
|
||||
use YooKassa\Request\PaymentMethods\PaymentMethodResponseFactory;
|
||||
use YooKassa\Request\PaymentMethods\PaymentMethodResponseInterface;
|
||||
use YooKassa\Request\Payments\CancelResponse;
|
||||
use YooKassa\Request\Payments\CreateCaptureRequest;
|
||||
use YooKassa\Request\Payments\CreateCaptureRequestInterface;
|
||||
@@ -134,7 +135,7 @@ class Client extends BaseClient
|
||||
/**
|
||||
* Текущая версия библиотеки.
|
||||
*/
|
||||
public const SDK_VERSION = '3.13.2';
|
||||
public const SDK_VERSION = '3.14.0';
|
||||
|
||||
/**
|
||||
* Получить список платежей магазина.
|
||||
@@ -1527,7 +1528,7 @@ class Client extends BaseClient
|
||||
* @throws JsonException
|
||||
*
|
||||
*/
|
||||
public function createPaymentMethod(array|CreatePaymentMethodRequestInterface $paymentMethod, ?string $idempotenceKey = null): ?SavePaymentMethodInterface
|
||||
public function createPaymentMethod(array|CreatePaymentMethodRequestInterface $paymentMethod, ?string $idempotenceKey = null): ?PaymentMethodResponseInterface
|
||||
{
|
||||
$path = self::PAYMENT_METHODS_PATH;
|
||||
|
||||
@@ -1543,7 +1544,7 @@ class Client extends BaseClient
|
||||
$result = null;
|
||||
if (200 === $response->getCode()) {
|
||||
$resultArray = $this->decodeData($response);
|
||||
$result = new PaymentMethodResponse($resultArray);
|
||||
$result = (new PaymentMethodResponseFactory)->factoryFromArray($resultArray);
|
||||
} else {
|
||||
$this->handleError($response);
|
||||
}
|
||||
@@ -1575,7 +1576,7 @@ class Client extends BaseClient
|
||||
* @throws UnauthorizedException
|
||||
*
|
||||
*/
|
||||
public function getPaymentMethodInfo(string $paymentMethodId): ?SavePaymentMethodInterface
|
||||
public function getPaymentMethodInfo(string $paymentMethodId): ?PaymentMethodResponseInterface
|
||||
{
|
||||
$path = self::PAYMENT_METHODS_PATH . '/' . $paymentMethodId;
|
||||
|
||||
@@ -1584,7 +1585,7 @@ class Client extends BaseClient
|
||||
$result = null;
|
||||
if (200 === $response->getCode()) {
|
||||
$resultArray = $this->decodeData($response);
|
||||
$result = new PaymentMethodResponse($resultArray);
|
||||
$result = (new PaymentMethodResponseFactory)->factoryFromArray($resultArray);
|
||||
} else {
|
||||
$this->handleError($response);
|
||||
}
|
||||
|
||||
@@ -69,6 +69,8 @@ class ErrorCode extends AbstractEnum
|
||||
public const TOO_MANY_REQUESTS = 'too_many_requests';
|
||||
/** Внутренняя ошибка сервера ЮKassa. */
|
||||
public const INTERNAL_SERVER_ERROR = 'internal_server_error';
|
||||
/** Запрос не может быть выполнен согласно правилам бизнес-логики. */
|
||||
public const REFUSAL = 'refusal';
|
||||
/** Для неописанных кодов ошибок. */
|
||||
public const UNKNOWN = 'unknown';
|
||||
|
||||
@@ -85,6 +87,7 @@ class ErrorCode extends AbstractEnum
|
||||
self::GONE => true,
|
||||
self::TOO_MANY_REQUESTS => true,
|
||||
self::INTERNAL_SERVER_ERROR => true,
|
||||
self::REFUSAL => true,
|
||||
self::UNKNOWN => false,
|
||||
];
|
||||
}
|
||||
|
||||
@@ -49,6 +49,7 @@ class ErrorFactory
|
||||
ErrorCode::GONE => 'ErrorGone',
|
||||
ErrorCode::TOO_MANY_REQUESTS => 'ErrorTooManyRequests',
|
||||
ErrorCode::INTERNAL_SERVER_ERROR => 'ErrorInternalServerError',
|
||||
ErrorCode::REFUSAL => 'ErrorRuleViolation',
|
||||
ErrorCode::UNKNOWN => 'ErrorUnknown',
|
||||
];
|
||||
|
||||
|
||||
@@ -0,0 +1,82 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* The MIT License
|
||||
*
|
||||
* Copyright (c) 2026 "YooMoney", NBСO LLC
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
|
||||
namespace YooKassa\Common\Errors;
|
||||
|
||||
use YooKassa\Validator\Constraints as Assert;
|
||||
|
||||
/**
|
||||
* Класс, представляющий модель ErrorRefusal.
|
||||
*
|
||||
* Запрос не может быть выполнен согласно правилам бизнес-логики.
|
||||
*
|
||||
* @category Class
|
||||
* @package YooKassa\Model
|
||||
* @author cms@yoomoney.ru
|
||||
* @link https://yookassa.ru/developers/api
|
||||
* @property string $reason Причина по которой запрос не может быть выполнен по правилам бизнес-логики.
|
||||
*/
|
||||
class ErrorRuleViolation extends AbstractError
|
||||
{
|
||||
public function __construct(?array $data = [])
|
||||
{
|
||||
parent::__construct($data);
|
||||
$this->setCode(ErrorCode::REFUSAL);
|
||||
}
|
||||
|
||||
/**
|
||||
* Причина по которой запрос не может быть выполнен по правилам бизнес-логики.
|
||||
*
|
||||
* @var string|null
|
||||
*/
|
||||
#[Assert\Type('string')]
|
||||
private ?string $_reason = null;
|
||||
|
||||
/**
|
||||
* Возвращает reason.
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function getReason(): ?string
|
||||
{
|
||||
return $this->_reason;
|
||||
}
|
||||
|
||||
/**
|
||||
* Устанавливает reason.
|
||||
*
|
||||
* @param string|null $reason Причина по которой запрос не может быть выполнен по правилам бизнес-логики.
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function setReason(?string $reason = null): self
|
||||
{
|
||||
$this->_reason = $this->validatePropertyValue('_reason', $reason);
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,8 +29,9 @@ namespace YooKassa\Model\Notification;
|
||||
use YooKassa\Common\Exceptions\EmptyPropertyValueException;
|
||||
use YooKassa\Common\Exceptions\InvalidPropertyValueException;
|
||||
use YooKassa\Model\Payment\PaymentInterface;
|
||||
use YooKassa\Model\SavePaymentMethod\AbstractSavePaymentMethod;
|
||||
use YooKassa\Model\SavePaymentMethod\SavePaymentMethodFactory;
|
||||
use YooKassa\Model\SavePaymentMethod\SavePaymentMethodInterface;
|
||||
use YooKassa\Request\PaymentMethods\PaymentMethodResponse;
|
||||
use YooKassa\Validator\Constraints as Assert;
|
||||
|
||||
/**
|
||||
@@ -55,7 +56,7 @@ class NotificationPaymentMethodActive extends AbstractNotification
|
||||
* @var SavePaymentMethodInterface Объект способа оплаты
|
||||
*/
|
||||
#[Assert\NotBlank]
|
||||
#[Assert\Type(PaymentMethodResponse::class)]
|
||||
#[Assert\Type(AbstractSavePaymentMethod::class)]
|
||||
#[Assert\Valid]
|
||||
private SavePaymentMethodInterface $_object;
|
||||
|
||||
@@ -125,6 +126,9 @@ class NotificationPaymentMethodActive extends AbstractNotification
|
||||
*/
|
||||
public function setObject(mixed $object): self
|
||||
{
|
||||
if (is_array($object)) {
|
||||
$object = (new SavePaymentMethodFactory())->factoryFromArray($object);
|
||||
}
|
||||
$this->_object = $this->validatePropertyValue('_object', $object);
|
||||
return $this;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* The MIT License
|
||||
*
|
||||
* Copyright (c) 2026 "YooMoney", NBСO LLC
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
|
||||
namespace YooKassa\Model\Payment\PaymentMethod;
|
||||
|
||||
use YooKassa\Model\Payment\PaymentMethodType;
|
||||
|
||||
/**
|
||||
* Класс, представляющий модель PaymentMethodAlfaPay.
|
||||
*
|
||||
* Оплата через Alfa Pay.
|
||||
*
|
||||
* @category Class
|
||||
* @package YooKassa\Model
|
||||
* @author cms@yoomoney.ru
|
||||
* @link https://yookassa.ru/developers/api
|
||||
*/
|
||||
class PaymentMethodAlfaPay extends PaymentMethodBankCard
|
||||
{
|
||||
public function __construct(?array $data = [])
|
||||
{
|
||||
parent::__construct($data);
|
||||
$this->setType(PaymentMethodType::ALFA_PAY);
|
||||
}
|
||||
}
|
||||
@@ -39,7 +39,7 @@ use YooKassa\Validator\Constraints as Assert;
|
||||
* @author cms@yoomoney.ru
|
||||
* @link https://yookassa.ru/developers/api
|
||||
*
|
||||
* @property string $card Данные банковской карты
|
||||
* @property BankCard $card Данные банковской карты
|
||||
*/
|
||||
class PaymentMethodBankCard extends AbstractPaymentMethod
|
||||
{
|
||||
|
||||
@@ -65,6 +65,7 @@ class PaymentMethodFactory
|
||||
PaymentMethodType::SBER_LOAN => 'PaymentMethodSberLoan',
|
||||
PaymentMethodType::ELECTRONIC_CERTIFICATE => 'PaymentMethodElectronicCertificate',
|
||||
PaymentMethodType::SBER_BNPL => 'PaymentMethodSberBnpl',
|
||||
PaymentMethodType::ALFA_PAY => 'PaymentMethodAlfaPay',
|
||||
PaymentMethodType::UNKNOWN => 'PaymentMethodUnknown',
|
||||
];
|
||||
|
||||
|
||||
@@ -139,6 +139,9 @@ class PaymentMethodType extends AbstractEnum
|
||||
/** Оплата через сервис «Плати частями» */
|
||||
public const SBER_BNPL = 'sber_bnpl';
|
||||
|
||||
/** Прием платежей через Alfa Pay */
|
||||
public const ALFA_PAY = 'alfa_pay';
|
||||
|
||||
/**
|
||||
* Для неизвестных методов оплаты
|
||||
*
|
||||
@@ -166,6 +169,7 @@ class PaymentMethodType extends AbstractEnum
|
||||
self::SBER_LOAN => true,
|
||||
self::ELECTRONIC_CERTIFICATE => true,
|
||||
self::SBER_BNPL => true,
|
||||
self::ALFA_PAY => true,
|
||||
self::UNKNOWN => false,
|
||||
];
|
||||
}
|
||||
|
||||
@@ -42,6 +42,7 @@ use YooKassa\Common\AbstractEnum;
|
||||
* - `too_many_refunding_articles` - Для одного или нескольких товаров количество возвращаемых единиц (`quantity`) больше, чем указано в одобренной корзине покупки
|
||||
* - `some_articles_already_refunded` - Некоторые товары уже возвращены
|
||||
* - `rejected_by_timeout` - Технические неполадки на стороне инициатора отмены возврата.
|
||||
* - `payment_expired` - Эквайер отклонил возврат, потому что с момента создания платежа прошло больше 15 месяцев. Договоритесь с пользователем напрямую, каким способом вернете ему деньги.
|
||||
*/
|
||||
class RefundCancellationDetailsReasonCode extends AbstractEnum
|
||||
{
|
||||
@@ -75,6 +76,9 @@ class RefundCancellationDetailsReasonCode extends AbstractEnum
|
||||
/** Технические неполадки на стороне инициатора отмены возврата. Повторите запрос с новым ключом идемпотентности. */
|
||||
public const REJECTED_BY_TIMEOUT = 'rejected_by_timeout';
|
||||
|
||||
/** Эквайер отклонил возврат, потому что с момента создания платежа прошло больше 15 месяцев. Договоритесь с пользователем напрямую, каким способом вернете ему деньги. */
|
||||
public const PAYMENT_EXPIRED = 'payment_expired';
|
||||
|
||||
protected static array $validValues = [
|
||||
self::GENERAL_DECLINE => true,
|
||||
self::INSUFFICIENT_FUNDS => true,
|
||||
@@ -86,5 +90,6 @@ class RefundCancellationDetailsReasonCode extends AbstractEnum
|
||||
self::TOO_MANY_REFUNDING_ARTICLES => true,
|
||||
self::SOME_ARTICLES_ALREADY_REFUNDED => true,
|
||||
self::REJECTED_BY_TIMEOUT => true,
|
||||
self::PAYMENT_EXPIRED => true,
|
||||
];
|
||||
}
|
||||
|
||||
+5
-40
@@ -27,7 +27,6 @@
|
||||
namespace YooKassa\Model\SavePaymentMethod;
|
||||
|
||||
use YooKassa\Common\AbstractObject;
|
||||
use YooKassa\Model\Payment\PaymentMethod\BankCard;
|
||||
use YooKassa\Model\SavePaymentMethod\Confirmation\AbstractConfirmation;
|
||||
use YooKassa\Model\SavePaymentMethod\Confirmation\ConfirmationFactory;
|
||||
use YooKassa\Validator\Constraints as Assert;
|
||||
@@ -42,19 +41,18 @@ use YooKassa\Validator\Constraints as Assert;
|
||||
* @author cms@yoomoney.ru
|
||||
* @link https://yookassa.ru/developers/api
|
||||
*
|
||||
* @property SavePaymentMethodType $type Код способа оплаты. Возможное значение: ~`bank_card` — банковская карта.
|
||||
* @property BankCard $card Данные банковской карты
|
||||
* @property string $type Код способа оплаты. Возможное значение: ~`bank_card` — банковская карта, ~`sbp` - СБП (Система быстрых платежей)
|
||||
* @property string $id Идентификатор сохраненного способа оплаты.
|
||||
* @property bool $saved Признак сохранения способа оплаты для [автоплатежей](https://yookassa.ru/developers/payment-acceptance/scenario-extensions/recurring-payments/pay-with-saved). Возможные значения: * ~`true` — способ оплаты сохранен для автоплатежей и выплат; * ~`false` — способ оплаты не сохранен.
|
||||
* @property SavePaymentMethodStatus $status Статус проверки и сохранения способа оплаты.
|
||||
* @property string $status Статус проверки и сохранения способа оплаты.
|
||||
* @property SavePaymentMethodHolder $holder Данные магазина, для которого сохраняется способ оплаты.
|
||||
* @property string $title Название способа оплаты.
|
||||
* @property AbstractConfirmation $confirmation Выбранный сценарий подтверждения привязки. Присутствует, когда привязка ожидает подтверждения от пользователя.
|
||||
*/
|
||||
class SavePaymentMethod extends AbstractObject implements SavePaymentMethodInterface
|
||||
abstract class AbstractSavePaymentMethod extends AbstractObject implements SavePaymentMethodInterface
|
||||
{
|
||||
/**
|
||||
* Код способа оплаты. Возможное значение: ~`bank_card` — банковская карта.
|
||||
* Код способа оплаты. Возможное значение: ~`bank_card` — банковская карта, ~`sbp` - СБП (Система быстрых платежей)
|
||||
*
|
||||
* @var string|null
|
||||
*/
|
||||
@@ -63,15 +61,6 @@ class SavePaymentMethod extends AbstractObject implements SavePaymentMethodInter
|
||||
#[Assert\Type('string')]
|
||||
protected ?string $_type = null;
|
||||
|
||||
/**
|
||||
* Данные банковской карты
|
||||
*
|
||||
* @var BankCard|null
|
||||
*/
|
||||
#[Assert\Valid]
|
||||
#[Assert\Type(BankCard::class)]
|
||||
protected ?BankCard $_card = null;
|
||||
|
||||
/**
|
||||
* Идентификатор сохраненного способа оплаты.
|
||||
*
|
||||
@@ -139,7 +128,7 @@ class SavePaymentMethod extends AbstractObject implements SavePaymentMethodInter
|
||||
/**
|
||||
* Устанавливает type.
|
||||
*
|
||||
* @param string|null $type Код способа оплаты. Возможное значение: ~`bank_card` — банковская карта.
|
||||
* @param string|null $type Код способа оплаты. Возможное значение: ~`bank_card` — банковская карта, ~`sbp` - СБП (Система быстрых платежей)
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
@@ -149,29 +138,6 @@ class SavePaymentMethod extends AbstractObject implements SavePaymentMethodInter
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Возвращает card.
|
||||
*
|
||||
* @return BankCard|null
|
||||
*/
|
||||
public function getCard(): ?BankCard
|
||||
{
|
||||
return $this->_card;
|
||||
}
|
||||
|
||||
/**
|
||||
* Устанавливает card.
|
||||
*
|
||||
* @param BankCard|array|null $card Данные банковской карты.
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function setCard(mixed $card = null): self
|
||||
{
|
||||
$this->_card = $this->validatePropertyValue('_card', $card);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Возвращает id.
|
||||
*
|
||||
@@ -312,6 +278,5 @@ class SavePaymentMethod extends AbstractObject implements SavePaymentMethodInter
|
||||
$this->_confirmation = $this->validatePropertyValue('_confirmation', $confirmation);
|
||||
return $this;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -41,7 +41,8 @@ use InvalidArgumentException;
|
||||
class ConfirmationFactory
|
||||
{
|
||||
private array $typeClassMap = [
|
||||
ConfirmationType::REDIRECT => 'ConfirmationRedirect'
|
||||
ConfirmationType::REDIRECT => 'ConfirmationRedirect',
|
||||
ConfirmationType::QR => 'ConfirmationQr'
|
||||
];
|
||||
|
||||
/**
|
||||
@@ -54,7 +55,7 @@ class ConfirmationFactory
|
||||
public function factory(?string $type): AbstractConfirmation
|
||||
{
|
||||
if (!is_string($type)) {
|
||||
throw new InvalidArgumentException('Invalid confirmation type value in payment order factory');
|
||||
throw new InvalidArgumentException('Invalid confirmation type value in save payment method confirmation factory');
|
||||
}
|
||||
if (!array_key_exists($type, $this->typeClassMap)) {
|
||||
throw new InvalidArgumentException('Invalid confirmation data type "' . $type . '"');
|
||||
|
||||
@@ -0,0 +1,84 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* The MIT License
|
||||
*
|
||||
* Copyright (c) 2026 "YooMoney", NBСO LLC
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
|
||||
namespace YooKassa\Model\SavePaymentMethod\Confirmation;
|
||||
|
||||
use YooKassa\Validator\Constraints as Assert;
|
||||
|
||||
/**
|
||||
* Класс, представляющий модель PaymentMethodsConfirmationQr.
|
||||
*
|
||||
|
||||
* @category Class
|
||||
* @package YooKassa\Model
|
||||
* @author cms@yoomoney.ru
|
||||
* @link https://yookassa.ru/developers/api
|
||||
* @property string $confirmation_data Данные для генерации QR-кода.
|
||||
* @property string $confirmationData Данные для генерации QR-кода.
|
||||
*/
|
||||
class ConfirmationQr extends AbstractConfirmation
|
||||
{
|
||||
/**
|
||||
* Данные для генерации QR-кода.
|
||||
*
|
||||
* @var string|null
|
||||
*/
|
||||
#[Assert\NotBlank]
|
||||
#[Assert\Type('string')]
|
||||
private ?string $_confirmation_data = null;
|
||||
|
||||
/**
|
||||
* Возвращает confirmation_data.
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function getConfirmationData(): ?string
|
||||
{
|
||||
return $this->_confirmation_data;
|
||||
}
|
||||
|
||||
public function __construct(?array $data = [])
|
||||
{
|
||||
parent::__construct($data);
|
||||
$this->setType(ConfirmationType::QR);
|
||||
}
|
||||
|
||||
/**
|
||||
* Устанавливает confirmation_data.
|
||||
*
|
||||
* @param string|null $confirmation_data Данные для генерации QR-кода.
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function setConfirmationData(?string $confirmation_data = null): self
|
||||
{
|
||||
$this->_confirmation_data = $this->validatePropertyValue('_confirmation_data', $confirmation_data);
|
||||
return $this;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -44,11 +44,14 @@ class ConfirmationType extends AbstractEnum
|
||||
/** Перенаправление пользователя на сайт ЮKassa для подтверждения привязки или страницу банка-эмитента для аутентификации по 3-D Secure. */
|
||||
public const REDIRECT = 'redirect';
|
||||
|
||||
public const QR = 'qr';
|
||||
|
||||
/**
|
||||
* Возвращает список доступных значений
|
||||
* @return string[]
|
||||
*/
|
||||
protected static array $validValues = [
|
||||
self::REDIRECT => true
|
||||
self::REDIRECT => true,
|
||||
self::QR => true
|
||||
];
|
||||
}
|
||||
|
||||
@@ -0,0 +1,84 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* The MIT License
|
||||
*
|
||||
* Copyright (c) 2026 "YooMoney", NBСO LLC
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
namespace YooKassa\Model\SavePaymentMethod;
|
||||
|
||||
use YooKassa\Model\Payment\PaymentMethod\BankCard;
|
||||
use YooKassa\Validator\Constraints as Assert;
|
||||
|
||||
/**
|
||||
* Класс, представляющий модель SavePaymentMethod.
|
||||
*
|
||||
* Сохраненный способ оплаты.
|
||||
*
|
||||
* @category Class
|
||||
* @package YooKassa\Model
|
||||
* @author cms@yoomoney.ru
|
||||
* @link https://yookassa.ru/developers/api
|
||||
*
|
||||
* @property BankCard $card Данные банковской карты
|
||||
*/
|
||||
class SavePaymentMethodBankCard extends AbstractSavePaymentMethod
|
||||
{
|
||||
/**
|
||||
* Данные банковской карты
|
||||
*
|
||||
* @var BankCard|null
|
||||
*/
|
||||
#[Assert\Valid]
|
||||
#[Assert\Type(BankCard::class)]
|
||||
protected ?BankCard $_card = null;
|
||||
|
||||
public function __construct(?array $data = [])
|
||||
{
|
||||
parent::__construct($data);
|
||||
$this->setType(SavePaymentMethodType::BANK_CARD);
|
||||
}
|
||||
|
||||
/**
|
||||
* Возвращает card.
|
||||
*
|
||||
* @return BankCard|null
|
||||
*/
|
||||
public function getCard(): ?BankCard
|
||||
{
|
||||
return $this->_card;
|
||||
}
|
||||
|
||||
/**
|
||||
* Устанавливает card.
|
||||
*
|
||||
* @param BankCard|array|null $card Данные банковской карты.
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function setCard(mixed $card = null): self
|
||||
{
|
||||
$this->_card = $this->validatePropertyValue('_card', $card);
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,92 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* The MIT License
|
||||
*
|
||||
* Copyright (c) 2026 "YooMoney", NBСO LLC
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
namespace YooKassa\Model\SavePaymentMethod;
|
||||
|
||||
use InvalidArgumentException;
|
||||
|
||||
/**
|
||||
* Класс, представляющий модель SavePaymentMethodFactory.
|
||||
*
|
||||
* Фабрика создания объекта способа оплаты из массива.
|
||||
*
|
||||
* @category Class
|
||||
* @package YooKassa\Model
|
||||
* @author cms@yoomoney.ru
|
||||
* @link https://yookassa.ru/developers/api
|
||||
*/
|
||||
class SavePaymentMethodFactory
|
||||
{
|
||||
private array $typeClassMap = [
|
||||
SavePaymentMethodType::BANK_CARD => 'SavePaymentMethodBankCard',
|
||||
SavePaymentMethodType::SBP => 'SavePaymentMethodSbp'
|
||||
];
|
||||
|
||||
/**
|
||||
* Фабричный метод создания объекта способа оплаты по коду способа оплаты.
|
||||
*
|
||||
* @param string|null $type Код способа оплаты
|
||||
*
|
||||
* @return AbstractSavePaymentMethod
|
||||
*/
|
||||
public function factory(?string $type): AbstractSavePaymentMethod
|
||||
{
|
||||
if (!is_string($type)) {
|
||||
throw new InvalidArgumentException('Invalid confirmation type value in save payment method factory');
|
||||
}
|
||||
if (!array_key_exists($type, $this->typeClassMap)) {
|
||||
throw new InvalidArgumentException('Invalid save payment method data type "' . $type . '"');
|
||||
}
|
||||
$className = __NAMESPACE__ . '\\' . $this->typeClassMap[$type];
|
||||
|
||||
return new $className();
|
||||
}
|
||||
|
||||
/**
|
||||
* Фабричный метод создания объекта способа оплаты из массива.
|
||||
*
|
||||
* @param array $data Массив данных способа оплаты
|
||||
* @param null|string $type Коду способа оплаты
|
||||
*/
|
||||
public function factoryFromArray(array $data, ?string $type = null): AbstractSavePaymentMethod
|
||||
{
|
||||
if (null === $type) {
|
||||
if (array_key_exists('type', $data)) {
|
||||
$type = $data['type'];
|
||||
unset($data['type']);
|
||||
} else {
|
||||
throw new InvalidArgumentException(
|
||||
'Parameter type not specified in SavePaymentMethodFactory.factoryFromArray()'
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
$confirmationData = $this->factory($type);
|
||||
$confirmationData->fromArray($data);
|
||||
|
||||
return $confirmationData;
|
||||
}
|
||||
}
|
||||
@@ -39,10 +39,10 @@ use YooKassa\Model\SavePaymentMethod\Confirmation\AbstractConfirmation;
|
||||
* @author cms@yoomoney.ru
|
||||
* @link https://yookassa.ru/developers/api
|
||||
*
|
||||
* @property SavePaymentMethodType $type Код способа оплаты. Возможное значение: ~`bank_card` — банковская карта.
|
||||
* @property SavePaymentMethodType $type Код способа оплаты. Возможное значение: ~`bank_card` — банковская карта, ~`sbp` - СБП (Система быстрых платежей)
|
||||
* @property string $id Идентификатор сохраненного способа оплаты.
|
||||
* @property bool $saved Признак сохранения способа оплаты для [автоплатежей](/developers/payment-acceptance/scenario-extensions/recurring-payments/pay-with-saved). Возможные значения: * ~`true` — способ оплаты сохранен для автоплатежей и выплат; * ~`false` — способ оплаты не сохранен.
|
||||
* @property SavePaymentMethodStatus $status Статус проверки и сохранения способа оплаты.
|
||||
* @property string $status Статус проверки и сохранения способа оплаты.
|
||||
* @property SavePaymentMethodHolder $holder Данные магазина, для которого сохраняется способ оплаты.
|
||||
* @property string $title Название способа оплаты.
|
||||
* @property AbstractConfirmation $confirmation Выбранный сценарий подтверждения привязки. Присутствует, когда привязка ожидает подтверждения от пользователя.
|
||||
@@ -50,19 +50,12 @@ use YooKassa\Model\SavePaymentMethod\Confirmation\AbstractConfirmation;
|
||||
interface SavePaymentMethodInterface
|
||||
{
|
||||
/**
|
||||
* Возвращает код способа оплаты. Возможное значение: ~`bank_card` — банковская карта.
|
||||
* Возвращает код способа оплаты. Возможное значение: ~`bank_card` — банковская карта, ~`sbp` - СБП (Система быстрых платежей)
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function getType(): ?string;
|
||||
|
||||
/**
|
||||
* Возвращает card.
|
||||
*
|
||||
* @return BankCard|null
|
||||
*/
|
||||
public function getCard(): ?BankCard;
|
||||
|
||||
/**
|
||||
* Возвращает идентификатор сохраненного способа оплаты.
|
||||
*
|
||||
|
||||
@@ -0,0 +1,82 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* The MIT License
|
||||
*
|
||||
* Copyright (c) 2026 "YooMoney", NBСO LLC
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
|
||||
namespace YooKassa\Model\SavePaymentMethod;
|
||||
|
||||
use YooKassa\Validator\Constraints as Assert;
|
||||
|
||||
/**
|
||||
* Класс, представляющий модель SavePaymentMethodSbp.
|
||||
*
|
||||
* Сохраненный счет СБП.
|
||||
*
|
||||
* @category Class
|
||||
* @package YooKassa\Model
|
||||
* @author cms@yoomoney.ru
|
||||
* @link https://yookassa.ru/developers/api
|
||||
* @property SavePaymentMethodSbpPayerBankDetails $payer_bank_details
|
||||
* @property SavePaymentMethodSbpPayerBankDetails $payerBankDetails
|
||||
*/
|
||||
class SavePaymentMethodSbp extends AbstractSavePaymentMethod
|
||||
{
|
||||
/**
|
||||
* @var SavePaymentMethodSbpPayerBankDetails|null
|
||||
*/
|
||||
#[Assert\Type(SavePaymentMethodSbpPayerBankDetails::class)]
|
||||
private ?SavePaymentMethodSbpPayerBankDetails $_payer_bank_details = null;
|
||||
|
||||
public function __construct(?array $data = [])
|
||||
{
|
||||
parent::__construct($data);
|
||||
$this->setType(SavePaymentMethodType::SBP);
|
||||
}
|
||||
|
||||
/**
|
||||
* Возвращает payer_bank_details.
|
||||
*
|
||||
* @return SavePaymentMethodSbpPayerBankDetails|null
|
||||
*/
|
||||
public function getPayerBankDetails(): ?SavePaymentMethodSbpPayerBankDetails
|
||||
{
|
||||
return $this->_payer_bank_details;
|
||||
}
|
||||
|
||||
/**
|
||||
* Устанавливает payer_bank_details.
|
||||
*
|
||||
* @param SavePaymentMethodSbpPayerBankDetails|array|null $payer_bank_details
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function setPayerBankDetails(mixed $payer_bank_details = null): self
|
||||
{
|
||||
$this->_payer_bank_details = $this->validatePropertyValue('_payer_bank_details', $payer_bank_details);
|
||||
return $this;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,84 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* The MIT License
|
||||
*
|
||||
* Copyright (c) 2026 "YooMoney", NBСO LLC
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
|
||||
namespace YooKassa\Model\SavePaymentMethod;
|
||||
|
||||
use YooKassa\Common\AbstractObject;
|
||||
use YooKassa\Validator\Constraints as Assert;
|
||||
|
||||
/**
|
||||
* Класс, представляющий модель SavePaymentMethodSbpPayerBankDetails.
|
||||
*
|
||||
* Реквизиты счета, который использовался для привязки.
|
||||
* Обязательный параметр для платежей в статусе ~`succeeded`.
|
||||
* В остальных случаях может отсутствовать.
|
||||
*
|
||||
* @category Class
|
||||
* @package YooKassa\Model
|
||||
* @author cms@yoomoney.ru
|
||||
* @link https://yookassa.ru/developers/api
|
||||
* @property string $bank_id Идентификатор банка или платежного сервиса в СБП (НСПК).
|
||||
* @property string $bankId Идентификатор банка или платежного сервиса в СБП (НСПК).
|
||||
*/
|
||||
class SavePaymentMethodSbpPayerBankDetails extends AbstractObject
|
||||
{
|
||||
/**
|
||||
* Идентификатор банка или платежного сервиса в СБП (НСПК).
|
||||
*
|
||||
* @var string|null
|
||||
*/
|
||||
#[Assert\NotBlank]
|
||||
#[Assert\Type('string')]
|
||||
#[Assert\Length(max: 12)]
|
||||
#[Assert\Regex("/[a-zA-Z0-9]{12}/")]
|
||||
private ?string $_bank_id = null;
|
||||
|
||||
/**
|
||||
* Возвращает bank_id.
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function getBankId(): ?string
|
||||
{
|
||||
return $this->_bank_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Устанавливает bank_id.
|
||||
*
|
||||
* @param string|null $bank_id Идентификатор банка или платежного сервиса в СБП (НСПК).
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function setBankId(?string $bank_id = null): self
|
||||
{
|
||||
$this->_bank_id = $this->validatePropertyValue('_bank_id', $bank_id);
|
||||
return $this;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@ use YooKassa\Common\AbstractEnum;
|
||||
*
|
||||
* Статус проверки и сохранения способа оплаты. Возможные значения:
|
||||
* ~`pending` — ожидает действий от пользователя;
|
||||
* ~`active` — способ оплаты сохранен, его можно использовать для автоплатежей или выплат;
|
||||
* ~`active` — способ оплаты сохранен, его можно использовать для автоплатежей или выплат(для выплат можно сохранить только [банковскую карту](/developers/payouts/scenario-extensions/multipurpose-token));
|
||||
* ~`inactive` — способ оплаты не сохранен: пользователь не подтвердил привязку платежного средства или при сохранении способа оплаты возникла ошибка. Чтобы узнать подробности, обратитесь в техническую поддержку ЮKassa.
|
||||
*
|
||||
* @category Class
|
||||
|
||||
@@ -33,6 +33,7 @@ use YooKassa\Common\AbstractEnum;
|
||||
*
|
||||
* Тип способа оплаты. Возможное значение:
|
||||
* ~`bank_card` — банковская карта.
|
||||
* ~`sbp` — СБП (Система быстрых платежей).
|
||||
*
|
||||
* @category Class
|
||||
* @package YooKassa\Model
|
||||
@@ -43,13 +44,16 @@ class SavePaymentMethodType extends AbstractEnum
|
||||
{
|
||||
/** Банковская карта */
|
||||
public const BANK_CARD = 'bank_card';
|
||||
/** СБП (Система быстрых платежей) */
|
||||
public const SBP = 'sbp';
|
||||
|
||||
/**
|
||||
* Возвращает список доступных значений
|
||||
* @return string[]
|
||||
*/
|
||||
protected static array $validValues = [
|
||||
self::BANK_CARD => true
|
||||
self::BANK_CARD => true,
|
||||
self::SBP => true,
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
@@ -42,7 +42,8 @@ use YooKassa\Model\SavePaymentMethod\Confirmation\ConfirmationType;
|
||||
class ConfirmationFactory
|
||||
{
|
||||
private array $typeClassMap = [
|
||||
ConfirmationType::REDIRECT => 'ConfirmationRedirect'
|
||||
ConfirmationType::REDIRECT => 'ConfirmationRedirect',
|
||||
ConfirmationType::QR => 'ConfirmationQr'
|
||||
];
|
||||
|
||||
/**
|
||||
|
||||
@@ -0,0 +1,79 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* The MIT License
|
||||
*
|
||||
* Copyright (c) 2026 "YooMoney", NBСO LLC
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
|
||||
namespace YooKassa\Request\PaymentMethods\ConfirmationData;
|
||||
|
||||
use YooKassa\Model\SavePaymentMethod\Confirmation\ConfirmationType;
|
||||
use YooKassa\Validator\Constraints as Assert;
|
||||
|
||||
/**
|
||||
* Класс, представляющий модель PaymentMethodsConfirmationDataQr.
|
||||
*
|
||||
* @category Class
|
||||
* @package YooKassa\Model
|
||||
* @author cms@yoomoney.ru
|
||||
* @link https://yookassa.ru/developers/api
|
||||
* @property string $return_url
|
||||
*/
|
||||
class ConfirmationQr extends AbstractConfirmation
|
||||
{
|
||||
/**
|
||||
* @var string|null
|
||||
*/
|
||||
#[Assert\Type('string')]
|
||||
private ?string $_return_url = null;
|
||||
|
||||
public function __construct(?array $data = [])
|
||||
{
|
||||
parent::__construct($data);
|
||||
$this->setType(ConfirmationType::QR);
|
||||
}
|
||||
|
||||
/**
|
||||
* Возвращает return_url.
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function getReturnUrl(): ?string
|
||||
{
|
||||
return $this->_return_url;
|
||||
}
|
||||
|
||||
/**
|
||||
* Устанавливает return_url.
|
||||
*
|
||||
* @param string|null $return_url
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function setReturnUrl(?string $return_url = null): self
|
||||
{
|
||||
$this->_return_url = $this->validatePropertyValue('_return_url', $return_url);
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@ use YooKassa\Validator\Constraints as Assert;
|
||||
* @author cms@yoomoney.ru
|
||||
* @link https://yookassa.ru/developers/api
|
||||
*
|
||||
* @property string $type Код способа оплаты. Возможное значение: ~`bank_card` — банковская карта.
|
||||
* @property string $type Код способа оплаты. Возможное значение: ~`bank_card` — банковская карта, ~`sbp` - СБП (Система быстрых платежей)
|
||||
* @property PaymentMethodCard $card Данные банковской карты (необходимы, если вы собираете данные карты пользователей на своей стороне).
|
||||
* @property PaymentMethodHolder $holder Данные магазина, для которого сохраняется способ оплаты.
|
||||
* @property string $client_ip IPv4 или IPv6-адрес пользователя. Если не указан, используется IP-адрес TCP-подключения.
|
||||
@@ -52,7 +52,7 @@ use YooKassa\Validator\Constraints as Assert;
|
||||
class CreatePaymentMethodRequest extends AbstractRequest implements CreatePaymentMethodRequestInterface
|
||||
{
|
||||
/**
|
||||
* Код способа оплаты. Возможное значение: ~`bank_card` — банковская карта.
|
||||
* Код способа оплаты. Возможное значение: ~`bank_card` — банковская карта, ~`sbp` - СБП (Система быстрых платежей)
|
||||
*
|
||||
* @var string|null
|
||||
*/
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* The MIT License
|
||||
*
|
||||
* Copyright (c) 2026 "YooMoney", NBСO LLC
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
namespace YooKassa\Request\PaymentMethods;
|
||||
|
||||
use YooKassa\Model\SavePaymentMethod\SavePaymentMethodBankCard;
|
||||
|
||||
/**
|
||||
* Класс, представляющий модель PaymentMethodBankCartResponse.
|
||||
*
|
||||
* Объект ответа от API, возвращающего информацию о способе оплаты.
|
||||
*
|
||||
* @category Class
|
||||
* @package YooKassa\Model
|
||||
* @author cms@yoomoney.ru
|
||||
* @link https://yookassa.ru/developers/api
|
||||
*/
|
||||
class PaymentMethodBankCartResponse extends SavePaymentMethodBankCard implements PaymentMethodResponseInterface
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,93 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* The MIT License
|
||||
*
|
||||
* Copyright (c) 2026 "YooMoney", NBСO LLC
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
namespace YooKassa\Request\PaymentMethods;
|
||||
|
||||
use InvalidArgumentException;
|
||||
use YooKassa\Model\SavePaymentMethod\SavePaymentMethodType;
|
||||
|
||||
/**
|
||||
* Класс, представляющий модель PaymentMethodResponseFactory.
|
||||
*
|
||||
* Фабрика создания объекта способа оплаты из массива.
|
||||
*
|
||||
* @category Class
|
||||
* @package YooKassa\Model
|
||||
* @author cms@yoomoney.ru
|
||||
* @link https://yookassa.ru/developers/api
|
||||
*/
|
||||
class PaymentMethodResponseFactory
|
||||
{
|
||||
private array $typeClassMap = [
|
||||
SavePaymentMethodType::BANK_CARD => 'PaymentMethodBankCartResponse',
|
||||
SavePaymentMethodType::SBP => 'PaymentMethodSbpResponse'
|
||||
];
|
||||
|
||||
/**
|
||||
* Фабричный метод создания объекта способа оплаты по коду способа оплаты.
|
||||
*
|
||||
* @param string|null $type Код способа оплаты
|
||||
*
|
||||
* @return PaymentMethodResponseInterface
|
||||
*/
|
||||
public function factory(?string $type): PaymentMethodResponseInterface
|
||||
{
|
||||
if (!is_string($type)) {
|
||||
throw new InvalidArgumentException('Invalid confirmation type value in save payment method factory');
|
||||
}
|
||||
if (!array_key_exists($type, $this->typeClassMap)) {
|
||||
throw new InvalidArgumentException('Invalid save payment method data type "' . $type . '"');
|
||||
}
|
||||
$className = __NAMESPACE__ . '\\' . $this->typeClassMap[$type];
|
||||
|
||||
return new $className();
|
||||
}
|
||||
|
||||
/**
|
||||
* Фабричный метод создания объекта способа оплаты из массива.
|
||||
*
|
||||
* @param array $data Массив данных способа оплаты
|
||||
* @param null|string $type Коду способа оплаты
|
||||
*/
|
||||
public function factoryFromArray(array $data, ?string $type = null): PaymentMethodResponseInterface
|
||||
{
|
||||
if (null === $type) {
|
||||
if (array_key_exists('type', $data)) {
|
||||
$type = $data['type'];
|
||||
unset($data['type']);
|
||||
} else {
|
||||
throw new InvalidArgumentException(
|
||||
'Parameter type not specified in PaymentMethodResponseFactory.factoryFromArray()'
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
$confirmationData = $this->factory($type);
|
||||
$confirmationData->fromArray($data);
|
||||
|
||||
return $confirmationData;
|
||||
}
|
||||
}
|
||||
+3
-4
@@ -26,10 +26,10 @@
|
||||
|
||||
namespace YooKassa\Request\PaymentMethods;
|
||||
|
||||
use YooKassa\Model\SavePaymentMethod\SavePaymentMethod;
|
||||
use YooKassa\Model\SavePaymentMethod\SavePaymentMethodInterface;
|
||||
|
||||
/**
|
||||
* Класс, представляющий модель PaymentMethodResponse.
|
||||
* Класс, представляющий модель PaymentMethodResponseInterface.
|
||||
*
|
||||
* Объект ответа от API, возвращающего информацию о способе оплаты.
|
||||
*
|
||||
@@ -38,7 +38,6 @@ use YooKassa\Model\SavePaymentMethod\SavePaymentMethod;
|
||||
* @author cms@yoomoney.ru
|
||||
* @link https://yookassa.ru/developers/api
|
||||
*/
|
||||
class PaymentMethodResponse extends SavePaymentMethod
|
||||
interface PaymentMethodResponseInterface extends SavePaymentMethodInterface
|
||||
{
|
||||
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* The MIT License
|
||||
*
|
||||
* Copyright (c) 2026 "YooMoney", NBСO LLC
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
namespace YooKassa\Request\PaymentMethods;
|
||||
|
||||
use YooKassa\Model\SavePaymentMethod\SavePaymentMethodBankCard;
|
||||
use YooKassa\Model\SavePaymentMethod\SavePaymentMethodType;
|
||||
|
||||
/**
|
||||
* Класс, представляющий модель PaymentMethodSbpResponse.
|
||||
*
|
||||
* Объект ответа от API, возвращающего информацию о способе оплаты.
|
||||
*
|
||||
* @category Class
|
||||
* @package YooKassa\Model
|
||||
* @author cms@yoomoney.ru
|
||||
* @link https://yookassa.ru/developers/api
|
||||
*/
|
||||
class PaymentMethodSbpResponse extends SavePaymentMethodBankCard implements PaymentMethodResponseInterface
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* The MIT License
|
||||
*
|
||||
* Copyright (c) 2026 "YooMoney", NBСO LLC
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
|
||||
namespace YooKassa\Request\Payments\PaymentData;
|
||||
|
||||
use YooKassa\Model\Payment\PaymentMethodType;
|
||||
|
||||
/**
|
||||
* Класс, представляющий модель PaymentDataAlfaPay.
|
||||
*
|
||||
* Данные для оплаты через Alfa Pay.
|
||||
*
|
||||
* @category Class
|
||||
* @package YooKassa\Model
|
||||
* @author cms@yoomoney.ru
|
||||
* @link https://yookassa.ru/developers/api
|
||||
*/
|
||||
class PaymentDataAlfaPay extends AbstractPaymentData
|
||||
{
|
||||
public function __construct(?array $data = [])
|
||||
{
|
||||
parent::__construct($data);
|
||||
$this->setType(PaymentMethodType::ALFA_PAY);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -55,6 +55,7 @@ class PaymentDataFactory
|
||||
PaymentMethodType::SBER_LOAN => 'PaymentDataSberLoan',
|
||||
PaymentMethodType::ELECTRONIC_CERTIFICATE => 'PaymentDataElectronicCertificate',
|
||||
PaymentMethodType::SBER_BNPL => 'PaymentDataSberBnpl',
|
||||
PaymentMethodType::ALFA_PAY => 'PaymentDataAlfaPay',
|
||||
];
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user