From bf4cddf35a96e181c3387c7137356670849f7263 Mon Sep 17 00:00:00 2001 From: RTLer Date: Thu, 26 Oct 2017 13:44:08 +0330 Subject: [PATCH] remove soap derivers --- composer.json | 5 +- phpunit.xml | 2 - src/Drivers/NuSoapDriver.php | 133 ----------------------------------- src/Drivers/SoapDriver.php | 92 ------------------------ test/NuSoapTestCase.php | 43 ----------- test/RestTestCase.php | 2 +- test/SoapTestCase.php | 43 ----------- 7 files changed, 3 insertions(+), 317 deletions(-) delete mode 100644 src/Drivers/NuSoapDriver.php delete mode 100644 src/Drivers/SoapDriver.php delete mode 100644 test/NuSoapTestCase.php delete mode 100644 test/SoapTestCase.php diff --git a/composer.json b/composer.json index c2fdfdc..92584e3 100644 --- a/composer.json +++ b/composer.json @@ -10,11 +10,10 @@ ], "minimum-stability": "stable", "require": { - "guzzlehttp/guzzle": "^6.2", - "deviservi/nusoap": "^1.1" + "guzzlehttp/guzzle": "^6.2" }, "require-dev": { - "phpunit/phpunit": "5.3.*", + "phpunit/phpunit": "6.3.*", "satooshi/php-coveralls": "^1.0" }, "autoload": { diff --git a/phpunit.xml b/phpunit.xml index 8d4bbec..16bf6af 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -2,8 +2,6 @@ ./test/RestTestCase.php - ./test/SoapTestCase.php - ./test/NuSoapTestCase.php diff --git a/src/Drivers/NuSoapDriver.php b/src/Drivers/NuSoapDriver.php deleted file mode 100644 index 91a71f4..0000000 --- a/src/Drivers/NuSoapDriver.php +++ /dev/null @@ -1,133 +0,0 @@ -client = new \nusoap_client($this->wsdlAddress, 'wsdl'); - } - - /** - * request driver. - * - * @param $inputs - * - * @return array - */ - public function request($inputs) - { - $this->client->soap_defencoding = 'UTF-8'; - $result = $this->client->call('PaymentRequest', [$inputs]); - if ($result['Status'] == 100) { - return ['Authority' => $result['Authority']]; - } else { - return ['error' => $result['Status']]; - } - } - - /** - * request driver. - * - * @param $inputs - * - * @return array - */ - public function requestWithExtra($inputs) - { - $this->client->soap_defencoding = 'UTF-8'; - $result = $this->client->call('PaymentRequestWithExtra', [$inputs]); - if ($result['Status'] == 100) { - return ['Authority' => $result['Authority']]; - } else { - return ['error' => $result['Status']]; - } - } - - /** - * verify driver. - * - * @param $inputs - * - * @return array - */ - public function verify($inputs) - { - $this->client->soap_defencoding = 'UTF-8'; - $result = $this->client->call('PaymentVerification', [$inputs]); - - if ($result['Status'] == 100) { - return ['Status' => 'success', 'RefID' => $result['RefID']]; - } else { - return ['Status' => 'error', 'error' => $result['Status']]; - } - } - - /** - * verify driver. - * - * @param $inputs - * - * @return array - */ - public function verifyWithExtra($inputs) - { - $this->client->soap_defencoding = 'UTF-8'; - $result = $this->client->call('PaymentVerificationWithExtra', [$inputs]); - if ($result['Status'] == 100) { - return ['Authority' => $result['Authority']]; - } else { - return ['error' => $result['Status']]; - } - } - - /** - * verify driver. - * - * @param $inputs - * - * @return array - */ - public function unverifiedTransactions($inputs) - { - $this->client->soap_defencoding = 'UTF-8'; - $result = $this->client->call('UnverifiedTransactions', [$inputs]); - if ($result['Status'] == 100) { - return ['Authority' => $result['Authority']]; - } else { - return ['error' => $result['Status']]; - } - } - - /** - * verify driver. - * - * @param $inputs - * - * @return array - */ - public function refreshAuthority($inputs) - { - $this->client->soap_defencoding = 'UTF-8'; - $result = $this->client->call('RefreshAuthority', [$inputs]); - if ($result['Status'] == 100) { - return ['Authority' => $result['Authority']]; - } else { - return ['error' => $result['Status']]; - } - } - - /** - * @param mixed $wsdlAddress - */ - public function setAddress($wsdlAddress) - { - $this->wsdlAddress = $wsdlAddress; - $this->client = new \nusoap_client($this->wsdlAddress, 'wsdl'); - } -} diff --git a/src/Drivers/SoapDriver.php b/src/Drivers/SoapDriver.php deleted file mode 100644 index c5dda29..0000000 --- a/src/Drivers/SoapDriver.php +++ /dev/null @@ -1,92 +0,0 @@ -wsdlAddress, ['encoding' => 'UTF-8']); - $result = $client->PaymentRequest($inputs); - if ($result->Status == 100) { - return ['Authority' => $result->Authority]; - } else { - return ['error' => $result->Status]; - } - } - - /** - * request driver. - * - * @param $inputs - * - * @return array - */ - public function requestWithExtra($inputs) - { - $client = new \SoapClient($this->wsdlAddress, ['encoding' => 'UTF-8']); - $result = $client->PaymentRequestWithExtra($inputs); - if ($result->Status == 100) { - return ['Authority' => $result->Authority]; - } else { - return ['error' => $result->Status]; - } - } - - /** - * verify driver. - * - * @param $inputs - * - * @return array - */ - public function verify($inputs) - { - $client = new \SoapClient($this->wsdlAddress, ['encoding' => 'UTF-8']); - $result = $client->PaymentVerification($inputs); - - if ($result->Status == 100) { - return ['Status' => 'success', 'RefID' => $result->RefID]; - } else { - return ['Status' => 'error', 'error' => $result->Status]; - } - } - - /** - * verify driver. - * - * @param $inputs - * - * @return array - */ - public function verifyWithExtra($inputs) - { - $client = new \SoapClient($this->wsdlAddress, ['encoding' => 'UTF-8']); - $result = $client->PaymentVerificationWithExtra($inputs); - - if ($result->Status == 100) { - return ['Status' => 'success', 'RefID' => $result->RefID]; - } else { - return ['Status' => 'error', 'error' => $result->Status]; - } - } - - /** - * @param mixed $wsdlAddress - * - * @return void - */ - public function setAddress($wsdlAddress) - { - $this->wsdlAddress = $wsdlAddress; - } -} diff --git a/test/NuSoapTestCase.php b/test/NuSoapTestCase.php deleted file mode 100644 index 7ce1de6..0000000 --- a/test/NuSoapTestCase.php +++ /dev/null @@ -1,43 +0,0 @@ -zarinpal = new Zarinpal('XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX', $restDriver); - $this->zarinpal->getDriver()->setAddress('https://sandbox.zarinpal.com/pg/services/WebGate/wsdl'); - - parent::__construct($name, $data, $dataName); - } - - public function testCorrectRequest() - { - $answer = $this->zarinpal->request('http://www.example.com/testVerify.php', 1000, 'testing'); - $this->assertEquals(strlen($answer['Authority']), 36); - - // try and mock pay form - try { - $client = new Client(); - $response = $client->request( - 'POST', - 'https://sandbox.zarinpal.com/pg/transaction/pay/'.$answer['Authority'], - [ - 'form_params' => [ - 'ok' => 'ok', - ], - ]); - } catch (Exception $e) { - } - - $answer = $this->zarinpal->verify('OK', 1000, $answer['Authority']); - $this->assertEquals($answer['Status'], 'success'); - $this->assertEquals(strlen($answer['Status']), 7); - } -} diff --git a/test/RestTestCase.php b/test/RestTestCase.php index 3d15488..c2e24af 100644 --- a/test/RestTestCase.php +++ b/test/RestTestCase.php @@ -3,7 +3,7 @@ use GuzzleHttp\Client; use Zarinpal\Zarinpal; -class RestTestCase extends PHPUnit_Framework_TestCase +class RestTestCase extends \PHPUnit\Framework\TestCase { private $zarinpal; diff --git a/test/SoapTestCase.php b/test/SoapTestCase.php deleted file mode 100644 index cfa220f..0000000 --- a/test/SoapTestCase.php +++ /dev/null @@ -1,43 +0,0 @@ -zarinpal = new Zarinpal('XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX', $restDriver); - $this->zarinpal->getDriver()->setAddress('https://sandbox.zarinpal.com/pg/services/WebGate/wsdl'); - - parent::__construct($name, $data, $dataName); - } - - public function testCorrectRequest() - { - $answer = $this->zarinpal->request('http://www.example.com/testVerify.php', 1000, 'testing'); - $this->assertEquals(strlen($answer['Authority']), 36); - - // try and mock pay form - try { - $client = new Client(); - $response = $client->request( - 'POST', - 'https://sandbox.zarinpal.com/pg/transaction/pay/'.$answer['Authority'], - [ - 'form_params' => [ - 'ok' => 'ok', - ], - ]); - } catch (Exception $e) { - } - - $answer = $this->zarinpal->verify('OK', 1000, $answer['Authority']); - $this->assertEquals($answer['Status'], 'success'); - $this->assertEquals(strlen($answer['Status']), 7); - } -}