From 948cf6fff4b6f2e4df713e012f2a39a1299da959 Mon Sep 17 00:00:00 2001 From: "v.niznevskiy@unitpay.ru" Date: Wed, 11 Mar 2020 12:03:41 +0300 Subject: [PATCH] Added domains support --- controllers/front/payment_process.php | 3 ++- unitpay.php | 15 ++++++++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/controllers/front/payment_process.php b/controllers/front/payment_process.php index 0ba606b..bee1ae1 100644 --- a/controllers/front/payment_process.php +++ b/controllers/front/payment_process.php @@ -25,13 +25,14 @@ public function initContent() $this->module->validateOrder((int)$cart->id, Configuration::get('UNIT_OS_NEEDPAY'), $total, $this->module->displayName, NULL, array(), (int)$currency->id, false, $customer->secure_key); + $domain = Configuration::get('UNIT_DOMAIN'); $public_key = Configuration::get('UNIT_PUBLIC_KEY'); $desc = 'Оплата заказа из магазина ' . Configuration::get('PS_SHOP_NAME'); $sum = $this->context->cart->getOrderTotal(); $id_order = Order::getOrderByCartId($cart->id); $account = $id_order; - Tools::redirect('https://unitpay.ru/pay/' . $public_key . '?' . + Tools::redirect("https://$domain/pay/" . $public_key . '?' . http_build_query(array( 'sum' => $sum, 'currency' => $this->context->currency->iso_code, diff --git a/unitpay.php b/unitpay.php index 6a4e42b..72ebd56 100755 --- a/unitpay.php +++ b/unitpay.php @@ -35,6 +35,7 @@ public function install() !Configuration::updateValue('UNIT_OS_NEEDPAY', 800)|| !Configuration::updateValue('UNIT_OS_PAYED', 801)|| !Configuration::updateValue('UNIT_OS_ERROR_PAY', 802)|| + !Configuration::updateValue('UNIT_DOMAIN', '')|| !Configuration::updateValue('UNIT_SECRET_KEY', '')|| !Configuration::updateValue('UNIT_PUBLIC_KEY', '') ) @@ -96,6 +97,7 @@ public function uninstall() !Configuration::deleteByName('UNIT_OS_NEEDPAY')|| !Configuration::deleteByName('UNIT_OS_PAYED')|| !Configuration::deleteByName('UNIT_OS_ERROR_PAY')|| + !Configuration::deleteByName('UNIT_DOMAIN')|| !Configuration::deleteByName('UNIT_SECRET_KEY')|| !Configuration::deleteByName('UNIT_PUBLIC_KEY') ) @@ -110,7 +112,9 @@ private function _postValidation() { if (Tools::isSubmit('btnSubmit')) { - if (!Tools::getValue('UNIT_SECRET_KEY')) + if (!Tools::getValue('UNIT_DOMAIN')) + $this->_postErrors[] = $this->l('Необходимо ввести домен'); + elseif (!Tools::getValue('UNIT_SECRET_KEY')) $this->_postErrors[] = $this->l('Необходимо ввести SECRET KEY'); elseif (!Tools::getValue('UNIT_PUBLIC_KEY')) $this->_postErrors[] = $this->l('Необходимо ввести PUBLIC KEY'); @@ -121,6 +125,7 @@ private function _postProcess() { if (Tools::isSubmit('btnSubmit')) { + Configuration::updateValue('UNIT_DOMAIN', Tools::getValue('UNIT_DOMAIN')); Configuration::updateValue('UNIT_SECRET_KEY', Tools::getValue('UNIT_SECRET_KEY')); Configuration::updateValue('UNIT_PUBLIC_KEY', Tools::getValue('UNIT_PUBLIC_KEY')); } @@ -154,6 +159,13 @@ public function renderForm() 'title' => $this->l('settings') ), 'input' => array( + array( + 'type' => 'text', + 'label' => $this->l('DOMAIN'), + 'desc' => "Вставьте ваш рабочий домен Unitpay", + 'name' => 'UNIT_DOMAIN', + 'required' => true + ), array( 'type' => 'text', 'label' => $this->l('SECRET KEY'), @@ -189,6 +201,7 @@ public function renderForm() public function getConfigFieldsValues() { return array( + 'UNIT_DOMAIN' => Tools::getValue('UNIT_DOMAIN', Configuration::get('UNIT_DOMAIN')), 'UNIT_SECRET_KEY' => Tools::getValue('UNIT_SECRET_KEY', Configuration::get('UNIT_SECRET_KEY')), 'UNIT_PUBLIC_KEY' => Tools::getValue('UNIT_PUBLIC_KEY', Configuration::get('UNIT_PUBLIC_KEY')), );