Passed
Pull Request — master (#122)
by
unknown
07:52
created
src/Drivers/Behpardakht/Behpardakht.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -38,7 +38,7 @@  discard block
 block discarded – undo
38 38
     public function __construct(Invoice $invoice, $settings)
39 39
     {
40 40
         $this->invoice($invoice);
41
-        $this->settings = (object)$settings;
41
+        $this->settings = (object) $settings;
42 42
     }
43 43
 
44 44
     /**
@@ -79,7 +79,7 @@  discard block
 block discarded – undo
79 79
 
80 80
         // purchase was not successful
81 81
         if ($data[0] != "0") {
82
-            throw new PurchaseFailedException($this->translateStatus($data[0]), (int)$data[0]);
82
+            throw new PurchaseFailedException($this->translateStatus($data[0]), (int) $data[0]);
83 83
         }
84 84
 
85 85
         $this->invoice->transactionId($data[1]);
@@ -143,7 +143,7 @@  discard block
 block discarded – undo
143 143
         }
144 144
 
145 145
         // step1: verify request
146
-        $verifyResponse = (int)$soap->bpVerifyRequest($data)->return;
146
+        $verifyResponse = (int) $soap->bpVerifyRequest($data)->return;
147 147
         if ($verifyResponse != 0) {
148 148
             // rollback money and throw exception
149 149
             // avoid rollback if request was already verified
Please login to merge, or discard this patch.
src/Drivers/Asanpardakht/Asanpardakht.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -58,7 +58,7 @@  discard block
 block discarded – undo
58 58
     public function __construct(Invoice $invoice, $settings)
59 59
     {
60 60
         $this->invoice($invoice);
61
-        $this->settings = (object)$settings;
61
+        $this->settings = (object) $settings;
62 62
 
63 63
         //convert to rial
64 64
         $this->invoice->amount($this->invoice->getAmount() * 10);
@@ -199,7 +199,7 @@  discard block
 block discarded – undo
199 199
             'localInvoiceId' => $this->invoice->getUuid(),
200 200
             'amountInRials' => $this->invoice->getAmount(),
201 201
             'localDate' => $this->getTime()['content'],
202
-            'callbackURL' => $this->settings->callbackUrl . "?" . http_build_query(['invoice' => $this->invoice->getUuid()]),
202
+            'callbackURL' => $this->settings->callbackUrl."?".http_build_query(['invoice' => $this->invoice->getUuid()]),
203 203
             'paymentId' => "0",
204 204
             'additionalData' => '',
205 205
         ]);
@@ -213,8 +213,8 @@  discard block
 block discarded – undo
213 213
     public function reverse(): array
214 214
     {
215 215
         return $this->callApi('POST', self::ReverseURL, [
216
-            'merchantConfigurationId' => (int)$this->settings->merchantConfigID,
217
-            'payGateTranId' => (int)$this->invoice->getUuid()
216
+            'merchantConfigurationId' => (int) $this->settings->merchantConfigID,
217
+            'payGateTranId' => (int) $this->invoice->getUuid()
218 218
         ]);
219 219
     }
220 220
 
@@ -226,8 +226,8 @@  discard block
 block discarded – undo
226 226
     public function cancel(): array
227 227
     {
228 228
         return $this->callApi('POST', self::CancelURL, [
229
-            'merchantConfigurationId' => (int)$this->settings->merchantConfigID,
230
-            'payGateTranId' => (int)$this->payGateTransactionId
229
+            'merchantConfigurationId' => (int) $this->settings->merchantConfigID,
230
+            'payGateTranId' => (int) $this->payGateTransactionId
231 231
         ]);
232 232
     }
233 233
 
@@ -239,8 +239,8 @@  discard block
 block discarded – undo
239 239
     public function verifyTransaction(): array
240 240
     {
241 241
         return $this->callApi('POST', self::VerifyURL, [
242
-            'merchantConfigurationId' => (int)$this->settings->merchantConfigID,
243
-            'payGateTranId' => (int)$this->payGateTransactionId
242
+            'merchantConfigurationId' => (int) $this->settings->merchantConfigID,
243
+            'payGateTranId' => (int) $this->payGateTransactionId
244 244
         ]);
245 245
     }
246 246
 
@@ -252,8 +252,8 @@  discard block
 block discarded – undo
252 252
     public function settlement(): array
253 253
     {
254 254
         return $this->callApi('POST', self::SettlementURL, [
255
-            'merchantConfigurationId' => (int)$this->settings->merchantConfigID,
256
-            'payGateTranId' => (int)$this->payGateTransactionId
255
+            'merchantConfigurationId' => (int) $this->settings->merchantConfigID,
256
+            'payGateTranId' => (int) $this->payGateTransactionId
257 257
         ]);
258 258
     }
259 259
 
@@ -264,7 +264,7 @@  discard block
 block discarded – undo
264 264
      */
265 265
     public function cardHash(): array
266 266
     {
267
-        return $this->callApi('GET', self::CardHashURL . '?merchantConfigurationId=' . $this->settings->merchantConfigID . '&localInvoiceId=' . $this->invoice->getTransactionId(), []);
267
+        return $this->callApi('GET', self::CardHashURL.'?merchantConfigurationId='.$this->settings->merchantConfigID.'&localInvoiceId='.$this->invoice->getTransactionId(), []);
268 268
     }
269 269
 
270 270
     /**
@@ -274,7 +274,7 @@  discard block
 block discarded – undo
274 274
      */
275 275
     public function transactionResult(): array
276 276
     {
277
-        return $this->callApi('GET', self::TranResultURL . '?merchantConfigurationId=' . $this->settings->merchantConfigID . '&localInvoiceId=' . $this->invoice->getTransactionId(), []);
277
+        return $this->callApi('GET', self::TranResultURL.'?merchantConfigurationId='.$this->settings->merchantConfigID.'&localInvoiceId='.$this->invoice->getTransactionId(), []);
278 278
     }
279 279
 
280 280
     /**
Please login to merge, or discard this patch.
src/Drivers/Digipay/Digipay.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -52,7 +52,7 @@  discard block
 block discarded – undo
52 52
     public function __construct(Invoice $invoice, $settings)
53 53
     {
54 54
         $this->invoice($invoice);
55
-        $this->settings=$settings;
55
+        $this->settings = $settings;
56 56
         $this->client = new Client();
57 57
         $this->oauthToken = $this->oauth();
58 58
     }
@@ -113,7 +113,7 @@  discard block
 block discarded – undo
113 113
 
114 114
     public function verify(): ReceiptInterface
115 115
     {
116
-        $tracingId=Request::input("trackingCode");
116
+        $tracingId = Request::input("trackingCode");
117 117
 
118 118
         $response = $this->client->request(
119 119
             'POST',
@@ -155,8 +155,8 @@  discard block
 block discarded – undo
155 155
                     "grant_type" => 'password',
156 156
                 ]
157 157
             );
158
-        if ($response->getStatusCode()!=200) {
159
-            if ($response->getStatusCode()==401) {
158
+        if ($response->getStatusCode() != 200) {
159
+            if ($response->getStatusCode() == 401) {
160 160
                 throw new PurchaseFailedException("خطا نام کاربری یا رمز عبور شما اشتباه می باشد.");
161 161
             } else {
162 162
                 throw new PurchaseFailedException("خطا در هنگام احراز هویت.");
Please login to merge, or discard this patch.
src/Drivers/Walleta/Walleta.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -43,7 +43,7 @@  discard block
 block discarded – undo
43 43
     public function __construct(Invoice $invoice, $settings)
44 44
     {
45 45
         $this->invoice($invoice);
46
-        $this->settings = (object)$settings;
46
+        $this->settings = (object) $settings;
47 47
     }
48 48
 
49 49
     /**
@@ -75,7 +75,7 @@  discard block
 block discarded – undo
75 75
      */
76 76
     public function pay(): RedirectionForm
77 77
     {
78
-        return $this->redirectWithForm($this->settings->apiPaymentUrl . $this->invoice->getTransactionId(), [], 'GET');
78
+        return $this->redirectWithForm($this->settings->apiPaymentUrl.$this->invoice->getTransactionId(), [], 'GET');
79 79
     }
80 80
 
81 81
     /**
Please login to merge, or discard this patch.
src/Drivers/Zarinpal/Strategies/Normal.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -120,7 +120,7 @@
 block discarded – undo
120 120
         $transactionId = $this->invoice->getTransactionId();
121 121
         $paymentUrl = $this->getPaymentUrl();
122 122
 
123
-        $payUrl = $paymentUrl . $transactionId;
123
+        $payUrl = $paymentUrl.$transactionId;
124 124
 
125 125
         return $this->redirectWithForm($payUrl, [], 'GET');
126 126
     }
Please login to merge, or discard this patch.
src/Drivers/Etebarino/Etebarino.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -36,7 +36,7 @@
 block discarded – undo
36 36
     public function __construct(Invoice $invoice, $settings)
37 37
     {
38 38
         $this->invoice($invoice);
39
-        $this->settings = (object)$settings;
39
+        $this->settings = (object) $settings;
40 40
     }
41 41
 
42 42
     /**
Please login to merge, or discard this patch.
src/Drivers/Paystar/Paystar.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -81,7 +81,7 @@  discard block
 block discarded – undo
81 81
             'sign' =>
82 82
                 hash_hmac(
83 83
                     'SHA512',
84
-                    $amount . '#' . $order_id . '#' . $callback,
84
+                    $amount.'#'.$order_id.'#'.$callback,
85 85
                     $this->settings->signKey
86 86
                 ),
87 87
         ];
@@ -95,7 +95,7 @@  discard block
 block discarded – undo
95 95
                     'headers' => [
96 96
                         'Content-Type' => 'application/json',
97 97
                         'Accept' => 'application/json',
98
-                        'Authorization' => 'Bearer ' . $this->settings->gatewayId,
98
+                        'Authorization' => 'Bearer '.$this->settings->gatewayId,
99 99
                     ],
100 100
                     'body' => json_encode($data),
101 101
                 ]
@@ -153,7 +153,7 @@  discard block
 block discarded – undo
153 153
             'sign' =>
154 154
                 hash_hmac(
155 155
                     'SHA512',
156
-                    $amount . '#' . $refNum . '#' . $cardNumber . '#' . $trackingCode,
156
+                    $amount.'#'.$refNum.'#'.$cardNumber.'#'.$trackingCode,
157 157
                     $this->settings->signKey
158 158
                 ),
159 159
         ];
@@ -165,7 +165,7 @@  discard block
 block discarded – undo
165 165
                 'headers' => [
166 166
                     'Content-Type' => 'application/json',
167 167
                     'Accept' => 'application/json',
168
-                    'Authorization' => 'Bearer ' . $this->settings->gatewayId,
168
+                    'Authorization' => 'Bearer '.$this->settings->gatewayId,
169 169
                 ],
170 170
                 'body' => json_encode($data),
171 171
             ]
Please login to merge, or discard this patch.
src/Drivers/Sepordeh/Sepordeh.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -45,7 +45,7 @@  discard block
 block discarded – undo
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->client = new Client();
50 50
     }
51 51
 
@@ -86,7 +86,7 @@  discard block
 block discarded – undo
86 86
 
87 87
         $responseBody = mb_strtolower($response->getBody()->getContents());
88 88
         $body = @json_decode($responseBody, true);
89
-        $statusCode = (int)$body['status'];
89
+        $statusCode = (int) $body['status'];
90 90
 
91 91
         if ($statusCode !== 200) {
92 92
             // some error has happened
@@ -142,7 +142,7 @@  discard block
 block discarded – undo
142 142
     {
143 143
         $basePayUrl = $this->settings->mode == 'normal' ? $this->settings->apiPaymentUrl
144 144
             : $this->settings->apiDirectPaymentUrl;
145
-        $payUrl =  $basePayUrl . $this->invoice->getTransactionId();
145
+        $payUrl = $basePayUrl.$this->invoice->getTransactionId();
146 146
 
147 147
         return $this->redirectWithForm($payUrl, [], 'GET');
148 148
     }
@@ -177,7 +177,7 @@  discard block
 block discarded – undo
177 177
 
178 178
         $responseBody = mb_strtolower($response->getBody()->getContents());
179 179
         $body = @json_decode($responseBody, true);
180
-        $statusCode = (int)$body['status'];
180
+        $statusCode = (int) $body['status'];
181 181
 
182 182
         if ($statusCode !== 200) {
183 183
             $message = $body['message'] ?? $this->convertStatusCodeToMessage($statusCode);
Please login to merge, or discard this patch.
src/Drivers/Atipay/Core/fn.atipay.php 1 patch
Spacing   +60 added lines, -60 removed lines patch added patch discarded remove patch
@@ -1,36 +1,36 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-define('ATIPAY_URL','https://mipg.atipay.net/v1/');
4
-define('ATIPAY_TOKEN_URL',ATIPAY_URL . 'get-token');
5
-define('ATIPAY_REDIRECT_TO_PSP_URL',ATIPAY_URL . 'redirect-to-gateway');
6
-define('ATIPAY_VERIFY_URL',ATIPAY_URL . 'verify-payment');
3
+define('ATIPAY_URL', 'https://mipg.atipay.net/v1/');
4
+define('ATIPAY_TOKEN_URL', ATIPAY_URL.'get-token');
5
+define('ATIPAY_REDIRECT_TO_PSP_URL', ATIPAY_URL.'redirect-to-gateway');
6
+define('ATIPAY_VERIFY_URL', ATIPAY_URL.'verify-payment');
7 7
 
8 8
 function fn_atipay_get_token($params)
9 9
 {
10 10
 
11
-    $r = wsRequestPost(ATIPAY_TOKEN_URL,$params);
11
+    $r = wsRequestPost(ATIPAY_TOKEN_URL, $params);
12 12
     $return = array();
13
-    if ($r){
14
-        if (isset($r['status']) && !empty($r['status'])){
13
+    if ($r) {
14
+        if (isset($r['status']) && !empty($r['status'])) {
15 15
             $status = $r['status'];
16
-            if ($status == 1){
17
-                $return['success']=1;
18
-                $return['token']=$r['token'];
19
-            }else{
20
-                $return['success']=0;
21
-                $return['']=$r['errorDescription'];
16
+            if ($status == 1) {
17
+                $return['success'] = 1;
18
+                $return['token'] = $r['token'];
19
+            } else {
20
+                $return['success'] = 0;
21
+                $return[''] = $r['errorDescription'];
22 22
             }
23
-        }else{
24
-            $return['success']=0;
25
-            if (isset($r['faMessage']) && !empty($r['faMessage'])){
23
+        } else {
24
+            $return['success'] = 0;
25
+            if (isset($r['faMessage']) && !empty($r['faMessage'])) {
26 26
                 $return['errorMessage'] = $r['faMessage'];
27
-            }else{
27
+            } else {
28 28
                 $return['errorMessage'] = "خطا در دریافت توکن پرداخت";
29 29
             }
30 30
         }
31 31
 
32
-    }else{
33
-        $return['success']=0;
32
+    } else {
33
+        $return['success'] = 0;
34 34
         $return['errorMessage'] = "خطا در دریافت اطلاعات توکن پرداخت";
35 35
     }
36 36
 
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
     return $form;
56 56
 }
57 57
 
58
-function fn_atipay_get_token_form($params, $submit_text,$action)
58
+function fn_atipay_get_token_form($params, $submit_text, $action)
59 59
 {
60 60
     $form = _fn_generate_get_token_form($params, $submit_text, $action);
61 61
     return $form;
@@ -64,8 +64,8 @@  discard block
 block discarded – undo
64 64
 function _fn_generate_get_token_form($params, $submit_text, $action)
65 65
 {
66 66
 
67
-    $form ="<form action='$action' method='POST' align='center' name='atipay_payment_form_token' id='atipay_payment_form_token' >";
68
-    foreach ($params as $k=>$v){
67
+    $form = "<form action='$action' method='POST' align='center' name='atipay_payment_form_token' id='atipay_payment_form_token' >";
68
+    foreach ($params as $k=>$v) {
69 69
         $form .= "<input type='hidden' value='$v' name='$k' >";
70 70
     }
71 71
 
@@ -78,43 +78,43 @@  discard block
 block discarded – undo
78 78
 function fn_check_callback_data($params)
79 79
 {
80 80
     $result = array();
81
-    if (isset($params['state']) && !empty($params['state'])){
81
+    if (isset($params['state']) && !empty($params['state'])) {
82 82
         $state = $params['state'];
83
-        if ($state == 'OK'){
84
-            $result['success']=1;
85
-            $result['error']="";
86
-        }else{
87
-            $result['success']=0;
88
-            $result['error']= _fn_return_state_text($state);
83
+        if ($state == 'OK') {
84
+            $result['success'] = 1;
85
+            $result['error'] = "";
86
+        } else {
87
+            $result['success'] = 0;
88
+            $result['error'] = _fn_return_state_text($state);
89 89
         }
90
-    }else{
91
-        $result['success']=0;
92
-        $result['error']="خطای نامشخص در پرداخت. در صورتیکه مبلغی از شما کسر شده باشد، برگشت داده می شود.";
90
+    } else {
91
+        $result['success'] = 0;
92
+        $result['error'] = "خطای نامشخص در پرداخت. در صورتیکه مبلغی از شما کسر شده باشد، برگشت داده می شود.";
93 93
     }
94 94
 
95 95
     return $result;
96 96
 }
97 97
 
98
-function fn_atipay_verify_payment($params,$amount)
98
+function fn_atipay_verify_payment($params, $amount)
99 99
 {
100
-    $r = wsRequestPost(ATIPAY_VERIFY_URL,$params);
100
+    $r = wsRequestPost(ATIPAY_VERIFY_URL, $params);
101 101
     $return = array();
102
-    if ($r){
103
-
104
-        if (isset($r['amount']) && !empty($r['amount'])){
105
-            if ($r['amount'] == $amount){
106
-                $return['success']=1;
107
-                $return['errorMessage']="";
108
-            }else{
109
-                $return['success']=0;
110
-                $return['errorMessage']="خطا در تایید مبلغ پرداخت.در صورتیکه مبلغی از شما کسر شده باشد، برگشت داده می شود.";
102
+    if ($r) {
103
+
104
+        if (isset($r['amount']) && !empty($r['amount'])) {
105
+            if ($r['amount'] == $amount) {
106
+                $return['success'] = 1;
107
+                $return['errorMessage'] = "";
108
+            } else {
109
+                $return['success'] = 0;
110
+                $return['errorMessage'] = "خطا در تایید مبلغ پرداخت.در صورتیکه مبلغی از شما کسر شده باشد، برگشت داده می شود.";
111 111
             }
112
-        }else{
113
-            $return['success']=0;
114
-            $return['errorMessage']="خطا در تایید اطلاعات پرداخت. در صورتیکه مبلغی از شما کسر شده باشد، برگشت داده می شود.";
112
+        } else {
113
+            $return['success'] = 0;
114
+            $return['errorMessage'] = "خطا در تایید اطلاعات پرداخت. در صورتیکه مبلغی از شما کسر شده باشد، برگشت داده می شود.";
115 115
         }
116
-    }else{
117
-        $return['success']=0;
116
+    } else {
117
+        $return['success'] = 0;
118 118
         $return['errorMessage'] = "خطا در تایید نهایی پرداخت. در صورتیکه مبلغی از شما کسر شده باشد، برگشت داده می شود.";
119 119
     }
120 120
 
@@ -123,7 +123,7 @@  discard block
 block discarded – undo
123 123
 
124 124
 function _fn_return_state_text($state)
125 125
 {
126
-    switch ($state){
126
+    switch ($state) {
127 127
         case "CanceledByUser":
128 128
             return "پرداخت توسط شما لغو شده است.";
129 129
             break;
@@ -162,9 +162,9 @@  discard block
 block discarded – undo
162 162
         !isset($params['reservationNumber']) ||
163 163
         !isset($params['referenceNumber']) ||
164 164
         !isset($params['terminalId']) ||
165
-        !isset($params['traceNumber'])){
165
+        !isset($params['traceNumber'])) {
166 166
         return false;
167
-    }else{
167
+    } else {
168 168
         return true;
169 169
     }
170 170
 }
@@ -185,16 +185,16 @@  discard block
 block discarded – undo
185 185
     $httpcode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
186 186
     curl_close($ch);
187 187
 
188
-    if ($httpcode == "200"){
188
+    if ($httpcode == "200") {
189 189
         //nothing YET
190
-    }else{
191
-        $json= json_encode(array('error'=>'Y'));
190
+    } else {
191
+        $json = json_encode(array('error'=>'Y'));
192 192
     }
193 193
 
194 194
     return $json;
195 195
 }
196 196
 
197
-function wsRequestPost($url,$params)
197
+function wsRequestPost($url, $params)
198 198
 {
199 199
     set_time_limit(30);
200 200
     $ch = curl_init($url);
@@ -204,15 +204,15 @@  discard block
 block discarded – undo
204 204
     curl_setopt($ch, CURLOPT_TIMEOUT, 30); //timeout in seconds
205 205
     curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type: application/json;"));
206 206
     curl_setopt($ch, CURLOPT_POST, 1);
207
-    curl_setopt($ch, CURLOPT_POSTFIELDS,$postFields);
207
+    curl_setopt($ch, CURLOPT_POSTFIELDS, $postFields);
208 208
     $json = curl_exec($ch);
209 209
     $httpcode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
210 210
     curl_close($ch);
211 211
 
212
-    if ($httpcode == "200"){
213
-        return json_decode($json,true);
214
-    }else{
215
-        $json = array('error'=>'Y','jsonError'=>$httpcode,'message'=>$httpcode);
212
+    if ($httpcode == "200") {
213
+        return json_decode($json, true);
214
+    } else {
215
+        $json = array('error'=>'Y', 'jsonError'=>$httpcode, 'message'=>$httpcode);
216 216
     }
217 217
 
218 218
     return $json;
Please login to merge, or discard this patch.