Skip to content

Commit

Permalink
Merge pull request #20 from yoomoney/release/v2.2.1
Browse files Browse the repository at this point in the history
* Обновление статуса платежа сразу после оплаты
* Обновлен SDK до версии 2.2.4
  • Loading branch information
SaShaSpi authored Dec 15, 2021
2 parents 6b3d293 + e2a56a0 commit 12e24fb
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
### v2.2.1 от 15.12.2021
* Обновление статуса платежа сразу после оплаты
* Обновлен SDK до версии 2.2.4

### v2.2.0 от 13.10.2021
* Замена Сбербанк Онлайн на SberPay

Expand Down
7 changes: 6 additions & 1 deletion src/Plugin/Commerce/PaymentGateway/YooKassa.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
*/
class YooKassa extends OffsitePaymentGatewayBase
{
const YOOMONEY_MODULE_VERSION = '2.2.0';
const YOOMONEY_MODULE_VERSION = '2.2.1';

/**
* @property Client apiClient
Expand Down Expand Up @@ -405,6 +405,7 @@ public function onNotify(Request $request)
$this->log('Payment info after capture: ' . json_encode($captureResponse));
if ($captureResponse->status == PaymentStatus::SUCCEEDED) {
$payment->setRemoteState($paymentInfo->status);
$payment->setState('completed');
$order->state = 'completed';
$order->setCompletedTime(Drupal::time()->getRequestTime());
$order->save();
Expand All @@ -414,6 +415,7 @@ public function onNotify(Request $request)
return new Response('Payment completed', 200);
} elseif ($captureResponse->status == PaymentStatus::CANCELED) {
$payment->setRemoteState($paymentInfo->status);
$payment->setState('canceled');
$payment->save();
$this->log('Payment canceled');

Expand All @@ -422,12 +424,14 @@ public function onNotify(Request $request)
break;
case PaymentStatus::PENDING:
$payment->setRemoteState($paymentInfo->status);
$payment->setState('pending');
$payment->save();
$this->log('Payment pending');

return new Response(' Payment Required', 402);
case PaymentStatus::SUCCEEDED:
$payment->setRemoteState($paymentInfo->status);
$payment->setState('completed');
$order->state = 'completed';
$order->setCompletedTime(Drupal::time()->getRequestTime());
$order->save();
Expand All @@ -437,6 +441,7 @@ public function onNotify(Request $request)
return new Response('Payment complete', 200);
case PaymentStatus::CANCELED:
$payment->setRemoteState($paymentInfo->status);
$payment->setState('canceled');
$payment->save();
$this->log('Payment canceled');

Expand Down
2 changes: 1 addition & 1 deletion yookassa.libraries.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ billing_validation:

yookassa-sdk-php:
remote: https://github.com/yoomoney/yookassa-sdk-php
version: "2.0.5"
version: "2.2.4"
license:
name: MIT
url: https://github.com/yoomoney/yookassa-sdk-php/blob/master/LICENSE.md
Expand Down

0 comments on commit 12e24fb

Please sign in to comment.