-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpayat.php
123 lines (101 loc) · 3.18 KB
/
payat.php
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
112
113
114
115
116
117
118
119
120
121
122
123
<?php
if(!defined('_PS_VERSION_'))
exit;
class payat extends PaymentModule
{
private $_html = '';
private $_postErrors = array();
public function __construct() {
$this->name = 'payat';
$this->tab = 'payments_gateways';
$this->version = '1.0.0';
$this->author = 'ZASoundz';
$this->currencies = true;
$this->currencies_mode = 'radio';
if(!sizeof(Currency::checkPaymentCurrencies($this->id)))
$this->warning = $this->l('No currency set for this module');
parent::__construct();
$this->displayName = $this->l('Pay@ ZA');
$this->description = $this->l('Hybrid payment module to integrate Pay@');
$this->confirmUninstall = $this->l('Are you sure about removing these module?');
}
public function install() {
return parent::install()
&& $this->installCurrency()
&& $this->registerHook('header')
&& $this->registerHook('payment')
&& $this->registerHook('paymentReturn');
}
public function uninstall() {
return parent::uninstall()
&& $this->unregisterHook('header')
&& $this->unregisterHook('payment')
&& $this->unregisterHook('paymentReturn');
}
public function installCurrency()
{
$currency = new Currency();
$currency_rand_id = $currency->getIdByIsoCode('ZAR');
if(is_null($currency_rand_id))
{
$currency->name = "South African Rand";
$currency->iso_code = "ZAR";
$currency->sign = "R";
$currency->format = 1;
$currency->blank = 1;
$currency->decimals = 1;
$currency->deleted = 0;
$currency->conversion_rate = 0.45; // we set it to an arbitrary value
$currency->add();
$currency->refreshCurrencies();
}
return true;
}
public function hookHeader($params) {
}
public function getContent()
{
}
public function displayMessage()
{
$this->_html .= '
<div class="conf confirm">
<img src"../img/admin/ok.gif" alt="'.$this->l('Confirmation').'" />
'.$this->l('Module settings updated').'
</div>';
}
public function hookPayment($params) {
if (!$this->active)
return;
if (!$this->checkCurrency($params['cart']))
return;
$this->smarty->assign(array(
'this_path' => $this->_path,
'this_path_pa' => $this->_path,
'this_path_ssl' => Tools::getShopDomainSsl(true, true).__PS_BASE_URI__.'modules/'.$this->name.'/'
));
return $this->display(__FILE__, 'payment.tpl');
}
public function hookPaymentReturn($params) {
if (!$this->active)
return;
$state = $params['objOrder']->getCurrentState();
if ($state == Configuration::get('PS_OS_BANKWIRE') || $state == Configuration::get('PS_OS_OUTOFSTOCK'))
{
$this->smarty->assign(array(
'total_to_pay' => Tools::displayPrice($params['total_to_pay'], $params['currencyObj'], false),
'bankwireDetails' => Tools::nl2br($this->details),
'bankwireAddress' => Tools::nl2br($this->address),
'bankwireOwner' => $this->owner,
'status' => 'ok',
'id_order' => $params['objOrder']->id
));
if (isset($params['objOrder']->reference) && !empty($params['objOrder']->reference))
$this->smarty->assign('reference', $params['objOrder']->reference);
}
else
$this->smarty->assign('status', 'failed');
return $this->display(__FILE__, 'payment_return.tpl');
}
}
?>