File tree Expand file tree Collapse file tree 10 files changed +62
-40
lines changed Expand file tree Collapse file tree 10 files changed +62
-40
lines changed Original file line number Diff line number Diff line change @@ -20,6 +20,19 @@ class PurchaseRequest extends AbstractSignatureRequest
2020 */
2121 protected $ responseClass = PurchaseResponse::class;
2222
23+ /**
24+ * {@inheritdoc}
25+ */
26+ public function initialize (array $ parameters = []): self
27+ {
28+ parent ::initialize ($ parameters );
29+ $ this ->setOrderInfo ($ this ->getParameter ('orderInfo ' ) ?? '' );
30+ $ this ->setExtraData ($ this ->getParameter ('extraData ' ) ?? '' );
31+ $ this ->setParameter ('requestType ' , 'captureMoMoWallet ' );
32+
33+ return $ this ;
34+ }
35+
2336 /**
2437 * Trả về extra data gửi đến MoMo.
2538 *
@@ -62,19 +75,6 @@ public function setOrderInfo(string $info): self
6275 return $ this ->setParameter ('orderInfo ' , $ info );
6376 }
6477
65- /**
66- * {@inheritdoc}
67- * @throws \Omnipay\Common\Exception\InvalidRequestException
68- */
69- public function getData (): array
70- {
71- $ this ->setOrderInfo ($ this ->getParameter ('orderInfo ' ) ?? '' );
72- $ this ->setExtraData ($ this ->getParameter ('extraData ' ) ?? '' );
73- $ this ->setParameter ('requestType ' , 'captureMoMoWallet ' );
74-
75- return parent ::getData ();
76- }
77-
7878 /**
7979 * {@inheritdoc}
8080 */
Original file line number Diff line number Diff line change @@ -22,13 +22,13 @@ class QueryRefundRequest extends AbstractSignatureRequest
2222
2323 /**
2424 * {@inheritdoc}
25- * @throws \Omnipay\Common\Exception\InvalidRequestException
2625 */
27- public function getData ( ): array
26+ public function initialize ( array $ parameters = [] ): self
2827 {
28+ parent ::initialize ($ parameters );
2929 $ this ->setParameter ('requestType ' , 'refundStatus ' );
3030
31- return parent :: getData () ;
31+ return $ this ;
3232 }
3333
3434 /**
Original file line number Diff line number Diff line change @@ -23,11 +23,12 @@ class QueryTransactionRequest extends AbstractSignatureRequest
2323 /**
2424 * {@inheritdoc}
2525 */
26- public function getData ( ): array
26+ public function initialize ( array $ parameters = [] ): self
2727 {
28+ parent ::initialize ($ parameters );
2829 $ this ->setParameter ('requestType ' , 'transactionStatus ' );
2930
30- return parent :: getData () ;
31+ return $ this ;
3132 }
3233
3334 /**
Original file line number Diff line number Diff line change @@ -20,6 +20,17 @@ class RefundRequest extends AbstractSignatureRequest
2020 */
2121 protected $ responseClass = RefundResponse::class;
2222
23+ /**
24+ * {@inheritdoc}
25+ */
26+ public function initialize (array $ parameters = []): self
27+ {
28+ parent ::initialize ($ parameters );
29+ $ this ->setParameter ('requestType ' , 'refundMoMoWallet ' );
30+
31+ return $ this ;
32+ }
33+
2334 /**
2435 * {@inheritdoc}
2536 */
@@ -57,17 +68,6 @@ public function setTransId(string $id): self
5768 return $ this ->setParameter ('transId ' , $ id );
5869 }
5970
60- /**
61- * {@inheritdoc}
62- * @throws \Omnipay\Common\Exception\InvalidRequestException
63- */
64- public function getData (): array
65- {
66- $ this ->setParameter ('requestType ' , 'refundMoMoWallet ' );
67-
68- return parent ::getData ();
69- }
70-
7171 /**
7272 * {@inheritdoc}
7373 */
Original file line number Diff line number Diff line change @@ -18,12 +18,22 @@ class PurchaseRequest extends AbstractHashRequest
1818 /**
1919 * {@inheritdoc}
2020 */
21- public function getData ( ): array
21+ public function initialize ( array $ parameters = [] ): self
2222 {
23- $ this -> validate ( ' appData ' , ' customerNumber ' );
23+ parent :: initialize ( $ parameters );
2424 $ this ->setParameter ('payType ' , 3 );
2525 $ this ->setParameter ('version ' , 2 );
2626
27+ return $ this ;
28+ }
29+
30+ /**
31+ * {@inheritdoc}
32+ */
33+ public function getData (): array
34+ {
35+ $ this ->validate ('appData ' , 'customerNumber ' );
36+
2737 return parent ::getData ();
2838 }
2939
Original file line number Diff line number Diff line change 1515 */
1616class PurchaseRequest extends AbstractHashRequest
1717{
18+ /**
19+ * {@inheritdoc}
20+ */
21+ public function initialize (array $ parameters = []): self
22+ {
23+ parent ::initialize ($ parameters );
24+ $ this ->setParameter ('payType ' , 3 );
25+ $ this ->setParameter ('version ' , 2 );
26+
27+ return $ this ;
28+ }
29+
1830 /**
1931 * {@inheritdoc}
2032 * @throws \Omnipay\Common\Exception\InvalidRequestException
2133 */
2234 public function getData (): array
2335 {
2436 $ this ->validate ('paymentCode ' );
25- $ this ->setParameter ('payType ' , 3 );
26- $ this ->setParameter ('version ' , 2 );
2737 $ parameters = parent ::getData ();
2838 unset($ parameters ['paymentCode ' ]);
2939
Original file line number Diff line number Diff line change @@ -15,13 +15,13 @@ class PayQueryStatusRequest extends AbstractHashRequest
1515{
1616 /**
1717 * {@inheritdoc}
18- * @throws \Omnipay\Common\Exception\InvalidRequestException
1918 */
20- public function getData ( ): array
19+ public function initialize ( array $ parameters = [] ): self
2120 {
21+ parent ::initialize ($ parameters );
2222 $ this ->setParameter ('version ' , 2 );
2323
24- return parent :: getData () ;
24+ return $ this ;
2525 }
2626
2727 /**
Original file line number Diff line number Diff line change @@ -32,7 +32,7 @@ public function getTransactionId(): ?string
3232 /**
3333 * {@inheritdoc}
3434 */
35- public function getTransactionReference ()
35+ public function getTransactionReference (): ? string
3636 {
3737 return $ this ->data ['data ' ]['transid ' ] ?? null ;
3838 }
Original file line number Diff line number Diff line change @@ -16,11 +16,12 @@ class PayRefundRequest extends AbstractHashRequest
1616 /**
1717 * {@inheritdoc}
1818 */
19- public function getData ( ): array
19+ public function initialize ( array $ parameters = [] ): self
2020 {
21+ parent ::initialize ($ parameters );
2122 $ this ->setParameter ('version ' , 2 );
2223
23- return parent :: getData () ;
24+ return $ this ;
2425 }
2526
2627 /**
Original file line number Diff line number Diff line change @@ -32,7 +32,7 @@ public function getTransactionId(): ?string
3232 /**
3333 * {@inheritdoc}
3434 */
35- public function getTransactionReference ()
35+ public function getTransactionReference (): ? string
3636 {
3737 return $ this ->data ['transid ' ] ?? null ;
3838 }
You can’t perform that action at this time.
0 commit comments