Initial Commit

This commit is contained in:
2024-02-08 12:07:49 -07:00
parent 5813b1109f
commit 43077b57ed
5471 changed files with 682195 additions and 0 deletions
@@ -0,0 +1,78 @@
<?php
/**
* The MIT License
*
* Copyright (c) 2020 "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\PaymentData;
use YooKassa\Common\AbstractObject;
use YooKassa\Common\Exceptions\EmptyPropertyValueException;
use YooKassa\Common\Exceptions\InvalidPropertyValueException;
use YooKassa\Common\Exceptions\InvalidPropertyValueTypeException;
use YooKassa\Helpers\TypeCast;
use YooKassa\Model\PaymentMethodType;
/**
* Данные используемые для создания метода оплаты.
* @property string $type
*/
abstract class AbstractPaymentData extends AbstractObject
{
/**
* @var string
*/
private $_type;
/**
* @return string
*/
public function getType()
{
return $this->_type;
}
/**
* @param string $value
*/
protected function _setType($value)
{
if ($value === null || $value === '') {
throw new EmptyPropertyValueException(
'Empty payment data type', 0, 'paymentData.type'
);
} elseif (TypeCast::canCastToEnumString($value)) {
if (PaymentMethodType::valueExists($value)) {
$this->_type = (string)$value;
} else {
throw new InvalidPropertyValueException(
'Invalid value for "type" parameter in PaymentData', 0, 'paymentData.type', $value
);
}
} else {
throw new InvalidPropertyValueTypeException(
'Invalid value type for "type" parameter in PaymentData', 0, 'paymentData.type', $value
);
}
}
}
@@ -0,0 +1,167 @@
<?php
/**
* The MIT License
*
* Copyright (c) 2020 "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\PaymentData\B2b\Sberbank;
use YooKassa\Common\AbstractObject;
use YooKassa\Common\Exceptions\InvalidPropertyValueException;
use YooKassa\Common\Exceptions\InvalidPropertyValueTypeException;
use YooKassa\Helpers\TypeCast;
use YooKassa\Model\AmountInterface;
use YooKassa\Model\MonetaryAmount;
/**
* Данные об НДС
* @property string $type Способ расчёта НДС
* @property string $rate Данные об НДС в случае, если сумма НДС включена в сумму платежа
* @property AmountInterface $amount Сумма НДС
*/
class VatData extends AbstractObject implements VatDataInterface
{
/**
* @var string Способ расчёта НДС
*/
private $_type;
/**
* @var string Налоговая ставка НДС
*/
private $_rate;
/**
* @var AmountInterface Сумма НДС
*/
private $_amount;
/**
* VatData constructor.
* @param string|null $type Способ расчёта НДС
* @param string|null $rate Налоговая ставка НДС
* @param AmountInterface|null $amount Сумма НДС
*/
public function __construct($type = null, $rate = null, $amount = null)
{
if ($type !== null) {
$this->setType($type);
}
if ($rate !== null) {
$this->setRate($rate);
}
if ($amount !== null) {
$this->setAmount($amount);
}
}
/**
* @return string Способ расчёта НДС
*/
public function getType()
{
return $this->_type;
}
/**
* Устанавливает способ расчёта НДС
* @param string $value Способ расчёта НДС
*
* @throws InvalidPropertyValueException Выбрасывается если переданная строка не является валидным способом
* @throws InvalidPropertyValueTypeException Выбрасывается если в метод была передана не строка
*/
public function setType($value)
{
if (TypeCast::canCastToEnumString($value)) {
if (!VatDataType::valueExists((string)$value)) {
throw new InvalidPropertyValueException('Invalid B2bSberbankVatData.type value', 0,
'B2bSberbankVatData.type', $value);
}
$this->_type = (string)$value;
} else {
throw new InvalidPropertyValueTypeException(
'Invalid B2bSberbankVatData.type value type', 0, 'B2bSberbankVatData.type', $value
);
}
}
/**
* @return string Налоговая ставка НДС
*/
public function getRate()
{
return $this->_rate;
}
/**
* Устанавливает налоговую ставку НДС
* @param string $value Налоговая ставка НДС
*
* @throws InvalidPropertyValueException Выбрасывается если переданная строка не является валидной ставкой
* @throws InvalidPropertyValueTypeException Выбрасывается если в метод была передана не строка
*/
public function setRate($value)
{
if (TypeCast::canCastToString($value)) {
if (!VatDataRate::valueExists((string)$value)) {
throw new InvalidPropertyValueException('Invalid B2bSberbankVatData.rate value', 0,
'B2bSberbankVatData.rate', $value);
}
$this->_rate = (string)$value;
} else {
throw new InvalidPropertyValueTypeException(
'Invalid B2bSberbankVatData.rate value type', 0, 'B2bSberbankVatData.rate', $value
);
}
}
/**
* Возвращает сумму НДС
* @return AmountInterface Сумма НДС
*/
public function getAmount()
{
return $this->_amount;
}
/**
* Устанавливает сумму НДС
* @param AmountInterface|array|null $value Сумма НДС
*/
public function setAmount($value)
{
if ($value === null) {
$this->_amount = null;
} elseif ($value instanceof AmountInterface) {
$this->_amount = $value;
} elseif (is_array($value)) {
$this->_amount = new MonetaryAmount();
$this->_amount->fromArray($value);
} else {
throw new InvalidPropertyValueTypeException(
'Invalid B2bSberbankVatData.amount value type', 0, 'B2bSberbankVatData.amount', $value
);
}
}
}
@@ -0,0 +1,60 @@
<?php
/**
* The MIT License
*
* Copyright (c) 2020 "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\PaymentData\B2b\Sberbank;
use YooKassa\Model\AmountInterface;
/**
* Interface VatDataInterface
*
* @package YooKassa\Model
*
* @property-read string $type Способ расчёта НДС
* @property-read string $rate Данные об НДС в случае, если сумма НДС включена в сумму платежа
* @property-read AmountInterface $amount Сумма НДС
*/
interface VatDataInterface
{
/**
* Возвращает способ расчёта НДС
* @return string Способ расчёта НДС
*/
function getType();
/**
* Возвращает данные об НДС
* @return string Данные об НДС
*/
function getRate();
/**
* Возвращает сумму НДС
* @return AmountInterface Сумма НДС
*/
function getAmount();
}
@@ -0,0 +1,54 @@
<?php
/**
* The MIT License
*
* Copyright (c) 2020 "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\PaymentData\B2b\Sberbank;
use YooKassa\Common\AbstractEnum;
/**
* PaymentDataB2bSberbankVatDataRate - Налоговая ставка НДС
* |Код|Описание|
* --- | ---
* |7|7%|
* |10|10%|
* |18|18%|
* |20|20%|
*/
class VatDataRate extends AbstractEnum
{
const RATE_7 = '7';
const RATE_10 = '10';
const RATE_18 = '18';
const RATE_20 = '20';
protected static $validValues = array(
self::RATE_7 => true,
self::RATE_10 => true,
self::RATE_18 => true,
self::RATE_20 => true,
);
}
@@ -0,0 +1,51 @@
<?php
/**
* The MIT License
*
* Copyright (c) 2020 "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\PaymentData\B2b\Sberbank;
use YooKassa\Common\AbstractEnum;
/**
* PaymentDataB2bSberbankVatDataType - Способ расчёта НДС
* |Код|Описание|
* --- | ---
* |calculated|Сумма НДС включена в сумму платежа|
* |mixed|Разные ставки НДС для разных товаров|
* |untaxed|Сумма платежа НДС не облагается|
*/
class VatDataType extends AbstractEnum
{
const CALCULATED = 'calculated';
const MIXED = 'mixed';
const UNTAXED = 'untaxed';
protected static $validValues = array(
self::CALCULATED => true,
self::MIXED => true,
self::UNTAXED => true,
);
}
@@ -0,0 +1,74 @@
<?php
/**
* The MIT License
*
* Copyright (c) 2020 "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\PaymentData;
use YooKassa\Common\Exceptions\EmptyPropertyValueException;
use YooKassa\Common\Exceptions\InvalidPropertyValueTypeException;
use YooKassa\Helpers\TypeCast;
use YooKassa\Model\PaymentMethodType;
/**
* PaymentDataAlfabank
* Платежные данные для проведения оплаты через Альфа Клик или Альфа Молнию.
* @property string $login Имя пользователя в Альфа-Клике
*/
class PaymentDataAlfabank extends AbstractPaymentData
{
/**
* @var string Имя пользователя в Альфа-Клике
*/
private $_login;
public function __construct()
{
$this->_setType(PaymentMethodType::ALFABANK);
}
/**
* @return string Имя пользователя в Альфа-Клике
*/
public function getLogin()
{
return $this->_login;
}
/**
* @param string $value Имя пользователя в Альфа-Клике
*/
public function setLogin($value)
{
if ($value === null || $value === '') {
throw new EmptyPropertyValueException('Empty login value', 0, 'PaymentDataAlfabank.login');
} elseif (TypeCast::canCastToString($value)) {
$this->_login = (string)$value;
} else {
throw new InvalidPropertyValueTypeException(
'Invalid login value type', 0, 'PaymentDataAlfabank.login', $value
);
}
}
}
@@ -0,0 +1,78 @@
<?php
/**
* The MIT License
*
* Copyright (c) 2020 "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\PaymentData;
use YooKassa\Common\Exceptions\EmptyPropertyValueException;
use YooKassa\Common\Exceptions\InvalidPropertyValueTypeException;
use YooKassa\Helpers\TypeCast;
use YooKassa\Model\PaymentMethodType;
/**
* PaymentDataApplePay
* Платежные данные для проведения оплаты при помощи Apple Pay
* @property string $type Тип объекта
* @property string $paymentData содержимое поля paymentData объекта PKPaymentToken, закодированное в Base64
* @property string $payment_data содержимое поля paymentData объекта PKPaymentToken, закодированное в Base64
*/
class PaymentDataApplePay extends AbstractPaymentData
{
/**
* @var string содержимое поля paymentData объекта PKPaymentToken, закодированное в Base64
*/
private $_paymentData;
public function __construct()
{
$this->_setType(PaymentMethodType::APPLE_PAY);
}
/**
* @return string содержимое поля paymentData объекта PKPaymentToken, закодированное в Base64
*/
public function getPaymentData()
{
return $this->_paymentData;
}
/**
* @param string $value содержимое поля paymentData объекта PKPaymentToken, закодированное в Base64
*/
public function setPaymentData($value)
{
if ($value === null || $value === '') {
throw new EmptyPropertyValueException(
'Empty value for paymentData', 0, 'PaymentDataApplePay.paymentData'
);
} elseif (TypeCast::canCastToString($value)) {
$this->_paymentData = (string)$value;
} else {
throw new InvalidPropertyValueTypeException(
'Invalid value type for paymentData', 0, 'PaymentDataApplePay.paymentData', $value
);
}
}
}
@@ -0,0 +1,120 @@
<?php
/**
* The MIT License
*
* Copyright (c) 2020 "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\PaymentData;
use YooKassa\Common\Exceptions\EmptyPropertyValueException;
use YooKassa\Common\Exceptions\InvalidPropertyValueException;
use YooKassa\Common\Exceptions\InvalidPropertyValueTypeException;
use YooKassa\Helpers\TypeCast;
use YooKassa\Model\PaymentData\B2b\Sberbank\VatData;
use YooKassa\Model\PaymentMethodType;
/**
* PaymentDataB2BSberbank
* Платежные данные для проведения оплаты при помощи Сбербанк Бизнес Онлайн.
* @property string $paymentPurpose Назначение платежа
* @property VatData $vatData Данные об НДС
*/
class PaymentDataB2bSberbank extends AbstractPaymentData
{
/**
* @var string Назначение платежа
*/
private $_paymentPurpose;
/**
* @var VatData Данные об НДС
*/
private $_vatData;
public function __construct()
{
$this->_setType(PaymentMethodType::B2B_SBERBANK);
}
/**
* @return string Назначение платежа
*/
public function getPaymentPurpose()
{
return $this->_paymentPurpose;
}
/**
* @param string $value Назначение платежа
*/
public function setPaymentPurpose($value)
{
if ($value === null || $value === '') {
throw new EmptyPropertyValueException('Empty paymentPurpose value', 0,
'PaymentDataB2bSberbank.paymentPurpose');
} elseif (TypeCast::canCastToString($value)) {
if (preg_match('/^.{1,210}$/', $value)) {
$this->_paymentPurpose = (string)$value;
} else {
throw new InvalidPropertyValueException(
'Invalid paymentPurpose value', 0, 'PaymentDataB2bSberbank.paymentPurpose', $value
);
}
} else {
throw new InvalidPropertyValueTypeException(
'Invalid paymentPurpose value type', 0, 'PaymentDataB2bSberbank.paymentPurpose', $value
);
}
}
/**
* @return VatData Данные об НДС
*/
public function getVatData()
{
return $this->_vatData;
}
/**
* @param VatData|array|null $value Данные об НДС
*/
public function setVatData($value)
{
if ($value === null || $value === array()) {
$this->_vatData = null;
} elseif ($value instanceof VatData) {
$this->_vatData = $value;
} elseif (is_array($value) || $value instanceof \Traversable) {
$vatData = new VatData();
foreach ($value as $property => $val) {
$vatData->offsetSet($property, $val);
}
$this->_vatData = $vatData;
} else {
throw new InvalidPropertyValueTypeException(
'Invalid vatData value type in PaymentDataB2BSberbank', 0,
'PaymentDataB2BSberbank.vatData', $value
);
}
}
}
@@ -0,0 +1,80 @@
<?php
/**
* The MIT License
*
* Copyright (c) 2020 "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\PaymentData;
use YooKassa\Common\Exceptions\InvalidPropertyValueTypeException;
use YooKassa\Model\PaymentMethodType;
/**
* PaymentDataBankCard
* Платежные данные для проведения оплаты при помощи банковской карты
*
* @property PaymentDataBankCardCard $card Данные банковской карты
*/
class PaymentDataBankCard extends AbstractPaymentData
{
/**
* Необходим при оплате PCI-DSS данными.
* @var PaymentDataBankCardCard Данные банковской карты
*/
private $_card;
public function __construct()
{
$this->_setType(PaymentMethodType::BANK_CARD);
}
/**
* @return PaymentDataBankCardCard Данные банковской карты
*/
public function getCard()
{
return $this->_card;
}
/**
* @param PaymentDataBankCardCard|array $value Данные банковской карты
*/
public function setCard($value)
{
if ($value === null || $value === '' || $value === array()) {
$this->_card = null;
} elseif (is_object($value) && $value instanceof PaymentDataBankCardCard) {
$this->_card = $value;
} elseif (is_array($value) || $value instanceof \Traversable) {
$card = new PaymentDataBankCardCard();
foreach ($value as $property => $val) {
$card->offsetSet($property, $val);
}
$this->_card = $card;
} else {
throw new InvalidPropertyValueTypeException(
'Invalid card value type in PaymentDataBankCard', 0, 'PaymentDataBankCard.card', $value
);
}
}
}
@@ -0,0 +1,239 @@
<?php
/**
* The MIT License
*
* Copyright (c) 2020 "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\PaymentData;
use YooKassa\Common\AbstractObject;
use YooKassa\Common\Exceptions\EmptyPropertyValueException;
use YooKassa\Common\Exceptions\InvalidPropertyValueException;
use YooKassa\Common\Exceptions\InvalidPropertyValueTypeException;
use YooKassa\Helpers\TypeCast;
/**
* Данные банковской карты
* Необходим при оплате PCI-DSS данными.
* @property string $number Номер банковской карты
* @property string $expiryYear Срок действия, год, YY
* @property string $expiry_year Срок действия, год, YY
* @property string $expiryMonth Срок действия, месяц, MM
* @property string $expiry_month Срок действия, месяц, MM
* @property string $csc CVV2/CVC2 код
* @property string $cardholder Имя держателя карты
*/
class PaymentDataBankCardCard extends AbstractObject
{
/**
* @var string Номер банковской карты
*/
private $_number;
/**
* @var string Срок действия, год, YY
*/
private $_expiryYear;
/**
* @var string Срок действия, месяц, MM
*/
private $_expiryMonth;
/**
* @var string CVV2/CVC2 код
*/
private $_csc;
/**
* @var string Имя держателя карты
*/
private $_cardholder;
/**
* @return string Номер банковской карты
*/
public function getNumber()
{
return $this->_number;
}
/**
* @param string $value Номер банковской карты
*/
public function setNumber($value)
{
if ($value === null || $value === '') {
throw new EmptyPropertyValueException('Empty card number value', 0, 'PaymentDataBankCardCard.number');
} elseif (TypeCast::canCastToString($value)) {
if (preg_match('/^[0-9]{16,19}$/', (string)$value)) {
$this->_number = (string)$value;
} else {
throw new InvalidPropertyValueException(
'Invalid card number value', 0, 'PaymentDataBankCardCard.number', $value
);
}
} else {
throw new InvalidPropertyValueTypeException(
'Invalid card number value type', 0, 'PaymentDataBankCardCard.number', $value
);
}
}
/**
* @return string Срок действия, год, YYYY
*/
public function getExpiryYear()
{
return $this->_expiryYear;
}
/**
* @param string $value Срок действия, год, YYYY
*/
public function setExpiryYear($value)
{
if ($value === null || $value === '') {
throw new EmptyPropertyValueException(
'Empty card expiry year value', 0, 'PaymentDataBankCardCard.expiryYear'
);
} elseif (is_numeric($value)) {
if (!preg_match('/^\d\d\d\d$/', $value) || $value < 2000 || $value > 2200) {
throw new InvalidPropertyValueException(
'Invalid card expiry year value', 0, 'PaymentDataBankCardCard.expiryYear', $value
);
}
$this->_expiryYear = (string)$value;
} else {
throw new InvalidPropertyValueException(
'Invalid card expiry year value', 0, 'PaymentDataBankCardCard.expiryYear', $value
);
}
}
/**
* @return string Срок действия, месяц, MM
*/
public function getExpiryMonth()
{
return $this->_expiryMonth;
}
/**
* @param string $value Срок действия, месяц, MM
*/
public function setExpiryMonth($value)
{
if ($value === null || $value === '') {
throw new EmptyPropertyValueException(
'Empty card expiry month value', 0, 'PaymentDataBankCardCard.expiryMonth'
);
} elseif (is_numeric($value)) {
if (!preg_match('/^\d\d$/', $value)) {
throw new InvalidPropertyValueException(
'Invalid card expiry month value', 0, 'PaymentDataBankCardCard.expiryMonth', $value
);
}
if (is_string($value) && $value[0] == '0') {
$month = (int)($value[1]);
} else {
$month = (int)$value;
}
if ($month < 1 || $month > 12) {
throw new InvalidPropertyValueException(
'Invalid card expiry month value', 0, 'PaymentDataBankCardCard.expiryMonth', $value
);
} else {
$this->_expiryMonth = (string)$value;
}
} else {
throw new InvalidPropertyValueException(
'Invalid card expiry month value', 0, 'PaymentDataBankCardCard.expiryMonth', $value
);
}
}
/**
* @return string CVV2/CVC2 код
*/
public function getCsc()
{
return $this->_csc;
}
/**
* @param string $value CVV2/CVC2 код
*/
public function setCsc($value)
{
if ($value === null || $value === '') {
throw new EmptyPropertyValueException(
'Empty card CSC code value', 0, 'PaymentDataBankCardCard.csc'
);
} elseif (is_numeric($value)) {
if (preg_match('/^\d{3,4}$/', $value)) {
$this->_csc = (string)$value;
} else {
throw new InvalidPropertyValueException(
'Invalid card CSC code value', 0, 'PaymentDataBankCardCard.csc', $value
);
}
} else {
throw new InvalidPropertyValueException(
'Invalid card CSC code value', 0, 'PaymentDataBankCardCard.csc', $value
);
}
}
/**
* @return string Имя держателя карты
*/
public function getCardholder()
{
return $this->_cardholder;
}
/**
* @param string $value Имя держателя карты
*/
public function setCardholder($value)
{
if ($value === null || $value === '') {
throw new EmptyPropertyValueException(
'Empty card holder value', 0, 'PaymentDataBankCardCard.cardholder'
);
} elseif (TypeCast::canCastToString($value)) {
if (preg_match('/^[a-zA-Z\s]{1,26}$/', $value)) {
$this->_cardholder = (string)$value;
} else {
throw new InvalidPropertyValueException(
'Invalid card holder value', 0, 'PaymentDataBankCardCard.cardholder', $value
);
}
} else {
throw new InvalidPropertyValueException(
'Invalid card holder value', 0, 'PaymentDataBankCardCard.cardholder', $value
);
}
}
}
@@ -0,0 +1,81 @@
<?php
/**
* The MIT License
*
* Copyright (c) 2020 "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\PaymentData;
use YooKassa\Common\Exceptions\InvalidPropertyValueException;
use YooKassa\Common\Exceptions\InvalidPropertyValueTypeException;
use YooKassa\Helpers\TypeCast;
use YooKassa\Model\PaymentMethodType;
/**
* PaymentDataCash
* Платежные данные для проведения оплаты Qiwi.
* @property string $phone
*/
class PaymentDataCash extends AbstractPaymentData
{
/**
* Номер телефона в формате ITU-T E.164 на который будет отправлена информация для оплаты.
* @var string
*/
private $_phone;
public function __construct()
{
$this->_setType(PaymentMethodType::CASH);
}
/**
* @return string
*/
public function getPhone()
{
return $this->_phone;
}
/**
* @param string $value
*/
public function setPhone($value)
{
if ($value === null || $value === '') {
$this->_phone = null;
} elseif (TypeCast::canCastToString($value)) {
if (preg_match('/^[0-9]{4,15}$/', $value)) {
$this->_phone = (string)$value;
} else {
throw new InvalidPropertyValueException(
'Invalid phone value', 0, 'PaymentDataCash.phone', $value
);
}
} else {
throw new InvalidPropertyValueTypeException(
'Invalid phone value type', 0, 'PaymentDataCash.phone', $value
);
}
}
}
@@ -0,0 +1,95 @@
<?php
/**
* The MIT License
*
* Copyright (c) 2020 "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\PaymentData;
use YooKassa\Model\PaymentMethodType;
class PaymentDataFactory
{
private $typeClassMap = array(
PaymentMethodType::YOO_MONEY => 'PaymentDataYooMoney',
PaymentMethodType::BANK_CARD => 'PaymentDataBankCard',
PaymentMethodType::SBERBANK => 'PaymentDataSberbank',
PaymentMethodType::CASH => 'PaymentDataCash',
PaymentMethodType::MOBILE_BALANCE => 'PaymentDataMobileBalance',
PaymentMethodType::APPLE_PAY => 'PaymentDataApplePay',
PaymentMethodType::GOOGLE_PAY => 'PaymentDataGooglePay',
PaymentMethodType::QIWI => 'PaymentDataQiwi',
PaymentMethodType::WEBMONEY => 'PaymentDataWebmoney',
PaymentMethodType::ALFABANK => 'PaymentDataAlfabank',
PaymentMethodType::INSTALLMENTS => 'PaymentDataInstallments',
PaymentMethodType::B2B_SBERBANK => 'PaymentDataB2bSberbank',
PaymentMethodType::TINKOFF_BANK => 'PaymentDataTinkoffBank',
PaymentMethodType::WECHAT => 'PaymentDataWechat',
);
/**
* @param string $type
*
* @return AbstractPaymentData
*/
public function factory($type)
{
if (!is_string($type)) {
throw new \InvalidArgumentException('Invalid payment type value in payment factory');
}
if (!array_key_exists($type, $this->typeClassMap)) {
throw new \InvalidArgumentException('Invalid payment data type "'.$type.'"');
}
$className = __NAMESPACE__.'\\'.$this->typeClassMap[$type];
return new $className();
}
/**
* @param array $data
* @param string|null $type
*
* @return AbstractPaymentData
*/
public function factoryFromArray(array $data, $type = null)
{
if ($type === null) {
if (array_key_exists('type', $data)) {
$type = $data['type'];
unset($data['type']);
} else {
throw new \InvalidArgumentException(
'Parameter type not specified in PaymentDataFactory.factoryFromArray()'
);
}
}
$paymentData = $this->factory($type);
foreach ($data as $key => $value) {
if ($paymentData->offsetExists($key)) {
$paymentData->offsetSet($key, $value);
}
}
return $paymentData;
}
}
@@ -0,0 +1,108 @@
<?php
/**
* The MIT License
*
* Copyright (c) 2020 "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\PaymentData;
use YooKassa\Common\Exceptions\EmptyPropertyValueException;
use YooKassa\Common\Exceptions\InvalidPropertyValueTypeException;
use YooKassa\Helpers\TypeCast;
use YooKassa\Model\PaymentMethodType;
/**
* PaymentDataGooglePay
* Платежные данные для проведения оплаты при помощи Google Pay.
* @property string $paymentMethodToken Криптограмма Payment Token Cryptography для проведения оплаты через Google Pay
* @property string $googleTransactionId Уникальный идентификатор транзакции, выданный Google
*/
class PaymentDataGooglePay extends AbstractPaymentData
{
/**
* @var string Криптограмма Payment Token Cryptography для проведения оплаты через Google Pay
*/
private $_paymentMethodToken;
/**
* @var string Уникальный идентификатор транзакции, выданный Google
*/
private $_googleTransactionId;
public function __construct()
{
$this->_setType(PaymentMethodType::GOOGLE_PAY);
}
/**
* @return string Криптограмма Payment Token Cryptography для проведения оплаты через Google Pay
*/
public function getPaymentMethodToken()
{
return $this->_paymentMethodToken;
}
/**
* @param string $value Криптограмма Payment Token Cryptography для проведения оплаты через Google Pay
*/
public function setPaymentMethodToken($value)
{
if ($value === null || $value === '') {
throw new EmptyPropertyValueException(
'Empty value for paymentMethodToken', 0, 'PaymentDataGooglePay.paymentMethodToken'
);
} elseif (TypeCast::canCastToString($value)) {
$this->_paymentMethodToken = (string)$value;
} else {
throw new InvalidPropertyValueTypeException(
'Invalid value type for paymentMethodToken', 0, 'PaymentDataGooglePay.paymentMethodToken', $value
);
}
}
/**
* @return string Уникальный идентификатор транзакции, выданный Google
*/
public function getGoogleTransactionId()
{
return $this->_googleTransactionId;
}
/**
* @param string $value Уникальный идентификатор транзакции, выданный Google
*/
public function setGoogleTransactionId($value)
{
if ($value === null || $value === '') {
throw new EmptyPropertyValueException(
'Empty value for googleTransactionId', 0, 'PaymentDataGooglePay.googleTransactionId'
);
} elseif (TypeCast::canCastToString($value)) {
$this->_googleTransactionId = (string)$value;
} else {
throw new InvalidPropertyValueTypeException(
'Invalid value type for googleTransactionId', 0, 'PaymentDataGooglePay.googleTransactionId', $value
);
}
}
}
@@ -0,0 +1,40 @@
<?php
/**
* The MIT License
*
* Copyright (c) 2020 "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\PaymentData;
use YooKassa\Model\PaymentMethodType;
/**
* Данные для проведения оплаты по частям
*/
class PaymentDataInstallments extends AbstractPaymentData
{
public function __construct()
{
$this->_setType(PaymentMethodType::INSTALLMENTS);
}
}
@@ -0,0 +1,82 @@
<?php
/**
* The MIT License
*
* Copyright (c) 2020 "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\PaymentData;
use YooKassa\Common\Exceptions\EmptyPropertyValueException;
use YooKassa\Common\Exceptions\InvalidPropertyValueException;
use YooKassa\Common\Exceptions\InvalidPropertyValueTypeException;
use YooKassa\Helpers\TypeCast;
use YooKassa\Model\PaymentMethodType;
/**
* PaymentDataMobileBalance
* Платежные данные для проведения оплаты Qiwi.
* @property string $phone
*/
class PaymentDataMobileBalance extends AbstractPaymentData
{
/**
* Номер телефона в формате ITU-T E.164 с которого плательщик собирается произвести оплату.
* @var string
*/
private $_phone;
public function __construct()
{
$this->_setType(PaymentMethodType::MOBILE_BALANCE);
}
/**
* @return string
*/
public function getPhone()
{
return $this->_phone;
}
/**
* @param string $value
*/
public function setPhone($value)
{
if ($value === null || $value === '') {
throw new EmptyPropertyValueException('Empty phone value', 0, 'PaymentDataMobileBalance.phone');
} elseif (TypeCast::canCastToString($value)) {
if (preg_match('/^[0-9]{4,15}$/', $value)) {
$this->_phone = (string)$value;
} else {
throw new InvalidPropertyValueException(
'Invalid phone value', 0, 'PaymentDataMobileBalance.phone', $value
);
}
} else {
throw new InvalidPropertyValueTypeException(
'Invalid phone value type', 0, 'PaymentDataMobileBalance.phone', $value
);
}
}
}
@@ -0,0 +1,81 @@
<?php
/**
* The MIT License
*
* Copyright (c) 2020 "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\PaymentData;
use YooKassa\Common\Exceptions\EmptyPropertyValueException;
use YooKassa\Common\Exceptions\InvalidPropertyValueException;
use YooKassa\Common\Exceptions\InvalidPropertyValueTypeException;
use YooKassa\Helpers\TypeCast;
use YooKassa\Model\PaymentMethodType;
/**
* PaymentDataQiwi
* Платежные данные для проведения оплаты Qiwi.
*/
class PaymentDataQiwi extends AbstractPaymentData
{
/**
* Номер телефона в формате ITU-T E.164 с которого плательщик собирается произвести оплату.
* @var string
*/
private $_phone;
public function __construct()
{
$this->_setType(PaymentMethodType::QIWI);
}
/**
* @return string
*/
public function getPhone()
{
return $this->_phone;
}
/**
* @param string $value
*/
public function setPhone($value)
{
if ($value === null || $value === '') {
throw new EmptyPropertyValueException('Empty phone value', 0, 'PaymentDataQiwi.phone');
} elseif (TypeCast::canCastToString($value)) {
if (preg_match('/^[0-9]{4,15}$/', $value)) {
$this->_phone = (string)$value;
} else {
throw new InvalidPropertyValueException(
'Invalid phone value', 0, 'PaymentDataQiwi.phone', $value
);
}
} else {
throw new InvalidPropertyValueTypeException(
'Invalid phone value type', 0, 'PaymentDataQiwi.phone', $value
);
}
}
}
@@ -0,0 +1,86 @@
<?php
/**
* The MIT License
*
* Copyright (c) 2020 "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\PaymentData;
use YooKassa\Common\Exceptions\EmptyPropertyValueException;
use YooKassa\Common\Exceptions\InvalidPropertyValueException;
use YooKassa\Common\Exceptions\InvalidPropertyValueTypeException;
use YooKassa\Helpers\TypeCast;
use YooKassa\Model\PaymentMethodType;
/**
* PaymentDataSberbank
* Платежные данные для проведения оплаты при помощи Сбербанк Онлайн.
* @property string $phone
*/
class PaymentDataSberbank extends AbstractPaymentData
{
/**
* Телефон пользователя, на который зарегистрирован аккаунт в Сбербанке Онлайн.
*
* Необходим для подтверждения оплаты по смс (сценарий подтверждения `external`).
* Указывается в формате [ITU-T E.164](https://ru.wikipedia.org/wiki/E.164), например `79000000000`.
*
* @var string Телефон пользователя
*/
private $_phone;
public function __construct()
{
$this->_setType(PaymentMethodType::SBERBANK);
}
/**
* @return string
*/
public function getPhone()
{
return $this->_phone;
}
/**
* @param string $value
*/
public function setPhone($value)
{
if ($value === null || $value === '') {
throw new EmptyPropertyValueException('Empty phone value', 0, 'PaymentDataSberbank.phone');
} elseif (TypeCast::canCastToString($value)) {
if (preg_match('/^[0-9]{4,15}$/', $value)) {
$this->_phone = (string)$value;
} else {
throw new InvalidPropertyValueException(
'Invalid phone value', 0, 'PaymentDataSberbank.phone', $value
);
}
} else {
throw new InvalidPropertyValueTypeException(
'Invalid phone value type', 0, 'PaymentDataSberbank.phone', $value
);
}
}
}
@@ -0,0 +1,37 @@
<?php
/**
* The MIT License
*
* Copyright (c) 2020 "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\PaymentData;
use YooKassa\Model\PaymentMethodType;
class PaymentDataTinkoffBank extends AbstractPaymentData
{
public function __construct()
{
$this->_setType(PaymentMethodType::TINKOFF_BANK);
}
}
@@ -0,0 +1,41 @@
<?php
/**
* The MIT License
*
* Copyright (c) 2020 "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\PaymentData;
use YooKassa\Model\PaymentMethodType;
/**
* PaymentDataWebmoney
* Платежные данные для проведения оплаты Webmoney.
*/
class PaymentDataWebmoney extends AbstractPaymentData
{
public function __construct()
{
$this->_setType(PaymentMethodType::WEBMONEY);
}
}
@@ -0,0 +1,40 @@
<?php
/**
* The MIT License
*
* Copyright (c) 2020 "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\PaymentData;
use YooKassa\Model\PaymentMethodType;
/**
* @deprecated Класс будет удалён в одной из будущих версий.
*/
class PaymentDataWechat extends AbstractPaymentData
{
public function __construct()
{
$this->_setType(PaymentMethodType::WECHAT);
}
}
@@ -0,0 +1,40 @@
<?php
/**
* The MIT License
*
* Copyright (c) 2020 "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\PaymentData;
use YooKassa\Model\PaymentMethodType;
/**
* Данные для проведения оплаты через ЮMoney
*/
class PaymentDataYooMoney extends AbstractPaymentData
{
public function __construct()
{
$this->_setType(PaymentMethodType::YOO_MONEY);
}
}