paypoint.php (6411B)
1 <?php 2 class ControllerExtensionPaymentPaypoint extends Controller { 3 public function index() { 4 $data['button_confirm'] = $this->language->get('button_confirm'); 5 6 $this->load->model('checkout/order'); 7 8 $order_info = $this->model_checkout_order->getOrder($this->session->data['order_id']); 9 10 $data['merchant'] = $this->config->get('payment_paypoint_merchant'); 11 $data['trans_id'] = $this->session->data['order_id']; 12 $data['amount'] = $this->currency->format($order_info['total'], $order_info['currency_code'], $order_info['currency_value'], false); 13 14 if ($this->config->get('payment_paypoint_password')) { 15 $data['digest'] = md5($this->session->data['order_id'] . $this->currency->format($order_info['total'], $order_info['currency_code'], $order_info['currency_value'], false) . $this->config->get('payment_paypoint_password')); 16 } else { 17 $data['digest'] = ''; 18 } 19 20 $data['bill_name'] = $order_info['payment_firstname'] . ' ' . $order_info['payment_lastname']; 21 $data['bill_addr_1'] = $order_info['payment_address_1']; 22 $data['bill_addr_2'] = $order_info['payment_address_2']; 23 $data['bill_city'] = $order_info['payment_city']; 24 $data['bill_state'] = $order_info['payment_zone']; 25 $data['bill_post_code'] = $order_info['payment_postcode']; 26 $data['bill_country'] = $order_info['payment_country']; 27 $data['bill_tel'] = $order_info['telephone']; 28 $data['bill_email'] = $order_info['email']; 29 30 if ($this->cart->hasShipping()) { 31 $data['ship_name'] = $order_info['shipping_firstname'] . ' ' . $order_info['shipping_lastname']; 32 $data['ship_addr_1'] = $order_info['shipping_address_1']; 33 $data['ship_addr_2'] = $order_info['shipping_address_2']; 34 $data['ship_city'] = $order_info['shipping_city']; 35 $data['ship_state'] = $order_info['shipping_zone']; 36 $data['ship_post_code'] = $order_info['shipping_postcode']; 37 $data['ship_country'] = $order_info['shipping_country']; 38 } else { 39 $data['ship_name'] = ''; 40 $data['ship_addr_1'] = ''; 41 $data['ship_addr_2'] = ''; 42 $data['ship_city'] = ''; 43 $data['ship_state'] = ''; 44 $data['ship_post_code'] = ''; 45 $data['ship_country'] = ''; 46 } 47 48 $data['currency'] = $this->session->data['currency']; 49 $data['callback'] = $this->url->link('extension/payment/paypoint/callback', '', true); 50 51 switch ($this->config->get('payment_paypoint_test')) { 52 case 'live': 53 $status = 'live'; 54 break; 55 case 'successful': 56 default: 57 $status = 'true'; 58 break; 59 case 'fail': 60 $status = 'false'; 61 break; 62 } 63 64 $data['options'] = 'test_status=' . $status . ',dups=false,cb_post=false'; 65 66 return $this->load->view('extension/payment/paypoint', $data); 67 } 68 69 public function callback() { 70 if (isset($this->request->get['trans_id'])) { 71 $order_id = $this->request->get['trans_id']; 72 } else { 73 $order_id = 0; 74 } 75 76 $this->load->model('checkout/order'); 77 78 $order_info = $this->model_checkout_order->getOrder($order_id); 79 80 // Validate the request is from PayPoint 81 if ($this->config->get('payment_paypoint_password')) { 82 if (!empty($this->request->get['hash'])) { 83 $status = ($this->request->get['hash'] == md5(str_replace('hash=' . $this->request->get['hash'], '', htmlspecialchars_decode($this->request->server['REQUEST_URI'], ENT_COMPAT)) . $this->config->get('payment_paypoint_password'))); 84 } else { 85 $status = false; 86 } 87 } else { 88 $status = true; 89 } 90 91 if ($order_info) { 92 $this->load->language('extension/payment/paypoint'); 93 94 $data['title'] = sprintf($this->language->get('heading_title'), $this->config->get('config_name')); 95 96 if (!$this->request->server['HTTPS']) { 97 $data['base'] = HTTP_SERVER; 98 } else { 99 $data['base'] = HTTPS_SERVER; 100 } 101 102 $data['language'] = $this->language->get('code'); 103 $data['direction'] = $this->language->get('direction'); 104 105 $data['heading_title'] = sprintf($this->language->get('heading_title'), $this->config->get('config_name')); 106 107 $data['text_success_wait'] = sprintf($this->language->get('text_success_wait'), $this->url->link('checkout/success')); 108 $data['text_failure_wait'] = sprintf($this->language->get('text_failure_wait'), $this->url->link('checkout/cart')); 109 110 if (isset($this->request->get['code']) && $this->request->get['code'] == 'A' && $status) { 111 $message = ''; 112 113 if (isset($this->request->get['code'])) { 114 $message .= 'code: ' . $this->request->get['code'] . "\n"; 115 } 116 117 if (isset($this->request->get['auth_code'])) { 118 $message .= 'auth_code: ' . $this->request->get['auth_code'] . "\n"; 119 } 120 121 if (isset($this->request->get['ip'])) { 122 $message .= 'ip: ' . $this->request->get['ip'] . "\n"; 123 } 124 125 if (isset($this->request->get['cv2avs'])) { 126 $message .= 'cv2avs: ' . $this->request->get['cv2avs'] . "\n"; 127 } 128 129 if (isset($this->request->get['valid'])) { 130 $message .= 'valid: ' . $this->request->get['valid'] . "\n"; 131 } 132 133 $this->load->model('checkout/order'); 134 135 $this->model_checkout_order->addOrderHistory($order_id, $this->config->get('payment_paypoint_order_status_id'), $message, false); 136 137 $data['continue'] = $this->url->link('checkout/success'); 138 139 $data['column_left'] = $this->load->controller('common/column_left'); 140 $data['column_right'] = $this->load->controller('common/column_right'); 141 $data['content_top'] = $this->load->controller('common/content_top'); 142 $data['content_bottom'] = $this->load->controller('common/content_bottom'); 143 $data['footer'] = $this->load->controller('common/footer'); 144 $data['header'] = $this->load->controller('common/header'); 145 146 $this->response->setOutput($this->load->view('extension/payment/paypoint_success', $data)); 147 } else { 148 $data['continue'] = $this->url->link('checkout/cart'); 149 150 $data['column_left'] = $this->load->controller('common/column_left'); 151 $data['column_right'] = $this->load->controller('common/column_right'); 152 $data['content_top'] = $this->load->controller('common/content_top'); 153 $data['content_bottom'] = $this->load->controller('common/content_bottom'); 154 $data['footer'] = $this->load->controller('common/footer'); 155 $data['header'] = $this->load->controller('common/header'); 156 157 $this->response->setOutput($this->load->view('extension/payment/paypoint_failure', $data)); 158 } 159 } 160 } 161 }