Skip to content

Commit

Permalink
Some test fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
sudiptpa committed Nov 26, 2016
1 parent 397971f commit cba93b6
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 50 deletions.
10 changes: 9 additions & 1 deletion src/Message/DirectPostCompletePurchaseResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,17 @@
*/
class DirectPostCompletePurchaseResponse extends AbstractResponse
{
/**
* @return mixed
*/
public function isSuccessful()
{
return isset($this->data['summarycode']) && $this->data['summarycode'] == 1;
return $this->summaryCode() && (int) $this->getCode() == 00;
}

public function summaryCode()
{
return isset($this->data['summarycode']) && (int) $this->data['summarycode'] == 1;
}

/**
Expand Down
20 changes: 10 additions & 10 deletions tests/Message/DirectPostAuthorizeRequestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@ public function setUp()

$this->request->initialize(
array(
'merchantId' => 'foo',
'transactionPassword' => 'bar',
'amount' => '12.00',
'returnUrl' => 'https://www.abc.com/return',
'card' => array(
'number' => '4444333322221111',
'merchantId' => 'XYZ0010',
'transactionPassword' => 'abcd1234',
'amount' => '12.00',
'returnUrl' => 'https://www.abc.com/return',
'card' => array(
'number' => '4444333322221111',
'expiryMonth' => '6',
'expiryYear' => '2030',
'cvv' => '123',
'expiryYear' => '2030',
'cvv' => '123',
),
)
);
Expand All @@ -29,9 +29,9 @@ public function setUp()
public function testFingerprint()
{
$data = $this->request->getData();
$data['EPS_TIMESTAMP'] = '20130416123332';
$data['EPS_TIMESTAMP'] = '20161126053143';

$this->assertSame('46b6a59173c9fea66f71b8679558837895f0bce8', $this->request->generateFingerprint($data));
$this->assertSame('687bb11413254824e3f854be330b5b5f2efaaf6d', $this->request->generateFingerprint($data));
}

public function testSend()
Expand Down
64 changes: 32 additions & 32 deletions tests/Message/DirectPostCompletePurchaseRequestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@ public function testGenerateResponseFingerprint()
{
$this->request->initialize(
array(
'amount' => '465.18',
'amount' => '465.18',
'transactionPassword' => 'abcd1234',
)
);

$data = array(
'timestamp' => '20161125123332',
'merchant' => 'XYZ0010',
'refid' => '222',
'timestamp' => '20161125123332',
'merchant' => 'XYZ0010',
'refid' => '222',
'summarycode' => '2',
);

Expand All @@ -35,26 +35,26 @@ public function testSuccess()
{
$this->request->initialize(
array(
'amount' => '12.00',
'amount' => '12.00',
'transactionPassword' => 'abcd1234',
'transactionId' => 'ORDER-ZYX8',
'transactionId' => 'ORDER-ZYX8',
)
);

$this->getHttpRequest()->query->replace(
array(
'timestamp' => '20161125130241',
'timestamp' => '20161125130241',
'callback_status_code' => '-1',
'fingerprint' => 'e30eb8381bc41201fbdf54a021d8228a3fbb6a6f',
'txnid' => '271337',
'merchant' => 'XYZ0010',
'restext' => 'Approved',
'rescode' => '00',
'expirydate' => '20161126',
'settdate' => '20161126',
'refid' => 'ORDER-ZYX8',
'pan' => '444433...111',
'summarycode' => '1',
'fingerprint' => 'e30eb8381bc41201fbdf54a021d8228a3fbb6a6f',
'txnid' => '271337',
'merchant' => 'XYZ0010',
'restext' => 'Approved',
'rescode' => '00',
'expirydate' => '20161126',
'settdate' => '20161126',
'refid' => 'ORDER-ZYX8',
'pan' => '444433...111',
'summarycode' => '1',
)
);

Expand All @@ -75,23 +75,23 @@ public function testSuccess()
public function testFailure()
{
$this->request->initialize(array(
'amount' => '465.18',
'transactionPassword' => 'abc123',
'amount' => '465.18',
'transactionPassword' => 'abcd1234',
));

$this->getHttpRequest()->query->replace(array(
'timestamp' => '20130602102927',
'callback_status_code' => '',
'fingerprint' => '0516a31bf96ad89c354266afb9bd4be43aaf853f',
'txnid' => '205833',
'merchant' => 'ABC0030',
'restext' => 'Customer Dispute',
'rescode' => '18',
'expirydate' => '052016',
'settdate' => '20130602',
'refid' => '222',
'pan' => '444433...111',
'summarycode' => '2',
'timestamp' => '20161126051715',
'callback_status_code' => '404',
'fingerprint' => 'cd75e2ef38cf63a2fa390024539acc7691eebc1d',
'txnid' => '274279',
'merchant' => 'XYZ0010',
'restext' => 'Customer Dispute',
'rescode' => '18',
'expirydate' => '102030',
'settdate' => '20161126',
'refid' => 'ORDER-ZYX8',
'pan' => '444433...111',
'summarycode' => '2',
));

$response = $this->request->send();
Expand All @@ -100,7 +100,7 @@ public function testFailure()

$this->assertFalse($response->isSuccessful());
$this->assertFalse($response->isRedirect());
$this->assertSame('205833', $response->getTransactionReference());
$this->assertSame('274279', $response->getTransactionReference());
$this->assertSame('Customer Dispute', $response->getMessage());
$this->assertSame('18', $response->getCode());
}
Expand Down
14 changes: 7 additions & 7 deletions tests/Message/DirectPostPurchaseRequestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@ public function setUp()

$this->request->initialize(
array(
'merchantId' => 'XYZ0010',
'merchantId' => 'XYZ0010',
'transactionPassword' => 'abcd1234',
'amount' => '12.00',
'returnUrl' => 'https://www.example.com/return',
'card' => array(
'number' => '4444333322221111',
'amount' => '12.00',
'returnUrl' => 'https://www.example.com/return',
'card' => array(
'number' => '4444333322221111',
'expiryMonth' => '06',
'expiryYear' => '2020',
'cvv' => '123',
'expiryYear' => '2020',
'cvv' => '123',
),
)
);
Expand Down

0 comments on commit cba93b6

Please sign in to comment.