From 12f7fd230c2242e442c48e301eb9423252130117 Mon Sep 17 00:00:00 2001
From: Aboozar Ghaffari <aboozar.ghf@gmail.com>
Date: Thu, 29 Dec 2022 10:23:15 +0330
Subject: [PATCH] fixed banktest urls

---
 src/Adapter/Idpay.php    | 152 +++++++++++++++++++--------------------
 src/Adapter/Mellat.php   |  14 ++--
 src/Adapter/Nextpay.php  | 144 ++++++++++++++++++-------------------
 src/Adapter/Parsian.php  |  10 +--
 src/Adapter/Pasargad.php |   8 +--
 src/Adapter/Payir.php    | 142 ++++++++++++++++++------------------
 src/Adapter/Saderat.php  |   4 +-
 src/Adapter/Saman.php    |   6 +-
 src/Adapter/Zarinpal.php |   2 +-
 src/Adapter/Zibal.php    | 135 ++++++++++++++++------------------
 10 files changed, 299 insertions(+), 318 deletions(-)

diff --git a/src/Adapter/Idpay.php b/src/Adapter/Idpay.php
index b4c4eff..c4d4f8a 100644
--- a/src/Adapter/Idpay.php
+++ b/src/Adapter/Idpay.php
@@ -1,4 +1,5 @@
 <?php
+
 declare(strict_types=1);
 
 namespace PhpMonsters\Larapay\Adapter;
@@ -13,15 +14,65 @@
  */
 class Idpay extends AdapterAbstract implements AdapterInterface
 {
+    public $endPointVerify = 'https://api.idpay.ir/v1.1/payment/verify';
+    public $reverseSupport = false;
     protected $WSDL = 'https://api.idpay.ir/v1.1/payment';
-    protected $endPoint  = 'https://idpay.ir/p/ws/{order-id}';
-
+    protected $endPoint = 'https://idpay.ir/p/ws/{order-id}';
     protected $testWSDL = 'https://api.idpay.ir/v1.1/payment';
     protected $testEndPoint = 'https://idpay.ir/p/ws-sandbox/{order-id}';
 
-    public $endPointVerify = 'https://api.idpay.ir/v1.1/payment/verify';
+    /**
+     * @return array
+     * @throws Exception
+     * @throws \PhpMonsters\Larapay\Adapter\Exception
+     */
+    public function formParams(): array
+    {
+        $authority = $this->requestToken();
 
-    public $reverseSupport = false;
+        return [
+            'endPoint' => strtr($this->getEndPoint(), ['{authority}' => $authority]),
+        ];
+    }
+
+    /**
+     * @return bool
+     */
+    public function canContinueWithCallbackParameters(): bool
+    {
+        if (!empty($this->transaction['gate_refid'])) {
+            return true;
+        }
+
+        return false;
+    }
+
+    public function getGatewayReferenceId(): string
+    {
+        $this->checkRequiredParameters([
+            'merchant_id',
+        ]);
+
+        return strval($this->transaction['gate_refid']);
+    }
+
+    /**
+     * @return string
+     * @throws Exception
+     * @throws \PhpMonsters\Larapay\Adapter\Exception
+     */
+    protected function generateForm(): string
+    {
+        $authority = $this->requestToken();
+
+        $form = view('larapay::idpay-form', [
+            'endPoint' => strtr($this->getEndPoint(), ['{order-id}' => $authority]),
+            'submitLabel' => !empty($this->submit_label) ? $this->submit_label : trans("larapay::larapay.goto_gate"),
+            'autoSubmit' => boolval($this->auto_submit),
+        ]);
+
+        return $form->__toString();
+    }
 
     /**
      * @return string
@@ -30,7 +81,7 @@ class Idpay extends AdapterAbstract implements AdapterInterface
      */
     protected function requestToken(): string
     {
-        if ($this->getTransaction()->checkForRequestToken() == false) {
+        if ($this->getTransaction()->checkForRequestToken() === false) {
             throw new Exception('larapay::larapay.could_not_request_payment');
         }
 
@@ -41,25 +92,25 @@ protected function requestToken(): string
         ]);
 
         $sendParams = [
-            'order_id'  => $this->getTransaction()->bank_order_id,
-            'amount'      => intval($this->amount),
+            'order_id' => $this->getTransaction()->bank_order_id,
+            'amount' => intval($this->amount),
             'desc' => $this->description ? $this->description : '',
-            'mail'       => $this->email ? $this->email : '',
-            'phone'      => $this->mobile ? $this->mobile : '',
+            'mail' => $this->email ? $this->email : '',
+            'phone' => $this->mobile ? $this->mobile : '',
             'callback' => $this->redirect_url,
         ];
 
         $header = [
             'Content-Type: application/json',
-            'X-API-KEY:' .$this->merchant_id,
-            'X-SANDBOX:' .$this->getSandbox()
+            'X-API-KEY:'.$this->merchant_id,
+            'X-SANDBOX:'.$this->getSandbox()
         ];
         try {
             XLog::debug('PaymentRequest call', $sendParams);
             $ch = curl_init();
             curl_setopt($ch, CURLOPT_URL, $this->WSDL);
             curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($sendParams));
-            curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
+            curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
             curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
             $response = curl_exec($ch);
             $ch_error = curl_error($ch);
@@ -73,47 +124,14 @@ protected function requestToken(): string
             XLog::info('PaymentRequest response', $this->obj2array($result));
             $this->getTransaction()->setGatewayToken(strval($result->id)); // update transaction reference id
             return $result->id;
-        } catch(\Exception $e) {
+        } catch (\Exception $e) {
             throw new Exception($e->getMessage());
         };
     }
 
-
-    /**
-     * @return string
-     * @throws Exception
-     * @throws \PhpMonsters\Larapay\Adapter\Exception
-     */
-    protected function generateForm(): string
-    {
-        $authority = $this->requestToken();
-
-        $form = view('larapay::idpay-form', [
-            'endPoint'    => strtr($this->getEndPoint(), ['{order-id}' => $authority]),
-            'submitLabel' => !empty($this->submit_label) ? $this->submit_label : trans("larapay::larapay.goto_gate"),
-            'autoSubmit'  => boolval($this->auto_submit),
-        ]);
-
-        return $form->__toString();
-    }
-
-    /**
-     * @return array
-     * @throws Exception
-     * @throws \PhpMonsters\Larapay\Adapter\Exception
-     */
-    public function formParams(): array
-    {
-        $authority = $this->requestToken();
-
-        return  [
-            'endPoint'    => strtr($this->getEndPoint(), ['{authority}' => $authority]),
-        ];
-    }
-
     public function getSandbox(): string
     {
-        if (config('larapay.mode') == 'production') {
+        if (config('larapay.mode') === 'production') {
             return "0";
         } else {
             return "1";
@@ -127,8 +145,7 @@ public function getSandbox(): string
      */
     protected function verifyTransaction(): bool
     {
-
-        if ($this->getTransaction()->checkForVerify() == false) {
+        if ($this->getTransaction()->checkForVerify() === false) {
             throw new Exception('larapay::larapay.could_not_verify_payment');
         }
 
@@ -137,21 +154,21 @@ protected function verifyTransaction(): bool
         ]);
 
         $sendParams = [
-            'id'  => $this->getTransaction()->gate_refid,
-            'order_id'     => $this->getTransaction()->bank_order_id,
+            'id' => $this->getTransaction()->gate_refid,
+            'order_id' => $this->getTransaction()->bank_order_id,
         ];
 
         $header = [
             'Content-Type: application/json',
-            'X-API-KEY:' .$this->merchant_id,
-            'X-SANDBOX:' .$this->getSandbox()
+            'X-API-KEY:'.$this->merchant_id,
+            'X-SANDBOX:'.$this->getSandbox()
         ];
 
         try {
             $ch = curl_init();
             curl_setopt($ch, CURLOPT_URL, $this->endPointVerify);
             curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($sendParams));
-            curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
+            curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
             curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
             $response = curl_exec($ch);
             $ch_error = curl_error($ch);
@@ -161,10 +178,9 @@ protected function verifyTransaction(): bool
             XLog::info('PaymentVerification response', $this->obj2array($result));
 
             if (isset($result->status)) {
-
                 if ($result->status == 100 || $result->status == 101) {
                     $this->getTransaction()->setVerified();
-                    $this->getTransaction()->setReferenceId((string)$result->id);
+                    $this->getTransaction()->setReferenceId((string) $result->id);
                     return true;
                 } else {
                     throw new Exception($result->status);
@@ -172,30 +188,8 @@ protected function verifyTransaction(): bool
             } else {
                 throw new Exception($result->error_code);
             }
-
-        } catch(\Exception $e) {
+        } catch (\Exception $e) {
             throw new Exception($e->getMessage());
         }
     }
-
-    /**
-     * @return bool
-     */
-    public function canContinueWithCallbackParameters(): bool
-    {
-        if (!empty($this->transaction['gate_refid'])) {
-            return true;
-        }
-
-        return false;
-    }
-
-    public function getGatewayReferenceId(): string
-    {
-        $this->checkRequiredParameters([
-            'merchant_id',
-        ]);
-
-        return strval($this->transaction['gate_refid']);
-    }
 }
diff --git a/src/Adapter/Mellat.php b/src/Adapter/Mellat.php
index 2f1bbde..842ccd3 100755
--- a/src/Adapter/Mellat.php
+++ b/src/Adapter/Mellat.php
@@ -16,8 +16,8 @@ class Mellat extends AdapterAbstract implements AdapterInterface
     protected $WSDL     = 'https://bpm.shaparak.ir/pgwchannel/services/pgw?wsdl';
     protected $endPoint = 'https://bpm.shaparak.ir/pgwchannel/startpay.mellat';
 
-    protected $testWSDL     = 'https://banktest.ir/gateway/mellat/ws?wsdl';
-    protected $testEndPoint = 'https://banktest.ir/gateway/mellat/gate';
+    protected $testWSDL     = 'https://sandbox.banktest.ir/mellat/bpm.shaparak.ir/pgwchannel/services/pgw?wsdl';
+    protected $testEndPoint = 'https://sandbox.banktest.ir/mellat/bpm.shaparak.ir/pgwchannel/startpay.mellat';
 
     protected $reverseSupport = true;
 
@@ -28,7 +28,7 @@ class Mellat extends AdapterAbstract implements AdapterInterface
      */
     protected function requestToken()
     {
-        if ($this->getTransaction()->checkForRequestToken() == false) {
+        if ($this->getTransaction()->checkForRequestToken() === false) {
             throw new Exception('larapay::larapay.could_not_request_payment');
         }
 
@@ -120,7 +120,7 @@ public function formParams(): array
      */
     protected function verifyTransaction()
     {
-        if ($this->getTransaction()->checkForVerify() == false) {
+        if ($this->getTransaction()->checkForVerify() === false) {
             throw new Exception('larapay::larapay.could_not_verify_payment');
         }
 
@@ -182,7 +182,7 @@ protected function verifyTransaction()
      */
     public function inquiryTransaction()
     {
-        if ($this->getTransaction()->checkForInquiry() == false) {
+        if ($this->getTransaction()->checkForInquiry() === false) {
             throw new Exception('larapay::larapay.could_not_inquiry_payment');
         }
 
@@ -244,7 +244,7 @@ public function inquiryTransaction()
      */
     protected function settleTransaction()
     {
-        if ($this->getTransaction()->checkForAfterVerify() == false) {
+        if ($this->getTransaction()->checkForAfterVerify() === false) {
             throw new Exception('larapay::larapay.could_not_settle_payment');
         }
 
@@ -302,7 +302,7 @@ protected function settleTransaction()
      */
     protected function reverseTransaction(): bool
     {
-        if ($this->reverseSupport == false || $this->getTransaction()->checkForReverse() == false) {
+        if ($this->reverseSupport === false || $this->getTransaction()->checkForReverse() === false) {
             throw new Exception('larapay::larapay.could_not_reverse_payment');
         }
 
diff --git a/src/Adapter/Nextpay.php b/src/Adapter/Nextpay.php
index ed91739..5252542 100644
--- a/src/Adapter/Nextpay.php
+++ b/src/Adapter/Nextpay.php
@@ -1,4 +1,5 @@
 <?php
+
 declare(strict_types=1);
 
 namespace PhpMonsters\Larapay\Adapter;
@@ -14,12 +15,68 @@
 class Nextpay extends AdapterAbstract implements AdapterInterface
 {
 
-    public $endPoint       = 'https://nextpay.org/nx/gateway/token';
-    public $endPointForm   = 'https://nextpay.org/nx/gateway/payment/{trans_id}';
+    public $endPoint = 'https://nextpay.org/nx/gateway/token';
+    public $endPointForm = 'https://nextpay.org/nx/gateway/payment/{trans_id}';
     public $endPointVerify = 'https://nextpay.org/nx/gateway/verify';
 
     public $reverseSupport = false;
 
+    /**
+     * @return array
+     * @throws Exception
+     * @throws \PhpMonsters\Larapay\Adapter\Exception
+     */
+    public function formParams(): array
+    {
+        $authority = $this->requestToken();
+
+        return [
+            'endPoint' => strtr($this->endPointForm, ['{trans_id}' => $authority]),
+        ];
+    }
+
+    /**
+     * @return bool
+     */
+    public function canContinueWithCallbackParameters(): bool
+    {
+        if (!empty($this->parameters['trans_id'])) {
+            return true;
+        }
+
+        return false;
+    }
+
+    /**
+     * @return string
+     * @throws \PhpMonsters\Larapay\Adapter\Exception
+     */
+    public function getGatewayReferenceId(): string
+    {
+        $this->checkRequiredParameters([
+            'trans_id',
+        ]);
+
+        return strval($this->trans_id);
+    }
+
+    /**
+     * @return string
+     * @throws Exception
+     * @throws \PhpMonsters\Larapay\Adapter\Exception
+     */
+    protected function generateForm(): string
+    {
+        $authority = $this->requestToken();
+
+        $form = view('larapay::nextpay-form', [
+            'endPoint' => strtr($this->endPointForm, ['{trans_id}' => $authority]),
+            'submitLabel' => !empty($this->submit_label) ? $this->submit_label : trans("larapay::larapay.goto_gate"),
+            'autoSubmit' => true,
+        ]);
+        return $form->__toString();
+    }
+
     /**
      * @return string
      * @throws Exception
@@ -27,7 +84,7 @@ class Nextpay extends AdapterAbstract implements AdapterInterface
      */
     protected function requestToken(): string
     {
-        if ($this->getTransaction()->checkForRequestToken() == false) {
+        if ($this->getTransaction()->checkForRequestToken() === false) {
             throw new Exception('larapay::larapay.could_not_request_payment');
         }
 
@@ -39,12 +96,12 @@ protected function requestToken(): string
         ]);
 
         $sendParams = [
-            'api_key'      => $this->api_key,
-            'amount'       => intval($this->amount),
+            'api_key' => $this->api_key,
+            'amount' => intval($this->amount),
             'order_id' => ($this->order_id),
-            'payer_desc'  => $this->description ? $this->description : '',
-            'customer_phone'       => $this->mobile ? $this->mobile : '',
-            'callback_uri'     => $this->redirect_url,
+            'payer_desc' => $this->description ? $this->description : '',
+            'customer_phone' => $this->mobile ? $this->mobile : '',
+            'callback_uri' => $this->redirect_url,
         ];
 
         try {
@@ -55,7 +112,6 @@ protected function requestToken(): string
             XLog::info('PaymentRequest response', $this->obj2array($resultObj));
 
             if (isset($resultObj->code)) {
-
                 if ($resultObj->code == -1) {
                     $this->getTransaction()->setGatewayToken(strval($resultObj->trans_id)); // update transaction reference id
                     return $resultObj->trans_id;
@@ -66,42 +122,10 @@ protected function requestToken(): string
                 throw new Exception('larapay::larapay.invalid_response');
             }
         } catch (\Exception $e) {
-            throw new Exception('Nextpay Fault: ' . $e->getMessage() . ' #' . $e->getCode(), $e->getCode());
+            throw new Exception('Nextpay Fault: '.$e->getMessage().' #'.$e->getCode(), $e->getCode());
         }
     }
 
-
-    /**
-     * @return string
-     * @throws Exception
-     * @throws \PhpMonsters\Larapay\Adapter\Exception
-     */
-    protected function generateForm(): string
-    {
-        $authority = $this->requestToken();
-
-        $form = view('larapay::nextpay-form', [
-            'endPoint'    => strtr($this->endPointForm, ['{trans_id}' => $authority]),
-            'submitLabel' => !empty($this->submit_label) ? $this->submit_label : trans("larapay::larapay.goto_gate"),
-            'autoSubmit'  => true,
-        ]);
-        return $form->__toString();
-    }
-
-    /**
-     * @return array
-     * @throws Exception
-     * @throws \PhpMonsters\Larapay\Adapter\Exception
-     */
-    public function formParams(): array
-    {
-        $authority = $this->requestToken();
-
-        return  [
-            'endPoint'    => strtr($this->endPointForm, ['{trans_id}' => $authority]),
-        ];
-    }
-
     /**
      * @return bool
      * @throws Exception
@@ -109,8 +133,7 @@ public function formParams(): array
      */
     protected function verifyTransaction(): bool
     {
-
-        if ($this->getTransaction()->checkForVerify() == false) {
+        if ($this->getTransaction()->checkForVerify() === false) {
             throw new Exception('larapay::larapay.could_not_verify_payment');
         }
 
@@ -121,17 +144,17 @@ protected function verifyTransaction(): bool
         ]);
 
         $sendParams = [
-            'api_key'     => $this->api_key,
+            'api_key' => $this->api_key,
             'trans_id' => $this->trans_id,
             'amount' => $this->amount,
         ];
 
         try {
             XLog::debug('PaymentVerification call', $sendParams);
-            $result   = Helper::post2https($sendParams, $this->endPointVerify);
+            $result = Helper::post2https($sendParams, $this->endPointVerify);
             $response = json_decode($result);
             XLog::info('PaymentVerification response', $this->obj2array($response));
-            if (isset($response->code , $response->Shaparak_Ref_Id)) {
+            if (isset($response->code, $response->Shaparak_Ref_Id)) {
                 if ($response->code == 0) {
                     $this->getTransaction()->setVerified();
                     $this->getTransaction()->setReferenceId(strval($response->Shaparak_Ref_Id)); // update transaction reference id
@@ -143,32 +166,7 @@ protected function verifyTransaction(): bool
                 throw new Exception('larapay::larapay.invalid_response');
             }
         } catch (\Exception $e) {
-            throw new Exception('Nextpay Fault: ' . $e->getMessage() . ' #' . $e->getCode(), $e->getCode());
-        }
-    }
-
-    /**
-     * @return bool
-     */
-    public function canContinueWithCallbackParameters(): bool
-    {
-        if (!empty($this->parameters['trans_id'])) {
-            return true;
+            throw new Exception('Nextpay Fault: '.$e->getMessage().' #'.$e->getCode(), $e->getCode());
         }
-
-        return false;
-    }
-
-    /**
-     * @return string
-     * @throws \PhpMonsters\Larapay\Adapter\Exception
-     */
-    public function getGatewayReferenceId(): string
-    {
-        $this->checkRequiredParameters([
-            'trans_id',
-        ]);
-
-        return strval($this->trans_id);
     }
 }
diff --git a/src/Adapter/Parsian.php b/src/Adapter/Parsian.php
index 69f3255..45d8dd1 100755
--- a/src/Adapter/Parsian.php
+++ b/src/Adapter/Parsian.php
@@ -22,12 +22,12 @@ class Parsian extends AdapterAbstract implements AdapterInterface
 
     protected $endPoint = 'https://pec.shaparak.ir/NewIPG/';
 
-    protected $testWSDLSale      = 'https://banktest.ir/gateway/Parsian/NewIPGServices/Sale/SaleService.asmx?WSDL';
-    protected $testWSDLConfirm   = 'https://banktest.ir/gateway/Parsian/NewIPGServices/Confirm/ConfirmService.asmx?WSDL';
-    protected $testWSDLReversal  = 'https://banktest.ir/gateway/Parsian/NewIPGServices/Reverse/ReversalService.asmx?WSDL';
-    protected $testWSDLMultiplex = 'https://banktest.ir/gateway/Parsian/NewIPGServices/MultiplexedSale/OnlineMultiplexedSalePaymentService.asmx?WSDL';
+    protected $testWSDLSale      = 'https://sandbox.banktest.ir/parsian/pec.shaparak.ir/NewIPGServices/Sale/SaleService.asmx?wsdl';
+    protected $testWSDLConfirm   = 'https://sandbox.banktest.ir/parsian/pec.shaparak.ir/NewIPGServices/Confirm/ConfirmService.asmx?wsdl';
+    protected $testWSDLReversal  = 'https://sandbox.banktest.ir/parsian/pec.shaparak.ir/NewIPGServices/Reverse/ReversalService.asmx?wsdl';
+    protected $testWSDLMultiplex = 'https://sandbox.banktest.ir/parsian/pec.shaparak.ir/NewIPGServices/MultiplexedSale/OnlineMultiplexedSalePaymentService.asmx?wsdl';
 
-    protected $testEndPoint = 'https://banktest.ir/gateway/Parsian/NewIPGq';
+    protected $testEndPoint = 'https://sandbox.banktest.ir/parsian/pec.shaparak.ir/NewIPG';
 
     protected $reverseSupport = true;
 
diff --git a/src/Adapter/Pasargad.php b/src/Adapter/Pasargad.php
index 556f198..40c9876 100644
--- a/src/Adapter/Pasargad.php
+++ b/src/Adapter/Pasargad.php
@@ -21,10 +21,10 @@ class Pasargad extends AdapterAbstract implements AdapterInterface
 	protected $refundUrl = 'https://pep.shaparak.ir/doRefund.aspx';
 
 
-	protected $testEndPoint = 'https://banktest.ir/gateway/pasargad/gateway';
-	protected $testCheckTransactionUrl = 'https://banktest.ir/gateway/pasargad/CheckTransactionResult';
-	protected $testVerifyUrl = 'https://banktest.ir/gateway/pasargad/VerifyPayment';
-	protected $testRefundUrl = 'https://banktest.ir/gateway/pasargad/doRefund';
+	protected $testEndPoint = 'https://sandbox.banktest.ir/pasargad/pep.shaparak.ir/gateway.aspx';
+	protected $testCheckTransactionUrl = 'https://sandbox.banktest.ir/pasargad/pep.shaparak.ir/CheckTransactionResult.aspx';
+	protected $testVerifyUrl = 'https://sandbox.banktest.ir/pasargad/pep.shaparak.ir/VerifyPayment.aspx';
+	protected $testRefundUrl = 'https://sandbox.banktest.ir/pasargad/pep.shaparak.ir/doRefund.aspx';
 
 
     /**
diff --git a/src/Adapter/Payir.php b/src/Adapter/Payir.php
index 64875c2..b39360a 100755
--- a/src/Adapter/Payir.php
+++ b/src/Adapter/Payir.php
@@ -1,4 +1,5 @@
 <?php
+
 declare(strict_types=1);
 
 namespace PhpMonsters\Larapay\Adapter;
@@ -14,12 +15,68 @@
 class Payir extends AdapterAbstract implements AdapterInterface
 {
 
-    public $endPoint       = 'https://pay.ir/pg/send';
-    public $endPointForm   = 'https://pay.ir/pg/';
+    public $endPoint = 'https://pay.ir/pg/send';
+    public $endPointForm = 'https://pay.ir/pg/';
     public $endPointVerify = 'https://pay.ir/pg/verify';
 
     public $reverseSupport = false;
 
+    /**
+     * @return array
+     * @throws Exception
+     * @throws \PhpMonsters\Larapay\Adapter\Exception
+     */
+    public function formParams(): array
+    {
+        $authority = $this->requestToken();
+
+        return [
+            'endPoint' => $this->endPointForm.$authority,
+        ];
+    }
+
+    /**
+     * @return bool
+     */
+    public function canContinueWithCallbackParameters(): bool
+    {
+        if (!empty($this->parameters['token'])) {
+            return true;
+        }
+
+        return false;
+    }
+
+    /**
+     * @return string
+     * @throws \PhpMonsters\Larapay\Adapter\Exception
+     */
+    public function getGatewayReferenceId(): string
+    {
+        $this->checkRequiredParameters([
+            'token',
+        ]);
+
+        return strval($this->transId);
+    }
+
+    /**
+     * @return string
+     * @throws Exception
+     * @throws \PhpMonsters\Larapay\Adapter\Exception
+     */
+    protected function generateForm(): string
+    {
+        $authority = $this->requestToken();
+
+        $form = view('larapay::payir-form', [
+            'endPoint' => $this->endPointForm.$authority,
+            'submitLabel' => !empty($this->submit_label) ? $this->submit_label : trans("larapay::larapay.goto_gate"),
+            'autoSubmit' => true,
+        ]);
+        return $form->__toString();
+    }
+
     /**
      * @return string
      * @throws Exception
@@ -27,7 +84,7 @@ class Payir extends AdapterAbstract implements AdapterInterface
      */
     protected function requestToken(): string
     {
-        if ($this->getTransaction()->checkForRequestToken() == false) {
+        if ($this->getTransaction()->checkForRequestToken() === false) {
             throw new Exception('larapay::larapay.could_not_request_payment');
         }
 
@@ -39,12 +96,12 @@ protected function requestToken(): string
         ]);
 
         $sendParams = [
-            'api'          => $this->api,
-            'amount'       => intval($this->amount),
+            'api' => $this->api,
+            'amount' => intval($this->amount),
             'orderId' => ($this->order_id),
-            'description'  => $this->description ? $this->description : '',
-            'mobile'       => $this->mobile ? $this->mobile : '',
-            'redirect'     => $this->redirect_url,
+            'description' => $this->description ? $this->description : '',
+            'mobile' => $this->mobile ? $this->mobile : '',
+            'redirect' => $this->redirect_url,
         ];
 
         try {
@@ -57,7 +114,6 @@ protected function requestToken(): string
 
 
             if (isset($resultObj->status)) {
-
                 if ($resultObj->status == 1) {
                     $this->getTransaction()->setGatewayToken(strval($resultObj->token)); // update transaction reference id
 
@@ -69,42 +125,10 @@ protected function requestToken(): string
                 throw new Exception('larapay::larapay.invalid_response');
             }
         } catch (\Exception $e) {
-            throw new Exception('PayIr Fault: ' . $e->getMessage() . ' #' . $e->getCode(), $e->getCode());
+            throw new Exception('PayIr Fault: '.$e->getMessage().' #'.$e->getCode(), $e->getCode());
         }
     }
 
-
-    /**
-     * @return string
-     * @throws Exception
-     * @throws \PhpMonsters\Larapay\Adapter\Exception
-     */
-    protected function generateForm(): string
-    {
-        $authority = $this->requestToken();
-
-        $form = view('larapay::payir-form', [
-            'endPoint'    => $this->endPointForm . $authority,
-            'submitLabel' => !empty($this->submit_label) ? $this->submit_label : trans("larapay::larapay.goto_gate"),
-            'autoSubmit'  => true,
-        ]);
-        return $form->__toString();
-    }
-
-    /**
-     * @return array
-     * @throws Exception
-     * @throws \PhpMonsters\Larapay\Adapter\Exception
-     */
-    public function formParams(): array
-    {
-        $authority = $this->requestToken();
-
-        return  [
-            'endPoint'    => $this->endPointForm . $authority,
-        ];
-    }
-
     /**
      * @return bool
      * @throws Exception
@@ -112,8 +136,7 @@ public function formParams(): array
      */
     protected function verifyTransaction(): bool
     {
-
-        if ($this->getTransaction()->checkForVerify() == false) {
+        if ($this->getTransaction()->checkForVerify() === false) {
             throw new Exception('larapay::larapay.could_not_verify_payment');
         }
 
@@ -123,13 +146,13 @@ protected function verifyTransaction(): bool
         ]);
 
         $sendParams = [
-            'api'     => $this->api,
+            'api' => $this->api,
             'token' => $this->token,
         ];
 
         try {
             XLog::debug('PaymentVerification call', $sendParams);
-            $result   = Helper::post2https($sendParams, $this->endPointVerify);
+            $result = Helper::post2https($sendParams, $this->endPointVerify);
             $response = json_decode($result);
             XLog::info('PaymentVerification response', $this->obj2array($response));
 
@@ -145,32 +168,7 @@ protected function verifyTransaction(): bool
                 throw new Exception($response->status);
             }
         } catch (\Exception $e) {
-            throw new Exception('Payir Fault: ' . $e->getMessage() . ' #' . $e->getCode(), $e->getCode());
-        }
-    }
-
-    /**
-     * @return bool
-     */
-    public function canContinueWithCallbackParameters(): bool
-    {
-        if (!empty($this->parameters['token'])) {
-            return true;
+            throw new Exception('Payir Fault: '.$e->getMessage().' #'.$e->getCode(), $e->getCode());
         }
-
-        return false;
-    }
-
-    /**
-     * @return string
-     * @throws \PhpMonsters\Larapay\Adapter\Exception
-     */
-    public function getGatewayReferenceId(): string
-    {
-        $this->checkRequiredParameters([
-            'token',
-        ]);
-
-        return strval($this->transId);
     }
 }
\ No newline at end of file
diff --git a/src/Adapter/Saderat.php b/src/Adapter/Saderat.php
index 442bf5a..5b669a3 100755
--- a/src/Adapter/Saderat.php
+++ b/src/Adapter/Saderat.php
@@ -30,7 +30,7 @@ class Saderat extends AdapterAbstract implements AdapterInterface
      */
     protected function requestToken(): string
     {
-        if ($this->getTransaction()->checkForRequestToken() == false) {
+        if ($this->getTransaction()->checkForRequestToken() === false) {
             throw new Exception('larapay::larapay.could_not_request_payment');
         }
 
@@ -110,7 +110,7 @@ public function formParams(): array
      */
     protected function verifyTransaction(): bool
     {
-        if ($this->getTransaction()->checkForVerify() == false) {
+        if ($this->getTransaction()->checkForVerify() === false) {
             throw new Exception('larapay::larapay.could_not_verify_payment');
         }
 
diff --git a/src/Adapter/Saman.php b/src/Adapter/Saman.php
index 332af3b..2c6f8a5 100755
--- a/src/Adapter/Saman.php
+++ b/src/Adapter/Saman.php
@@ -19,9 +19,9 @@ class Saman extends AdapterAbstract implements AdapterInterface
     protected $tokenWSDL = 'https://sep.shaparak.ir/Payments/InitPayment.asmx?WSDL';
     protected $endPoint = 'https://sep.shaparak.ir/Payment.aspx';
 
-    protected $testWSDL      = 'https://banktest.ir/gateway/saman/payments/referencepayment?wsdl';
-    protected $testTokenWSDL = 'https://banktest.ir/gateway/saman/Payments/InitPayment?wsdl';
-    protected $testEndPoint  = 'https://banktest.ir/gateway/saman/gate';
+    protected $testWSDL      = 'https://sandbox.banktest.ir/saman/sep.shaparak.ir/payments/referencepayment.asmx?wsdl';
+    protected $testTokenWSDL = 'https://sandbox.banktest.ir/saman/sep.shaparak.ir/payments/initpayment.asmx?wsdl';
+    protected $testEndPoint  = 'https://sandbox.banktest.ir/saman/sep.shaparak.ir/payment.aspx';
 
     protected $reverseSupport = true;
 
diff --git a/src/Adapter/Zarinpal.php b/src/Adapter/Zarinpal.php
index 30118e0..a1294d9 100755
--- a/src/Adapter/Zarinpal.php
+++ b/src/Adapter/Zarinpal.php
@@ -32,7 +32,7 @@ class Zarinpal extends AdapterAbstract implements AdapterInterface
      */
     protected function requestToken(): string
     {
-        if ($this->getTransaction()->checkForRequestToken() == false) {
+        if ($this->getTransaction()->checkForRequestToken() === false) {
             throw new Exception('larapay::larapay.could_not_request_payment');
         }
 
diff --git a/src/Adapter/Zibal.php b/src/Adapter/Zibal.php
index c02adbf..98a23fc 100644
--- a/src/Adapter/Zibal.php
+++ b/src/Adapter/Zibal.php
@@ -1,4 +1,5 @@
 <?php
+
 declare(strict_types=1);
 
 namespace PhpMonsters\Larapay\Adapter;
@@ -14,15 +15,64 @@
  */
 class Zibal extends AdapterAbstract implements AdapterInterface
 {
+    public $endPointVerify = 'https://gateway.zibal.ir/v1/verify';
+    public $reverseSupport = false;
     protected $WSDL = 'https://gateway.zibal.ir/v1/request';
-    protected $endPoint  = 'https://gateway.zibal.ir/start/{trackId}';
-
+    protected $endPoint = 'https://gateway.zibal.ir/start/{trackId}';
     protected $testWSDL = 'https://gateway.zibal.ir/v1/request';
     protected $testEndPoint = 'https://gateway.zibal.ir/start/{trackId}';
 
-    public $endPointVerify = 'https://gateway.zibal.ir/v1/verify';
+    /**
+     * @return array
+     * @throws Exception
+     * @throws \PhpMonsters\Larapay\Adapter\Exception
+     */
+    public function formParams(): array
+    {
+        $authority = $this->requestToken();
 
-    public $reverseSupport = false;
+        return [
+            'endPoint' => strtr($this->getEndPoint(), ['{authority}' => $authority]),
+        ];
+    }
+
+    /**
+     * @return bool
+     */
+    public function canContinueWithCallbackParameters(): bool
+    {
+        if ($this->success == 1) {
+            return true;
+        }
+
+        return false;
+    }
+
+    public function getGatewayReferenceId(): string
+    {
+        $this->checkRequiredParameters([
+            'trackid',
+        ]);
+        return strval($this->trackid);
+    }
+
+    /**
+     * @return string
+     * @throws Exception
+     * @throws \PhpMonsters\Larapay\Adapter\Exception
+     */
+    protected function generateForm(): string
+    {
+        $authority = $this->requestToken();
+
+        $form = view('larapay::zibal-form', [
+            'endPoint' => strtr($this->getEndPoint(), ['{trackId}' => $authority]),
+            'submitLabel' => !empty($this->submit_label) ? $this->submit_label : trans("larapay::larapay.goto_gate"),
+            'autoSubmit' => boolval($this->auto_submit),
+        ]);
+
+        return $form->__toString();
+    }
 
     /**
      * @return string
@@ -31,7 +81,7 @@ class Zibal extends AdapterAbstract implements AdapterInterface
      */
     protected function requestToken(): string
     {
-        if ($this->getTransaction()->checkForRequestToken() == false) {
+        if ($this->getTransaction()->checkForRequestToken() === false) {
             throw new Exception('larapay::larapay.could_not_request_payment');
         }
 
@@ -42,11 +92,11 @@ protected function requestToken(): string
         ]);
 
         $sendParams = [
-            'merchant'  => $this->getSandbox(),
-            'orderId'  => $this->getTransaction()->bank_order_id,
-            'amount'      => intval($this->amount),
+            'merchant' => $this->getSandbox(),
+            'orderId' => $this->getTransaction()->bank_order_id,
+            'amount' => intval($this->amount),
             'description' => $this->description ? $this->description : '',
-            'mobile'      => $this->mobile ? $this->mobile : '',
+            'mobile' => $this->mobile ? $this->mobile : '',
             'callbackUrl' => $this->redirect_url,
         ];
 
@@ -70,41 +120,6 @@ protected function requestToken(): string
         } catch (\Exception $e) {
             throw new Exception($e->getMessage());
         }
-
-    }
-
-
-    /**
-     * @return string
-     * @throws Exception
-     * @throws \PhpMonsters\Larapay\Adapter\Exception
-     */
-    protected function generateForm(): string
-    {
-
-        $authority = $this->requestToken();
-
-        $form = view('larapay::zibal-form', [
-            'endPoint'    => strtr($this->getEndPoint(), ['{trackId}' => $authority]),
-            'submitLabel' => !empty($this->submit_label) ? $this->submit_label : trans("larapay::larapay.goto_gate"),
-            'autoSubmit'  => boolval($this->auto_submit),
-        ]);
-
-        return $form->__toString();
-    }
-
-    /**
-     * @return array
-     * @throws Exception
-     * @throws \PhpMonsters\Larapay\Adapter\Exception
-     */
-    public function formParams(): array
-    {
-        $authority = $this->requestToken();
-
-        return  [
-            'endPoint'    => strtr($this->getEndPoint(), ['{authority}' => $authority]),
-        ];
     }
 
     public function getSandbox(): string
@@ -123,8 +138,7 @@ public function getSandbox(): string
      */
     protected function verifyTransaction(): bool
     {
-
-        if ($this->getTransaction()->checkForVerify() == false) {
+        if ($this->getTransaction()->checkForVerify() === false) {
             throw new Exception('larapay::larapay.could_not_verify_payment');
         }
 
@@ -134,8 +148,8 @@ protected function verifyTransaction(): bool
         ]);
 
         $sendParams = [
-            'merchant'  => $this->getSandbox(),
-            'trackId'     => $this->trackid,
+            'merchant' => $this->getSandbox(),
+            'trackId' => $this->trackid,
         ];
 
 
@@ -148,7 +162,7 @@ protected function verifyTransaction(): bool
             if (isset($resultObj->result)) {
                 if ($resultObj->result == 100 || $resultObj->result == 201) {
                     $this->getTransaction()->setVerified();
-                    $this->getTransaction()->setReferenceId((string)$this->trackId);
+                    $this->getTransaction()->setReferenceId((string) $this->trackId);
                     return true;
                 } else {
                     throw new Exception($resultObj->result);
@@ -159,28 +173,5 @@ protected function verifyTransaction(): bool
         } catch (\Exception $e) {
             throw new Exception($e->getMessage());
         }
-
-    }
-
-    /**
-     * @return bool
-     */
-    public function canContinueWithCallbackParameters(): bool
-    {
-
-        if ($this->success == 1) {
-            return true;
-        }
-
-        return false;
-    }
-
-    public function getGatewayReferenceId(): string
-    {
-        $test = (array)$this->checkRequiredParameters([
-            'trackid',
-        ]);
-        return strval($this->trackid);
-
     }
 }