Skip to content

Commit 388c2fe

Browse files
committed
feat: get reply
1 parent e088ac3 commit 388c2fe

File tree

9 files changed

+46
-34
lines changed

9 files changed

+46
-34
lines changed

.github/workflows/tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ jobs:
99
strategy:
1010
fail-fast: true
1111
matrix:
12-
php: [ '5.6', '7.0', '7.1','7.2', '7.3', '7.4' ]
12+
php: [ '7.1','7.2', '7.3', '7.4', '8.0', '8.1' ]
1313
stability: [ prefer-stable ]
1414

1515
name: PHP ${{ matrix.php }} - ${{ matrix.stability }}

composer.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,12 @@
4040
"omnipay/common": "~3.0"
4141
},
4242
"require-dev": {
43-
"omnipay/tests": "~3.0",
44-
"squizlabs/php_codesniffer": "~3.0"
43+
"omnipay/tests": "~3.0|~4.0",
44+
"squizlabs/php_codesniffer": "^3.0"
4545
},
4646
"extra": {
4747
"branch-alias": {
48-
"dev-master": "3.0.x-dev"
48+
"dev-master": "3.1.x-dev"
4949
}
5050
},
5151
"prefer-stable": true

src/Message/AcceptNotificationRequest.php

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,39 @@
22

33
namespace Omnipay\Payware\Message;
44

5-
class AcceptNotificationRequest extends CompletePurchaseRequest
5+
use Omnipay\Common\Message\NotificationInterface;
6+
7+
class AcceptNotificationRequest extends CompletePurchaseRequest implements NotificationInterface
68
{
79
/**
810
* @param mixed $data
9-
* @return CompletePurchaseResponse
11+
* @return AcceptNotificationResponse
1012
*/
1113
public function sendData($data)
1214
{
1315
return $this->response = new AcceptNotificationResponse($this, $data);
1416
}
17+
18+
public function getTransactionStatus()
19+
{
20+
return $this->getNotificationResponse()->getTransactionStatus();
21+
}
22+
23+
public function getMessage()
24+
{
25+
return $this->getNotificationResponse()->getMessage();
26+
}
27+
28+
public function getReply()
29+
{
30+
return $this->getNotificationResponse()->getReply();
31+
}
32+
33+
/**
34+
* @return AcceptNotificationResponse
35+
*/
36+
private function getNotificationResponse()
37+
{
38+
return ! $this->response ? $this->send() : $this->response;
39+
}
1540
}

src/Message/AcceptNotificationResponse.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
class AcceptNotificationResponse extends CompletePurchaseResponse implements NotificationInterface
88
{
9-
public function getMessage()
9+
public function getReply()
1010
{
1111
return $this->isSuccessful() ? 'OK' : 'FAIL';
1212
}

src/Message/CompletePurchaseRequest.php

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,13 @@
44

55
use Omnipay\Common\Exception\InvalidRequestException;
66
use Omnipay\Common\Exception\InvalidResponseException;
7-
use Omnipay\Common\Message\NotificationInterface;
87
use Omnipay\Payware\Support\Helper;
98
use Omnipay\Payware\Traits\HasBooking;
109
use Omnipay\Payware\Traits\HasCreditCard;
1110
use Omnipay\Payware\Traits\HasCVS;
1211
use Omnipay\Payware\Traits\HasMerchant;
1312

14-
class CompletePurchaseRequest extends AbstractRequest implements NotificationInterface
13+
class CompletePurchaseRequest extends AbstractRequest
1514
{
1615
use HasMerchant;
1716
use HasBooking;
@@ -154,24 +153,6 @@ public function sendData($data)
154153
return $this->response = new CompletePurchaseResponse($this, $data);
155154
}
156155

157-
public function getTransactionStatus()
158-
{
159-
return $this->getNotification()->getTransactionStatus();
160-
}
161-
162-
public function getMessage()
163-
{
164-
return $this->getNotification()->getMessage();
165-
}
166-
167-
/**
168-
* @return NotificationInterface
169-
*/
170-
private function getNotification()
171-
{
172-
return ! $this->response ? $this->send() : $this->response;
173-
}
174-
175156
/**
176157
* @return array
177158
* @throws InvalidResponseException

src/Message/ReceiveTransactionInfoResponse.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public function isSuccessful()
2323
*/
2424
public function getMessage()
2525
{
26-
return 'OK';
26+
return '';
2727
}
2828

2929
/**
@@ -45,4 +45,9 @@ public function getTransactionId()
4545
{
4646
return $this->data['CustOrderNo'];
4747
}
48+
49+
public function getReply()
50+
{
51+
return 'OK';
52+
}
4853
}

tests/GatewayTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
class GatewayTest extends GatewayTestCase
1313
{
14-
public function setUp()
14+
public function setUp(): void
1515
{
1616
parent::setUp();
1717

tests/Message/AcceptNotificationRequestTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,8 @@ public function testSend($result)
5151
self::assertEquals('6636797108956306177', $notification->getTransactionId());
5252
self::assertEquals('PW118120600018', $notification->getTransactionReference());
5353
self::assertEquals(NotificationInterface::STATUS_COMPLETED, $notification->getTransactionStatus());
54-
self::assertEquals('OK', $notification->getMessage());
54+
self::assertEquals('授權成功。', $notification->getMessage());
55+
// self::assertEquals('OK', $notification->getReply());
5556
}
5657

5758
public function testInvalidCheckMacValue()

tests/Message/ReceiveTransactionInfoRequestTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,11 @@ public function testAtmNoGetData()
4848
*/
4949
public function testAtmSend($results)
5050
{
51-
list($response, $options) = $results;
51+
[$response, $options] = $results;
5252

5353
self::assertTrue($response->isSuccessful());
5454
self::assertEquals($options['AtmNo'], $response->getData()['AtmNo']);
55-
self::assertEquals('OK', $response->getMessage());
55+
self::assertEquals('OK', $response->getReply());
5656
}
5757

5858
public function testPaymentNoGetData()
@@ -83,10 +83,10 @@ public function testPaymentNoGetData()
8383
*/
8484
public function testPaymentNoSend($results)
8585
{
86-
list($response, $options) = $results;
86+
[$response, $options] = $results;
8787

8888
self::assertTrue($response->isSuccessful());
8989
self::assertEquals($options['PaymentNo'], $response->getData()['PaymentNo']);
90-
self::assertEquals('OK', $response->getMessage());
90+
self::assertEquals('OK', $response->getReply());
9191
}
9292
}

0 commit comments

Comments
 (0)