├── LICENSE ├── README.md ├── admin ├── controller │ ├── extension │ │ └── payment │ │ │ └── liqpay_checkout.php │ └── payment │ │ └── liqpay.php ├── language │ └── en-gb │ │ ├── extension │ │ └── payment │ │ │ └── liqpay_checkout.php │ │ └── payment │ │ └── liqpay.php └── view │ ├── image │ └── payment │ │ └── liqpay.png │ └── template │ ├── extension │ └── payment │ │ └── liqpay_checkout.tpl │ └── payment │ └── liqpay.tpl └── catalog ├── controller ├── extension │ └── payment │ │ └── liqpay_checkout.php └── payment │ └── liqpay.php ├── language └── en-gb │ ├── extension │ └── payment │ │ └── liqpay_checkout.php │ └── payment │ └── liqpay.php ├── model ├── extension │ └── payment │ │ └── liqpay_checkout.php └── payment │ └── liqpay.php └── view └── theme └── default └── template ├── extension └── payment │ └── liqpay_checkout.tpl └── payment └── liqpay.tpl /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014 LiqPay 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | plugin-opencart 2 | =============== 3 | 4 | LiqPay Checkout plugin for opencart CMS since 2.x 5 | 6 | #### Для установки модуля скопируйте его в каталог: #### 7 | 8 | ``` 9 | /admin/ 10 | /catalog/ 11 | ``` 12 | 13 | #### Затем в панели администратора установите и настройте его: #### 14 | 15 | ``` 16 | Extensions > Payments > Liqpay Checkout нажать [Install] 17 | ``` 18 | 19 | 20 | #### Для начала приема платежей на Вашем сайте необходимо: #### 21 | - Зарегистрироваться на https://www.liqpay.ua 22 | - Создать магазин в Вашем аккаунте используя мастер-установки (https://www.liqpay.ua/admin/business) 23 | - Получите "Публичный ключ" и "Приватный ключ" 24 | -------------------------------------------------------------------------------- /admin/controller/extension/payment/liqpay_checkout.php: -------------------------------------------------------------------------------- 1 | load->language('extension/payment/liqpay_checkout'); 10 | 11 | $this->document->setTitle($this->language->get('heading_title')); 12 | 13 | $this->load->model('setting/setting'); 14 | 15 | if (($this->request->server['REQUEST_METHOD'] == 'POST') && $this->validate()) { 16 | $this->model_setting_setting->editSetting('liqpay_checkout', $this->request->post); 17 | 18 | $this->session->data['success'] = $this->language->get('text_success'); 19 | 20 | $this->response->redirect($this->url->link('extension/extension', 'token=' . $this->session->data['token'] . '&type=payment', true)); 21 | } 22 | 23 | $data['heading_title'] = $this->language->get('heading_title'); 24 | 25 | $data['text_edit'] = $this->language->get('text_edit'); 26 | $data['text_enabled'] = $this->language->get('text_enabled'); 27 | $data['text_disabled'] = $this->language->get('text_disabled'); 28 | $data['text_all_zones'] = $this->language->get('text_all_zones'); 29 | $data['text_pay'] = $this->language->get('text_pay'); 30 | $data['text_card'] = $this->language->get('text_card'); 31 | 32 | $data['entry_public_key'] = $this->language->get('entry_public_key'); 33 | $data['entry_private_key'] = $this->language->get('entry_private_key'); 34 | $data['entry_api'] = $this->language->get('entry_api'); 35 | $data['entry_type'] = $this->language->get('entry_type'); 36 | $data['entry_total'] = $this->language->get('entry_total'); 37 | $data['entry_order_status'] = $this->language->get('entry_order_status'); 38 | $data['entry_geo_zone'] = $this->language->get('entry_geo_zone'); 39 | $data['entry_status'] = $this->language->get('entry_status'); 40 | $data['entry_sort_order'] = $this->language->get('entry_sort_order'); 41 | 42 | $data['help_total'] = $this->language->get('help_total'); 43 | 44 | $data['button_save'] = $this->language->get('button_save'); 45 | $data['button_cancel'] = $this->language->get('button_cancel'); 46 | 47 | if (isset($this->error['warning'])) { 48 | $data['error_warning'] = $this->error['warning']; 49 | } else { 50 | $data['error_warning'] = ''; 51 | } 52 | 53 | if (isset($this->error['public_key'])) { 54 | $data['error_public_key'] = $this->error['public_key']; 55 | } else { 56 | $data['error_public_key'] = ''; 57 | } 58 | 59 | if (isset($this->error['private_key'])) { 60 | $data['error_private_key'] = $this->error['private_key']; 61 | } else { 62 | $data['error_private_key'] = ''; 63 | } 64 | 65 | if (isset($this->error['api'])) { 66 | $data['error_api'] = $this->error['api']; 67 | } else { 68 | $data['error_api'] = ''; 69 | } 70 | 71 | if (isset($this->error['action'])) { 72 | $data['error_action'] = $this->error['action']; 73 | } else { 74 | $data['error_action'] = ''; 75 | } 76 | 77 | if (isset($this->error['type'])) { 78 | $data['error_type'] = $this->error['type']; 79 | } else { 80 | $data['error_type'] = ''; 81 | } 82 | 83 | $data['breadcrumbs'] = array(); 84 | 85 | $data['breadcrumbs'][] = array( 86 | 'text' => $this->language->get('text_home'), 87 | 'href' => $this->url->link('common/dashboard', 'token=' . $this->session->data['token'], 'SSL') 88 | ); 89 | 90 | $data['breadcrumbs'][] = array( 91 | 'text' => $this->language->get('text_payment'), 92 | 'href' => $this->url->link('extension/payment', 'token=' . $this->session->data['token'], 'SSL') 93 | ); 94 | 95 | $data['breadcrumbs'][] = array( 96 | 'text' => $this->language->get('heading_title'), 97 | 'href' => $this->url->link('extension/payment/liqpay_checkout', 'token=' . $this->session->data['token'], 'SSL') 98 | ); 99 | 100 | $data['action'] = $this->url->link('extension/payment/liqpay_checkout', 'token=' . $this->session->data['token'], 'SSL'); 101 | 102 | $data['cancel'] = $this->url->link('extension/payment', 'token=' . $this->session->data['token'], 'SSL'); 103 | 104 | if (isset($this->request->post['liqpay_checkout_public_key'])) { 105 | $data['liqpay_checkout_public_key'] = $this->request->post['liqpay_checkout_public_key']; 106 | } else { 107 | $data['liqpay_checkout_public_key'] = $this->config->get('liqpay_checkout_public_key'); 108 | } 109 | 110 | if (isset($this->request->post['liqpay_checkout_private_key'])) { 111 | $data['liqpay_checkout_private_key'] = $this->request->post['liqpay_checkout_private_key']; 112 | } else { 113 | $data['liqpay_checkout_private_key'] = $this->config->get('liqpay_checkout_private_key'); 114 | } 115 | 116 | if (isset($this->request->post['liqpay_checkout_api'])) { 117 | $data['liqpay_checkout_api'] = $this->request->post['liqpay_checkout_api']; 118 | } else { 119 | $data['liqpay_checkout_api'] = $this->config->get('liqpay_checkout_api'); 120 | } 121 | 122 | // if (isset($this->request->post['liqpay_checkout_action'])) { 123 | // $data['liqpay_checkout_action'] = $this->request->post['liqpay_checkout_action']; 124 | // } else { 125 | // $data['liqpay_checkout_action'] = $this->config->get('liqpay_checkout_action'); 126 | // } 127 | 128 | if (isset($this->request->post['liqpay_checkout_type'])) { 129 | $data['liqpay_checkout_type'] = $this->request->post['liqpay_checkout_type']; 130 | } else { 131 | $data['liqpay_checkout_type'] = $this->config->get('liqpay_checkout_type'); 132 | } 133 | 134 | if (isset($this->request->post['liqpay_checkout_total'])) { 135 | $data['liqpay_checkout_total'] = $this->request->post['liqpay_checkout_total']; 136 | } else { 137 | $data['liqpay_checkout_total'] = $this->config->get('liqpay_checkout_total'); 138 | } 139 | 140 | if (isset($this->request->post['liqpay_checkout_order_status_id'])) { 141 | $data['liqpay_checkout_order_status_id'] = $this->request->post['liqpay_checkout_order_status_id']; 142 | } else { 143 | $data['liqpay_checkout_order_status_id'] = $this->config->get('liqpay_checkout_order_status_id'); 144 | } 145 | 146 | $this->load->model('localisation/order_status'); 147 | 148 | $data['order_statuses'] = $this->model_localisation_order_status->getOrderStatuses(); 149 | 150 | if (isset($this->request->post['liqpay_checkout_geo_zone_id'])) { 151 | $data['liqpay_checkout_geo_zone_id'] = $this->request->post['liqpay_checkout_geo_zone_id']; 152 | } else { 153 | $data['liqpay_checkout_geo_zone_id'] = $this->config->get('liqpay_checkout_geo_zone_id'); 154 | } 155 | 156 | $this->load->model('localisation/geo_zone'); 157 | 158 | $data['geo_zones'] = $this->model_localisation_geo_zone->getGeoZones(); 159 | 160 | if (isset($this->request->post['liqpay_checkout_status'])) { 161 | $data['liqpay_checkout_status'] = $this->request->post['liqpay_checkout_status']; 162 | } else { 163 | $data['liqpay_checkout_status'] = $this->config->get('liqpay_checkout_status'); 164 | } 165 | 166 | if (isset($this->request->post['liqpay_checkout_sort_order'])) { 167 | $data['liqpay_checkout_sort_order'] = $this->request->post['liqpay_checkout_sort_order']; 168 | } else { 169 | $data['liqpay_checkout_sort_order'] = $this->config->get('liqpay_checkout_sort_order'); 170 | } 171 | 172 | $data['header'] = $this->load->controller('common/header'); 173 | $data['column_left'] = $this->load->controller('common/column_left'); 174 | $data['footer'] = $this->load->controller('common/footer'); 175 | 176 | $this->response->setOutput($this->load->view('extension/payment/liqpay_checkout', $data)); 177 | } 178 | 179 | protected function validate() 180 | { 181 | if (!$this->user->hasPermission('modify', 'extension/payment/liqpay_checkout')) { 182 | $this->error['warning'] = $this->language->get('error_permission'); 183 | } 184 | 185 | if (!$this->request->post['liqpay_checkout_public_key']) { 186 | $this->error['public_key'] = $this->language->get('error_public_key'); 187 | } 188 | 189 | if (!$this->request->post['liqpay_checkout_private_key']) { 190 | $this->error['private_key'] = $this->language->get('error_private_key'); 191 | } 192 | 193 | if (!$this->request->post['liqpay_checkout_api']) { 194 | $this->error['api'] = $this->language->get('error_api'); 195 | } 196 | 197 | // if (!$this->request->post['liqpay_checkout_action']) { 198 | // $this->error['action'] = $this->language->get('error_action'); 199 | // } 200 | 201 | return !$this->error; 202 | } 203 | } -------------------------------------------------------------------------------- /admin/controller/payment/liqpay.php: -------------------------------------------------------------------------------- 1 | 29 | */ 30 | class ControllerPaymentLiqPay extends Controller 31 | { 32 | private $error = array(); 33 | 34 | 35 | /** 36 | * Index action 37 | * 38 | * @return void 39 | */ 40 | public function index() 41 | { 42 | $this->language->load('payment/liqpay'); 43 | 44 | $this->document->setTitle($this->language->get('heading_title')); 45 | 46 | $this->load->model('setting/setting'); 47 | 48 | if (($this->request->server['REQUEST_METHOD'] == 'POST') && $this->validate()) { 49 | $this->model_setting_setting->editSetting('liqpay', $this->request->post); 50 | 51 | $this->session->data['success'] = $this->language->get('text_success'); 52 | 53 | $this->redirect($this->url->link('extension/payment', 'token=' . $this->session->data['token'], 'SSL')); 54 | } 55 | 56 | $this->data['heading_title'] = $this->language->get('heading_title'); 57 | 58 | $this->data['text_enabled'] = $this->language->get('text_enabled'); 59 | $this->data['text_disabled'] = $this->language->get('text_disabled'); 60 | $this->data['text_all_zones'] = $this->language->get('text_all_zones'); 61 | $this->data['text_buy'] = $this->language->get('text_buy'); 62 | $this->data['text_donate'] = $this->language->get('text_donate'); 63 | 64 | $this->data['entry_public_key'] = $this->language->get('entry_public_key'); 65 | $this->data['entry_private_key'] = $this->language->get('entry_private_key'); 66 | $this->data['entry_action'] = $this->language->get('entry_action'); 67 | $this->data['entry_type'] = $this->language->get('entry_type'); 68 | $this->data['entry_total'] = $this->language->get('entry_total'); 69 | $this->data['entry_order_status'] = $this->language->get('entry_order_status'); 70 | $this->data['entry_geo_zone'] = $this->language->get('entry_geo_zone'); 71 | $this->data['entry_status'] = $this->language->get('entry_status'); 72 | $this->data['entry_sort_order'] = $this->language->get('entry_sort_order'); 73 | $this->data['entry_pay_way'] = $this->language->get('entry_pay_way'); 74 | $this->data['entry_language'] = $this->language->get('entry_language'); 75 | 76 | $this->data['button_save'] = $this->language->get('button_save'); 77 | $this->data['button_cancel'] = $this->language->get('button_cancel'); 78 | 79 | if (isset($this->error['warning'])) { 80 | $this->data['error_warning'] = $this->error['warning']; 81 | } else { 82 | $this->data['error_warning'] = ''; 83 | } 84 | 85 | if (isset($this->error['public_key'])) { 86 | $this->data['error_public_key'] = $this->error['public_key']; 87 | } else { 88 | $this->data['error_public_key'] = ''; 89 | } 90 | 91 | if (isset($this->error['private_key'])) { 92 | $this->data['error_private_key'] = $this->error['private_key']; 93 | } else { 94 | $this->data['error_private_key'] = ''; 95 | } 96 | 97 | if (isset($this->error['action'])) { 98 | $this->data['error_action'] = $this->error['action']; 99 | } else { 100 | $this->data['error_action'] = ''; 101 | } 102 | 103 | $this->data['breadcrumbs'] = array(); 104 | 105 | $this->data['breadcrumbs'][] = array( 106 | 'text' => $this->language->get('text_home'), 107 | 'href' => $this->url->link('common/home', 'token=' . $this->session->data['token'], 'SSL'), 108 | 'separator' => false 109 | ); 110 | 111 | $this->data['breadcrumbs'][] = array( 112 | 'text' => $this->language->get('text_payment'), 113 | 'href' => $this->url->link('extension/payment', 'token=' . $this->session->data['token'], 'SSL'), 114 | 'separator' => ' :: ' 115 | ); 116 | 117 | $this->data['breadcrumbs'][] = array( 118 | 'text' => $this->language->get('heading_title'), 119 | 'href' => $this->url->link('payment/liqpay', 'token=' . $this->session->data['token'], 'SSL'), 120 | 'separator' => ' :: ' 121 | ); 122 | 123 | $this->data['action'] = $this->url->link('payment/liqpay', 'token=' . $this->session->data['token'], 'SSL'); 124 | 125 | $this->data['cancel'] = $this->url->link('extension/payment', 'token=' . $this->session->data['token'], 'SSL'); 126 | 127 | if (isset($this->request->post['liqpay_public_key'])) { 128 | $this->data['liqpay_public_key'] = $this->request->post['liqpay_public_key']; 129 | } else { 130 | $this->data['liqpay_public_key'] = $this->config->get('liqpay_public_key'); 131 | } 132 | 133 | if (isset($this->request->post['liqpay_private_key'])) { 134 | $this->data['liqpay_private_key'] = $this->request->post['liqpay_private_key']; 135 | } else { 136 | $this->data['liqpay_private_key'] = $this->config->get('liqpay_private_key'); 137 | } 138 | 139 | if (isset($this->request->post['liqpay_action'])) { 140 | $this->data['liqpay_action'] = $this->request->post['liqpay_action']; 141 | } else { 142 | $this->data['liqpay_action'] = $this->config->get('liqpay_action'); 143 | if (empty($this->data['liqpay_action'])) { 144 | $this->data['liqpay_action'] = 'https://www.liqpay.ua/api/3/checkout'; 145 | } 146 | } 147 | 148 | if (isset($this->request->post['liqpay_total'])) { 149 | $this->data['liqpay_total'] = $this->request->post['liqpay_total']; 150 | } else { 151 | $this->data['liqpay_total'] = $this->config->get('liqpay_total'); 152 | } 153 | 154 | if (isset($this->request->post['liqpay_order_status_id'])) { 155 | $this->data['liqpay_order_status_id'] = $this->request->post['liqpay_order_status_id']; 156 | } else { 157 | $this->data['liqpay_order_status_id'] = $this->config->get('liqpay_order_status_id'); 158 | } 159 | 160 | $this->load->model('localisation/order_status'); 161 | 162 | $this->data['order_statuses'] = $this->model_localisation_order_status->getOrderStatuses(); 163 | 164 | if (isset($this->request->post['liqpay_geo_zone_id'])) { 165 | $this->data['liqpay_geo_zone_id'] = $this->request->post['liqpay_geo_zone_id']; 166 | } else { 167 | $this->data['liqpay_geo_zone_id'] = $this->config->get('liqpay_geo_zone_id'); 168 | } 169 | 170 | $this->load->model('localisation/geo_zone'); 171 | 172 | $this->data['geo_zones'] = $this->model_localisation_geo_zone->getGeoZones(); 173 | 174 | if (isset($this->request->post['liqpay_status'])) { 175 | $this->data['liqpay_status'] = $this->request->post['liqpay_status']; 176 | } else { 177 | $this->data['liqpay_status'] = $this->config->get('liqpay_status'); 178 | } 179 | 180 | if (isset($this->request->post['liqpay_sort_order'])) { 181 | $this->data['liqpay_sort_order'] = $this->request->post['liqpay_sort_order']; 182 | } else { 183 | $this->data['liqpay_sort_order'] = $this->config->get('liqpay_sort_order'); 184 | } 185 | 186 | if (isset($this->request->post['liqpay_pay_way'])) { 187 | $this->data['liqpay_pay_way'] = $this->request->post['liqpay_pay_way']; 188 | } else { 189 | $this->data['liqpay_pay_way'] = $this->config->get('liqpay_pay_way'); 190 | } 191 | 192 | if (isset($this->request->post['liqpay_language'])) { 193 | $this->data['liqpay_language'] = $this->request->post['liqpay_language']; 194 | } else { 195 | $this->data['liqpay_language'] = $this->config->get('liqpay_language'); 196 | } 197 | 198 | $this->template = 'payment/liqpay.tpl'; 199 | $this->children = array( 200 | 'common/header', 201 | 'common/footer' 202 | ); 203 | 204 | $this->response->setOutput($this->render()); 205 | } 206 | 207 | 208 | /** 209 | * Validate input data 210 | * 211 | * @return boolean 212 | */ 213 | protected function validate() 214 | { 215 | if (!$this->user->hasPermission('modify', 'payment/liqpay')) { 216 | $this->error['warning'] = $this->language->get('error_permission'); 217 | } 218 | 219 | if (!$this->request->post['liqpay_public_key']) { 220 | $this->error['public_key'] = $this->language->get('error_public_key'); 221 | } 222 | 223 | if (!$this->request->post['liqpay_private_key']) { 224 | $this->error['private_key'] = $this->language->get('error_private_key'); 225 | } 226 | 227 | if (!$this->request->post['liqpay_action']) { 228 | $this->error['action'] = $this->language->get('error_action'); 229 | } 230 | 231 | return !$this->error; 232 | } 233 | } 234 | -------------------------------------------------------------------------------- /admin/language/en-gb/extension/payment/liqpay_checkout.php: -------------------------------------------------------------------------------- 1 | '; 12 | 13 | // Entry 14 | $_['entry_public_key'] = 'Public Key'; 15 | $_['entry_private_key'] = 'Private Key'; 16 | $_['entry_api'] = 'https://www.liqpay.ua/api/3/checkout'; 17 | $_['entry_action'] = 'pay'; 18 | $_['entry_type'] = 'Type'; 19 | $_['entry_total'] = 'Total'; 20 | $_['entry_order_status'] = 'Order Status'; 21 | $_['entry_geo_zone'] = 'Geo Zone'; 22 | $_['entry_status'] = 'Status'; 23 | $_['entry_sort_order'] = 'Sort Order'; 24 | 25 | // Help 26 | $_['help_total'] = 'The checkout total the order must reach before this payment method becomes active.'; 27 | 28 | // Error 29 | $_['error_permission'] = 'Warning: You do not have permission to modify payment LIQPAY!'; 30 | $_['error_public_key'] = 'Public Key Required!'; 31 | $_['error_private_key'] = 'Private Key Required!'; 32 | $_['error_api'] = 'API Required!'; 33 | $_['error_action'] = 'Action Required!'; -------------------------------------------------------------------------------- /admin/language/en-gb/payment/liqpay.php: -------------------------------------------------------------------------------- 1 | Liqpay'; 34 | 35 | // Entry 36 | $_['entry_public_key'] = 'Public key:'; 37 | $_['entry_private_key'] = 'Private key:'; 38 | $_['entry_action'] = 'Action:'; 39 | $_['entry_type'] = 'Type:'; 40 | $_['entry_total'] = 'Total:
The checkout total the order must reach before this payment method becomes active.'; 41 | $_['entry_order_status'] = 'Order Status:'; 42 | $_['entry_geo_zone'] = 'Geo Zone:'; 43 | $_['entry_status'] = 'Status:'; 44 | $_['entry_sort_order'] = 'Sort Order:'; 45 | $_['entry_pay_way'] = 'Pay way:'; 46 | $_['entry_language'] = 'Language:'; 47 | 48 | // Error 49 | $_['error_permission'] = 'Warning: You do not have permission to modify payment Liqpay!'; 50 | $_['error_public_key'] = 'Public key Required!'; 51 | $_['error_private_key'] = 'Private key Required!'; 52 | $_['error_action'] = 'Action Required!'; 53 | -------------------------------------------------------------------------------- /admin/view/image/payment/liqpay.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liqpay/plugin-opencart/cd84f6db2684129f8b2f4f193a8f448cabc06061/admin/view/image/payment/liqpay.png -------------------------------------------------------------------------------- /admin/view/template/extension/payment/liqpay_checkout.tpl: -------------------------------------------------------------------------------- 1 | 2 |
3 | 16 |
17 | 18 |
19 | 20 |
21 | 22 |
23 |
24 |

25 |
26 |
27 |
28 |
29 | 30 |
31 | 32 | 33 |
34 | 35 |
36 |
37 |
38 | 39 |
40 | 41 | 42 |
43 | 44 |
45 |
46 |
47 | 48 |
49 | 50 | 51 |
52 | 53 |
54 |
55 |
56 | 57 |
58 | 70 |
71 |
72 |
73 | 74 |
75 | 76 |
77 |
78 |
79 | 80 |
81 | 90 |
91 |
92 |
93 | 94 |
95 | 105 |
106 |
107 |
108 | 109 |
110 | 119 |
120 |
121 |
122 | 123 |
124 | 125 |
126 |
127 |
128 |
129 |
130 |
131 |
132 | -------------------------------------------------------------------------------- /admin/view/template/payment/liqpay.tpl: -------------------------------------------------------------------------------- 1 | 25 | 26 | 27 |
28 | 33 | 34 |
35 | 36 |
37 |
38 |

39 |
40 | 41 | 42 |
43 |
44 |
45 |
46 | 47 | 48 | 49 | 52 | 53 | 54 | 55 | 58 | 59 | 60 | 61 | 64 | 65 | 66 | 67 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 118 | 119 | 120 | 121 | 135 | 136 | 137 | 138 | 148 | 149 | 150 | 151 | 161 | 162 | 163 | 164 | 165 | 166 |
* 50 | 51 |
* 56 | 57 |
* 62 | 63 |
68 | 69 | 72 | 73 | 74 | 77 | 78 | 79 | 82 | 83 | 84 | 87 | 88 | 89 | 92 | 93 | 94 | 96 | 97 |
106 | 117 |
122 | 134 |
139 | 147 |
152 | 160 |
167 |
168 |
169 |
170 |
171 | 183 | -------------------------------------------------------------------------------- /catalog/controller/extension/payment/liqpay_checkout.php: -------------------------------------------------------------------------------- 1 | 29 | */ 30 | class ControllerExtensionPaymentLiqPayCheckout extends Controller 31 | { 32 | private $version = 3; 33 | private $action = 'pay'; 34 | 35 | public function index() 36 | { 37 | $this->load->language('extension/payment/liqpay_checkout'); 38 | $data['button_confirm'] = $this->language->get('button_confirm'); 39 | $order_id = $this->session->data['order_id']; 40 | $this->load->model('checkout/order'); 41 | $order_info = $this->model_checkout_order->getOrder($order_id); 42 | 43 | // Collect info about the order to be sent to the API 44 | 45 | $description = $this->language->get('text_order_number') . $order_id; 46 | $result_url = $this->url->link('checkout/success', '', 'SSL'); 47 | $server_url = $this->url->link('extension/payment/liqpay_checkout/callback', '', 'SSL'); 48 | $private_key = $this->config->get('liqpay_checkout_private_key'); 49 | $public_key = $this->config->get('liqpay_checkout_public_key'); 50 | $currency = $order_info['currency_code']; 51 | if ($currency == 'RUR') { 52 | $currency = 'RUB'; 53 | } 54 | $amount = $this->currency->format( 55 | $order_info['total'], 56 | $order_info['currency_code'], 57 | $order_info['currency_value'], 58 | false 59 | ); 60 | 61 | $pay_way = $this->config->get('liqpay_checkout_pay_way'); 62 | $language = $this->config->get('liqpay_checkout_language'); 63 | 64 | $send_data = array('version' => $this->version, 65 | 'public_key' => $public_key, 66 | 'amount' => $amount, 67 | 'currency' => $currency, 68 | 'description' => $description, 69 | 'order_id' => $order_id, 70 | 'action' => $this->action, 71 | 'language' => $language, 72 | 'server_url' => $server_url, 73 | 'result_url' => $result_url); 74 | 75 | 76 | $liqpay_data = base64_encode(json_encode($send_data)); 77 | $liqpay_signature = $this->calculateSignature($liqpay_data, $private_key); 78 | 79 | $data['data'] = $liqpay_data; 80 | $data['signature'] = $liqpay_signature; 81 | $data['action'] = $this->config->get('liqpay_checkout_api'); 82 | $view_path = 'extension/payment/liqpay_checkout'; 83 | 84 | return $this->load->view($view_path, $data); 85 | } 86 | 87 | private function calculateSignature($data, $private_key) 88 | { 89 | return base64_encode(sha1($private_key . $data . $private_key, true)); 90 | } 91 | 92 | public function callback() 93 | { 94 | $data = $this->request->post['data']; 95 | $private_key = $this->config->get('liqpay_checkout_private_key'); 96 | $signature = $this->calculateSignature($data, $private_key); 97 | $parsed_data = json_decode(base64_decode($data), true); 98 | $order_id = $parsed_data['order_id']; 99 | 100 | if ($signature == $this->request->post['signature']) { 101 | $this->load->model('checkout/order'); 102 | $this->model_checkout_order->addOrderHistory($order_id, $this->config->get('liqpay_checkout_order_status_id')); 103 | //here you can update your order status 104 | } 105 | } 106 | } 107 | -------------------------------------------------------------------------------- /catalog/controller/payment/liqpay.php: -------------------------------------------------------------------------------- 1 | 29 | */ 30 | class ControllerPaymentLiqpay extends Controller 31 | { 32 | 33 | /** 34 | * Index action 35 | * 36 | * @return void 37 | */ 38 | protected function index() 39 | { 40 | $this->load->model('checkout/order'); 41 | 42 | $order_id = $this->session->data['order_id']; 43 | /*set order_id to global variable*/ 44 | $this->data['order_id'] = $this->session->data['order_id']; 45 | 46 | $order_info = $this->model_checkout_order->getOrder($order_id); 47 | 48 | $description = 'Order #'.$order_id; 49 | 50 | $order_id .= '#'.time(); 51 | $result_url = $this->url->link('checkout/success', '', 'SSL'); 52 | $server_url = $this->url->link('payment/liqpay/server', '', 'SSL'); 53 | 54 | $private_key = $this->config->get('liqpay_private_key'); 55 | $public_key = $this->config->get('liqpay_public_key'); 56 | $type = 'buy'; 57 | $currency = $order_info['currency_code']; 58 | if ($currency == 'RUR') { $currency = 'RUB'; } 59 | $amount = $this->currency->format( 60 | $order_info['total'], 61 | $order_info['currency_code'], 62 | $order_info['currency_value'], 63 | false 64 | ); 65 | $version = '3'; 66 | //$language = $this->language->get('code'); 67 | 68 | //$language = $language == 'ru' ? 'ru' : 'en'; 69 | $pay_way = $this->config->get('liqpay_pay_way'); 70 | $language = $this->config->get('liqpay_language'); 71 | 72 | $send_data = array('version' => $version, 73 | 'public_key' => $public_key, 74 | 'amount' => $amount, 75 | 'currency' => $currency, 76 | 'description' => $description, 77 | 'order_id' => $order_id, 78 | 'type' => $type, 79 | 'language' => $language, 80 | 'server_url' => $server_url, 81 | 'result_url' => $result_url); 82 | if(isset($pay_way)){ 83 | $send_data['pay_way'] = $pay_way; 84 | } 85 | 86 | $data = base64_encode(json_encode($send_data)); 87 | 88 | $signature = base64_encode(sha1($private_key.$data.$private_key, 1)); 89 | 90 | $this->data['action'] = $this->config->get('liqpay_action'); 91 | $this->data['signature'] = $signature; 92 | $this->data['data'] = $data; 93 | $this->data['button_confirm'] = 'Оплатить'; 94 | $this->data['url_confirm'] = $this->url->link('payment/liqpay/confirm', '', 'SSL'); 95 | 96 | $this->template = $this->config->get('config_template').'/template/payment/liqpay.tpl'; 97 | 98 | if (!file_exists(DIR_TEMPLATE.$this->template)) { 99 | $this->template = 'default/template/payment/liqpay.tpl'; 100 | } 101 | 102 | $this->render(); 103 | } 104 | 105 | 106 | /** 107 | * Confirm action 108 | * 109 | * @return void 110 | */ 111 | public function confirm() 112 | { 113 | $this->load->model('checkout/order'); 114 | $order = $this->session->data['order_id']; 115 | //$this->model_checkout_order->confirm($order, $this->config->get('config_order_status_id'), 'unpaid'); 116 | $this->model_checkout_order->confirm($this->session->data['order_id'], 2); 117 | } 118 | 119 | 120 | /** 121 | * Check and return posts data 122 | * 123 | * @return array 124 | */ 125 | private function getPosts() 126 | { 127 | $success = 128 | isset($_POST['data']) && 129 | isset($_POST['signature']); 130 | 131 | if ($success) { 132 | return array( 133 | $_POST['data'], 134 | $_POST['signature'], 135 | ); 136 | } 137 | return array(); 138 | } 139 | 140 | 141 | /** 142 | * get real order ID 143 | * 144 | * @return string 145 | */ 146 | public function getRealOrderID($order_id) 147 | { 148 | $real_order_id = explode('#', $order_id); 149 | return $real_order_id[0]; 150 | } 151 | 152 | 153 | /** 154 | * Server action 155 | * 156 | * @return void 157 | */ 158 | public function server() 159 | { 160 | if (!$posts = $this->getPosts()) { die('Posts error'); } 161 | 162 | list( 163 | $data, 164 | $signature 165 | ) = $posts; 166 | 167 | if(!$data || !$signature) {die("No data or signature");} 168 | 169 | $parsed_data = json_decode(base64_decode($data), true); 170 | 171 | $received_public_key = $parsed_data['public_key']; 172 | $order_id = $parsed_data['order_id']; 173 | $status = $parsed_data['status']; 174 | $sender_phone = $parsed_data['sender_phone']; 175 | $amount = $parsed_data['amount']; 176 | $currency = $parsed_data['currency']; 177 | $transaction_id = $parsed_data['transaction_id']; 178 | 179 | $real_order_id = $this->getRealOrderID($order_id); 180 | 181 | if ($real_order_id <= 0) { die("Order_id real_order_id < 0"); } 182 | 183 | $this->load->model('checkout/order'); 184 | if (!$this->model_checkout_order->getOrder($real_order_id)) { die("Order_id fail");} 185 | 186 | $private_key = $this->config->get('liqpay_private_key'); 187 | $public_key = $this->config->get('liqpay_public_key'); 188 | 189 | $generated_signature = base64_encode(sha1($private_key.$data.$private_key, 1)); 190 | 191 | if ($signature != $generated_signature) { die("Signature secure fail"); } 192 | if ($public_key != $received_public_key) { die("public_key secure fail"); } 193 | 194 | if ($status == 'success') { 195 | // there you can update your order 196 | } 197 | 198 | } 199 | } 200 | -------------------------------------------------------------------------------- /catalog/language/en-gb/extension/payment/liqpay_checkout.php: -------------------------------------------------------------------------------- 1 | 29 | */ 30 | class ModelExtensionPaymentLiqPayCheckout extends Model 31 | { 32 | private $code = 'liqpay_checkout'; 33 | 34 | public function getMethod($address, $total) 35 | { 36 | $this->load->language('extension/payment/liqpay_checkout'); 37 | 38 | $query = $this->db->query("SELECT * FROM " . DB_PREFIX . "zone_to_geo_zone WHERE geo_zone_id = '" . (int)$this->config->get('liqpay_checkout_geo_zone_id') . "' AND country_id = '" . (int)$address['country_id'] . "' AND (zone_id = '" . (int)$address['zone_id'] . "' OR zone_id = '0')"); 39 | 40 | if ($this->config->get('liqpay_checkout_total') > 0 && $this->config->get('liqpay_checkout_total') > $total) { 41 | $status = false; 42 | } elseif (!$this->config->get('liqpay_checkout_geo_zone_id')) { 43 | $status = true; 44 | } elseif ($query->num_rows) { 45 | $status = true; 46 | } else { 47 | $status = false; 48 | } 49 | 50 | $method_data = array(); 51 | 52 | if ($status) { 53 | $method_data = array( 54 | 'code' => $this->code, 55 | 'title' => $this->language->get('text_title'), 56 | 'terms' => '', 57 | 'sort_order' => $this->config->get('liqpay_checkout_sort_order') 58 | ); 59 | } 60 | 61 | return $method_data; 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /catalog/model/payment/liqpay.php: -------------------------------------------------------------------------------- 1 | 29 | */ 30 | class ModelPaymentLiqPay extends Model 31 | { 32 | 33 | /** 34 | * Index action 35 | * 36 | * @return void 37 | */ 38 | public function getMethod($address, $total) 39 | { 40 | $this->language->load('payment/liqpay'); 41 | 42 | $tbl_zone_to_geo_zone = DB_PREFIX.'zone_to_geo_zone'; 43 | $liqpay_geo_zone_id = (int)$this->config->get('liqpay_geo_zone_id'); 44 | $country_id = (int)$address['country_id']; 45 | $zone_id = (int)$address['zone_id']; 46 | 47 | $sql = " 48 | SELECT * 49 | FROM {$tbl_zone_to_geo_zone} 50 | WHERE geo_zone_id = '{$liqpay_geo_zone_id}' 51 | AND country_id = '{$country_id}' 52 | AND (zone_id = '{$zone_id}' OR zone_id = '0') 53 | "; 54 | 55 | $query = $this->db->query($sql); 56 | 57 | if ($this->config->get('liqpay_total') > 0 && $this->config->get('liqpay_total') > $total) { 58 | $status = false; 59 | } elseif (!$this->config->get('liqpay_geo_zone_id')) { 60 | $status = true; 61 | } elseif ($query->num_rows) { 62 | $status = true; 63 | } else { 64 | $status = false; 65 | } 66 | 67 | $method_data = array(); 68 | 69 | if ($status) { 70 | $method_data = array( 71 | 'code' => 'liqpay', 72 | 'title' => $this->language->get('text_title'), 73 | 'sort_order' => $this->config->get('liqpay_sort_order') 74 | ); 75 | } 76 | 77 | return $method_data; 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /catalog/view/theme/default/template/extension/payment/liqpay_checkout.tpl: -------------------------------------------------------------------------------- 1 | 25 | 26 |
27 | 28 | 29 |
30 |
31 | 32 |
33 |
34 |
-------------------------------------------------------------------------------- /catalog/view/theme/default/template/payment/liqpay.tpl: -------------------------------------------------------------------------------- 1 | 25 | 26 |
27 | 28 | 29 |
30 |
31 | 32 |
33 |
34 |
35 | 36 | 48 | --------------------------------------------------------------------------------