Skip to content

Commit cba93b6

Browse files
committed
Some test fixes
1 parent 397971f commit cba93b6

File tree

4 files changed

+58
-50
lines changed

4 files changed

+58
-50
lines changed

src/Message/DirectPostCompletePurchaseResponse.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,17 @@
99
*/
1010
class DirectPostCompletePurchaseResponse extends AbstractResponse
1111
{
12+
/**
13+
* @return mixed
14+
*/
1215
public function isSuccessful()
1316
{
14-
return isset($this->data['summarycode']) && $this->data['summarycode'] == 1;
17+
return $this->summaryCode() && (int) $this->getCode() == 00;
18+
}
19+
20+
public function summaryCode()
21+
{
22+
return isset($this->data['summarycode']) && (int) $this->data['summarycode'] == 1;
1523
}
1624

1725
/**

tests/Message/DirectPostAuthorizeRequestTest.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,15 @@ public function setUp()
1212

1313
$this->request->initialize(
1414
array(
15-
'merchantId' => 'foo',
16-
'transactionPassword' => 'bar',
17-
'amount' => '12.00',
18-
'returnUrl' => 'https://www.abc.com/return',
19-
'card' => array(
20-
'number' => '4444333322221111',
15+
'merchantId' => 'XYZ0010',
16+
'transactionPassword' => 'abcd1234',
17+
'amount' => '12.00',
18+
'returnUrl' => 'https://www.abc.com/return',
19+
'card' => array(
20+
'number' => '4444333322221111',
2121
'expiryMonth' => '6',
22-
'expiryYear' => '2030',
23-
'cvv' => '123',
22+
'expiryYear' => '2030',
23+
'cvv' => '123',
2424
),
2525
)
2626
);
@@ -29,9 +29,9 @@ public function setUp()
2929
public function testFingerprint()
3030
{
3131
$data = $this->request->getData();
32-
$data['EPS_TIMESTAMP'] = '20130416123332';
32+
$data['EPS_TIMESTAMP'] = '20161126053143';
3333

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

3737
public function testSend()

tests/Message/DirectPostCompletePurchaseRequestTest.php

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,15 @@ public function testGenerateResponseFingerprint()
1515
{
1616
$this->request->initialize(
1717
array(
18-
'amount' => '465.18',
18+
'amount' => '465.18',
1919
'transactionPassword' => 'abcd1234',
2020
)
2121
);
2222

2323
$data = array(
24-
'timestamp' => '20161125123332',
25-
'merchant' => 'XYZ0010',
26-
'refid' => '222',
24+
'timestamp' => '20161125123332',
25+
'merchant' => 'XYZ0010',
26+
'refid' => '222',
2727
'summarycode' => '2',
2828
);
2929

@@ -35,26 +35,26 @@ public function testSuccess()
3535
{
3636
$this->request->initialize(
3737
array(
38-
'amount' => '12.00',
38+
'amount' => '12.00',
3939
'transactionPassword' => 'abcd1234',
40-
'transactionId' => 'ORDER-ZYX8',
40+
'transactionId' => 'ORDER-ZYX8',
4141
)
4242
);
4343

4444
$this->getHttpRequest()->query->replace(
4545
array(
46-
'timestamp' => '20161125130241',
46+
'timestamp' => '20161125130241',
4747
'callback_status_code' => '-1',
48-
'fingerprint' => 'e30eb8381bc41201fbdf54a021d8228a3fbb6a6f',
49-
'txnid' => '271337',
50-
'merchant' => 'XYZ0010',
51-
'restext' => 'Approved',
52-
'rescode' => '00',
53-
'expirydate' => '20161126',
54-
'settdate' => '20161126',
55-
'refid' => 'ORDER-ZYX8',
56-
'pan' => '444433...111',
57-
'summarycode' => '1',
48+
'fingerprint' => 'e30eb8381bc41201fbdf54a021d8228a3fbb6a6f',
49+
'txnid' => '271337',
50+
'merchant' => 'XYZ0010',
51+
'restext' => 'Approved',
52+
'rescode' => '00',
53+
'expirydate' => '20161126',
54+
'settdate' => '20161126',
55+
'refid' => 'ORDER-ZYX8',
56+
'pan' => '444433...111',
57+
'summarycode' => '1',
5858
)
5959
);
6060

@@ -75,23 +75,23 @@ public function testSuccess()
7575
public function testFailure()
7676
{
7777
$this->request->initialize(array(
78-
'amount' => '465.18',
79-
'transactionPassword' => 'abc123',
78+
'amount' => '465.18',
79+
'transactionPassword' => 'abcd1234',
8080
));
8181

8282
$this->getHttpRequest()->query->replace(array(
83-
'timestamp' => '20130602102927',
84-
'callback_status_code' => '',
85-
'fingerprint' => '0516a31bf96ad89c354266afb9bd4be43aaf853f',
86-
'txnid' => '205833',
87-
'merchant' => 'ABC0030',
88-
'restext' => 'Customer Dispute',
89-
'rescode' => '18',
90-
'expirydate' => '052016',
91-
'settdate' => '20130602',
92-
'refid' => '222',
93-
'pan' => '444433...111',
94-
'summarycode' => '2',
83+
'timestamp' => '20161126051715',
84+
'callback_status_code' => '404',
85+
'fingerprint' => 'cd75e2ef38cf63a2fa390024539acc7691eebc1d',
86+
'txnid' => '274279',
87+
'merchant' => 'XYZ0010',
88+
'restext' => 'Customer Dispute',
89+
'rescode' => '18',
90+
'expirydate' => '102030',
91+
'settdate' => '20161126',
92+
'refid' => 'ORDER-ZYX8',
93+
'pan' => '444433...111',
94+
'summarycode' => '2',
9595
));
9696

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

101101
$this->assertFalse($response->isSuccessful());
102102
$this->assertFalse($response->isRedirect());
103-
$this->assertSame('205833', $response->getTransactionReference());
103+
$this->assertSame('274279', $response->getTransactionReference());
104104
$this->assertSame('Customer Dispute', $response->getMessage());
105105
$this->assertSame('18', $response->getCode());
106106
}

tests/Message/DirectPostPurchaseRequestTest.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,15 @@ public function setUp()
1212

1313
$this->request->initialize(
1414
array(
15-
'merchantId' => 'XYZ0010',
15+
'merchantId' => 'XYZ0010',
1616
'transactionPassword' => 'abcd1234',
17-
'amount' => '12.00',
18-
'returnUrl' => 'https://www.example.com/return',
19-
'card' => array(
20-
'number' => '4444333322221111',
17+
'amount' => '12.00',
18+
'returnUrl' => 'https://www.example.com/return',
19+
'card' => array(
20+
'number' => '4444333322221111',
2121
'expiryMonth' => '06',
22-
'expiryYear' => '2020',
23-
'cvv' => '123',
22+
'expiryYear' => '2020',
23+
'cvv' => '123',
2424
),
2525
)
2626
);

0 commit comments

Comments
 (0)