diff --git a/Plugin.php b/Plugin.php index abf1455..6fdc840 100644 --- a/Plugin.php +++ b/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() + { + } + } diff --git a/classes/DefaultMoneyRepair.php b/classes/DefaultMoneyRepair.php deleted file mode 100644 index d2fdd06..0000000 --- a/classes/DefaultMoneyRepair.php +++ /dev/null @@ -1,16 +0,0 @@ -decimals, ',', ' ').' '.$vars['currency']->symbol; - } -} diff --git a/classes/SberCheckout.php b/classes/SberCheckout.php index eea7f19..7685e08 100644 --- a/classes/SberCheckout.php +++ b/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(); diff --git a/lang/en/lang.php b/lang/en/lang.php index 078864e..62974d2 100644 --- a/lang/en/lang.php +++ b/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 №', diff --git a/lang/ru/lang.php b/lang/ru/lang.php index 1031dba..0295057 100644 --- a/lang/ru/lang.php +++ b/lang/ru/lang.php @@ -11,6 +11,7 @@ 'username_label' => 'Пользователь', 'password' => 'Пароль', 'password_label' => 'Пароль', + 'set_payed_virtual_order_as_complete' => 'Изменять статус оплаченных виртуальных заказов на "Выполнен"', ], 'messages' => [ 'order_number' => 'Заказ №', diff --git a/routes.php b/routes.php new file mode 100644 index 0000000..e36799c --- /dev/null +++ b/routes.php @@ -0,0 +1,13 @@ +changePaymentState($request); + + return exit(); +});