@@ -135,15 +135,15 @@ discard block |
||
135 | 135 | { |
136 | 136 | $receipt = new Receipt('fanavacard', $referenceId); |
137 | 137 | $receipt->detail([ |
138 | - 'ResNum'=>Request::input('ResNum'), |
|
139 | - 'RefNum'=>Request::input('RefNum'), |
|
140 | - 'token'=>Request::input('token'), |
|
141 | - 'CustomerRefNum'=>Request::input('CustomerRefNum'), |
|
142 | - 'CardMaskPan'=>Request::input('CardMaskPan'), |
|
143 | - 'transactionAmount'=>Request::input('transactionAmount'), |
|
144 | - 'emailAddress'=>Request::input('emailAddress'), |
|
145 | - 'mobileNo'=>Request::input('mobileNo'), |
|
146 | - ]); |
|
138 | + 'ResNum'=>Request::input('ResNum'), |
|
139 | + 'RefNum'=>Request::input('RefNum'), |
|
140 | + 'token'=>Request::input('token'), |
|
141 | + 'CustomerRefNum'=>Request::input('CustomerRefNum'), |
|
142 | + 'CardMaskPan'=>Request::input('CardMaskPan'), |
|
143 | + 'transactionAmount'=>Request::input('transactionAmount'), |
|
144 | + 'emailAddress'=>Request::input('emailAddress'), |
|
145 | + 'mobileNo'=>Request::input('mobileNo'), |
|
146 | + ]); |
|
147 | 147 | return $receipt; |
148 | 148 | } |
149 | 149 | |
@@ -185,11 +185,11 @@ discard block |
||
185 | 185 | private function httpClientInit(): void |
186 | 186 | { |
187 | 187 | $this->client = new Client([ |
188 | - 'curl'=>[\CURLOPT_SSL_CIPHER_LIST=>'DEFAULT@SECLEVEL=1',], |
|
189 | - 'verify' => false, |
|
190 | - 'base_uri' => $this->settings->baseUri, |
|
191 | - 'headers' => ['Content-Type' => 'application/json',], |
|
192 | - ]); |
|
188 | + 'curl'=>[\CURLOPT_SSL_CIPHER_LIST=>'DEFAULT@SECLEVEL=1',], |
|
189 | + 'verify' => false, |
|
190 | + 'base_uri' => $this->settings->baseUri, |
|
191 | + 'headers' => ['Content-Type' => 'application/json',], |
|
192 | + ]); |
|
193 | 193 | } |
194 | 194 | |
195 | 195 | private function getWsContext(): array |
@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | public function __construct(Invoice $invoice, $settings) |
46 | 46 | { |
47 | 47 | $this->invoice($invoice); |
48 | - $this->settings = (object)$settings; |
|
48 | + $this->settings = (object) $settings; |
|
49 | 49 | $this->httpClientInit(); |
50 | 50 | } |
51 | 51 | |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | public function purchase() |
60 | 60 | { |
61 | 61 | $this->invoice->uuid(crc32($this->invoice->getUuid())); |
62 | - $token = $this->getToken(); |
|
62 | + $token = $this->getToken(); |
|
63 | 63 | $this->invoice->transactionId($token['Token']); |
64 | 64 | |
65 | 65 | return $this->invoice->getTransactionId(); |
@@ -92,7 +92,7 @@ discard block |
||
92 | 92 | { |
93 | 93 | $transaction_amount = Request::input('transactionAmount'); |
94 | 94 | |
95 | - if ($this->invoice->getAmount()*10 == $transaction_amount) { |
|
95 | + if ($this->invoice->getAmount() * 10 == $transaction_amount) { |
|
96 | 96 | $param = ['Token'=>Request::input('token'), 'RefNum'=>Request::input('RefNum')]; |
97 | 97 | $response = $this->client->post($this->settings->apiVerificationUrl, [ |
98 | 98 | 'json'=> array_merge( |
@@ -103,7 +103,7 @@ discard block |
||
103 | 103 | $response_data = json_decode($response->getBody()->getContents()); |
104 | 104 | if ($response_data->Result != 'erSucceed') { |
105 | 105 | throw new InvalidPaymentException($response_data->Result); |
106 | - } elseif ($this->invoice->getAmount()*10 != $response_data->Amount) { |
|
106 | + } elseif ($this->invoice->getAmount() * 10 != $response_data->Amount) { |
|
107 | 107 | $this->client->post( |
108 | 108 | $this->settings->apiReverseAmountUrl, |
109 | 109 | [ |
@@ -182,10 +182,10 @@ discard block |
||
182 | 182 | private function httpClientInit(): void |
183 | 183 | { |
184 | 184 | $this->client = new Client([ |
185 | - 'curl'=>[\CURLOPT_SSL_CIPHER_LIST=>'DEFAULT@SECLEVEL=1',], |
|
185 | + 'curl'=>[\CURLOPT_SSL_CIPHER_LIST=>'DEFAULT@SECLEVEL=1', ], |
|
186 | 186 | 'verify' => false, |
187 | 187 | 'base_uri' => $this->settings->baseUri, |
188 | - 'headers' => ['Content-Type' => 'application/json',], |
|
188 | + 'headers' => ['Content-Type' => 'application/json', ], |
|
189 | 189 | ]); |
190 | 190 | } |
191 | 191 |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | public function __construct(Invoice $invoice, $settings) |
50 | 50 | { |
51 | 51 | $this->invoice($invoice); |
52 | - $this->settings = (object)$settings; |
|
52 | + $this->settings = (object) $settings; |
|
53 | 53 | $this->client = new Client( |
54 | 54 | [ |
55 | 55 | 'base_uri' => $this->settings->apiPurchaseUrl, |
@@ -112,7 +112,7 @@ discard block |
||
112 | 112 | $referenceId = hexdec(uniqid()); |
113 | 113 | $amount = $this->invoice->getAmount(); |
114 | 114 | |
115 | - $callback = $this->settings->callbackUrl . "?referenceId=" . $referenceId . "&price=" . $amount . "&mobile=" . $mobile; |
|
115 | + $callback = $this->settings->callbackUrl."?referenceId=".$referenceId."&price=".$amount."&mobile=".$mobile; |
|
116 | 116 | |
117 | 117 | $data = [ |
118 | 118 | 'referenceId' => $referenceId, |
@@ -168,7 +168,7 @@ discard block |
||
168 | 168 | public function verify(): ReceiptInterface |
169 | 169 | { |
170 | 170 | $data = [ |
171 | - 'referenceId' => (int)$this->getInvoice()->getTransactionId(), |
|
171 | + 'referenceId' => (int) $this->getInvoice()->getTransactionId(), |
|
172 | 172 | 'header' => '', |
173 | 173 | 'content' => http_build_query($_POST), |
174 | 174 | ]; |
@@ -306,7 +306,7 @@ discard block |
||
306 | 306 | { |
307 | 307 | $header[] = 'Content-Type: application/json'; |
308 | 308 | if ($forAuth) { |
309 | - $header[] = 'Authorization: Bearer ' . $this->auth(); |
|
309 | + $header[] = 'Authorization: Bearer '.$this->auth(); |
|
310 | 310 | } |
311 | 311 | $ch = curl_init($url); |
312 | 312 | curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST'); |
@@ -195,7 +195,7 @@ |
||
195 | 195 | $terminalCode = $this->settings->terminalCode; |
196 | 196 | $amount = $this->invoice->getAmount(); //rial |
197 | 197 | $redirectAddress = $this->settings->callbackUrl; |
198 | - $invoiceNumber = crc32($this->invoice->getUuid()) . rand(0, time()); |
|
198 | + $invoiceNumber = crc32($this->invoice->getUuid()).rand(0, time()); |
|
199 | 199 | |
200 | 200 | $iranTime = new DateTime('now', new DateTimeZone('Asia/Tehran')); |
201 | 201 | $timeStamp = $iranTime->format("Y/m/d H:i:s"); |
@@ -77,7 +77,7 @@ discard block |
||
77 | 77 | ))->GetToken2Result; |
78 | 78 | $result = json_decode($response); |
79 | 79 | |
80 | - if (! isset($result->ResCod) || ! in_array($result->ResCod, ['0', '00'])) { |
|
80 | + if (!isset($result->ResCod) || !in_array($result->ResCod, ['0', '00'])) { |
|
81 | 81 | // error has happened |
82 | 82 | $message = $result->Message ?? 'خطای ناشناخته رخ داده'; |
83 | 83 | throw new PurchaseFailedException($message); |
@@ -121,7 +121,7 @@ discard block |
||
121 | 121 | public function verify() : ReceiptInterface |
122 | 122 | { |
123 | 123 | $resCode = Request::input('ResCod'); |
124 | - if (! in_array($resCode, array('0', '00'))) { |
|
124 | + if (!in_array($resCode, array('0', '00'))) { |
|
125 | 125 | $message = 'پرداخت توسط کاربر لغو شد'; |
126 | 126 | throw new InvalidPaymentException($message); |
127 | 127 | } |
@@ -139,7 +139,7 @@ discard block |
||
139 | 139 | $response = $client->Confirm2($data)->Confirm2Result; |
140 | 140 | $result = json_decode($response); |
141 | 141 | |
142 | - if (! isset($result->ResCod) || ! in_array($result->ResCod, array('0', '00'))) { |
|
142 | + if (!isset($result->ResCod) || !in_array($result->ResCod, array('0', '00'))) { |
|
143 | 143 | $message = $result->Message ?? 'خطا در انجام عملیات رخ داده است'; |
144 | 144 | throw new InvalidPaymentException($message); |
145 | 145 | } |