Skip to content

Commit

Permalink
Added domains support
Browse files Browse the repository at this point in the history
  • Loading branch information
[email protected] authored and [email protected] committed Mar 11, 2020
1 parent 767ad81 commit 948cf6f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
3 changes: 2 additions & 1 deletion controllers/front/payment_process.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
15 changes: 14 additions & 1 deletion unitpay.php
Original file line number Diff line number Diff line change
Expand Up @@ -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', '')
)
Expand Down Expand Up @@ -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')
)
Expand All @@ -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');
Expand All @@ -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'));
}
Expand Down Expand Up @@ -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'),
Expand Down Expand Up @@ -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')),
);
Expand Down

0 comments on commit 948cf6f

Please sign in to comment.