Skip to content

Commit

Permalink
Merge pull request #19 from yoomoney/release/v2.0.2
Browse files Browse the repository at this point in the history
Release/2.0.2
  • Loading branch information
tonchik-tm authored Jan 12, 2021
2 parents f90ba70 + a655b33 commit 9065027
Show file tree
Hide file tree
Showing 18 changed files with 97 additions and 346 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
### v2.0.2 от 12.01.2020
* Обновлен SDK до версии 2.0.4
* Исправлены некоторые ошибки

### v2.0.1 от 15.12.2020
* Новый виджет кредитования

Expand Down
13 changes: 8 additions & 5 deletions payment/YooMoneyApi/YooMoneyApi.php
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<?php
/**
* Version: 2.0.1
* Version: 2.0.2
* License: Любое использование Вами программы означает полное и безоговорочное принятие Вами условий лицензионного договора, размещенного по адресу https://yoomoney.ru/doc.xml?id=527132 (далее – «Лицензионный договор»). Если Вы не принимаете условия Лицензионного договора в полном объёме, Вы не имеете права использовать программу в каких-либо целях.
*/

require_once 'api/Simpla.php';
require_once 'autoload.php';
define('YOOMONEY_MODULE_VERSION', '2.0.1');
define('YOOMONEY_MODULE_VERSION', '2.0.2');

use YooKassa\Client;
use YooKassa\Model\Payment;
Expand Down Expand Up @@ -39,11 +39,13 @@ public function checkout_form($order_id, $button_text = null)
$payment_sitemode = ($settings['yoomoney_paymode'] == 'site') ? true : false;
$payment_type = ($payment_sitemode) ? $settings['yoomoney_paymenttype'] : '';

$logger = new YooMoneyLogger($settings['yookassa_debug']);

if (($payment_type == \YooKassa\Model\PaymentMethodType::INSTALLMENTS)
&& ($amount < self::INSTALLMENTS_MIN_AMOUNT)
) {
return '<span style="color:#ec0060;">Заплатить этим способом не получится: сумма должна быть больше '
.self::INSTALLMENTS_MIN_AMOUNT.' рублей.</span>';
. self::INSTALLMENTS_MIN_AMOUNT . ' рублей.</span>';
}

if ($payment_type == \YooKassa\Model\PaymentMethodType::ALFABANK) {
Expand Down Expand Up @@ -123,7 +125,6 @@ public function checkout_form($order_id, $button_text = null)
try {
$response = $apiClient->createPayment($paymentRequest, $idempotencyKey);
} catch (Exception $exception) {
$logger = new YooMoneyLogger($settings['yookassa_debug']);
$logger->error($exception->getMessage());
}

Expand Down Expand Up @@ -273,7 +274,9 @@ private function getForm($button_text, $settings, $amount)
</div>
<?php
}
} else {
}

if (!$onKassaSide || ($onKassaSide && !$showInstallmentsButton)) {
?>
<input type="submit" name="submit-button" value="<?= $button_text; ?>"
class="checkout_button yookassa_button">
Expand Down
4 changes: 3 additions & 1 deletion payment/YooMoneyApi/autoload.php
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
<?php

require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . 'vendor' . DIRECTORY_SEPARATOR . 'autoload.php';
require_once __DIR__ . DIRECTORY_SEPARATOR . 'vendor' . DIRECTORY_SEPARATOR . 'autoload.php';

function yooMoneyClassLoader($className)
{
if (strncmp('YooMoneyModule', $className, 14) === 0) {
$length = 14;
$path = __DIR__;
} else {
return;
}

if (DIRECTORY_SEPARATOR === '/') {
Expand Down
2 changes: 1 addition & 1 deletion payment/YooMoneyApi/composer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"require": {
"php": ">=5.4",
"vendor/yoomoney/yookassa-sdk-php": "^2.0"
"yoomoney/yookassa-sdk-php": "^2.0"
}
}
2 changes: 1 addition & 1 deletion payment/YooMoneyApi/settings.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<module>
<name>
ЮKassa (версия 2.0.1)
ЮKassa (версия 2.0.2)
</name>
<settings>
<variable>yoomoney_shopid</variable>
Expand Down
4 changes: 2 additions & 2 deletions payment/YooMoneyApi/vendor/composer/autoload_static.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ class ComposerStaticInit72a0a89f022b8535ec3a0ca68643c330
public static $prefixDirsPsr4 = array (
'YooKassa\\' =>
array (
0 => __DIR__ . '/..',
0 => __DIR__ . '/..' . '/yoomoney/yookassa-sdk-php/lib',
),
'Psr\\Log\\' =>
array (
0 => __DIR__ . '/..',
0 => __DIR__ . '/..' . '/psr/log/Psr/Log',
),
);

Expand Down
12 changes: 6 additions & 6 deletions payment/YooMoneyApi/vendor/composer/installed.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,17 +50,17 @@
},
{
"name": "yoomoney/yookassa-sdk-php",
"version": "2.0.3",
"version_normalized": "2.0.3.0",
"version": "2.0.4",
"version_normalized": "2.0.4.0",
"source": {
"type": "git",
"url": "https://github.com/yoomoney/yookassa-sdk-php.git",
"reference": "427c05f0cf31ee0ac3afcaedcc9c9b65ea4f352b"
"reference": "ca1e77bc3cd2c1c7f21fbc947a90464e496109f4"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/yoomoney/yookassa-sdk-php/zipball/427c05f0cf31ee0ac3afcaedcc9c9b65ea4f352b",
"reference": "427c05f0cf31ee0ac3afcaedcc9c9b65ea4f352b",
"url": "https://api.github.com/repos/yoomoney/yookassa-sdk-php/zipball/ca1e77bc3cd2c1c7f21fbc947a90464e496109f4",
"reference": "ca1e77bc3cd2c1c7f21fbc947a90464e496109f4",
"shasum": ""
},
"require": {
Expand All @@ -75,7 +75,7 @@
"mockery/mockery": "^0.9.9",
"phpunit/phpunit": "^4.8.35 || ^5.7"
},
"time": "2020-12-10T06:27:14+00:00",
"time": "2020-12-28T14:10:36+00:00",
"type": "library",
"installation-source": "dist",
"autoload": {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
### v2.0.4 от 28.12.2020
* Оптимизация получения списка платежей

### v2.0.3 от 10.12.2020
* Возвращены методы для email и phone в receipt

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@
"email": "[email protected]"
}
],
"version": "2.0.3",
"version": "2.0.4",
"require": {
"php": ">=5.3.0",
"ext-curl": "*",
"ext-json": "*",
"ext-mbstring": "*",
"../../psr/log": "^1.0"
"psr/log": "^1.0"
},
"require-dev": {
"ext-xml": "*",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ class Client extends BaseClient
/**
* Текущая версия библиотеки
*/
const SDK_VERSION = '2.0.3';
const SDK_VERSION = '2.0.4';

/**
* Получить список платежей магазина.
Expand All @@ -107,6 +107,7 @@ class Client extends BaseClient
* @throws TooManyRequestsException
* @throws UnauthorizedException
* @throws ExtensionNotFoundException
* @throws Exception
*/
public function getPayments($filter = null)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public function load($filePath = null)
if ($filePath) {
$data = file_get_contents($filePath);
} else {
$data = file_get_contents(__DIR__ . DIRECTORY_SEPARATOR);
$data = file_get_contents(__DIR__ . DIRECTORY_SEPARATOR . ".." . DIRECTORY_SEPARATOR . ".." . DIRECTORY_SEPARATOR . "configuration.json");
}

$paramsArray = json_decode($data, true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,66 +56,66 @@ abstract class AbstractPaymentResponse extends Payment implements PaymentInterfa
/**
* Конструктор, устанавливает настройки платежа из ассоциативного массива
*
* @param array $paymentInfo Массив с информацией о платеже, пришедший от API
* @param array $sourceArray Массив с информацией о платеже, пришедший от API
* @throws \Exception
*/
public function __construct($paymentInfo)
public function fromArray($sourceArray)
{
$this->setId($paymentInfo['id']);
$this->setStatus($paymentInfo['status']);
$this->setAmount($this->factoryAmount($paymentInfo['amount']));
$this->setCreatedAt($paymentInfo['created_at']);
$this->setPaid($paymentInfo['paid']);
$this->setRefundable($paymentInfo['refundable']);
if (!empty($paymentInfo['test'])) {
$this->setTest($paymentInfo['test']);
$this->setId($sourceArray['id']);
$this->setStatus($sourceArray['status']);
$this->setAmount($this->factoryAmount($sourceArray['amount']));
$this->setCreatedAt($sourceArray['created_at']);
$this->setPaid($sourceArray['paid']);
$this->setRefundable($sourceArray['refundable']);
if (!empty($sourceArray['test'])) {
$this->setTest($sourceArray['test']);
}
if (!empty($paymentInfo['payment_method'])) {
$this->setPaymentMethod($this->factoryPaymentMethod($paymentInfo['payment_method']));
if (!empty($sourceArray['payment_method'])) {
$this->setPaymentMethod($this->factoryPaymentMethod($sourceArray['payment_method']));
}

if (!empty($paymentInfo['description'])) {
$this->setDescription($paymentInfo['description']);
if (!empty($sourceArray['description'])) {
$this->setDescription($sourceArray['description']);
}

if (!empty($paymentInfo['recipient'])) {
if (!empty($sourceArray['recipient'])) {
$recipient = new Recipient();
if (!empty($paymentInfo['recipient']['account_id'])) {
$recipient->setAccountId($paymentInfo['recipient']['account_id']);
if (!empty($sourceArray['recipient']['account_id'])) {
$recipient->setAccountId($sourceArray['recipient']['account_id']);
}
if (!empty($paymentInfo['recipient']['gateway_id'])) {
$recipient->setGatewayId($paymentInfo['recipient']['gateway_id']);
if (!empty($sourceArray['recipient']['gateway_id'])) {
$recipient->setGatewayId($sourceArray['recipient']['gateway_id']);
}
$this->setRecipient($recipient);
}
if (!empty($paymentInfo['captured_at'])) {
$this->setCapturedAt(strtotime($paymentInfo['captured_at']));
if (!empty($sourceArray['captured_at'])) {
$this->setCapturedAt(strtotime($sourceArray['captured_at']));
}
if (!empty($paymentInfo['expires_at'])) {
$this->setExpiresAt($paymentInfo['expires_at']);
if (!empty($sourceArray['expires_at'])) {
$this->setExpiresAt($sourceArray['expires_at']);
}
if (!empty($paymentInfo['confirmation'])) {
$confirmationType = $paymentInfo['confirmation']['type'];
if (!empty($sourceArray['confirmation'])) {
$confirmationType = $sourceArray['confirmation']['type'];
switch ($confirmationType) {
case ConfirmationType::REDIRECT:
$confirmation = new ConfirmationRedirect();
if (!empty($paymentInfo['confirmation']['confirmation_url'])) {
$confirmation->setConfirmationUrl($paymentInfo['confirmation']['confirmation_url']);
if (!empty($sourceArray['confirmation']['confirmation_url'])) {
$confirmation->setConfirmationUrl($sourceArray['confirmation']['confirmation_url']);
}
if (empty($paymentInfo['confirmation']['enforce'])) {
if (empty($sourceArray['confirmation']['enforce'])) {
$confirmation->setEnforce(false);
} else {
$confirmation->setEnforce($paymentInfo['confirmation']['enforce']);
$confirmation->setEnforce($sourceArray['confirmation']['enforce']);
}
if (!empty($paymentInfo['confirmation']['return_url'])) {
$confirmation->setReturnUrl($paymentInfo['confirmation']['return_url']);
if (!empty($sourceArray['confirmation']['return_url'])) {
$confirmation->setReturnUrl($sourceArray['confirmation']['return_url']);
}
break;

case ConfirmationType::EMBEDDED:
$confirmation = new ConfirmationEmbedded();
if (!empty($paymentInfo['confirmation']['confirmation_token'])) {
$confirmation->setConfirmationToken($paymentInfo['confirmation']['confirmation_token']);
if (!empty($sourceArray['confirmation']['confirmation_token'])) {
$confirmation->setConfirmationToken($sourceArray['confirmation']['confirmation_token']);
}
break;

Expand All @@ -133,8 +133,8 @@ public function __construct($paymentInfo)

case ConfirmationType::QR:
$confirmation = new ConfirmationQr();
if (!empty($paymentInfo['confirmation']['confirmation_data'])) {
$confirmation->setConfirmationData($paymentInfo['confirmation']['confirmation_data']);
if (!empty($sourceArray['confirmation']['confirmation_data'])) {
$confirmation->setConfirmationData($sourceArray['confirmation']['confirmation_data']);
}
break;
}
Expand All @@ -145,44 +145,44 @@ public function __construct($paymentInfo)
throw new InvalidArgumentException('confirmation type '.$confirmationType.' is incorrect');
}
}
if (!empty($paymentInfo['refunded_amount'])) {
$this->setRefundedAmount($this->factoryAmount($paymentInfo['refunded_amount']));
if (!empty($sourceArray['refunded_amount'])) {
$this->setRefundedAmount($this->factoryAmount($sourceArray['refunded_amount']));
}
if (!empty($paymentInfo['receipt_registration'])) {
$this->setReceiptRegistration($paymentInfo['receipt_registration']);
if (!empty($sourceArray['receipt_registration'])) {
$this->setReceiptRegistration($sourceArray['receipt_registration']);
}
if (!empty($paymentInfo['metadata'])) {
if (!empty($sourceArray['metadata'])) {
$metadata = new Metadata();
foreach ($paymentInfo['metadata'] as $key => $value) {
foreach ($sourceArray['metadata'] as $key => $value) {
$metadata->offsetSet($key, $value);
}
$this->setMetadata($metadata);
}
if (!empty($paymentInfo['cancellation_details'])) {
$cancellationDetails = $paymentInfo['cancellation_details'];
if (!empty($sourceArray['cancellation_details'])) {
$cancellationDetails = $sourceArray['cancellation_details'];
$party = isset($cancellationDetails['party']) ? $cancellationDetails['party'] : null;
$reason = isset($cancellationDetails['reason']) ? $cancellationDetails['reason'] : null;
$this->setCancellationDetails(new CancellationDetails($party, $reason));
}
if (!empty($paymentInfo['authorization_details'])) {
$authorizationDetails = $paymentInfo['authorization_details'];
if (!empty($sourceArray['authorization_details'])) {
$authorizationDetails = $sourceArray['authorization_details'];
$rrn = isset($authorizationDetails['rrn']) ? $authorizationDetails['rrn'] : null;
$authCode = isset($authorizationDetails['auth_code']) ? $authorizationDetails['auth_code'] : null;
$this->setAuthorizationDetails(new AuthorizationDetails($rrn, $authCode));
}
if (!empty($paymentInfo['transfers'])) {
if (!empty($sourceArray['transfers'])) {
$transfers = array();
foreach ($paymentInfo['transfers'] as $transferDefinition) {
foreach ($sourceArray['transfers'] as $transferDefinition) {
$transfers[] = new Transfer($transferDefinition);
}

$this->setTransfers($transfers);
}
if (!empty($paymentInfo['income_amount'])) {
$this->setIncomeAmount($this->factoryAmount($paymentInfo['income_amount']));
if (!empty($sourceArray['income_amount'])) {
$this->setIncomeAmount($this->factoryAmount($sourceArray['income_amount']));
}
if (!empty($paymentInfo['requestor'])) {
$this->setRequestor($paymentInfo['requestor']);
if (!empty($sourceArray['requestor'])) {
$this->setRequestor($sourceArray['requestor']);
}
}

Expand Down
Loading

0 comments on commit 9065027

Please sign in to comment.