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,162 @@
<?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\PaymentMethod;
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 $id Идентификатор записи о сохраненных платежных данных
* @property bool $saved Возможность многократного использования
* @property string $title Название метода оплаты
*/
abstract class AbstractPaymentMethod extends AbstractObject
{
/**
* @var string Идентификатор записи о сохраненных платежных данных
*/
private $_id;
/**
* @var string Тип объекта
*/
private $_type;
/**
* @var bool Возможность многократного использования
*/
private $_saved = false;
/**
* @var string Название метода оплаты
*/
private $_title;
/**
* @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, 'PaymentMethod.type'
);
} elseif (TypeCast::canCastToEnumString($value)) {
if (PaymentMethodType::valueExists($value)) {
$this->_type = (string)$value;
} else {
throw new InvalidPropertyValueException(
'Invalid value for "type" parameter in PaymentMethod', 0, 'PaymentMethod.type', $value
);
}
} else {
throw new InvalidPropertyValueTypeException(
'Invalid value type for "type" parameter in PaymentMethod', 0, 'PaymentMethod.type', $value
);
}
}
/**
* @return string Идентификатор записи о сохраненных платежных данных
*/
public function getId()
{
return $this->_id;
}
/**
* @param string $value Идентификатор записи о сохраненных платежных данных
*/
public function setId($value)
{
if ($value === null || $value === '') {
$this->_id = null;
} elseif (TypeCast::canCastToString($value)) {
$this->_id = (string)$value;
} else {
throw new InvalidPropertyValueTypeException('Invalid id value type', 0, 'PaymentMethod.id', $value);
}
}
/**
* @return bool Возможность многократного использования
*/
public function getSaved()
{
return $this->_saved;
}
/**
* @param bool $value Возможность многократного использования
*/
public function setSaved($value)
{
if ($value === null || $value === '') {
throw new EmptyPropertyValueException('Empty saved value', 0, 'PaymentMethod.saved');
} elseif (TypeCast::canCastToBoolean($value)) {
$this->_saved = (bool)$value;
} else {
throw new InvalidPropertyValueTypeException(
'Invalid saved value type', 0, 'PaymentMethod.saved', $value
);
}
}
/**
* @return string|null Название метода оплаты
*/
public function getTitle()
{
return $this->_title;
}
/**
* @param string $value Название метода оплаты
*/
public function setTitle($value)
{
if ($value === null || $value === '') {
$this->_title = null;
} elseif (TypeCast::canCastToString($value)) {
$this->_title = (string)$value;
} else {
throw new InvalidPropertyValueTypeException('Invalid title value type', 0, 'PaymentMethod.title', $value);
}
}
}
@@ -0,0 +1,243 @@
<?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\PaymentMethod\B2b\Sberbank;
use YooKassa\Common\AbstractObject;
/**
* Банковские реквизиты плательщика
* @property string $fullName Полное наименование организации
* @property string $shortName Сокращенное наименование организации
* @property string $address Адрес организации
* @property string $inn ИНН организации
* @property string $kpp КПП организации
* @property string $bankName Наименование банка организации
* @property string $bankBranch Отделение банка организации
* @property string $bankBik БИК банка организации
* @property string $account Номер счета организации
*/
class PayerBankDetails extends AbstractObject implements PayerBankDetailsInterface
{
/**
* @var string Полное наименование организации
*/
private $_fullName;
/**
* @var string Сокращенное наименование организации
*/
private $_shortName;
/**
* @var string Адрес организации
*/
private $_address;
/**
* @var string ИНН организации
*/
private $_inn;
/**
* @var string КПП организации
*/
private $_kpp;
/**
* @var string Наименование банка организации
*/
private $_bankName;
/**
* @var string Отделение банка организации
*/
private $_bankBranch;
/**
* @var string БИК банка организации
*/
private $_bankBik;
/**
* @var string Номер счета организации
*/
private $_account;
/**
* Возвращает полное наименование организации
* @return string Полное наименование организации
*/
public function getFullName()
{
return $this->_fullName;
}
/**
* @param string $value
*/
public function setFullName($value)
{
$this->_fullName = $value;
}
/**
* Возвращает сокращенное наименование организации
* @return string Сокращенное наименование организации
*/
public function getShortName()
{
return $this->_shortName;
}
/**
* @param string $value
*/
public function setShortName($value)
{
$this->_shortName = $value;
}
/**
* Возвращает адрес организации
* @return string Адрес организации
*/
public function getAddress()
{
return $this->_address;
}
/**
* @param string $value
*/
public function setAddress($value)
{
$this->_address = $value;
}
/**
* Возвращает ИНН организации
* @return string ИНН организации
*/
public function getInn()
{
return $this->_inn;
}
/**
* @param string $value
*/
public function setInn($value)
{
$this->_inn = $value;
}
/**
* Возвращает КПП организации
* @return string КПП организации
*/
public function getKpp()
{
return $this->_kpp;
}
/**
* @param string $value
*/
public function setKpp($value)
{
$this->_kpp = $value;
}
/**
* Возвращает наименование банка организации
* @return string Наименование банка организации
*/
public function getBankName()
{
return $this->_bankName;
}
/**
* @param string $value
*/
public function setBankName($value)
{
$this->_bankName = $value;
}
/**
* Возвращает отделение банка организации
* @return string Отделение банка организации
*/
public function getBankBranch()
{
return $this->_bankBranch;
}
/**
* @param string $value
*/
public function setBankBranch($value)
{
$this->_bankBranch = $value;
}
/**
* Возвращает БИК банка организации
* @return string БИК банка организации
*/
public function getBankBik()
{
return $this->_bankBik;
}
/**
* @param string $value
*/
public function setBankBik($value)
{
$this->_bankBik = $value;
}
/**
* Возвращает номер счета организации
* @return string Номер счета организации
*/
public function getAccount()
{
return $this->_account;
}
/**
* @param string $value
*/
public function setAccount($value)
{
$this->_account = $value;
}
}
@@ -0,0 +1,101 @@
<?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\PaymentMethod\B2b\Sberbank;
/**
* Interface PayerBankDetailsInterface
*
* @package YooKassa\Model
*
* @property-read string $fullName Полное наименование организации
* @property-read string $shortName Сокращенное наименование организации
* @property-read string $address Адрес организации
* @property-read string $inn ИНН организации
* @property-read string $kpp КПП организации
* @property-read string $bankName Наименование банка организации
* @property-read string $bankBranch Отделение банка организации
* @property-read string $bankBik БИК банка организации
* @property-read string $account Номер счета организации
*/
interface PayerBankDetailsInterface
{
/**
* Возвращает полное наименование организации
* @return string Полное наименование организации
*/
function getFullName();
/**
* Возвращает сокращенное наименование организации
* @return string Сокращенное наименование организации
*/
function getShortName();
/**
* Возвращает адрес организации
* @return string Адрес организации
*/
function getAddress();
/**
* Возвращает ИНН организации
* @return string ИНН организации
*/
function getInn();
/**
* Возвращает КПП организации
* @return string КПП организации
*/
function getKpp();
/**
* Возвращает наименование банка организации
* @return string Наименование банка организации
*/
function getBankName();
/**
* Возвращает отделение банка организации
* @return string Отделение банка организации
*/
function getBankBranch();
/**
* Возвращает БИК банка организации
* @return string БИК банка организации
*/
function getBankBik();
/**
* Возвращает номер счета организации
* @return string Номер счета организации
*/
function getAccount();
}
@@ -0,0 +1,26 @@
<?php
namespace YooKassa\Model\PaymentMethod;
use YooKassa\Common\AbstractEnum;
/**
* BankCardSource - Источник данных банковской карты
* |Код|Описание|
* --- | ---
* |apple_pay|Источник данных apple_pay|
* |google_pay|Источник данных google_pay|
*
*/
class BankCardSource extends AbstractEnum
{
const APPLE_PAY = 'apple_pay';
const GOOGLE_PAY = 'google_pay';
protected static $validValues = array(
self::APPLE_PAY => true,
self::GOOGLE_PAY => 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\PaymentMethod;
use YooKassa\Common\Exceptions\InvalidPropertyValueTypeException;
use YooKassa\Helpers\TypeCast;
use YooKassa\Model\PaymentMethodType;
/**
* PaymentMethodAlfaBank
* Объект, описывающий метод оплаты, при оплате через Альфа Банк.
* @property string $type Тип объекта
* @property string $login Имя пользователя в Альфа-Клике
*/
class PaymentMethodAlfaBank extends AbstractPaymentMethod
{
/**
* @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) {
$this->_login = '';
} elseif (TypeCast::canCastToString($value)) {
$this->_login = (string)$value;
} else {
throw new InvalidPropertyValueTypeException(
'Invalid login value type', 0, 'PaymentMethodAlfaBank.login', $value
);
}
}
}
@@ -0,0 +1,42 @@
<?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\PaymentMethod;
use YooKassa\Model\PaymentMethodType;
/**
* PaymentMethodApplePay
* Объект, описывающий метод оплаты, при оплате через Apple Pay
* @property string $type Тип объекта
*/
class PaymentMethodApplePay extends AbstractPaymentMethod
{
public function __construct()
{
$this->_setType(PaymentMethodType::APPLE_PAY);
}
}
@@ -0,0 +1,124 @@
<?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\PaymentMethod;
use YooKassa\Common\Exceptions\InvalidPropertyValueException;
use YooKassa\Model\PaymentData\B2b\Sberbank\VatData;
use YooKassa\Model\PaymentMethod\B2b\Sberbank\PayerBankDetails;
use YooKassa\Model\PaymentMethodType;
/**
* PaymentMethodB2bSberbank
* Объект, описывающий метод оплаты, при оплате через Сбербанк Бизнес Онлайн
*/
class PaymentMethodB2bSberbank extends AbstractPaymentMethod
{
/**
* @var string Назначение платежа
*/
private $_paymentPurpose;
/**
* @var VatData Данные об НДС
*/
private $_vatData;
/**
* @var PayerBankDetails
*/
private $_payerBankDetails;
public function __construct()
{
$this->_setType(PaymentMethodType::B2B_SBERBANK);
}
/**
* @return string
*/
public function getPaymentPurpose()
{
return $this->_paymentPurpose;
}
/**
* @param string $paymentPurpose
*/
public function setPaymentPurpose($paymentPurpose)
{
$this->_paymentPurpose = $paymentPurpose;
}
/**
* @return VatData
*/
public function getVatData()
{
return $this->_vatData;
}
/**
* @param VatData $vatData
*/
public function setVatData($vatData)
{
if(is_array($vatData)) {
$value = new VatData();
$value->fromArray($vatData);
$this->_vatData = $value;
} else if($vatData instanceof VatData){
$this->_vatData = $vatData;
} else{
throw new InvalidPropertyValueException('Invalid $vatData property type');
}
}
/**
* @return PayerBankDetails
*/
public function getPayerBankDetails()
{
return $this->_payerBankDetails;
}
/**
* @param $payerBankDetails
*/
public function setPayerBankDetails($payerBankDetails)
{
if(is_array($payerBankDetails)) {
$value = new PayerBankDetails();
$value->fromArray($payerBankDetails);
$this->_payerBankDetails = $value;
} else if($payerBankDetails instanceof PayerBankDetails){
$this->_payerBankDetails = $payerBankDetails;
} else{
throw new InvalidPropertyValueException('Invalid $payerBankDetails property type');
}
}
}
@@ -0,0 +1,343 @@
<?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\PaymentMethod;
use YooKassa\Common\Exceptions\EmptyPropertyValueException;
use YooKassa\Common\Exceptions\InvalidPropertyValueException;
use YooKassa\Common\Exceptions\InvalidPropertyValueTypeException;
use YooKassa\Helpers\TypeCast;
use YooKassa\Model\PaymentMethodType;
/**
* PaymentMethodBankCard
* Объект, описывающий метод оплаты банковской картой
* @property string $type Тип объекта
* @property string $last4 Последние 4 цифры номера карты
* @property string $first6 Первые 6 цифр номера карты
* @property string $expiryYear Срок действия, год
* @property string $expiry_year Срок действия, год
* @property string $expiryMonth Срок действия, месяц
* @property string $expiry_month Срок действия, месяц
* @property string $cardType Тип банковской карты
* @property string $card_type Тип банковской карты
* @property string $issuerCountry Тип банковской карты
* @property string $issuer_country Тип банковской карты
* @property string issuerName Тип банковской карты
* @property string $issuer_name Тип банковской карты
* @property string $source Тип банковской карты
*/
class PaymentMethodBankCard extends AbstractPaymentMethod
{
/**
* @var string Длина кода страны по ISO 3166 https://www.iso.org/obp/ui/#iso:pub:PUB500001:en
*/
const ISO_3166_CODE_LENGTH = 2;
/**
* @var string Последние 4 цифры номера карты
*/
private $_last4;
/**
* @var string Первые 6 цифр номера карты
*/
private $_first6;
/**
* @var string Срок действия, год
*/
private $_expiryYear;
/**
* @var string Срок действия, месяц
*/
private $_expiryMonth;
/**
* @var string Тип банковской карты
*/
private $_cardType;
/**
* @var string Код страны, в которой выпущена карта
*/
private $_issuerCountry;
/**
* @var string Наименование банка, выпустившего карту
*/
private $_issuerName;
/**
* @var string Источник данных банковской карты
*/
private $_source;
public function __construct()
{
$this->_setType(PaymentMethodType::BANK_CARD);
}
/**
* @return string Последние 4 цифры номера карты
*/
public function getLast4()
{
return $this->_last4;
}
/**
* @param string $value Последние 4 цифры номера карты
*/
public function setLast4($value)
{
if ($value === null || $value === '') {
throw new EmptyPropertyValueException('Empty card last4 value', 0, 'PaymentMethodBankCard.last4');
} elseif (TypeCast::canCastToString($value)) {
if (preg_match('/^[0-9]{4}$/', (string)$value)) {
$this->_last4 = (string)$value;
} else {
throw new InvalidPropertyValueException(
'Invalid card last4 value', 0, 'PaymentMethodBankCard.last4', $value
);
}
} else {
throw new InvalidPropertyValueTypeException(
'Invalid card last4 value type', 0, 'PaymentMethodBankCard.last4', $value
);
}
}
/**
* @return string
* @since 1.0.14
*/
public function getFirst6()
{
return $this->_first6;
}
/**
* @param $value
* @since 1.0.14
*/
public function setFirst6($value)
{
if ($value === null || $value === '') {
throw new EmptyPropertyValueException('Empty card first6 value', 0, 'PaymentMethodBankCard.first6');
} elseif (TypeCast::canCastToString($value)) {
if (preg_match('/^[0-9]{6}$/', (string)$value)) {
$this->_first6 = (string)$value;
} else {
throw new InvalidPropertyValueException(
'Invalid card first6 value', 0, 'PaymentMethodBankCard.first6', $value
);
}
} else {
throw new InvalidPropertyValueTypeException(
'Invalid card first6 value type', 0, 'PaymentMethodBankCard.first6', $value
);
}
}
/**
* @return string Срок действия, год
*/
public function getExpiryYear()
{
return $this->_expiryYear;
}
/**
* @param string $value Срок действия, год
*/
public function setExpiryYear($value)
{
if ($value === null || $value === '') {
throw new EmptyPropertyValueException(
'Empty card expiry year value', 0, 'PaymentMethodBankCard.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, 'PaymentMethodBankCard.expiryYear', $value
);
}
$this->_expiryYear = (string)$value;
} else {
throw new InvalidPropertyValueException(
'Invalid card expiry year value', 0, 'PaymentMethodBankCard.expiryYear', $value
);
}
}
/**
* @return string Срок действия, месяц
*/
public function getExpiryMonth()
{
return $this->_expiryMonth;
}
/**
* @param string $value Срок действия, месяц
*/
public function setExpiryMonth($value)
{
if ($value === null || $value === '') {
throw new EmptyPropertyValueException(
'Empty card expiry month value', 0, 'PaymentMethodBankCard.expiryMonth'
);
} elseif (is_numeric($value)) {
if (!preg_match('/^\d\d$/', $value)) {
throw new InvalidPropertyValueException(
'Invalid card expiry month value', 0, 'PaymentMethodBankCard.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, 'PaymentMethodBankCard.expiryMonth', $value
);
} else {
$this->_expiryMonth = (string)$value;
}
} else {
throw new InvalidPropertyValueException(
'Invalid card expiry month value', 0, 'PaymentMethodBankCard.expiryMonth', $value
);
}
}
/**
* @return string Тип банковской карты
*/
public function getCardType()
{
return $this->_cardType;
}
/**
* @param string $value Тип банковской карты
*/
public function setCardType($value)
{
if ($value === null || $value === '') {
throw new EmptyPropertyValueException('Empty cardType value', 0, 'PaymentMethodBankCard.cardType');
} elseif (TypeCast::canCastToString($value)) {
$this->_cardType = (string)$value;
} else {
throw new InvalidPropertyValueTypeException(
'Invalid cardType value type', 0, 'PaymentMethodBankCard.cardType', $value
);
}
}
/**
* @return string
*/
public function getIssuerCountry()
{
return $this->_issuerCountry;
}
/**
* @param string $value
*/
public function setIssuerCountry($value)
{
if ($value === null || $value === '') {
$this->_issuerCountry = (string)$value;
} elseif (!TypeCast::canCastToString($value)) {
throw new InvalidPropertyValueTypeException(
'Invalid issuerCountry value type', 0, 'PaymentMethodBankCard.issuerCountry', $value
);
} elseif (strlen($value) !== self::ISO_3166_CODE_LENGTH) {
throw new InvalidPropertyValueException(
'Invalid issuerCountry value', 0, 'PaymentMethodBankCard.issuerCountry', $value
);
}
$this->_issuerCountry = (string)$value;
}
/**
* @param string $value
*/
public function setIssuerName($value)
{
if ($value === null || $value === '') {
$this->_issuerName = (string)$value;
} elseif (!TypeCast::canCastToString($value)) {
throw new EmptyPropertyValueException(
'Empty issuerName value', 0, 'PaymentMethodBankCard.issuerName'
);
}
$this->_issuerName = (string)$value;
}
/**
* @return string
*/
public function getIssuerName()
{
return $this->_issuerName;
}
/**
* @param string $value
*/
public function setSource($value)
{
if ($value === null || $value === '') {
$this->_source = (string)$value;
} elseif (!TypeCast::canCastToEnumString($value)) {
throw new InvalidPropertyValueTypeException(
'Invalid source value type', 0, 'PaymentMethodBankCard.source', $value
);
} elseif (!BankCardSource::valueExists($value)) {
throw new InvalidPropertyValueException(
'Invalid source value', 0, 'PaymentMethodBankCard.source', $value
);
}
$this->_source = (string)$value;
}
/**
* @return string
*/
public function getSource()
{
return $this->_source;
}
}
@@ -0,0 +1,63 @@
<?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\PaymentMethod;
use YooKassa\Common\AbstractEnum;
/**
* Тип банковской карты. Возможные значения:
* - `MasterCard` (для карт Mastercard и Maestro),
* - `Visa` (для карт Visa и Visa Electron),
* - `Mir`,
* - `UnionPay`,
* - `JCB`,
* - `AmericanExpress`,
* - `DinersClub`
* - `Unknown`.
*/
class PaymentMethodCardType extends AbstractEnum
{
const MASTER_CARD = 'MasterCard';
const VISA = 'Visa';
const MIR = 'Mir';
const UNION_PAY = 'UnionPay';
const JCB = 'JCB';
const AMERICAN_EXPRESS = 'AmericanExpress';
const DINERS_CLUB = 'DinersClub';
const UNKNOWN = 'Unknown';
protected static $validValues = array(
self::MASTER_CARD => true,
self::VISA => true,
self::MIR => true,
self::UNION_PAY => true,
self::JCB => true,
self::AMERICAN_EXPRESS => true,
self::DINERS_CLUB => true,
self::UNKNOWN => true,
);
}
@@ -0,0 +1,42 @@
<?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\PaymentMethod;
use YooKassa\Model\PaymentMethodType;
/**
* PaymentMethodCash
* Объект, описывающий метод оплаты, при оплате наличными через терминал.
* @property string $type Тип объекта
*/
class PaymentMethodCash extends AbstractPaymentMethod
{
public function __construct()
{
$this->_setType(PaymentMethodType::CASH);
}
}
@@ -0,0 +1,114 @@
<?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\PaymentMethod;
use YooKassa\Model\PaymentMethodType;
class PaymentMethodFactory
{
private $typeClassMap = array(
PaymentMethodType::YOO_MONEY => 'PaymentMethodYooMoney',
PaymentMethodType::BANK_CARD => 'PaymentMethodBankCard',
PaymentMethodType::SBERBANK => 'PaymentMethodSberbank',
PaymentMethodType::CASH => 'PaymentMethodCash',
PaymentMethodType::MOBILE_BALANCE => 'PaymentMethodMobileBalance',
PaymentMethodType::APPLE_PAY => 'PaymentMethodApplePay',
PaymentMethodType::GOOGLE_PAY => 'PaymentMethodGooglePay',
PaymentMethodType::QIWI => 'PaymentMethodQiwi',
PaymentMethodType::WEBMONEY => 'PaymentMethodWebmoney',
PaymentMethodType::ALFABANK => 'PaymentMethodAlfaBank',
PaymentMethodType::INSTALLMENTS => 'PaymentMethodInstallments',
PaymentMethodType::B2B_SBERBANK => 'PaymentMethodB2bSberbank',
PaymentMethodType::TINKOFF_BANK => 'PaymentMethodTinkoffBank',
PaymentMethodType::PSB => 'PaymentMethodPsb',
PaymentMethodType::WECHAT => 'PaymentMethodWechat',
);
private $optionsMap = array(
'card_type' => 'cardType',
'expiry_month' => 'expiryMonth',
'expiry_year' => 'expiryYear',
'account_number' => 'accountNumber',
);
/**
* @param string $type
*
* @return AbstractPaymentMethod
*/
public function factory($type)
{
if (!is_string($type)) {
throw new \InvalidArgumentException('Invalid payment method type value in payment factory');
}
if (!array_key_exists($type, $this->typeClassMap)) {
throw new \InvalidArgumentException('Invalid payment method data type "'.$type.'"');
}
$className = __NAMESPACE__.'\\'.$this->typeClassMap[$type];
return new $className();
}
/**
* @param array $data
* @param string|null $type
*
* @return AbstractPaymentMethod
*/
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);
$this->fillModel($paymentData, $data);
return $paymentData;
}
private function fillModel(AbstractPaymentMethod $paymentData, array $data)
{
foreach ($data as $key => $value) {
if (array_key_exists($key, $this->optionsMap)) {
$key = $this->optionsMap[$key];
}
if ($paymentData->offsetExists($key)) {
$paymentData->offsetSet($key, $value);
} else if (is_array($value)) {
$this->fillModel($paymentData, $value);
}
}
}
}
@@ -0,0 +1,42 @@
<?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\PaymentMethod;
use YooKassa\Model\PaymentMethodType;
/**
* PaymentMethodGooglePay
* Объект, описывающий метод оплаты, при оплате через Google Pay
* @property string $type Тип объекта
*/
class PaymentMethodGooglePay extends AbstractPaymentMethod
{
public function __construct()
{
$this->_setType(PaymentMethodType::GOOGLE_PAY);
}
}
@@ -0,0 +1,42 @@
<?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\PaymentMethod;
use YooKassa\Model\PaymentMethodType;
/**
* PaymentMethodInstallments
* Объект, описывающий метод оплаты при оплате по частям
* @property string $type Тип объекта
*/
class PaymentMethodInstallments extends AbstractPaymentMethod
{
public function __construct()
{
$this->_setType(PaymentMethodType::INSTALLMENTS);
}
}
@@ -0,0 +1,83 @@
<?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\PaymentMethod;
use YooKassa\Common\Exceptions\EmptyPropertyValueException;
use YooKassa\Common\Exceptions\InvalidPropertyValueException;
use YooKassa\Common\Exceptions\InvalidPropertyValueTypeException;
use YooKassa\Helpers\TypeCast;
use YooKassa\Model\PaymentMethodType;
/**
* PaymentMethodMobileBalance
* Объект, описывающий метод оплаты, при оплате с баланса мобильного телефона.
* @property string $type Тип объекта
* @property string $phone
*/
class PaymentMethodMobileBalance extends AbstractPaymentMethod
{
/**
* Номер телефона в формате 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, 'PaymentMethodMobileBalance.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, 'PaymentMethodMobileBalance.phone', $value
);
}
} else {
throw new InvalidPropertyValueTypeException(
'Invalid phone value type', 0, 'PaymentMethodMobileBalance.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\PaymentMethod;
use YooKassa\Model\PaymentMethodType;
class PaymentMethodPsb extends AbstractPaymentMethod
{
public function __construct()
{
$this->_setType(PaymentMethodType::PSB);
}
}
@@ -0,0 +1,42 @@
<?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\PaymentMethod;
use YooKassa\Model\PaymentMethodType;
/**
* PaymentMethodQiwi
* Объект, описывающий метод оплаты, при оплате через Qiwi.
* @property string $type Тип объекта
*/
class PaymentMethodQiwi extends AbstractPaymentMethod
{
public function __construct()
{
$this->_setType(PaymentMethodType::QIWI);
}
}
@@ -0,0 +1,87 @@
<?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\PaymentMethod;
use YooKassa\Common\Exceptions\EmptyPropertyValueException;
use YooKassa\Common\Exceptions\InvalidPropertyValueException;
use YooKassa\Common\Exceptions\InvalidPropertyValueTypeException;
use YooKassa\Helpers\TypeCast;
use YooKassa\Model\PaymentMethodType;
/**
* PaymentMethodSberbank
* Объект, описывающий метод оплаты, при оплате через Сбербанк Онлайн
* @property string $type Тип объекта
* @property string $phone
*/
class PaymentMethodSberbank extends AbstractPaymentMethod
{
/**
* Телефон пользователя, на который зарегистрирован аккаунт в Сбербанке Онлайн.
*
* Необходим для подтверждения оплаты по смс (сценарий подтверждения `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, 'PaymentMethodSberbank.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, 'PaymentMethodSberbank.phone', $value
);
}
} else {
throw new InvalidPropertyValueTypeException(
'Invalid phone value type', 0, 'PaymentMethodSberbank.phone', $value
);
}
}
}
@@ -0,0 +1,36 @@
<?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\PaymentMethod;
use YooKassa\Model\PaymentMethodType;
class PaymentMethodTinkoffBank extends AbstractPaymentMethod
{
public function __construct()
{
$this->_setType(PaymentMethodType::TINKOFF_BANK);
}
}
@@ -0,0 +1,42 @@
<?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\PaymentMethod;
use YooKassa\Model\PaymentMethodType;
/**
* PaymentMethodWebmoney
* Объект, описывающий метод оплаты, при оплате через Webmoney.
* @property string $type Тип объекта
*/
class PaymentMethodWebmoney extends AbstractPaymentMethod
{
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\PaymentMethod;
use YooKassa\Model\PaymentMethodType;
/**
* @deprecated Класс будет удалён в одной из будущих версий.
*/
class PaymentMethodWechat extends AbstractPaymentMethod
{
public function __construct()
{
$this->_setType(PaymentMethodType::WECHAT);
}
}
@@ -0,0 +1,85 @@
<?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\PaymentMethod;
use YooKassa\Common\Exceptions\EmptyPropertyValueException;
use YooKassa\Common\Exceptions\InvalidPropertyValueException;
use YooKassa\Common\Exceptions\InvalidPropertyValueTypeException;
use YooKassa\Helpers\TypeCast;
use YooKassa\Model\PaymentMethodType;
/**
* PaymentMethodYooMoney
* Объект, описывающий метод оплаты, при оплате через ЮMoney
* @property string $type Тип объекта
* @property string $accountNumber Номер кошелька в ЮMoney с которого была произведена оплата.
* @property string $account_number Номер кошелька в ЮMoney с которого была произведена оплата.
*/
class PaymentMethodYooMoney extends AbstractPaymentMethod
{
/**
* @var string Номер кошелька в ЮMoney с которого была произведена оплата.
*/
private $_accountNumber;
public function __construct()
{
$this->_setType(PaymentMethodType::YOO_MONEY);
}
/**
* @return string Номер кошелька в ЮMoney с которого была произведена оплата.
*/
public function getAccountNumber()
{
return $this->_accountNumber;
}
/**
* @param string $value Номер кошелька в ЮMoney с которого была произведена оплата.
*/
public function setAccountNumber($value)
{
if ($value === null || $value === '') {
throw new EmptyPropertyValueException(
'Empty accountNumber value', 0, 'PaymentMethodYooMoney.accountNumber'
);
} elseif (TypeCast::canCastToString($value)) {
if (preg_match('/^[0-9]{11,33}$/', $value)) {
$this->_accountNumber = (string)$value;
} else {
throw new InvalidPropertyValueException(
'Invalid accountNumber value', 0, 'PaymentMethodYooMoney.accountNumber', $value
);
}
} else {
throw new InvalidPropertyValueTypeException(
'Invalid accountNumber value type', 0, 'PaymentMethodYooMoney.accountNumber', $value
);
}
}
}