paymate.php
4.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
<?php
class ControllerPaymentPaymate extends Controller {
public function index() {
$data['button_confirm'] = $this->language->get('button_confirm');
if (!$this->config->get('paymate_test')) {
$data['action'] = 'https://www.paymate.com/PayMate/ExpressPayment';
} else {
$data['action'] = 'https://www.paymate.com.au/PayMate/TestExpressPayment';
}
$this->load->model('checkout/order');
$order_info = $this->model_checkout_order->getOrder($this->session->data['order_id']);
$data['mid'] = $this->config->get('paymate_username');
$data['amt'] = $this->currency->format($order_info['total'], $order_info['currency_code'], $order_info['currency_value'], false);
$data['currency'] = $order_info['currency_code'];
$data['ref'] = $order_info['order_id'];
$data['pmt_sender_email'] = $order_info['email'];
$data['pmt_contact_firstname'] = html_entity_decode($order_info['payment_firstname'], ENT_QUOTES, 'UTF-8');
$data['pmt_contact_surname'] = html_entity_decode($order_info['payment_lastname'], ENT_QUOTES, 'UTF-8');
$data['pmt_contact_phone'] = $order_info['telephone'];
$data['pmt_country'] = $order_info['payment_iso_code_2'];
$data['regindi_address1'] = html_entity_decode($order_info['payment_address_1'], ENT_QUOTES, 'UTF-8');
$data['regindi_address2'] = html_entity_decode($order_info['payment_address_2'], ENT_QUOTES, 'UTF-8');
$data['regindi_sub'] = html_entity_decode($order_info['payment_city'], ENT_QUOTES, 'UTF-8');
$data['regindi_state'] = html_entity_decode($order_info['payment_zone'], ENT_QUOTES, 'UTF-8');
$data['regindi_pcode'] = html_entity_decode($order_info['payment_postcode'], ENT_QUOTES, 'UTF-8');
$data['return'] = $this->url->link('payment/paymate/callback', 'hash=' . md5($order_info['order_id'] . $this->currency->format($order_info['total'], $order_info['currency_code'], $order_info['currency_value'], false) . $order_info['currency_code'] . $this->config->get('paymate_password')));
return $this->load->view('payment/paymate', $data);
}
public function callback() {
$this->load->language('payment/paymate');
if (isset($this->request->post['ref'])) {
$order_id = $this->request->post['ref'];
} else {
$order_id = 0;
}
$this->load->model('checkout/order');
$order_info = $this->model_checkout_order->getOrder($order_id);
if ($order_info) {
$error = '';
if (!isset($this->request->post['responseCode']) || !isset($this->request->get['hash'])) {
$error = $this->language->get('text_unable');
} elseif ($this->request->get['hash'] != md5($order_info['order_id'] . $this->currency->format($this->request->post['paymentAmount'], $this->request->post['currency'], 1.0000000, false) . $this->request->post['currency'] . $this->config->get('paymate_password'))) {
$error = $this->language->get('text_unable');
} elseif ($this->request->post['responseCode'] != 'PA' && $this->request->post['responseCode'] != 'PP') {
$error = $this->language->get('text_declined');
}
} else {
$error = $this->language->get('text_unable');
}
if ($error) {
$data['breadcrumbs'] = array();
$data['breadcrumbs'][] = array(
'text' => $this->language->get('text_home'),
'href' => $this->url->link('common/home')
);
$data['breadcrumbs'][] = array(
'text' => $this->language->get('text_basket'),
'href' => $this->url->link('checkout/cart')
);
$data['breadcrumbs'][] = array(
'text' => $this->language->get('text_checkout'),
'href' => $this->url->link('checkout/checkout', '', true)
);
$data['breadcrumbs'][] = array(
'text' => $this->language->get('text_failed'),
'href' => $this->url->link('checkout/success')
);
$data['heading_title'] = $this->language->get('text_failed');
$data['text_message'] = sprintf($this->language->get('text_failed_message'), $error, $this->url->link('information/contact'));
$data['button_continue'] = $this->language->get('button_continue');
$data['continue'] = $this->url->link('common/home');
$data['column_left'] = $this->load->controller('common/column_left');
$data['column_right'] = $this->load->controller('common/column_right');
$data['content_top'] = $this->load->controller('common/content_top');
$data['content_bottom'] = $this->load->controller('common/content_bottom');
$data['footer'] = $this->load->controller('common/footer');
$data['header'] = $this->load->controller('common/header');
$this->response->setOutput($this->load->view('common/success', $data));
} else {
$this->model_checkout_order->addOrderHistory($order_id, $this->config->get('paymate_order_status_id'));
$this->response->redirect($this->url->link('checkout/success'));
}
}
}