* local up
This commit is contained in:
10
Plugin.php
10
Plugin.php
@ -13,7 +13,7 @@ class Plugin extends PluginBase
|
|||||||
*/
|
*/
|
||||||
public $require = ['Offline.Mall'];
|
public $require = ['Offline.Mall'];
|
||||||
|
|
||||||
final public function boot(): void
|
public function boot()
|
||||||
{
|
{
|
||||||
$gateway = $this->app->get(PaymentGateway::class);
|
$gateway = $this->app->get(PaymentGateway::class);
|
||||||
$gateway->registerProvider(new SberCheckout());
|
$gateway->registerProvider(new SberCheckout());
|
||||||
@ -23,4 +23,12 @@ class Plugin extends PluginBase
|
|||||||
return new DefaultMoneyRepair();
|
return new DefaultMoneyRepair();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
public function registerComponents()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public function registerSettings()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -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;
|
|
||||||
}
|
|
||||||
}
|
|
@ -7,7 +7,6 @@ use OFFLINE\Mall\Models\PaymentGatewaySettings;
|
|||||||
use OFFLINE\Mall\Models\OrderState;
|
use OFFLINE\Mall\Models\OrderState;
|
||||||
use OFFLINE\Mall\Models\Order;
|
use OFFLINE\Mall\Models\Order;
|
||||||
use Omnipay\Omnipay;
|
use Omnipay\Omnipay;
|
||||||
use Omnipay\Sberbank\Gateway;
|
|
||||||
use Omnipay\Sberbank\Message\AbstractRequest;
|
use Omnipay\Sberbank\Message\AbstractRequest;
|
||||||
use Omnipay\Sberbank\Message\AbstractResponse;
|
use Omnipay\Sberbank\Message\AbstractResponse;
|
||||||
use Omnipay\Sberbank\Message\AuthorizeRequest;
|
use Omnipay\Sberbank\Message\AuthorizeRequest;
|
||||||
@ -38,7 +37,7 @@ class SberCheckout extends PaymentProvider
|
|||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
final public function name(): string
|
public function name(): string
|
||||||
{
|
{
|
||||||
return Lang::get('wpstudio.sber::lang.settings.sber_checkout');
|
return Lang::get('wpstudio.sber::lang.settings.sber_checkout');
|
||||||
}
|
}
|
||||||
@ -48,7 +47,7 @@ class SberCheckout extends PaymentProvider
|
|||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
final public function identifier(): string
|
public function identifier(): string
|
||||||
{
|
{
|
||||||
return 'sber';
|
return 'sber';
|
||||||
}
|
}
|
||||||
@ -59,7 +58,7 @@ class SberCheckout extends PaymentProvider
|
|||||||
* @return bool
|
* @return bool
|
||||||
* @throws \October\Rain\Exception\ValidationException
|
* @throws \October\Rain\Exception\ValidationException
|
||||||
*/
|
*/
|
||||||
final public function validate(): bool
|
public function validate(): bool
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -72,7 +71,7 @@ class SberCheckout extends PaymentProvider
|
|||||||
*
|
*
|
||||||
* @return PaymentResult
|
* @return PaymentResult
|
||||||
*/
|
*/
|
||||||
final public function process(PaymentResult $result): PaymentResult
|
public function process(PaymentResult $result): PaymentResult
|
||||||
{
|
{
|
||||||
$gateway = $this->getGateway();
|
$gateway = $this->getGateway();
|
||||||
|
|
||||||
@ -114,7 +113,7 @@ class SberCheckout extends PaymentProvider
|
|||||||
* @return array
|
* @return array
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
final public function getOrderBundle(): array
|
public function getOrderBundle()
|
||||||
{
|
{
|
||||||
$orderCreationDateFormatted = $this->order->created_at->format('Y-m-dTH:m:s');
|
$orderCreationDateFormatted = $this->order->created_at->format('Y-m-dTH:m:s');
|
||||||
|
|
||||||
@ -135,7 +134,7 @@ class SberCheckout extends PaymentProvider
|
|||||||
*
|
*
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
final public function getOrderCartItems(): array
|
public function getOrderCartItems()
|
||||||
{
|
{
|
||||||
$cartItems = [];
|
$cartItems = [];
|
||||||
|
|
||||||
@ -168,7 +167,7 @@ class SberCheckout extends PaymentProvider
|
|||||||
*
|
*
|
||||||
* @return PaymentResult
|
* @return PaymentResult
|
||||||
*/
|
*/
|
||||||
final public function complete(PaymentResult $result): PaymentResult
|
public function complete(PaymentResult $result): PaymentResult
|
||||||
{
|
{
|
||||||
$this->setOrder($result->order);
|
$this->setOrder($result->order);
|
||||||
|
|
||||||
@ -204,7 +203,7 @@ class SberCheckout extends PaymentProvider
|
|||||||
*
|
*
|
||||||
* @return \Omnipay\Common\GatewayInterface
|
* @return \Omnipay\Common\GatewayInterface
|
||||||
*/
|
*/
|
||||||
final protected function getGateway(): Gateway
|
protected function getGateway()
|
||||||
{
|
{
|
||||||
$gateway = Omnipay::create('Sberbank');
|
$gateway = Omnipay::create('Sberbank');
|
||||||
|
|
||||||
@ -227,7 +226,7 @@ class SberCheckout extends PaymentProvider
|
|||||||
*
|
*
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
final public function settings(): array
|
public function settings(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'sber_test_mode' => [
|
'sber_test_mode' => [
|
||||||
@ -248,6 +247,11 @@ class SberCheckout extends PaymentProvider
|
|||||||
'span' => 'left',
|
'span' => 'left',
|
||||||
'type' => 'text',
|
'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
|
* @return array
|
||||||
*/
|
*/
|
||||||
final public function encryptedSettings(): array
|
public function encryptedSettings(): array
|
||||||
{
|
{
|
||||||
return ['password'];
|
return ['password'];
|
||||||
}
|
}
|
||||||
@ -270,7 +274,7 @@ class SberCheckout extends PaymentProvider
|
|||||||
* @param $orderStateFlag
|
* @param $orderStateFlag
|
||||||
* @return int
|
* @return int
|
||||||
*/
|
*/
|
||||||
final protected function getOrderStateId($orderStateFlag): int
|
protected function getOrderStateId($orderStateFlag): int
|
||||||
{
|
{
|
||||||
$orderStateModel = OrderState::where('flag', $orderStateFlag)->first();
|
$orderStateModel = OrderState::where('flag', $orderStateFlag)->first();
|
||||||
|
|
||||||
|
@ -11,6 +11,7 @@
|
|||||||
'username_label' => 'Sber api username: T****-api',
|
'username_label' => 'Sber api username: T****-api',
|
||||||
'password' => 'Password',
|
'password' => 'Password',
|
||||||
'password_label' => 'Sber api password',
|
'password_label' => 'Sber api password',
|
||||||
|
'set_payed_virtual_order_as_complete' => 'Change payed virtual orders status to "Completed"',
|
||||||
],
|
],
|
||||||
'messages' => [
|
'messages' => [
|
||||||
'order_number' => 'Order №',
|
'order_number' => 'Order №',
|
||||||
|
@ -11,6 +11,7 @@
|
|||||||
'username_label' => 'Пользователь',
|
'username_label' => 'Пользователь',
|
||||||
'password' => 'Пароль',
|
'password' => 'Пароль',
|
||||||
'password_label' => 'Пароль',
|
'password_label' => 'Пароль',
|
||||||
|
'set_payed_virtual_order_as_complete' => 'Изменять статус оплаченных виртуальных заказов на "Выполнен"',
|
||||||
],
|
],
|
||||||
'messages' => [
|
'messages' => [
|
||||||
'order_number' => 'Заказ №',
|
'order_number' => 'Заказ №',
|
||||||
|
13
routes.php
Normal file
13
routes.php
Normal file
@ -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();
|
||||||
|
});
|
Reference in New Issue
Block a user