Skip to content

Commit

Permalink
Merge pull request #5 from openpesa/hotfix/service-provider
Browse files Browse the repository at this point in the history
fix: service provider
  • Loading branch information
alphaolomi authored Apr 1, 2021
2 parents 87c0740 + 0f72e18 commit 7e0f70b
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 111 deletions.
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -34,7 +34,7 @@
"Openpesa\\Pesa\\": "src/"
},
"files": [
"src/Openpesa/Pesa/functions.php"
"src/functions.php"
]
},
"autoload-dev": {
Expand Down
File renamed without changes.
94 changes: 0 additions & 94 deletions src/Openpesa/Pesa/Pesa.php

This file was deleted.

File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand All @@ -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
]);
});
}

Expand All @@ -45,8 +41,5 @@ public function register()
public function boot()
{

$this->publishes([
__DIR__ . '/../config/laravel-pesa.php' => config_path('laravel-pesa.php'),
], 'config');
}
}
4 changes: 2 additions & 2 deletions src/Openpesa/Pesa/functions.php → src/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
*/
function pesa()
{
return app('Pesa');
return app('pesa');
}

}
}

0 comments on commit 7e0f70b

Please sign in to comment.