@@ -16,7 +16,7 @@  | 
                                                    ||
| 16 | 16 | $this->driver = $driver;  | 
                                                        
| 17 | 17 | }  | 
                                                        
| 18 | 18 | |
| 19 | - abstract public function init($amount, $orderId, $callbackUrl, $detail = []);  | 
                                                        |
| 19 | + abstract public function init($amount, $orderId, $callbackUrl, $detail = []);  | 
                                                        |
| 20 | 20 | |
| 21 | 21 | abstract public function verify($request);  | 
                                                        
| 22 | 22 | |
@@ -28,7 +28,7 @@  | 
                                                    ||
| 28 | 28 | $this->loadMigrationsFrom(__DIR__ . '/database/migrations');  | 
                                                        
| 29 | 29 | |
| 30 | 30 | $this->publishes([  | 
                                                        
| 31 | -            __DIR__.'/config/gateway.php' =>config_path('gateway.php') | 
                                                        |
| 31 | +            __DIR__ . '/config/gateway.php' =>config_path('gateway.php') | 
                                                        |
| 32 | 32 | ], 'gateway');  | 
                                                        
| 33 | 33 | }  | 
                                                        
| 34 | 34 | }  | 
                                                        
@@ -10,11 +10,11 @@  | 
                                                    ||
| 10 | 10 | use HasFactory;  | 
                                                        
| 11 | 11 | |
| 12 | 12 | protected $fillable = ['order_id', 'status', 'amount', 'driver', 'ref_no', 'token', 'description'];  | 
                                                        
| 13 | - protected $appends = ['gateway','toman','status_label','status_badge'];  | 
                                                        |
| 13 | + protected $appends = ['gateway', 'toman', 'status_label', 'status_badge'];  | 
                                                        |
| 14 | 14 | |
| 15 | 15 | public function parent()  | 
                                                        
| 16 | 16 |      { | 
                                                        
| 17 | -        return $this->belongsTo( config('gateway.model'), 'order_id' ); | 
                                                        |
| 17 | +        return $this->belongsTo(config('gateway.model'), 'order_id'); | 
                                                        |
| 18 | 18 | }  | 
                                                        
| 19 | 19 | |
| 20 | 20 | public function getGatewayAttribute()  | 
                                                        
@@ -13,10 +13,10 @@  | 
                                                    ||
| 13 | 13 | */  | 
                                                        
| 14 | 14 | public function up()  | 
                                                        
| 15 | 15 |      { | 
                                                        
| 16 | -        Schema::create('transactions', function (Blueprint $table) { | 
                                                        |
| 16 | +        Schema::create('transactions', function(Blueprint $table) { | 
                                                        |
| 17 | 17 | $table->id();  | 
                                                        
| 18 | 18 |              $table->unsignedBigInteger('order_id'); | 
                                                        
| 19 | -            $table->decimal('amount', 15,2); | 
                                                        |
| 19 | +            $table->decimal('amount', 15, 2); | 
                                                        |
| 20 | 20 |              $table->string('driver', 128); | 
                                                        
| 21 | 21 |              $table->enum('status', ['pending', 'successful', 'failed', 'refunded']); | 
                                                        
| 22 | 22 |              $table->string('ref_no')->nullable(); | 
                                                        
@@ -16,16 +16,16 @@ discard block  | 
                                                    ||
| 16 | 16 | $class = new PasargadIpg($this->getInformation());  | 
                                                        
| 17 | 17 |          $class->verifySSL(config('gateway.information')['pasargad']['options']['verifySSL']); | 
                                                        
| 18 | 18 | |
| 19 | -        $result = $class->getToken( $amount, $transaction->id, $transaction->created_at->format('Y/m/d H:i:s'), $callbackUrl ); | 
                                                        |
| 19 | +        $result = $class->getToken($amount, $transaction->id, $transaction->created_at->format('Y/m/d H:i:s'), $callbackUrl); | 
                                                        |
| 20 | 20 | |
| 21 | -        if(isset($detail['auto_redirect']) && $detail['auto_redirect'] == false && $result->status == 'success') { | 
                                                        |
| 21 | +        if (isset($detail['auto_redirect']) && $detail['auto_redirect'] == false && $result->status == 'success') { | 
                                                        |
| 22 | 22 | $result->token = $result->token;  | 
                                                        
| 23 | 23 | $result->url = 'https://pep.shaparak.ir/payment.aspx?n=' . $result->token;  | 
                                                        
| 24 | 24 | return $result;  | 
                                                        
| 25 | 25 | |
| 26 | -        } elseif($result->status == 'success') { | 
                                                        |
| 26 | +        } elseif ($result->status == 'success') { | 
                                                        |
| 27 | 27 | $this->updateTransactionData($transaction->id, ['token' => $result->token]);  | 
                                                        
| 28 | - header( 'Location: https://pep.shaparak.ir/payment.aspx?n=' . $result->token );  | 
                                                        |
| 28 | +            header('Location: https://pep.shaparak.ir/payment.aspx?n=' . $result->token); | 
                                                        |
| 29 | 29 | die();  | 
                                                        
| 30 | 30 | |
| 31 | 31 | }  | 
                                                        
@@ -38,11 +38,11 @@ discard block  | 
                                                    ||
| 38 | 38 | $class = new PasargadIpg($this->getInformation());  | 
                                                        
| 39 | 39 |          $class->verifySSL(config('gateway.information')['pasargad']['options']['verifySSL']); | 
                                                        
| 40 | 40 | |
| 41 | - $check = $class->checkTransaction( $request['iN'], $request['iD'] );  | 
                                                        |
| 41 | + $check = $class->checkTransaction($request['iN'], $request['iD']);  | 
                                                        |
| 42 | 42 | |
| 43 | 43 |          if ($check->status == 'success') { | 
                                                        
| 44 | 44 | $transaction = $this->getTransaction($request['iN']);  | 
                                                        
| 45 | - $result = $class->verifyTransaction( (int) $transaction->amount, $request['iN'], $request['iD'] );  | 
                                                        |
| 45 | + $result = $class->verifyTransaction((int) $transaction->amount, $request['iN'], $request['iD']);  | 
                                                        |
| 46 | 46 | |
| 47 | 47 |              if ($result->status == 'success') { | 
                                                        
| 48 | 48 | $this->updateTransactionData($request['iN'], ['status' => 'successful', 'ref_no' => $request['tref']]);  | 
                                                        
@@ -46,9 +46,9 @@  | 
                                                    ||
| 46 | 46 | }  | 
                                                        
| 47 | 47 | return $result;  | 
                                                        
| 48 | 48 | |
| 49 | -        }elseif ($result['status'] == 0){ | 
                                                        |
| 49 | +        } elseif ($result['status'] == 0){ | 
                                                        |
| 50 | 50 | $this->updateTransactionData($request['transId'], ['status' => 'failed', 'description' => $result['error']]);  | 
                                                        
| 51 | -        }elseif ($result['status'] == 3){ | 
                                                        |
| 51 | +        } elseif ($result['status'] == 3){ | 
                                                        |
| 52 | 52 | $this->updateTransactionData($request['transId'], ['status' => 'failed', 'description' => $result['errors'][0]]);  | 
                                                        
| 53 | 53 | }  | 
                                                        
| 54 | 54 | return $result;  | 
                                                        
@@ -16,15 +16,15 @@ discard block  | 
                                                    ||
| 16 | 16 | |
| 17 | 17 |          $given_result = (object) array('token' => '', 'url' => ''); | 
                                                        
| 18 | 18 | |
| 19 | -        if ($result['status'] == 1){ | 
                                                        |
| 19 | +        if ($result['status'] == 1) { | 
                                                        |
| 20 | 20 | $this->updateTransactionData($transaction->id, ['token' => $result['token']]);  | 
                                                        
| 21 | -            if(isset($detail['auto_redirect']) && $detail['auto_redirect'] == false) { | 
                                                        |
| 21 | +            if (isset($detail['auto_redirect']) && $detail['auto_redirect'] == false) { | 
                                                        |
| 22 | 22 | $given_result->token = $result['token'];  | 
                                                        
| 23 | 23 | $given_result->url = 'https://ipg.vandar.io/v3/' . $result['token'];  | 
                                                        
| 24 | 24 | return $given_result;  | 
                                                        
| 25 | 25 | |
| 26 | 26 |              } else { | 
                                                        
| 27 | - header( 'Location: https://ipg.vandar.io/v3/' . $result['token']);  | 
                                                        |
| 27 | +                header('Location: https://ipg.vandar.io/v3/' . $result['token']); | 
                                                        |
| 28 | 28 | die();  | 
                                                        
| 29 | 29 | }  | 
                                                        
| 30 | 30 | }  | 
                                                        
@@ -44,9 +44,9 @@ discard block  | 
                                                    ||
| 44 | 44 | }  | 
                                                        
| 45 | 45 | return $result;  | 
                                                        
| 46 | 46 | |
| 47 | -        }elseif ($result['status'] == 0){ | 
                                                        |
| 47 | +        }elseif ($result['status'] == 0) { | 
                                                        |
| 48 | 48 | $this->updateTransactionData($request['transId'], ['status' => 'failed', 'description' => $result['error']]);  | 
                                                        
| 49 | -        }elseif ($result['status'] == 3){ | 
                                                        |
| 49 | +        }elseif ($result['status'] == 3) { | 
                                                        |
| 50 | 50 | $this->updateTransactionData($request['transId'], ['status' => 'failed', 'description' => $result['errors'][0]]);  | 
                                                        
| 51 | 51 | }  | 
                                                        
| 52 | 52 | return $result;  | 
                                                        
@@ -16,14 +16,14 @@ discard block  | 
                                                    ||
| 16 | 16 | $class = new ParsianIpg($this->getInformation());  | 
                                                        
| 17 | 17 | $result = $class->paymentRequest($amount, $transaction->id, $callbackUrl);  | 
                                                        
| 18 | 18 | |
| 19 | -        if(isset($detail['auto_redirect']) && $detail['auto_redirect'] == false && $result->status == 'success') { | 
                                                        |
| 19 | +        if (isset($detail['auto_redirect']) && $detail['auto_redirect'] == false && $result->status == 'success') { | 
                                                        |
| 20 | 20 | $result->token = $result->token;  | 
                                                        
| 21 | 21 | $result->url = 'https://pec.shaparak.ir/NewIPG/?Token=' . $result->token;  | 
                                                        
| 22 | 22 | return $result;  | 
                                                        
| 23 | 23 | |
| 24 | -        } elseif($result->status == 'success') { | 
                                                        |
| 24 | +        } elseif ($result->status == 'success') { | 
                                                        |
| 25 | 25 | $this->updateTransactionData($transaction->id, ['token' => $result->token]);  | 
                                                        
| 26 | - header( 'Location: https://pec.shaparak.ir/NewIPG/?Token=' . $result->token );  | 
                                                        |
| 26 | +            header('Location: https://pec.shaparak.ir/NewIPG/?Token=' . $result->token); | 
                                                        |
| 27 | 27 | die();  | 
                                                        
| 28 | 28 | |
| 29 | 29 | }  | 
                                                        
@@ -35,7 +35,7 @@ discard block  | 
                                                    ||
| 35 | 35 |      { | 
                                                        
| 36 | 36 | $class = new ParsianIpg($this->getInformation());  | 
                                                        
| 37 | 37 | |
| 38 | - $result = $class->confirmPayment( $request['Token'] );  | 
                                                        |
| 38 | + $result = $class->confirmPayment($request['Token']);  | 
                                                        |
| 39 | 39 | |
| 40 | 40 |          if ($result->status == 'success') { | 
                                                        
| 41 | 41 | $this->updateTransactionData($request['OrderId'], ['status' => 'successful', 'ref_no' => $request['RRN']]);  | 
                                                        
@@ -15,14 +15,14 @@ discard block  | 
                                                    ||
| 15 | 15 |          // $amount, $transaction->id, $transaction->created_at->format('Y/m/d H:i:s'), $callbackUrl | 
                                                        
| 16 | 16 | $result = $this->payment_request($amount, $callbackUrl);  | 
                                                        
| 17 | 17 | |
| 18 | -        if(isset($detail['auto_redirect']) && $detail['auto_redirect'] == false && $result['status'] == 1) { | 
                                                        |
| 18 | +        if (isset($detail['auto_redirect']) && $detail['auto_redirect'] == false && $result['status'] == 1) { | 
                                                        |
| 19 | 19 | $result['token'] = $result['invoice_key'];  | 
                                                        
| 20 | 20 |              $result['url'] = config('gateway.information')['poolam']['api_url'] . "pay/" . $result['token']; | 
                                                        
| 21 | 21 | return $result;  | 
                                                        
| 22 | 22 | |
| 23 | -        } elseif($result['status'] == 1) { | 
                                                        |
| 23 | +        } elseif ($result['status'] == 1) { | 
                                                        |
| 24 | 24 | $this->updateTransactionData($transaction->id, ['token' => $result['invoice_key']]);  | 
                                                        
| 25 | -            header( 'Location: ' . config('gateway.information')['poolam']['api_url'] . "pay/" . $result['invoice_key']); | 
                                                        |
| 25 | +            header('Location: ' . config('gateway.information')['poolam']['api_url'] . "pay/" . $result['invoice_key']); | 
                                                        |
| 26 | 26 | die();  | 
                                                        
| 27 | 27 | |
| 28 | 28 | }  | 
                                                        
@@ -46,25 +46,25 @@ discard block  | 
                                                    ||
| 46 | 46 | return $check;  | 
                                                        
| 47 | 47 | }  | 
                                                        
| 48 | 48 | |
| 49 | -    protected function check_payment($inv_key){ | 
                                                        |
| 49 | +    protected function check_payment($inv_key) { | 
                                                        |
| 50 | 50 | $ch = curl_init();  | 
                                                        
| 51 | -        curl_setopt($ch,CURLOPT_URL,config('gateway.information')['poolam']['api_url'] . 'check/'.$inv_key); | 
                                                        |
| 52 | -        curl_setopt($ch,CURLOPT_POSTFIELDS,"api_key=" . config('gateway.information')['poolam']['api_key']); | 
                                                        |
| 51 | +        curl_setopt($ch, CURLOPT_URL, config('gateway.information')['poolam']['api_url'] . 'check/' . $inv_key); | 
                                                        |
| 52 | +        curl_setopt($ch, CURLOPT_POSTFIELDS, "api_key=" . config('gateway.information')['poolam']['api_key']); | 
                                                        |
| 53 | 53 | curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);  | 
                                                        
| 54 | - curl_setopt($ch,CURLOPT_RETURNTRANSFER,true);  | 
                                                        |
| 54 | + curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);  | 
                                                        |
| 55 | 55 | $res = curl_exec($ch);  | 
                                                        
| 56 | 56 | curl_close($ch);  | 
                                                        
| 57 | - return json_decode($res,1);  | 
                                                        |
| 57 | + return json_decode($res, 1);  | 
                                                        |
| 58 | 58 | }  | 
                                                        
| 59 | 59 | |
| 60 | -    protected function payment_request($amount,$redirect){ | 
                                                        |
| 60 | +    protected function payment_request($amount, $redirect) { | 
                                                        |
| 61 | 61 | $ch = curl_init();  | 
                                                        
| 62 | -        curl_setopt($ch,CURLOPT_URL,config('gateway.information')['poolam']['api_url'] . 'request'); | 
                                                        |
| 63 | -        curl_setopt($ch,CURLOPT_POSTFIELDS,"api_key=" . config('gateway.information')['poolam']['api_key'] . "&amount=$amount&return_url=$redirect"); | 
                                                        |
| 64 | - curl_setopt($ch,CURLOPT_SSL_VERIFYPEER, FALSE);  | 
                                                        |
| 65 | - curl_setopt($ch,CURLOPT_RETURNTRANSFER,true);  | 
                                                        |
| 62 | +        curl_setopt($ch, CURLOPT_URL, config('gateway.information')['poolam']['api_url'] . 'request'); | 
                                                        |
| 63 | +        curl_setopt($ch, CURLOPT_POSTFIELDS, "api_key=" . config('gateway.information')['poolam']['api_key'] . "&amount=$amount&return_url=$redirect"); | 
                                                        |
| 64 | + curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);  | 
                                                        |
| 65 | + curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);  | 
                                                        |
| 66 | 66 | $res = curl_exec($ch);  | 
                                                        
| 67 | 67 | curl_close($ch);  | 
                                                        
| 68 | - return json_decode($res,1);  | 
                                                        |
| 68 | + return json_decode($res, 1);  | 
                                                        |
| 69 | 69 | }  | 
                                                        
| 70 | 70 | }  |