Skip to content

Commit 66381ef

Browse files
committed
Add support for getting the reason code from the response
1 parent a20d585 commit 66381ef

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

src/Message/CompletePurchaseResponse.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,16 @@ public function getAuthCode()
7474
return $this->getKey('auth_code');
7575
}
7676

77+
/**
78+
* Get the reason code if available.
79+
*
80+
* @return null|string
81+
*/
82+
public function getReasonCode()
83+
{
84+
return $this->getKey('reason_code');
85+
}
86+
7787
/**
7888
* Get the merchant response message if available.
7989
*

tests/Message/CompletePurchaseResponseTest.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@ public function testCompletePurchaseSuccess()
132132
$this->assertFalse($this->response->isRedirect());
133133
$this->assertSame('1234567890123456789012', $this->response->getTransactionReference());
134134
$this->assertSame('831000', $this->response->getAuthCode());
135+
$this->assertSame('100', $this->response->getReasonCode());
135136
$this->assertSame('Request was processed successfully.', $this->response->getMessage());
136137
$this->assertSame('411111xxxxxx1111', $this->response->getCardNumber());
137138
$this->assertSame('001', $this->response->getCardType());
@@ -194,6 +195,7 @@ public function testCompletePurchaseFailure()
194195
$this->assertFalse($this->response->isRedirect());
195196
$this->assertSame('1234567890123456789012', $this->response->getTransactionReference());
196197
$this->assertNull($this->response->getAuthCode());
198+
$this->assertSame('101', $this->response->getReasonCode());
197199
$this->assertSame(
198200
'The request data did not pass the required fields check for this application: [bill_country]',
199201
$this->response->getMessage()
@@ -237,6 +239,7 @@ public function testCompletePurchaseError()
237239
$this->assertFalse($this->response->isRedirect());
238240
$this->assertNull($this->response->getTransactionReference());
239241
$this->assertNull($this->response->getAuthCode());
242+
$this->assertNull($this->response->getReasonCode());
240243
$this->assertSame('Issuing bank has indicated a fraud alert', $this->response->getMessage());
241244
$this->assertNull($this->response->getCardNumber());
242245
$this->assertNull($this->response->getCardType());

0 commit comments

Comments
 (0)