Skip to content

Commit db09422

Browse files
committed
feat: get reply
1 parent 5fab202 commit db09422

10 files changed

+46
-43
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: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
},
2020
"require-dev": {
2121
"roave/security-advisories": "dev-latest",
22-
"omnipay/tests": "^3.0",
22+
"omnipay/tests": "^3.0|^4.0",
2323
"squizlabs/php_codesniffer": "^3"
2424
},
2525
"autoload": {

src/Message/AcceptNotificationRequest.php

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@
22

33
namespace Omnipay\MyPay\Message;
44

5-
class AcceptNotificationRequest extends CompletePurchaseRequest
5+
use Omnipay\Common\Message\NotificationInterface;
6+
use Omnipay\Common\Message\ResponseInterface;
7+
8+
class AcceptNotificationRequest extends CompletePurchaseRequest implements NotificationInterface
69
{
710
/**
811
* @param array $data
@@ -12,4 +15,27 @@ public function sendData($data)
1215
{
1316
return $this->response = new AcceptNotificationResponse($this, $data);
1417
}
18+
19+
public function getTransactionStatus()
20+
{
21+
return $this->getNotificationResponse()->getTransactionStatus();
22+
}
23+
24+
public function getMessage()
25+
{
26+
return $this->getNotificationResponse()->getMessage();
27+
}
28+
29+
public function getReply()
30+
{
31+
return $this->getNotificationResponse()->getReply();
32+
}
33+
34+
/**
35+
* @return AcceptNotificationResponse
36+
*/
37+
private function getNotificationResponse()
38+
{
39+
return ! $this->response ? $this->send() : $this->response;
40+
}
1541
}

src/Message/AcceptNotificationResponse.php

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,17 @@
22

33
namespace Omnipay\MyPay\Message;
44

5-
class AcceptNotificationResponse extends CompletePurchaseResponse
5+
use Omnipay\Common\Message\NotificationInterface;
6+
7+
class AcceptNotificationResponse extends CompletePurchaseResponse implements NotificationInterface
68
{
7-
/**
8-
* Response Message.
9-
*
10-
* @return null|string A response message from the payment gateway
11-
*/
12-
public function getMessage()
9+
public function getReply()
1310
{
1411
return $this->isSuccessful() ? '8888' : '';
1512
}
13+
14+
public function getTransactionStatus()
15+
{
16+
return $this->isSuccessful() ? self::STATUS_COMPLETED : self::STATUS_FAILED;
17+
}
1618
}

src/Message/CompletePurchaseRequest.php

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,14 @@
33
namespace Omnipay\MyPay\Message;
44

55
use Omnipay\Common\Message\AbstractRequest as BaseAbstractRequest;
6-
use Omnipay\Common\Message\NotificationInterface;
7-
use Omnipay\Common\Message\ResponseInterface;
86
use Omnipay\MyPay\Traits\HasEcho;
97
use Omnipay\MyPay\Traits\HasKey;
108
use Omnipay\MyPay\Traits\HasOrderInfo;
119
use Omnipay\MyPay\Traits\HasOrderResult;
1210
use Omnipay\MyPay\Traits\HasStore;
1311
use Omnipay\MyPay\Traits\HasUid;
1412

15-
class CompletePurchaseRequest extends BaseAbstractRequest implements NotificationInterface
13+
class CompletePurchaseRequest extends BaseAbstractRequest
1614
{
1715
use HasStore;
1816
use HasKey;
@@ -294,22 +292,4 @@ public function sendData($data)
294292
{
295293
return $this->response = new CompletePurchaseResponse($this, $data);
296294
}
297-
298-
public function getTransactionStatus()
299-
{
300-
return $this->getNotification()->getTransactionStatus();
301-
}
302-
303-
public function getMessage()
304-
{
305-
return $this->getNotification()->getMessage();
306-
}
307-
308-
/**
309-
* @return ResponseInterface
310-
*/
311-
private function getNotification()
312-
{
313-
return ! $this->response ? $this->send() : $this->response;
314-
}
315295
}

src/Message/CompletePurchaseResponse.php

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,8 @@
33
namespace Omnipay\MyPay\Message;
44

55
use Omnipay\Common\Message\AbstractResponse;
6-
use Omnipay\Common\Message\NotificationInterface;
76

8-
class CompletePurchaseResponse extends AbstractResponse implements NotificationInterface
7+
class CompletePurchaseResponse extends AbstractResponse
98
{
109
/**
1110
* Is the response successful?
@@ -51,9 +50,4 @@ public function getTransactionReference()
5150
{
5251
return $this->data['uid'];
5352
}
54-
55-
public function getTransactionStatus()
56-
{
57-
return $this->isSuccessful() ? self::STATUS_COMPLETED : self::STATUS_FAILED;
58-
}
5953
}

tests/GatewayTest.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class GatewayTest extends GatewayTestCase
2525
*/
2626
private $storeKey = 'Xd668CSjnXQLD26Hia8vapkOgGXAv68s';
2727

28-
public function setUp()
28+
public function setUp(): void
2929
{
3030
parent::setUp();
3131

@@ -159,7 +159,8 @@ public function testAcceptNotification()
159159

160160
$response = $this->gateway->acceptNotification($options);
161161

162-
self::assertEquals('8888', $response->getMessage());
162+
self::assertEquals('付款完成', $response->getMessage());
163+
self::assertEquals('8888', $response->getReply());
163164
}
164165

165166
public function testFetchTransaction()

tests/Message/CompletePurchaseRequestTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ class CompletePurchaseRequestTest extends TestCase
1313
*/
1414
private $request;
1515

16-
public function setUp()
16+
public function setUp(): void
1717
{
1818
parent::setUp();
1919

tests/Message/FetchTransactionRequestTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ class FetchTransactionRequestTest extends TestCase
1212
*/
1313
private $request;
1414

15-
public function setUp()
15+
public function setUp(): void
1616
{
1717
parent::setUp();
1818

tests/Message/PurchaseRequestTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class PurchaseRequestTest extends TestCase
1616
*/
1717
private $request;
1818

19-
public function setUp()
19+
public function setUp(): void
2020
{
2121
parent::setUp();
2222

0 commit comments

Comments
 (0)