22
33namespace Omnipay \Payware \Message ;
44
5- use Omnipay \Common \Exception \InvalidRequestException ;
65use Omnipay \Common \Exception \InvalidResponseException ;
7- use Omnipay \Payware \Support \Helper ;
8- use Omnipay \Payware \Traits \HasAmount ;
9- use Omnipay \Payware \Traits \HasBooking ;
10- use Omnipay \Payware \Traits \HasCreditCard ;
11- use Omnipay \Payware \Traits \HasCVS ;
126use Omnipay \Payware \Traits \HasMerchant ;
137
148class CompletePurchaseRequest extends AbstractRequest
159{
1610 use HasMerchant;
17- use HasBooking;
18- use HasCreditCard;
19- use HasCVS;
20- use HasAmount;
2111
2212 /**
23- * @param int $authAmount
24- * @return CompletePurchaseRequest
25- */
26- public function setAuthAmount ($ authAmount )
27- {
28- return $ this ->setParameter ('AuthAmount ' , $ authAmount );
29- }
30-
31- /**
32- * @return int
33- */
34- public function getAuthAmount ()
35- {
36- return $ this ->getParameter ('AuthAmount ' );
37- }
38-
39- /**
40- * @param string $rtnCode
41- * @return CompletePurchaseRequest
42- */
43- public function setRtnCode ($ rtnCode )
44- {
45- return $ this ->setParameter ('RtnCode ' , $ rtnCode );
46- }
47-
48- /**
49- * @return string
50- */
51- public function getRtnCode ()
52- {
53- return $ this ->getParameter ('RtnCode ' );
54- }
55-
56- /**
57- * @param string $rtnMsg
58- * @return CompletePurchaseRequest
59- */
60- public function setRtnMsg ($ rtnMsg )
61- {
62- return $ this ->setParameter ('RtnMsg ' , $ rtnMsg );
63- }
64-
65- /**
66- * @return string
67- */
68- public function getRtnMsg ()
69- {
70- return $ this ->getParameter ('RtnMsg ' );
71- }
72-
73- /**
74- * @param string $paymentDate
75- * @return CompletePurchaseRequest
76- */
77- public function setPaymentDate ($ paymentDate )
78- {
79- return $ this ->setParameter ('PaymentDate ' , $ paymentDate );
80- }
81-
82- /**
83- * @return string
84- */
85- public function getPaymentDate ()
86- {
87- return $ this ->getParameter ('PaymentDate ' );
88- }
89-
90- /**
91- * @return CompletePurchaseRequest
92- */
93- public function setTransferOutAccount ($ transferOutAccount )
94- {
95- return $ this ->setParameter ('TransferOutAccount ' , $ transferOutAccount );
96- }
97-
98- /**
99- * @return string
100- */
101- public function getTransferOutAccount ()
102- {
103- return $ this ->getParameter ('TransferOutAccount ' );
104- }
105-
106- /**
107- * @param string $checkMacValue
108- * @return CompletePurchaseRequest
109- */
110- public function setCheckMacValue ($ checkMacValue )
111- {
112- return $ this ->setParameter ('CheckMacValue ' , $ checkMacValue );
113- }
114-
115- /**
116- * @return string
117- */
118- public function getCheckMacValue ()
119- {
120- return $ this ->getParameter ('CheckMacValue ' );
121- }
122-
123- /**
124- * @throws InvalidRequestException
12513 * @throws InvalidResponseException
12614 */
12715 public function getData ()
12816 {
129- return $ this ->checkMacValue (Helper::filterEmpty ([
130- 'MerchantId ' => $ this ->getMerchantId (),
131- 'TerminalId ' => $ this ->getTerminalId (),
132- 'PayType ' => $ this ->getPayType (),
133- 'BookingId ' => $ this ->getTransactionReference (),
134- 'CustOrderNo ' => $ this ->getTransactionId (),
135- 'Amount ' => $ this ->getAmount (),
136- 'AuthAmount ' => $ this ->getAuthAmount (),
137- 'RtnCode ' => $ this ->getRtnCode (),
138- 'Card4no ' => $ this ->getCard4No (),
139- 'Payment_no ' => $ this ->getPaymentNo (),
140- 'RtnMsg ' => $ this ->getRtnMsg (),
141- 'PaymentDate ' => Helper::parseDate ($ this ->getPaymentDate ()),
142- 'TransferOutAccount ' => $ this ->getTransferOutAccount (),
143- 'SendType ' => $ this ->getSendType (),
144- 'CheckMacValue ' => $ this ->getCheckMacValue (),
145- ]));
17+ return $ this ->checkMacValue ($ this ->httpRequest ->request ->all ());
14618 }
14719
14820 /**
@@ -161,16 +33,15 @@ public function sendData($data)
16133 */
16234 private function checkMacValue ($ data )
16335 {
164- $ checkMacValue = $ this ->getCheckMacValue ();
165- if (! $ checkMacValue || ! hash_equals ($ checkMacValue , $ this ->makeHash ($ data ))) {
36+ if (! hash_equals ($ this ->httpRequest ->request ->get ('CheckMacValue ' , '' ), $ this ->makeHash ($ data ))) {
16637 throw new InvalidResponseException ();
16738 }
16839
16940 return $ data ;
17041 }
17142
17243 /**
173- * @return false| string
44+ * @return string
17445 */
17546 private function makeHash ($ data )
17647 {
0 commit comments