Skip to content

Commit f37ae93

Browse files
committed
feat: implement notification interface
1 parent e0fab1f commit f37ae93

File tree

3 files changed

+32
-13
lines changed

3 files changed

+32
-13
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
[Omnipay](https://github.com/thephpleague/omnipay) is a framework agnostic, multi-gateway payment processing library for
1313
PHP 5.3+. This package implements ecpay support for Omnipay.
1414

15-
**Note:** Replace `omnipay-taiwan`, `:author_name`, `recca0120`, `:author_website`, `:author_email`, `ecpay`
15+
**Note:** Replace `omnipay-taiwan`, `recca0120`, `recca0120`, `recca0120@gmail.com`, `ecpay`
1616
, `:package_description` and `ecpay` with their correct values in [README.md](README.md)
1717
, [CHANGELOG.md](CHANGELOG.md), [CONTRIBUTING.md](CONTRIBUTING.md), [LICENSE.md](LICENSE.md)
1818
and [composer.json](composer.json) files, then delete this line.
@@ -65,11 +65,11 @@ Please see [CONTRIBUTING](CONTRIBUTING.md) for details.
6565

6666
## Security
6767

68-
If you discover any security related issues, please email :author_email instead of using the issue tracker.
68+
If you discover any security related issues, please email recca0120@gmail.com instead of using the issue tracker.
6969

7070
## Credits
7171

72-
- [:author_name](https://github.com/recca0120)
72+
- [recca0120](https://github.com/recca0120)
7373
- [All Contributors](../../contributors)
7474

7575
## License

src/Message/CompletePurchaseRequest.php

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,13 @@
44

55
use Omnipay\Common\Exception\InvalidRequestException;
66
use Omnipay\Common\Message\AbstractRequest;
7+
use Omnipay\Common\Message\NotificationInterface;
78
use Omnipay\ECPay\Traits\HasCustomFields;
89
use Omnipay\ECPay\Traits\HasDefaults;
910
use Omnipay\ECPay\Traits\HasMerchantTradeNo;
1011
use Omnipay\ECPay\Traits\HasStoreID;
1112

12-
class CompletePurchaseRequest extends AbstractRequest
13+
class CompletePurchaseRequest extends AbstractRequest implements NotificationInterface
1314
{
1415
use HasDefaults;
1516
use HasMerchantTradeNo;
@@ -223,4 +224,22 @@ public function sendData($data)
223224
{
224225
return $this->response = new CompletePurchaseResponse($this, $data);
225226
}
227+
228+
public function getTransactionStatus()
229+
{
230+
return $this->getNotification()->getTransactionStatus();
231+
}
232+
233+
public function getMessage()
234+
{
235+
return $this->getNotification()->getMessage();
236+
}
237+
238+
/**
239+
* @return NotificationInterface
240+
*/
241+
private function getNotification()
242+
{
243+
return ! $this->response ? $this->send() : $this->response;
244+
}
226245
}

tests/Message/AcceptNotificationRequestTest.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace Omnipay\ECPay\Tests\Message;
44

55
use Omnipay\Common\Exception\InvalidRequestException;
6+
use Omnipay\Common\Message\NotificationInterface;
67
use Omnipay\ECPay\Message\AcceptNotificationRequest;
78
use Omnipay\Tests\TestCase;
89

@@ -44,21 +45,20 @@ public function testGetData()
4445

4546
self::assertEquals($options, $request->getData());
4647

47-
return [$request->send(), $options];
48+
return [$request, $options];
4849
}
4950

5051
/**
5152
* @depends testGetData
52-
* @param $result
53+
* @param $results
5354
*/
54-
public function testSendData($result)
55+
public function testSendData($results)
5556
{
56-
list($response, $options) = $result;
57+
list($notification, $options) = $results;
5758

58-
self::assertTrue($response->isSuccessful());
59-
self::assertEquals('1|OK', $response->getMessage());
60-
self::assertEquals($options['RtnCode'], $response->getCode());
61-
self::assertEquals($options['TradeNo'], $response->getTransactionReference());
62-
self::assertEquals($options['MerchantTradeNo'], $response->getTransactionId());
59+
self::assertEquals($options['MerchantTradeNo'], $notification->getTransactionId());
60+
self::assertEquals($options['TradeNo'], $notification->getTransactionReference());
61+
self::assertEquals(NotificationInterface::STATUS_COMPLETED, $notification->getTransactionStatus());
62+
self::assertEquals('1|OK', $notification->getMessage());
6363
}
6464
}

0 commit comments

Comments
 (0)