Skip to content

Commit

Permalink
Load and use middleware for posting payments
Browse files Browse the repository at this point in the history
  • Loading branch information
bryceandy committed Jun 18, 2020
1 parent 588ff39 commit ae19076
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
8 changes: 8 additions & 0 deletions src/PesapalServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@

namespace Bryceandy\Laravel_Pesapal;

use Bryceandy\Laravel_Pesapal\Http\Middleware\ValidateConfigMiddleware;
use Bryceandy\Laravel_Pesapal\OAuth\OAuthSignatureMethod_HMAC_SHA1;
use Illuminate\Contracts\Container\BindingResolutionException;
use Illuminate\Routing\Router;
use Illuminate\Support\ServiceProvider;

class PesapalServiceProvider extends ServiceProvider
Expand All @@ -11,6 +14,7 @@ class PesapalServiceProvider extends ServiceProvider
* Bootstrap any application services.
*
* @return void
* @throws BindingResolutionException
*/
public function boot()
{
Expand All @@ -21,6 +25,10 @@ public function boot()
], 'pesapal-config');
}

// Load middleware alias
$router = $this->app->make(Router::class);
$router->aliasMiddleware('config', ValidateConfigMiddleware::class);
// Resources
$this->loadResources();
}

Expand Down
4 changes: 3 additions & 1 deletion src/routes/web.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,7 @@

Route::group(['namespace' => 'Bryceandy\Laravel_Pesapal\Http\Controllers'], function(){

Route::post('pesapal/iframe', 'PaymentController@store')->name('payment.store');
Route::post('pesapal/iframe', 'PaymentController@store')
->name('payment.store')
->middleware('config');
});
2 changes: 1 addition & 1 deletion tests/Feature/PaymentControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class PaymentControllerTest extends TestCase
{
/**
* Mocked Config
*
*
* @param Application $app
*/
protected function getEnvironmentSetUp($app)
Expand Down

0 comments on commit ae19076

Please sign in to comment.