Skip to content

Commit 20cc586

Browse files
1 parent 55919c6 commit 20cc586

File tree

4 files changed

+19
-23
lines changed

4 files changed

+19
-23
lines changed

src/Message/CompletePurchaseResponse.php

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@ class CompletePurchaseResponse extends PurchaseResponse
66
{
77
public function isSuccessful()
88
{
9-
if (!empty($_POST['x_result']))
10-
{
9+
if (!empty($_POST['x_result'])) {
1110
$data = parent::getRedirectData();
1211

1312
$hmacKey = $data['key_secret'];
@@ -16,7 +15,7 @@ public function isSuccessful()
1615
$verifySignature = new Signature($hmacKey);
1716
$signature = $verifySignature->getSignature($_POST);
1817

19-
return $this->hash_equals($signature, $razorpaySignature);
18+
return $this->hashEquals($signature, $razorpaySignature);
2019
}
2120

2221
return false;
@@ -26,21 +25,18 @@ public function isSuccessful()
2625
* Taken from https://stackoverflow.com/questions/10576827/secure-string-compare-function
2726
* under the MIT license
2827
*/
29-
protected function hash_equals($str1, $str2)
28+
protected function hashEquals($str1, $str2)
3029
{
31-
if (function_exists('hash_equals') === true)
32-
{
30+
if (function_exists('hash_equals') === true) {
3331
return hash_equals($str1, $str2);
3432
}
35-
if (strlen($str1) !== strlen($str2))
36-
{
33+
if (strlen($str1) !== strlen($str2)) {
3734
return false;
3835
}
3936

4037
$result = 0;
4138

42-
for ($i = 0; $i < strlen($str1); $i++)
43-
{
39+
for ($i = 0; $i < strlen($str1); $i++) {
4440
$result |= ord($str1) ^ ord($str2);
4541
}
4642

src/Message/PurchaseRequest.php

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,8 @@
1010
*/
1111
class PurchaseRequest extends AbstractRequest
1212
{
13-
public function getData()
14-
{
15-
if (!empty($this->getCard()))
16-
{
13+
public function getData() {
14+
if (!empty($this->getCard())) {
1715
$card = $this->getCard();
1816

1917
$hmacKey = $this->getKeySecret();
@@ -58,9 +56,9 @@ public function getData()
5856

5957
// Default case
6058
return $this->getParameters();
61-
}
59+
}
6260

63-
// To send the data for our
61+
// To send the data for our
6462
public function sendData($data)
6563
{
6664
return $this->createResponse($data);

src/Message/PurchaseResponse.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,9 @@ public function getRedirectData()
2525
return $this->data;
2626
}
2727

28-
public function redirect(){}
28+
public function redirect()
29+
{
30+
}
2931

3032
public function isRedirect()
3133
{

src/Message/Signature.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,16 @@
44

55
class Signature
66
{
7-
public function __construct($key)
8-
{
9-
$this->key = $key;
10-
}
7+
public function __construct($key)
8+
{
9+
$this->key = $key;
10+
}
1111

12-
public function getSignature(array $data)
12+
public function getSignature(array $data)
1313
{
1414
$validFields = array_filter(array_keys($data), function ($key)
1515
{
16-
return $key != 'x_signature' and substr($key,0,2) == 'x_';
16+
return $key != 'x_signature' and substr($key, 0, 2) == 'x_';
1717
});
1818

1919
$data = array_intersect_key($data, array_flip($validFields));

0 commit comments

Comments
 (0)