|
26 | 26 | if (!defined('_PS_VERSION_')) |
27 | 27 | exit; |
28 | 28 |
|
29 | | - |
30 | 29 | include_once(_PS_MODULE_DIR_.'payneteasypayment'.DIRECTORY_SEPARATOR.'classes'.DIRECTORY_SEPARATOR.'Client.php'); |
31 | 30 | include_once(_PS_MODULE_DIR_.'payneteasypayment'.DIRECTORY_SEPARATOR.'payneteasypayment.php'); |
32 | 31 | class PayneteasypaymentRedirectModuleFrontController extends ModuleFrontController { |
@@ -63,13 +62,13 @@ public function initContent() { |
63 | 62 | ]); |
64 | 63 |
|
65 | 64 | if (isset($createPayment) && $createPayment['type'] == 'error') |
66 | | - Tools::redirectLink($this->context->link->getPageLink('order', null, null, 'step=3')); |
| 65 | + $this->redirectLink($this->context->link->getPageLink('order', null, null, 'step=3')); |
67 | 66 | elseif (isset($createPayment) && $createPayment['type'] == 'validation-error') |
68 | | - Tools::redirectLink($this->context->link->getPageLink('order', null, null, 'step=3')); |
| 67 | + $this->redirectLink($this->context->link->getPageLink('order', null, null, 'step=3')); |
69 | 68 | else { |
70 | 69 | isset($createPayment['redirect-url']) |
71 | | - ? Tools::redirectLink($createPayment['redirect-url']) // редирект на платежную форму |
72 | | - : Tools::redirectLink($this->context->link->getModuleLink('payneteasypayment', 'confirmation', ['cart_id'=>$cart->id, 'secure_key'=>$cart->secure_key], true)); |
| 70 | + ? $this->redirectLink($createPayment['redirect-url']) // редирект на платежную форму |
| 71 | + : $this->redirectLink($this->context->link->getModuleLink('payneteasypayment', 'confirmation', ['cart_id'=>$cart->id, 'secure_key'=>$cart->secure_key], true)); |
73 | 72 | } |
74 | 73 |
|
75 | 74 | if ($cart->id_customer == 0 |
@@ -102,7 +101,7 @@ private function signStatusRequest($requestFields, $login, $merchantControl) |
102 | 101 |
|
103 | 102 | private function prepareData($cart, $card_data) { |
104 | 103 | $address = new Address($cart->id_address_delivery); |
105 | | - $orderId = Order::getOrderByCartId($cart->id); |
| 104 | + $order_id = $this->orderId($cart); |
106 | 105 |
|
107 | 106 | $currency = new Currency((int)($cart->id_currency)); |
108 | 107 | $currency_code = trim($currency->iso_code); |
@@ -131,22 +130,36 @@ private function prepareData($cart, $card_data) { |
131 | 130 | 'expire_year' => $card_data['expire_year'], |
132 | 131 | 'first_name' => $this->context->customer->firstname, |
133 | 132 | 'last_name' => $this->context->customer->lastname, |
134 | | - 'redirect_success_url' => $this->context->link->getModuleLink('payneteasypayment', 'confirmation', ['order_id' => $orderId, 'cart_id'=>$cart->id, 'secure_key'=>$cart->secure_key], true), |
135 | | - 'redirect_fail_url' => $this->context->link->getModuleLink('payneteasypayment', 'error', ['order_id' => $orderId, 'cart_id'=>$cart->id, 'secure_key'=>$cart->secure_key], true), |
136 | | - 'redirect_url' => $this->context->link->getModuleLink('payneteasypayment', 'confirmation', ['order_id' => $orderId, 'cart_id'=>$cart->id, 'secure_key'=>$cart->secure_key], true), |
137 | | - 'server_callback_url' => $this->context->link->getModuleLink('payneteasypayment', 'confirmation', ['order_id' => $orderId, 'cart_id'=>$cart->id, 'secure_key'=>$cart->secure_key], true), |
| 133 | + 'redirect_success_url' => $this->context->link->getModuleLink('payneteasypayment', 'confirmation', ['order_id' => $order_id, 'cart_id'=>$cart->id, 'secure_key'=>$cart->secure_key], true), |
| 134 | + 'redirect_fail_url' => $this->context->link->getModuleLink('payneteasypayment', 'error', ['order_id' => $order_id, 'cart_id'=>$cart->id, 'secure_key'=>$cart->secure_key], true), |
| 135 | + 'redirect_url' => $this->context->link->getModuleLink('payneteasypayment', 'confirmation', ['order_id' => $order_id, 'cart_id'=>$cart->id, 'secure_key'=>$cart->secure_key], true), |
| 136 | + 'server_callback_url' => $this->context->link->getModuleLink('payneteasypayment', 'confirmation', ['order_id' => $order_id, 'cart_id'=>$cart->id, 'secure_key'=>$cart->secure_key], true), |
138 | 137 | ]; |
139 | 138 |
|
140 | 139 | $data['control'] = $this->signPaymentRequest($data, $endpointId, $merchantControl); |
141 | 140 |
|
142 | 141 | return $data; |
143 | 142 | } |
144 | 143 |
|
| 144 | + private function orderId($cart) { |
| 145 | + if (method_exists('Order', 'getOrderByCartId')) |
| 146 | + return Order::getOrderByCartId((int) $cart->id); |
| 147 | + |
| 148 | + return Order::getIdByCartId((int) $cart->id); |
| 149 | + } |
| 150 | + |
| 151 | + private function redirectLink($where) { |
| 152 | + if (method_exists('Tools', 'redirectLink')) |
| 153 | + Tools::redirectLink($where); |
| 154 | + else |
| 155 | + Tools::redirect($where); |
| 156 | + } |
| 157 | + |
145 | 158 | private function signString($s) |
146 | 159 | { return sha1($s); } |
147 | 160 |
|
148 | 161 | private function signPaymentRequest($data, $endpointId, $merchantControl) |
149 | | - { return $this->signString($endpointId .$data['client_orderid'] .(int)($data['amount'] * 100) .$data['email'] .$merchantControl); } |
| 162 | + { return $this->signString($endpointId .$data['client_orderid'] .(string)($data['amount'] * 100) .$data['email'] .$merchantControl); } |
150 | 163 |
|
151 | 164 | private function createPayment($data) { |
152 | 165 | $client = $this->initClient(); |
|
0 commit comments