From 0f72e18c444e47795ac723493444f0552d52f624 Mon Sep 17 00:00:00 2001 From: Alpha Olomi Date: Thu, 1 Apr 2021 19:27:35 +0300 Subject: [PATCH] fix: service provider --- composer.json | 4 +- {src/config => config}/laravel-pesa.php | 0 src/Openpesa/Pesa/Pesa.php | 94 ------------------- src/{Openpesa/Pesa => }/PesaFacade.php | 0 .../Pesa => }/PesaServiceProvider.php | 19 ++-- src/{Openpesa/Pesa => }/functions.php | 4 +- 6 files changed, 10 insertions(+), 111 deletions(-) rename {src/config => config}/laravel-pesa.php (100%) delete mode 100644 src/Openpesa/Pesa/Pesa.php rename src/{Openpesa/Pesa => }/PesaFacade.php (100%) rename src/{Openpesa/Pesa => }/PesaServiceProvider.php (71%) rename src/{Openpesa/Pesa => }/functions.php (77%) diff --git a/composer.json b/composer.json index bff1854..1fc35b1 100644 --- a/composer.json +++ b/composer.json @@ -23,7 +23,7 @@ "require": { "php": "^7.1", "illuminate/support": "^7.0|^8.0", - "openpesa/pesa": "dev-develop" + "openpesa/pesa": "dev-main" }, "require-dev": { "phpunit/phpunit": "^7.1", @@ -34,7 +34,7 @@ "Openpesa\\Pesa\\": "src/" }, "files": [ - "src/Openpesa/Pesa/functions.php" + "src/functions.php" ] }, "autoload-dev": { diff --git a/src/config/laravel-pesa.php b/config/laravel-pesa.php similarity index 100% rename from src/config/laravel-pesa.php rename to config/laravel-pesa.php diff --git a/src/Openpesa/Pesa/Pesa.php b/src/Openpesa/Pesa/Pesa.php deleted file mode 100644 index 6791d9c..0000000 --- a/src/Openpesa/Pesa/Pesa.php +++ /dev/null @@ -1,94 +0,0 @@ -pesa = $pesa; - } - - - /** - *{@inheritdoc} - */ - public function get_session() - { - return $this->pesa->get_session(); - } - - /** - * {@inheritdoc} - */ - public function query($data, $session = null) - { - return $this->pesa->query($data, $session); - } - - /** - * {@inheritdoc} - */ - public function c2b($data, $session = null) - { - - return $this->pesa->c2b($data, $session); - } - - /** - *{@inheritdoc} - */ - public function b2c($data, $session = null) - { - - return $this->pesa->b2c($data, $session); - } - - - /** - * {@inheritdoc} - */ - public function b2b($data, $session = null) - { - return $this->pesa->b2b($data, $session); - } - - /** - * {@inheritdoc} - */ - public function reverse($data, $session = null) - { - - return $this->pesa->reverse($data, $session); - } - - /** - * - *{@inheritdoc} - */ - public function debit_create($data, $session = null) - { - - return $this->pesa->debit_create($data, $session); - } - - /** - * {@inheritdoc} - */ - public function debit_payment($data, $session = null) - { - - return $this->pesa->debit_payment($data, $session); - } -} diff --git a/src/Openpesa/Pesa/PesaFacade.php b/src/PesaFacade.php similarity index 100% rename from src/Openpesa/Pesa/PesaFacade.php rename to src/PesaFacade.php diff --git a/src/Openpesa/Pesa/PesaServiceProvider.php b/src/PesaServiceProvider.php similarity index 71% rename from src/Openpesa/Pesa/PesaServiceProvider.php rename to src/PesaServiceProvider.php index bf2e87e..eab51bf 100644 --- a/src/Openpesa/Pesa/PesaServiceProvider.php +++ b/src/PesaServiceProvider.php @@ -3,19 +3,13 @@ namespace Openpesa\Pesa; use Exception; -use Openpesa\SDK\Pesa as PesaSDK; +use Openpesa\SDK\Pesa; use Illuminate\Support\Facades\Config; use Illuminate\Support\ServiceProvider; class PesaServiceProvider extends ServiceProvider { - /** - * Indicates if loading of the provider is deferred. - * - * @var bool - */ - protected $defer = false; - + /** * Register the service provider. * @@ -26,14 +20,16 @@ public function register() $this->app->singleton('pesa', function () { $public_key = Config::get('services.pesa.public_key'); $apikey = Config::get('services.pesa.api_key'); + $env = Config::get('services.pesa.env'); if (is_null($public_key)) throw new Exception("InvalidConfiguration: PUBLIC KEY is required"); if (is_null($apikey)) throw new Exception("InvalidConfiguration: API KEY is required"); - return new Pesa(new PesaSDK([ + return new Pesa([ 'api_key' => $apikey, 'public_key' => $public_key, - ])); + 'env' => $env + ]); }); } @@ -45,8 +41,5 @@ public function register() public function boot() { - $this->publishes([ - __DIR__ . '/../config/laravel-pesa.php' => config_path('laravel-pesa.php'), - ], 'config'); } } diff --git a/src/Openpesa/Pesa/functions.php b/src/functions.php similarity index 77% rename from src/Openpesa/Pesa/functions.php rename to src/functions.php index a55fa72..7bf1756 100644 --- a/src/Openpesa/Pesa/functions.php +++ b/src/functions.php @@ -7,7 +7,7 @@ */ function pesa() { - return app('Pesa'); + return app('pesa'); } -} +} \ No newline at end of file