|
5 | 5 | * @license [MIT](http://www.opensource.org/licenses/MIT) |
6 | 6 | */ |
7 | 7 |
|
8 | | -namespace Omnipay\MoMo\Message\Pos; |
| 8 | +namespace Omnipay\MoMo\Message\POS; |
9 | 9 |
|
10 | | -use Omnipay\MoMo\Concerns\PosParameters; |
| 10 | +use Omnipay\MoMo\Concerns\POSParameters; |
11 | 11 | use Omnipay\MoMo\Message\AbstractHashRequest; |
12 | 12 |
|
13 | 13 | /** |
|
16 | 16 | */ |
17 | 17 | class PurchaseRequest extends AbstractHashRequest |
18 | 18 | { |
19 | | - use PosParameters; |
| 19 | + use POSParameters; |
| 20 | + |
| 21 | + /** |
| 22 | + * {@inheritdoc} |
| 23 | + * @throws \Omnipay\Common\Exception\InvalidRequestException |
| 24 | + */ |
| 25 | + public function getData(): array |
| 26 | + { |
| 27 | + $this->validate('paymentCode'); |
| 28 | + $this->setParameter('payType', 3); |
| 29 | + $parameters = parent::getData(); |
| 30 | + unset($parameters['paymentCode']); |
| 31 | + |
| 32 | + return $parameters; |
| 33 | + } |
| 34 | + |
| 35 | + /** |
| 36 | + * {@inheritdoc} |
| 37 | + */ |
| 38 | + public function sendData($data): PurchaseResponse |
| 39 | + { |
| 40 | + $response = $this->httpClient->request('POST', $this->getEndpoint().'/pay/pos', [ |
| 41 | + 'Content-Type' => 'application/json; charset=utf-8', |
| 42 | + ], json_encode($data)); |
| 43 | + $responseData = $response->getBody()->getContents(); |
| 44 | + |
| 45 | + return $this->response = new PurchaseResponse($this, json_decode($responseData, true) ?? []); |
| 46 | + } |
20 | 47 |
|
21 | 48 | /** |
22 | 49 | * Thiết lập mã cửa hàng. |
@@ -58,33 +85,6 @@ public function setPaymentCode(string $code): void |
58 | 85 | $this->setParameter('paymentCode', $code); |
59 | 86 | } |
60 | 87 |
|
61 | | - /** |
62 | | - * {@inheritdoc} |
63 | | - * @throws \Omnipay\Common\Exception\InvalidRequestException |
64 | | - */ |
65 | | - public function getData(): array |
66 | | - { |
67 | | - $this->validate('paymentCode'); |
68 | | - $this->setParameter('payType', 3); |
69 | | - $parameters = parent::getData(); |
70 | | - unset($parameters['paymentCode']); |
71 | | - |
72 | | - return $parameters; |
73 | | - } |
74 | | - |
75 | | - /** |
76 | | - * {@inheritdoc} |
77 | | - */ |
78 | | - public function sendData($data): PurchaseResponse |
79 | | - { |
80 | | - $response = $this->httpClient->request('POST', $this->getEndpoint().'/pay/pos', [ |
81 | | - 'Content-Type' => 'application/json; charset=utf-8', |
82 | | - ], json_encode($data)); |
83 | | - $responseData = $response->getBody()->getContents(); |
84 | | - |
85 | | - return $this->response = new PurchaseResponse($this, json_decode($responseData, true) ?? []); |
86 | | - } |
87 | | - |
88 | 88 | /** |
89 | 89 | * {@inheritdoc} |
90 | 90 | */ |
|
0 commit comments