Browse Source

* local up

master
dimti 1 month ago
parent
commit
b66e8151d8
  1. 10
      Plugin.php
  2. 16
      classes/DefaultMoneyRepair.php
  3. 28
      classes/SberCheckout.php
  4. 1
      lang/en/lang.php
  5. 1
      lang/ru/lang.php
  6. 13
      routes.php

10
Plugin.php

@ -13,7 +13,7 @@ class Plugin extends PluginBase
*/
public $require = ['Offline.Mall'];
final public function boot(): void
public function boot()
{
$gateway = $this->app->get(PaymentGateway::class);
$gateway->registerProvider(new SberCheckout());
@ -23,4 +23,12 @@ class Plugin extends PluginBase
return new DefaultMoneyRepair();
});
}
public function registerComponents()
{
}
public function registerSettings()
{
}
}

16
classes/DefaultMoneyRepair.php

@ -1,16 +0,0 @@
<?php namespace Wpstudio\Sber\Classes;
use OFFLINE\Mall\Classes\Utils\DefaultMoney;
/***
* Helper class to solve this problem https://github.com/OFFLINE-GmbH/oc-mall-plugin/issues/258
* paypal error after redirect to site
* After payment via PayPal upon returning to the site, we get an error Call to a member function getCurrent() on null
*/
class DefaultMoneyRepair extends DefaultMoney
{
final protected function render($contents, array $vars): string
{
return number_format($vars['price'],$vars['currency']->decimals, ',', ' ').' '.$vars['currency']->symbol;
}
}

28
classes/SberCheckout.php

@ -7,7 +7,6 @@ use OFFLINE\Mall\Models\PaymentGatewaySettings;
use OFFLINE\Mall\Models\OrderState;
use OFFLINE\Mall\Models\Order;
use Omnipay\Omnipay;
use Omnipay\Sberbank\Gateway;
use Omnipay\Sberbank\Message\AbstractRequest;
use Omnipay\Sberbank\Message\AbstractResponse;
use Omnipay\Sberbank\Message\AuthorizeRequest;
@ -38,7 +37,7 @@ class SberCheckout extends PaymentProvider
*
* @return string
*/
final public function name(): string
public function name(): string
{
return Lang::get('wpstudio.sber::lang.settings.sber_checkout');
}
@ -48,7 +47,7 @@ class SberCheckout extends PaymentProvider
*
* @return string
*/
final public function identifier(): string
public function identifier(): string
{
return 'sber';
}
@ -59,7 +58,7 @@ class SberCheckout extends PaymentProvider
* @return bool
* @throws \October\Rain\Exception\ValidationException
*/
final public function validate(): bool
public function validate(): bool
{
return true;
}
@ -72,7 +71,7 @@ class SberCheckout extends PaymentProvider
*
* @return PaymentResult
*/
final public function process(PaymentResult $result): PaymentResult
public function process(PaymentResult $result): PaymentResult
{
$gateway = $this->getGateway();
@ -114,7 +113,7 @@ class SberCheckout extends PaymentProvider
* @return array
*
*/
final public function getOrderBundle(): array
public function getOrderBundle()
{
$orderCreationDateFormatted = $this->order->created_at->format('Y-m-dTH:m:s');
@ -135,7 +134,7 @@ class SberCheckout extends PaymentProvider
*
* @return array
*/
final public function getOrderCartItems(): array
public function getOrderCartItems()
{
$cartItems = [];
@ -168,7 +167,7 @@ class SberCheckout extends PaymentProvider
*
* @return PaymentResult
*/
final public function complete(PaymentResult $result): PaymentResult
public function complete(PaymentResult $result): PaymentResult
{
$this->setOrder($result->order);
@ -204,7 +203,7 @@ class SberCheckout extends PaymentProvider
*
* @return \Omnipay\Common\GatewayInterface
*/
final protected function getGateway(): Gateway
protected function getGateway()
{
$gateway = Omnipay::create('Sberbank');
@ -227,7 +226,7 @@ class SberCheckout extends PaymentProvider
*
* @return array
*/
final public function settings(): array
public function settings(): array
{
return [
'sber_test_mode' => [
@ -248,6 +247,11 @@ class SberCheckout extends PaymentProvider
'span' => 'left',
'type' => 'text',
],
'setPayedVirtualOrderAsComplete' => [
'label' => Lang::get('wpstudio.sber::lang.settings.set_payed_virtual_order_as_complete'),
'span' => 'left',
'type' => 'checkbox',
],
];
}
@ -259,7 +263,7 @@ class SberCheckout extends PaymentProvider
*
* @return array
*/
final public function encryptedSettings(): array
public function encryptedSettings(): array
{
return ['password'];
}
@ -270,7 +274,7 @@ class SberCheckout extends PaymentProvider
* @param $orderStateFlag
* @return int
*/
final protected function getOrderStateId($orderStateFlag): int
protected function getOrderStateId($orderStateFlag): int
{
$orderStateModel = OrderState::where('flag', $orderStateFlag)->first();

1
lang/en/lang.php

@ -11,6 +11,7 @@
'username_label' => 'Sber api username: T****-api',
'password' => 'Password',
'password_label' => 'Sber api password',
'set_payed_virtual_order_as_complete' => 'Change payed virtual orders status to "Completed"',
],
'messages' => [
'order_number' => 'Order №',

1
lang/ru/lang.php

@ -11,6 +11,7 @@
'username_label' => 'Пользователь',
'password' => 'Пароль',
'password_label' => 'Пароль',
'set_payed_virtual_order_as_complete' => 'Изменять статус оплаченных виртуальных заказов на "Выполнен"',
],
'messages' => [
'order_number' => 'Заказ №',

13
routes.php

@ -0,0 +1,13 @@
<?php
use Illuminate\Http\Request;
use Wpstudio\Sber\Classes\SberCheckout;
Route::post('/sber-checkout', function (Request $request) {
$sberCheckout = new SberCheckout();
$sberCheckout->changePaymentState($request);
return exit();
});
Loading…
Cancel
Save