Skip to content

Commit c9cf6cc

Browse files
committed
Add extra Auth.net AIM response fields. Closes thephpleague#145
1 parent 529c9fe commit c9cf6cc

File tree

2 files changed

+47
-3
lines changed

2 files changed

+47
-3
lines changed

src/Omnipay/AuthorizeNet/Message/AIMResponse.php

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,16 +32,36 @@ public function __construct(RequestInterface $request, $data)
3232

3333
public function isSuccessful()
3434
{
35-
return '1' === $this->data[0];
35+
return '1' === $this->getCode();
3636
}
3737

38-
public function getTransactionReference()
38+
public function getCode()
3939
{
40-
return $this->data[6];
40+
return $this->data[0];
41+
}
42+
43+
public function getReasonCode()
44+
{
45+
return $this->data[2];
4146
}
4247

4348
public function getMessage()
4449
{
4550
return $this->data[3];
4651
}
52+
53+
public function getAuthorizationCode()
54+
{
55+
return $this->data[4];
56+
}
57+
58+
public function getAVSCode()
59+
{
60+
return $this->data[5];
61+
}
62+
63+
public function getTransactionReference()
64+
{
65+
return $this->data[6];
66+
}
4767
}

tests/Omnipay/AuthorizeNet/Message/AIMResponseTest.php

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@ public function testAuthorizeSuccess()
3131
$this->assertTrue($response->isSuccessful());
3232
$this->assertSame('2184493132', $response->getTransactionReference());
3333
$this->assertSame('This transaction has been approved.', $response->getMessage());
34+
$this->assertSame('1', $response->getCode());
35+
$this->assertSame('1', $response->getReasonCode());
36+
$this->assertSame('GA4OQP', $response->getAuthorizationCode());
37+
$this->assertSame('Y', $response->getAVSCode());
3438
}
3539

3640
public function testAuthorizeFailure()
@@ -41,6 +45,10 @@ public function testAuthorizeFailure()
4145
$this->assertFalse($response->isSuccessful());
4246
$this->assertSame('0', $response->getTransactionReference());
4347
$this->assertSame('A valid amount is required.', $response->getMessage());
48+
$this->assertSame('3', $response->getCode());
49+
$this->assertSame('5', $response->getReasonCode());
50+
$this->assertSame('', $response->getAuthorizationCode());
51+
$this->assertSame('P', $response->getAVSCode());
4452
}
4553

4654
public function testCaptureSuccess()
@@ -51,6 +59,10 @@ public function testCaptureSuccess()
5159
$this->assertTrue($response->isSuccessful());
5260
$this->assertSame('2184494531', $response->getTransactionReference());
5361
$this->assertSame('This transaction has been approved.', $response->getMessage());
62+
$this->assertSame('1', $response->getCode());
63+
$this->assertSame('1', $response->getReasonCode());
64+
$this->assertSame('F51OYG', $response->getAuthorizationCode());
65+
$this->assertSame('P', $response->getAVSCode());
5466
}
5567

5668
public function testCaptureFailure()
@@ -61,6 +73,10 @@ public function testCaptureFailure()
6173
$this->assertFalse($response->isSuccessful());
6274
$this->assertSame('0', $response->getTransactionReference());
6375
$this->assertSame('The transaction cannot be found.', $response->getMessage());
76+
$this->assertSame('3', $response->getCode());
77+
$this->assertSame('16', $response->getReasonCode());
78+
$this->assertSame('', $response->getAuthorizationCode());
79+
$this->assertSame('P', $response->getAVSCode());
6480
}
6581

6682
public function testPurchaseSuccess()
@@ -71,6 +87,10 @@ public function testPurchaseSuccess()
7187
$this->assertTrue($response->isSuccessful());
7288
$this->assertSame('2184492509', $response->getTransactionReference());
7389
$this->assertSame('This transaction has been approved.', $response->getMessage());
90+
$this->assertSame('1', $response->getCode());
91+
$this->assertSame('1', $response->getReasonCode());
92+
$this->assertSame('JE6JM1', $response->getAuthorizationCode());
93+
$this->assertSame('Y', $response->getAVSCode());
7494
}
7595

7696
public function testPurchaseFailure()
@@ -81,5 +101,9 @@ public function testPurchaseFailure()
81101
$this->assertFalse($response->isSuccessful());
82102
$this->assertSame('0', $response->getTransactionReference());
83103
$this->assertSame('A valid amount is required.', $response->getMessage());
104+
$this->assertSame('3', $response->getCode());
105+
$this->assertSame('5', $response->getReasonCode());
106+
$this->assertSame('', $response->getAuthorizationCode());
107+
$this->assertSame('P', $response->getAVSCode());
84108
}
85109
}

0 commit comments

Comments
 (0)