You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Apr 3, 2018. It is now read-only.
@@ -44,78 +43,96 @@ public function statusOptions()
44
43
45
44
46
45
/**
47
-
* Server 2 Server check
46
+
* Perform server to server data check
48
47
*/
49
48
publicfunctionprocessPostSale()
50
49
{
51
-
$this->import('Input');
52
-
53
-
// stop if something went wrong
50
+
// Verify payment status
54
51
if ($this->Input->post('status') != 'success')
55
52
{
56
-
$this->log('Order ID "' . $this->Input->post('refno') . '" has NOT succeedet. UPP Transaction Id: ' . $this->Input->post('uppTransactionId'), __METHOD__, TL_ERROR);
57
-
return;
53
+
$this->log('Payment for order ID "' . $this->Input->post('refno') . '" failed.', __METHOD__, TL_ERROR);
54
+
returnfalse;
58
55
}
59
-
56
+
60
57
$objOrder = newIsotopeOrder();
61
58
62
59
if (!$objOrder->findBy('id', $this->Input->post('refno')))
63
60
{
64
61
$this->log('Order ID "' . $this->Input->post('refno') . '" not found', __METHOD__, TL_ERROR);
65
-
return;
62
+
returnfalse;
66
63
}
67
64
68
-
// check if the details are okay
69
-
if ($this->Input->post('merchantId') == $this->datatrans_id)
65
+
// Validate HMAC sign
66
+
if ($this->Input->post('sign2') != hash_hmac('md5', $this->datatrans_id.$this->Input->post('amount').$this->Input->post('currency').$this->Input->post('uppTransactionId'), $this->datatrans_sign))
70
67
{
71
-
// do the optional sign check
72
-
if ($this->datatrans_sign == 1)
73
-
{
74
-
if ($this->datatrans_sign_value != $this->Input->post('sign'))
75
-
{
76
-
$this->log('Call without a valid sign id', __METHOD__, TL_ERROR);
77
-
return;
78
-
}
79
-
}
80
-
81
-
// new in isotope 1.3
82
-
if (version_compare(ISO_VERSION, '0.2', '>'))
83
-
{
84
-
$objOrder->checkout();
85
-
}
86
-
87
-
$objOrder->date_payed = time();
88
-
$objOrder->save();
68
+
$this->log('Invalid HMAC signature for Order ID ' . $this->Input->post('refno'), __METHOD__, TL_ERROR);
69
+
returnfalse;
70
+
}
89
71
72
+
// For maximum security, also validate individual parameters
0 commit comments