Skip to content
This repository was archived by the owner on Nov 9, 2023. It is now read-only.

Commit 07629d3

Browse files
author
Pim Elshoff
committed
Allow non-integer id formats such as hex
1 parent 866a130 commit 07629d3

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

src/model/response/PaymentCompletedResponse.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@ public function getStatus()
5252
public static function createInstance($orderID, $status, $signature, SigningKey $signingKey)
5353
{
5454
//Sanitize input
55-
$orderID = preg_replace('/[^0-9]/', '', $orderID);
5655
$status = preg_replace('/[^A-Z_]/', '', $status);
5756
$signature = preg_replace('/[^0-9a-f]/', '', $signature);
5857

@@ -72,4 +71,4 @@ public function getSignatureData()
7271
{
7372
return array($this->orderID, $this->status);
7473
}
75-
}
74+
}

test/model/response/PaymentCompletedResponseTest.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,13 @@ public function testThatIsValidReturnsTrueForUnderscoreInStatus() {
3030
$this->assertEquals('1', $paymentCompletedResponse->getOrderID());
3131
$this->assertEquals('IN_PROGRESS', $paymentCompletedResponse->getStatus());
3232
}
33+
34+
public function testIsValidReturnsTrueForNonIntegerIds()
35+
{
36+
$signingKey = new SigningKey('secret');
37+
$paymentCompletedResponse = PaymentCompletedResponse::createInstance('866a13038dd88f851fa3556a3b7d2da515018a95', 'COMPLETED', 'f29bc3142089ba67f3ff62a9b4b94fd2c923f50adbd752430ae480f70727863de750aa05d2dbae1bd0adb0c380135cbac34062b121cb051fbf9193a6a1c016fe', $signingKey);
38+
$this->assertNotFalse($paymentCompletedResponse);
39+
$this->assertEquals('866a13038dd88f851fa3556a3b7d2da515018a95', $paymentCompletedResponse->getOrderID());
40+
$this->assertEquals('COMPLETED', $paymentCompletedResponse->getStatus());
41+
}
3342
}

0 commit comments

Comments
 (0)