1: | <?php
2: | namespace Opencart\Catalog\Controller\Extension\Opencart\Payment;
3: | /**
4: | * Class Cod
5: | *
6: | * @package Opencart\Catalog\Controller\Extension\Opencart\Module
7: | */
8: | class Cod extends \Opencart\System\Engine\Controller {
9: | /**
10: | * Index
11: | *
12: | * @return string
13: | */
14: | public function index(): string {
15: | $this->load->language('extension/opencart/payment/cod');
16: |
17: | $data['language'] = $this->config->get('config_language');
18: |
19: | return $this->load->view('extension/opencart/payment/cod', $data);
20: | }
21: |
22: | /**
23: | * Confirm
24: | *
25: | * @return void
26: | */
27: | public function confirm(): void {
28: | $this->load->language('extension/opencart/payment/cod');
29: |
30: | $json = [];
31: |
32: | if (!isset($this->session->data['order_id'])) {
33: | $json['error'] = $this->language->get('error_order_id');
34: | }
35: |
36: | if (!isset($this->session->data['payment_method']) || $this->session->data['payment_method']['code'] != 'cod.cod') {
37: | $json['error'] = $this->language->get('error_payment_method');
38: | }
39: |
40: | if (!$json) {
41: | $this->load->model('checkout/order');
42: |
43: | $this->model_checkout_order->addHistory($this->session->data['order_id'], $this->config->get('payment_cod_order_status_id'));
44: |
45: | $json['redirect'] = $this->url->link('checkout/success', 'language=' . $this->config->get('config_language'), true);
46: | }
47: |
48: | $this->response->addHeader('Content-Type: application/json');
49: | $this->response->setOutput(json_encode($json));
50: | }
51: | }
52: |

OpenCart API API documentation generated by ApiGen dev-master