Skip to content

Commit 283798d

Browse files
Added POS test cases.
1 parent 940a99c commit 283798d

33 files changed

+623
-195
lines changed

src/AllInOneGateway.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
*/
2424
class AllInOneGateway extends AbstractGateway
2525
{
26-
use Concerns\AllInOneParameters;
26+
use Concerns\Parameters;
2727

2828
/**
2929
* {@inheritdoc}

src/AppInAppGateway.php

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
namespace Omnipay\MoMo;
99

1010
use Omnipay\Common\AbstractGateway;
11-
use Omnipay\MoMo\Message\PayConfirmResponse;
11+
use Omnipay\MoMo\Message\PayConfirmRequest;
1212
use Omnipay\MoMo\Message\AppInApp\PurchaseRequest;
1313

1414
/**
@@ -17,7 +17,7 @@
1717
*/
1818
class AppInAppGateway extends AbstractGateway
1919
{
20-
use Concerns\AppInAppParameters;
20+
use Concerns\Parameters;
2121

2222
/**
2323
* {@inheritdoc}
@@ -27,17 +27,6 @@ public function getName(): string
2727
return 'MoMo AIA';
2828
}
2929

30-
31-
/**
32-
* {@inheritdoc}
33-
*/
34-
public function getDefaultParameters(): array
35-
{
36-
return [
37-
'version' => '2.0',
38-
];
39-
}
40-
4130
/**
4231
* {@inheritdoc}
4332
* @return \Omnipay\Common\Message\RequestInterface|PurchaseRequest
@@ -51,10 +40,10 @@ public function purchase(array $options = []): PurchaseRequest
5140
* Tạo yêu cầu xác nhận hoàn thành hoặc hủy bỏ giao dịch đến MoMo.
5241
*
5342
* @param array $options
54-
* @return \Omnipay\Common\Message\RequestInterface|PayConfirmResponse
43+
* @return \Omnipay\Common\Message\RequestInterface|PayConfirmRequest
5544
*/
56-
public function payConfirm(array $options = []): PayConfirmResponse
45+
public function payConfirm(array $options = []): PayConfirmRequest
5746
{
58-
return $this->createRequest(PayConfirmResponse::class, $options);
47+
return $this->createRequest(PayConfirmRequest::class, $options);
5948
}
6049
}

src/Concerns/AllInOneParameters.php

Lines changed: 0 additions & 27 deletions
This file was deleted.

src/Concerns/AppInAppParameters.php

Lines changed: 0 additions & 33 deletions
This file was deleted.

src/Concerns/POSParameters.php

Lines changed: 0 additions & 37 deletions
This file was deleted.

src/Concerns/Parameters.php

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,36 @@
1313
*/
1414
trait Parameters
1515
{
16+
/**
17+
* Trả về access key do MoMo cấp.
18+
*
19+
* @return null|string
20+
*/
21+
public function getAccessKey(): ?string
22+
{
23+
return $this->getParameter('accessKey');
24+
}
25+
26+
/**
27+
* Thiết lập access key do MoMo cấp.
28+
*
29+
* @param string $key
30+
*/
31+
public function setAccessKey(string $key): void
32+
{
33+
$this->setParameter('accessKey', $key);
34+
}
35+
36+
/**
37+
* Trả về secret key do MoMo cấp.
38+
*
39+
* @return null|string
40+
*/
41+
public function getSecretKey(): ?string
42+
{
43+
return $this->getParameter('secretKey');
44+
}
45+
1646
/**
1747
* Thiết lập secret key do MoMo cấp.
1848
*
@@ -23,6 +53,16 @@ public function setSecretKey(string $key): void
2353
$this->setParameter('secretKey', $key);
2454
}
2555

56+
/**
57+
* Trả về partner code do MoMo cấp.
58+
*
59+
* @return null|string
60+
*/
61+
public function getPartnerCode(): ?string
62+
{
63+
return $this->getParameter('partnerCode');
64+
}
65+
2666
/**
2767
* Thiết lập partner code do MoMo cấp.
2868
*
@@ -32,4 +72,24 @@ public function setPartnerCode(string $code): void
3272
{
3373
$this->setParameter('partnerCode', $code);
3474
}
75+
76+
/**
77+
* Trả về public key do MoMo cấp.
78+
*
79+
* @return null|string
80+
*/
81+
public function getPublicKey(): ?string
82+
{
83+
return $this->getParameter('publicKey');
84+
}
85+
86+
/**
87+
* Thiết lập public key do MoMo cấp.
88+
*
89+
* @param string $key
90+
*/
91+
public function setPublicKey(string $key): void
92+
{
93+
$this->setParameter('publicKey', $key);
94+
}
3595
}

src/Concerns/QRCodeParameters.php

Lines changed: 0 additions & 27 deletions
This file was deleted.

src/Message/AbstractHashRequest.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@
77

88
namespace Omnipay\MoMo\Message;
99

10-
use Omnipay\Common\Message\AbstractRequest;
11-
1210
/**
1311
* @author Vuong Minh <[email protected]>
1412
* @since 1.0.0
@@ -26,7 +24,7 @@ public function getData(): array
2624
$parameters = $this->getParameters();
2725
call_user_func_array([$this, 'validate'], $this->getHashParameters());
2826
$parameters['hash'] = $this->generateHash();
29-
unset($parameters['secretKey'], $parameters['testMode'], $parameters['publicKey']);
27+
unset($parameters['testMode'], $parameters['publicKey'], $parameters['secretKey']);
3028

3129
return $parameters;
3230
}

src/Message/AbstractIncomingRequest.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@
77

88
namespace Omnipay\MoMo\Message;
99

10-
use Omnipay\Common\Message\AbstractRequest;
11-
1210
/**
1311
* @author Vuong Minh <[email protected]>
1412
* @since 1.0.0

src/Message/AbstractRequest.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?php
2+
/**
3+
* @link https://github.com/phpviet/omnipay-momo
4+
* @copyright (c) PHP Viet
5+
* @license [MIT](http://www.opensource.org/licenses/MIT)
6+
*/
7+
8+
namespace Omnipay\MoMo\Message;
9+
10+
use Omnipay\MoMo\Concerns\Parameters;
11+
use Omnipay\Common\Message\AbstractRequest as BaseAbstractRequest;
12+
13+
/**
14+
* @author Vuong Minh <[email protected]>
15+
* @since 1.0.0
16+
*/
17+
abstract class AbstractRequest extends BaseAbstractRequest
18+
{
19+
use Parameters;
20+
}

0 commit comments

Comments
 (0)