@@ -132,15 +132,15 @@ discard block |
||
| 132 | 132 | { |
| 133 | 133 | $receipt = new Receipt('fanavacard', $referenceId); |
| 134 | 134 | $receipt->detail([ |
| 135 | - 'ResNum'=>Request::input('ResNum'), |
|
| 136 | - 'RefNum'=>Request::input('RefNum'), |
|
| 137 | - 'token'=>Request::input('token'), |
|
| 138 | - 'CustomerRefNum'=>Request::input('CustomerRefNum'), |
|
| 139 | - 'CardMaskPan'=>Request::input('CardMaskPan'), |
|
| 140 | - 'transactionAmount'=>Request::input('transactionAmount'), |
|
| 141 | - 'emailAddress'=>Request::input('emailAddress'), |
|
| 142 | - 'mobileNo'=>Request::input('mobileNo'), |
|
| 143 | - ]); |
|
| 135 | + 'ResNum'=>Request::input('ResNum'), |
|
| 136 | + 'RefNum'=>Request::input('RefNum'), |
|
| 137 | + 'token'=>Request::input('token'), |
|
| 138 | + 'CustomerRefNum'=>Request::input('CustomerRefNum'), |
|
| 139 | + 'CardMaskPan'=>Request::input('CardMaskPan'), |
|
| 140 | + 'transactionAmount'=>Request::input('transactionAmount'), |
|
| 141 | + 'emailAddress'=>Request::input('emailAddress'), |
|
| 142 | + 'mobileNo'=>Request::input('mobileNo'), |
|
| 143 | + ]); |
|
| 144 | 144 | return $receipt; |
| 145 | 145 | } |
| 146 | 146 | |
@@ -173,11 +173,11 @@ discard block |
||
| 173 | 173 | |
| 174 | 174 | private function httpClientInit(): void { |
| 175 | 175 | $this->client = new Client([ |
| 176 | - 'curl'=>[\CURLOPT_SSL_CIPHER_LIST=>'DEFAULT@SECLEVEL=1',], |
|
| 177 | - 'verify' => false, |
|
| 178 | - 'base_uri' => $this->settings->baseUri, |
|
| 179 | - 'headers' => ['Content-Type' => 'application/json',], |
|
| 180 | - ]); |
|
| 176 | + 'curl'=>[\CURLOPT_SSL_CIPHER_LIST=>'DEFAULT@SECLEVEL=1',], |
|
| 177 | + 'verify' => false, |
|
| 178 | + 'base_uri' => $this->settings->baseUri, |
|
| 179 | + 'headers' => ['Content-Type' => 'application/json',], |
|
| 180 | + ]); |
|
| 181 | 181 | } |
| 182 | 182 | |
| 183 | 183 | 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 | |
@@ -56,9 +56,9 @@ discard block |
||
| 56 | 56 | * |
| 57 | 57 | * @throws PurchaseFailedException |
| 58 | 58 | */ |
| 59 | - public function purchase(){ |
|
| 59 | + public function purchase() { |
|
| 60 | 60 | $this->invoice->uuid(crc32($this->invoice->getUuid())); |
| 61 | - $token = $this->getToken(); |
|
| 61 | + $token = $this->getToken(); |
|
| 62 | 62 | $this->invoice->transactionId($token['Token']); |
| 63 | 63 | |
| 64 | 64 | return $this->invoice->getTransactionId(); |
@@ -71,7 +71,7 @@ discard block |
||
| 71 | 71 | */ |
| 72 | 72 | public function pay(): RedirectionForm |
| 73 | 73 | { |
| 74 | - $url = rtrim($this->settings->baseUri,'/')."/{$this->settings->apiPaymentUrl}"; |
|
| 74 | + $url = rtrim($this->settings->baseUri, '/')."/{$this->settings->apiPaymentUrl}"; |
|
| 75 | 75 | return $this->redirectWithForm($url, [ |
| 76 | 76 | 'token' => $this->invoice->getTransactionId(), |
| 77 | 77 | 'language' => 'fa' |
@@ -90,19 +90,19 @@ discard block |
||
| 90 | 90 | { |
| 91 | 91 | $transaction_amount = Request::input('transactionAmount'); |
| 92 | 92 | |
| 93 | - if($this->invoice->getAmount()*10 == $transaction_amount){ |
|
| 93 | + if ($this->invoice->getAmount() * 10 == $transaction_amount) { |
|
| 94 | 94 | |
| 95 | 95 | $param = ['Token'=>Request::input('token'), 'RefNum'=>Request::input('RefNum')]; |
| 96 | - $response = $this->client->post($this->settings->apiVerificationUrl,[ |
|
| 96 | + $response = $this->client->post($this->settings->apiVerificationUrl, [ |
|
| 97 | 97 | 'json'=> array_merge( |
| 98 | 98 | ['WSContext'=> $this->getWsContext()], |
| 99 | 99 | $param |
| 100 | 100 | )]); |
| 101 | 101 | |
| 102 | 102 | $response_data = json_decode($response->getBody()->getContents()); |
| 103 | - if($response_data->Result != 'erSucceed'){ |
|
| 103 | + if ($response_data->Result != 'erSucceed') { |
|
| 104 | 104 | return throw new InvalidPaymentException($response_data->Result); |
| 105 | - }elseif($this->invoice->getAmount()*10 != $response_data->Amount){ |
|
| 105 | + }elseif ($this->invoice->getAmount() * 10 != $response_data->Amount) { |
|
| 106 | 106 | $response = $this->client->post($this->settings->apiReverseAmountUrl, |
| 107 | 107 | [ |
| 108 | 108 | 'json'=> [ |
@@ -152,7 +152,7 @@ discard block |
||
| 152 | 152 | public function getToken(): array |
| 153 | 153 | { |
| 154 | 154 | |
| 155 | - $response = $this->client->request('POST',$this->settings->apiPurchaseUrl, [ |
|
| 155 | + $response = $this->client->request('POST', $this->settings->apiPurchaseUrl, [ |
|
| 156 | 156 | 'json'=>[ |
| 157 | 157 | 'WSContext'=> $this->getWsContext(), |
| 158 | 158 | 'TransType'=>'EN_GOODS', |
@@ -161,11 +161,11 @@ discard block |
||
| 161 | 161 | 'RedirectUrl'=>$this->settings->callbackUrl, |
| 162 | 162 | ]]); |
| 163 | 163 | |
| 164 | - if($response->getStatusCode() != 200) |
|
| 164 | + if ($response->getStatusCode() != 200) |
|
| 165 | 165 | return throw new PurchaseFailedException("cant get token | $response->getBody()->getContents()", $response->getStatusCode()); |
| 166 | 166 | |
| 167 | 167 | $response_data = json_decode($response->getBody()->getContents()); |
| 168 | - if($response_data->Result != 'erSucceed') |
|
| 168 | + if ($response_data->Result != 'erSucceed') |
|
| 169 | 169 | return throw new PurchaseFailedException("cant get token | $response->getBody()->getContents()", $response->getStatusCode()); |
| 170 | 170 | |
| 171 | 171 | return (array) $response_data; |
@@ -173,10 +173,10 @@ discard block |
||
| 173 | 173 | |
| 174 | 174 | private function httpClientInit(): void { |
| 175 | 175 | $this->client = new Client([ |
| 176 | - 'curl'=>[\CURLOPT_SSL_CIPHER_LIST=>'DEFAULT@SECLEVEL=1',], |
|
| 176 | + 'curl'=>[\CURLOPT_SSL_CIPHER_LIST=>'DEFAULT@SECLEVEL=1', ], |
|
| 177 | 177 | 'verify' => false, |
| 178 | 178 | 'base_uri' => $this->settings->baseUri, |
| 179 | - 'headers' => ['Content-Type' => 'application/json',], |
|
| 179 | + 'headers' => ['Content-Type' => 'application/json', ], |
|
| 180 | 180 | ]); |
| 181 | 181 | } |
| 182 | 182 | |
@@ -102,7 +102,7 @@ discard block |
||
| 102 | 102 | $response_data = json_decode($response->getBody()->getContents()); |
| 103 | 103 | if($response_data->Result != 'erSucceed'){ |
| 104 | 104 | return throw new InvalidPaymentException($response_data->Result); |
| 105 | - }elseif($this->invoice->getAmount()*10 != $response_data->Amount){ |
|
| 105 | + } elseif($this->invoice->getAmount()*10 != $response_data->Amount){ |
|
| 106 | 106 | $response = $this->client->post($this->settings->apiReverseAmountUrl, |
| 107 | 107 | [ |
| 108 | 108 | 'json'=> [ |
@@ -161,12 +161,14 @@ discard block |
||
| 161 | 161 | 'RedirectUrl'=>$this->settings->callbackUrl, |
| 162 | 162 | ]]); |
| 163 | 163 | |
| 164 | - if($response->getStatusCode() != 200) |
|
| 165 | - return throw new PurchaseFailedException("cant get token | $response->getBody()->getContents()", $response->getStatusCode()); |
|
| 164 | + if($response->getStatusCode() != 200) { |
|
| 165 | + return throw new PurchaseFailedException("cant get token | $response->getBody()->getContents()", $response->getStatusCode()); |
|
| 166 | + } |
|
| 166 | 167 | |
| 167 | 168 | $response_data = json_decode($response->getBody()->getContents()); |
| 168 | - if($response_data->Result != 'erSucceed') |
|
| 169 | - return throw new PurchaseFailedException("cant get token | $response->getBody()->getContents()", $response->getStatusCode()); |
|
| 169 | + if($response_data->Result != 'erSucceed') { |
|
| 170 | + return throw new PurchaseFailedException("cant get token | $response->getBody()->getContents()", $response->getStatusCode()); |
|
| 171 | + } |
|
| 170 | 172 | |
| 171 | 173 | return (array) $response_data; |
| 172 | 174 | } |