@@ -58,8 +58,8 @@ |
||
| 58 | 58 | } |
| 59 | 59 | |
| 60 | 60 | /** |
| 61 | - * @return \tbclla\Revolut\Builders\PaymentDraftBuilder |
|
| 62 | - */ |
|
| 61 | + * @return \tbclla\Revolut\Builders\PaymentDraftBuilder |
|
| 62 | + */ |
|
| 63 | 63 | public function build() |
| 64 | 64 | { |
| 65 | 65 | return new PaymentDraftBuilder($this); |
@@ -6,30 +6,30 @@ |
||
| 6 | 6 | |
| 7 | 7 | class CreateRevolutTokensTable extends Migration |
| 8 | 8 | { |
| 9 | - /** |
|
| 10 | - * Run the migrations. |
|
| 11 | - * |
|
| 12 | - * @return void |
|
| 13 | - */ |
|
| 14 | - public function up() |
|
| 15 | - { |
|
| 16 | - Schema::create(config('revolut.tokens_table'), function(Blueprint $table) { |
|
| 9 | + /** |
|
| 10 | + * Run the migrations. |
|
| 11 | + * |
|
| 12 | + * @return void |
|
| 13 | + */ |
|
| 14 | + public function up() |
|
| 15 | + { |
|
| 16 | + Schema::create(config('revolut.tokens_table'), function(Blueprint $table) { |
|
| 17 | 17 | $table->bigIncrements('id'); |
| 18 | 18 | $table->string('type'); |
| 19 | - $table->mediumText('value'); |
|
| 20 | - $table->boolean('is_encrypted')->default(false); |
|
| 19 | + $table->mediumText('value'); |
|
| 20 | + $table->boolean('is_encrypted')->default(false); |
|
| 21 | 21 | $table->timestamp('expires_at')->nullable(); |
| 22 | - $table->timestamp('created_at')->useCurrent(); |
|
| 23 | - }); |
|
| 24 | - } |
|
| 22 | + $table->timestamp('created_at')->useCurrent(); |
|
| 23 | + }); |
|
| 24 | + } |
|
| 25 | 25 | |
| 26 | - /** |
|
| 27 | - * Reverse the migrations. |
|
| 28 | - * |
|
| 29 | - * @return void |
|
| 30 | - */ |
|
| 31 | - public function down() |
|
| 32 | - { |
|
| 33 | - Schema::dropIfExists(config('revolut.tokens_table')); |
|
| 34 | - } |
|
| 26 | + /** |
|
| 27 | + * Reverse the migrations. |
|
| 28 | + * |
|
| 29 | + * @return void |
|
| 30 | + */ |
|
| 31 | + public function down() |
|
| 32 | + { |
|
| 33 | + Schema::dropIfExists(config('revolut.tokens_table')); |
|
| 34 | + } |
|
| 35 | 35 | } |
@@ -16,58 +16,58 @@ |
||
| 16 | 16 | |
| 17 | 17 | class RevolutServiceProvider extends ServiceProvider |
| 18 | 18 | { |
| 19 | - /** |
|
| 20 | - * Register services. |
|
| 21 | - * |
|
| 22 | - * @return void |
|
| 23 | - */ |
|
| 24 | - public function register() |
|
| 25 | - { |
|
| 26 | - $this->app->bind(MakesHttpRequests::class, GuzzleHttpClient::class); |
|
| 19 | + /** |
|
| 20 | + * Register services. |
|
| 21 | + * |
|
| 22 | + * @return void |
|
| 23 | + */ |
|
| 24 | + public function register() |
|
| 25 | + { |
|
| 26 | + $this->app->bind(MakesHttpRequests::class, GuzzleHttpClient::class); |
|
| 27 | 27 | |
| 28 | - $this->app->bind(ClientAssertion::class, function() { |
|
| 29 | - return new ClientAssertion( |
|
| 30 | - config('revolut.client_id'), |
|
| 31 | - config('revolut.private_key'), |
|
| 32 | - config('revolut.redirect_uri') |
|
| 33 | - ); |
|
| 34 | - }); |
|
| 28 | + $this->app->bind(ClientAssertion::class, function() { |
|
| 29 | + return new ClientAssertion( |
|
| 30 | + config('revolut.client_id'), |
|
| 31 | + config('revolut.private_key'), |
|
| 32 | + config('revolut.redirect_uri') |
|
| 33 | + ); |
|
| 34 | + }); |
|
| 35 | 35 | |
| 36 | - $this->app->bind(AuthorizationCodeRequest::class, function() { |
|
| 37 | - return new AuthorizationCodeRequest( |
|
| 38 | - config('revolut.client_id'), |
|
| 39 | - config('revolut.redirect_uri'), |
|
| 40 | - config('revolut.sandbox') |
|
| 41 | - ); |
|
| 42 | - }); |
|
| 36 | + $this->app->bind(AuthorizationCodeRequest::class, function() { |
|
| 37 | + return new AuthorizationCodeRequest( |
|
| 38 | + config('revolut.client_id'), |
|
| 39 | + config('revolut.redirect_uri'), |
|
| 40 | + config('revolut.sandbox') |
|
| 41 | + ); |
|
| 42 | + }); |
|
| 43 | 43 | |
| 44 | - $this->app->singleton('revolut', function() { |
|
| 45 | - return resolve(Client::class); |
|
| 46 | - }); |
|
| 47 | - } |
|
| 44 | + $this->app->singleton('revolut', function() { |
|
| 45 | + return resolve(Client::class); |
|
| 46 | + }); |
|
| 47 | + } |
|
| 48 | 48 | |
| 49 | - /** |
|
| 50 | - * Bootstrap services. |
|
| 51 | - * |
|
| 52 | - * @return void |
|
| 53 | - */ |
|
| 54 | - public function boot() |
|
| 55 | - { |
|
| 56 | - $this->publishes([ |
|
| 57 | - __DIR__ . '/../config/revolut.php' => config_path('revolut.php') |
|
| 58 | - ]); |
|
| 49 | + /** |
|
| 50 | + * Bootstrap services. |
|
| 51 | + * |
|
| 52 | + * @return void |
|
| 53 | + */ |
|
| 54 | + public function boot() |
|
| 55 | + { |
|
| 56 | + $this->publishes([ |
|
| 57 | + __DIR__ . '/../config/revolut.php' => config_path('revolut.php') |
|
| 58 | + ]); |
|
| 59 | 59 | |
| 60 | - $this->loadMigrationsFrom(__DIR__ . '/../database/migrations'); |
|
| 60 | + $this->loadMigrationsFrom(__DIR__ . '/../database/migrations'); |
|
| 61 | 61 | |
| 62 | - $this->loadRoutesFrom(__DIR__ . '/../routes/web.php'); |
|
| 62 | + $this->loadRoutesFrom(__DIR__ . '/../routes/web.php'); |
|
| 63 | 63 | |
| 64 | - if ($this->app->runningInConsole()) { |
|
| 65 | - $this->commands([ |
|
| 66 | - JWTCommand::class, |
|
| 67 | - CleanupCommand::class, |
|
| 68 | - ResetCommand::class, |
|
| 69 | - AuthorizeCommand::class, |
|
| 70 | - ]); |
|
| 71 | - } |
|
| 72 | - } |
|
| 64 | + if ($this->app->runningInConsole()) { |
|
| 65 | + $this->commands([ |
|
| 66 | + JWTCommand::class, |
|
| 67 | + CleanupCommand::class, |
|
| 68 | + ResetCommand::class, |
|
| 69 | + AuthorizeCommand::class, |
|
| 70 | + ]); |
|
| 71 | + } |
|
| 72 | + } |
|
| 73 | 73 | } |
@@ -14,11 +14,11 @@ |
||
| 14 | 14 | |
| 15 | 15 | Route::group(['namespace' => 'tbclla\Revolut\Controllers', 'middleware' => ['web']], function() { |
| 16 | 16 | |
| 17 | - $route = parse_url(config('revolut.redirect_uri'))['path']; |
|
| 17 | + $route = parse_url(config('revolut.redirect_uri'))['path']; |
|
| 18 | 18 | |
| 19 | - Route::get($route . '/create', 'AuthorizationController@create') |
|
| 20 | - ->middleware(config('revolut.auth_route.middleware')) |
|
| 21 | - ->name(config('revolut.auth_route.name')); |
|
| 19 | + Route::get($route . '/create', 'AuthorizationController@create') |
|
| 20 | + ->middleware(config('revolut.auth_route.middleware')) |
|
| 21 | + ->name(config('revolut.auth_route.name')); |
|
| 22 | 22 | |
| 23 | - Route::get($route, 'AuthorizationController@store'); |
|
| 23 | + Route::get($route, 'AuthorizationController@store'); |
|
| 24 | 24 | }); |
@@ -10,74 +10,74 @@ |
||
| 10 | 10 | |
| 11 | 11 | class JWTCommand extends Command |
| 12 | 12 | { |
| 13 | - /** |
|
| 14 | - * The name and signature of the console command. |
|
| 15 | - * |
|
| 16 | - * @var string |
|
| 17 | - */ |
|
| 18 | - protected $signature = 'revolut:jwt {--public= : The path to your public key}'; |
|
| 13 | + /** |
|
| 14 | + * The name and signature of the console command. |
|
| 15 | + * |
|
| 16 | + * @var string |
|
| 17 | + */ |
|
| 18 | + protected $signature = 'revolut:jwt {--public= : The path to your public key}'; |
|
| 19 | 19 | |
| 20 | - /** |
|
| 21 | - * The console command description. |
|
| 22 | - * |
|
| 23 | - * @var string |
|
| 24 | - */ |
|
| 25 | - protected $description = "Generate a JSON Web Token for Revolut's Oauth process."; |
|
| 20 | + /** |
|
| 21 | + * The console command description. |
|
| 22 | + * |
|
| 23 | + * @var string |
|
| 24 | + */ |
|
| 25 | + protected $description = "Generate a JSON Web Token for Revolut's Oauth process."; |
|
| 26 | 26 | |
| 27 | - /** |
|
| 28 | - * Execute the console command. |
|
| 29 | - * |
|
| 30 | - * @return mixed |
|
| 31 | - */ |
|
| 32 | - public function handle() |
|
| 33 | - { |
|
| 34 | - // build the JWT |
|
| 35 | - $jwt = $this->buildJWT(); |
|
| 27 | + /** |
|
| 28 | + * Execute the console command. |
|
| 29 | + * |
|
| 30 | + * @return mixed |
|
| 31 | + */ |
|
| 32 | + public function handle() |
|
| 33 | + { |
|
| 34 | + // build the JWT |
|
| 35 | + $jwt = $this->buildJWT(); |
|
| 36 | 36 | |
| 37 | - $this->info('Your JSON web token was created successfully:'); |
|
| 38 | - $this->info('<fg=black;bg=yellow>' . $jwt . '</>'); |
|
| 37 | + $this->info('Your JSON web token was created successfully:'); |
|
| 38 | + $this->info('<fg=black;bg=yellow>' . $jwt . '</>'); |
|
| 39 | 39 | |
| 40 | - // optionally, verify the key |
|
| 41 | - $key = $this->checkPublicKey($this->option('public') ?? null); |
|
| 40 | + // optionally, verify the key |
|
| 41 | + $key = $this->checkPublicKey($this->option('public') ?? null); |
|
| 42 | 42 | |
| 43 | - $decoded = JWT::decode($jwt, $key, [ClientAssertion::ALGORYTHM]); |
|
| 43 | + $decoded = JWT::decode($jwt, $key, [ClientAssertion::ALGORYTHM]); |
|
| 44 | 44 | |
| 45 | - $headers = ['parameter', 'value']; |
|
| 46 | - $data = [ |
|
| 47 | - ['issuer', $decoded->iss], |
|
| 48 | - ['subject', $decoded->sub], |
|
| 49 | - ['expiry', $decoded->exp], |
|
| 50 | - ['audience', $decoded->aud], |
|
| 51 | - ]; |
|
| 45 | + $headers = ['parameter', 'value']; |
|
| 46 | + $data = [ |
|
| 47 | + ['issuer', $decoded->iss], |
|
| 48 | + ['subject', $decoded->sub], |
|
| 49 | + ['expiry', $decoded->exp], |
|
| 50 | + ['audience', $decoded->aud], |
|
| 51 | + ]; |
|
| 52 | 52 | |
| 53 | - $this->info('Your JWT has been verified and is valid.'); |
|
| 54 | - $this->table($headers, $data); |
|
| 55 | - } |
|
| 53 | + $this->info('Your JWT has been verified and is valid.'); |
|
| 54 | + $this->table($headers, $data); |
|
| 55 | + } |
|
| 56 | 56 | |
| 57 | - /** |
|
| 58 | - * @return string |
|
| 59 | - */ |
|
| 60 | - private function buildJWT() |
|
| 61 | - { |
|
| 62 | - try { |
|
| 63 | - $clientAssertion = resolve(ClientAssertion::class); |
|
| 64 | - return $clientAssertion->build(); |
|
| 65 | - } catch (ConfigurationException $e) { |
|
| 66 | - $this->error($e->getMessage()); |
|
| 67 | - return; |
|
| 68 | - } |
|
| 69 | - } |
|
| 57 | + /** |
|
| 58 | + * @return string |
|
| 59 | + */ |
|
| 60 | + private function buildJWT() |
|
| 61 | + { |
|
| 62 | + try { |
|
| 63 | + $clientAssertion = resolve(ClientAssertion::class); |
|
| 64 | + return $clientAssertion->build(); |
|
| 65 | + } catch (ConfigurationException $e) { |
|
| 66 | + $this->error($e->getMessage()); |
|
| 67 | + return; |
|
| 68 | + } |
|
| 69 | + } |
|
| 70 | 70 | |
| 71 | - /** |
|
| 72 | - * @return string |
|
| 73 | - */ |
|
| 74 | - private function checkPublicKey($key = null) |
|
| 75 | - { |
|
| 76 | - try { |
|
| 77 | - return file_get_contents($key ?? $this->ask('If you want to validate this JWT, enter the path to your public key')); |
|
| 78 | - } catch (Exception $e) { |
|
| 79 | - $this->error($e->getMessage()); |
|
| 80 | - return $this->checkPublicKey(); |
|
| 81 | - } |
|
| 82 | - } |
|
| 71 | + /** |
|
| 72 | + * @return string |
|
| 73 | + */ |
|
| 74 | + private function checkPublicKey($key = null) |
|
| 75 | + { |
|
| 76 | + try { |
|
| 77 | + return file_get_contents($key ?? $this->ask('If you want to validate this JWT, enter the path to your public key')); |
|
| 78 | + } catch (Exception $e) { |
|
| 79 | + $this->error($e->getMessage()); |
|
| 80 | + return $this->checkPublicKey(); |
|
| 81 | + } |
|
| 82 | + } |
|
| 83 | 83 | } |
@@ -2,7 +2,7 @@ discard block |
||
| 2 | 2 | |
| 3 | 3 | return [ |
| 4 | 4 | |
| 5 | - /* |
|
| 5 | + /* |
|
| 6 | 6 | |-------------------------------------------------------------------------- |
| 7 | 7 | | Environment |
| 8 | 8 | |-------------------------------------------------------------------------- |
@@ -11,9 +11,9 @@ discard block |
||
| 11 | 11 | | Default is true. |
| 12 | 12 | | |
| 13 | 13 | */ |
| 14 | - 'sandbox' => env('REVOLUT_SANDBOX', true), |
|
| 14 | + 'sandbox' => env('REVOLUT_SANDBOX', true), |
|
| 15 | 15 | |
| 16 | - /* |
|
| 16 | + /* |
|
| 17 | 17 | |-------------------------------------------------------------------------- |
| 18 | 18 | | Private Key Path |
| 19 | 19 | |-------------------------------------------------------------------------- |
@@ -23,9 +23,9 @@ discard block |
||
| 23 | 23 | | authorization process. |
| 24 | 24 | | |
| 25 | 25 | */ |
| 26 | - 'private_key' => env('REVOLUT_PRIVATE_KEY'), |
|
| 26 | + 'private_key' => env('REVOLUT_PRIVATE_KEY'), |
|
| 27 | 27 | |
| 28 | - /* |
|
| 28 | + /* |
|
| 29 | 29 | |-------------------------------------------------------------------------- |
| 30 | 30 | | Client ID |
| 31 | 31 | |-------------------------------------------------------------------------- |
@@ -35,9 +35,9 @@ discard block |
||
| 35 | 35 | | selecting the relevant API certificate. |
| 36 | 36 | | |
| 37 | 37 | */ |
| 38 | - 'client_id' => env('REVOLUT_CLIENT_ID'), |
|
| 38 | + 'client_id' => env('REVOLUT_CLIENT_ID'), |
|
| 39 | 39 | |
| 40 | - /* |
|
| 40 | + /* |
|
| 41 | 41 | |-------------------------------------------------------------------------- |
| 42 | 42 | | Oauth Redirect URI |
| 43 | 43 | |-------------------------------------------------------------------------- |
@@ -49,9 +49,9 @@ discard block |
||
| 49 | 49 | | necessary route and controllers. |
| 50 | 50 | | |
| 51 | 51 | */ |
| 52 | - 'redirect_uri' => env('REVOLUT_REDIRECT_URI'), |
|
| 52 | + 'redirect_uri' => env('REVOLUT_REDIRECT_URI'), |
|
| 53 | 53 | |
| 54 | - /* |
|
| 54 | + /* |
|
| 55 | 55 | |-------------------------------------------------------------------------- |
| 56 | 56 | | Encryption |
| 57 | 57 | |-------------------------------------------------------------------------- |
@@ -61,9 +61,9 @@ discard block |
||
| 61 | 61 | | production environment |
| 62 | 62 | | |
| 63 | 63 | */ |
| 64 | - 'encrypt_tokens' => true, |
|
| 64 | + 'encrypt_tokens' => true, |
|
| 65 | 65 | |
| 66 | - /* |
|
| 66 | + /* |
|
| 67 | 67 | |-------------------------------------------------------------------------- |
| 68 | 68 | | Tokens table |
| 69 | 69 | |-------------------------------------------------------------------------- |
@@ -71,9 +71,9 @@ discard block |
||
| 71 | 71 | | Set the name of the table that will hold your Revolut tokens. |
| 72 | 72 | | |
| 73 | 73 | */ |
| 74 | - 'tokens_table' => 'revolut_tokens', |
|
| 74 | + 'tokens_table' => 'revolut_tokens', |
|
| 75 | 75 | |
| 76 | - /* |
|
| 76 | + /* |
|
| 77 | 77 | |-------------------------------------------------------------------------- |
| 78 | 78 | | Authorization Route |
| 79 | 79 | |-------------------------------------------------------------------------- |
@@ -88,16 +88,16 @@ discard block |
||
| 88 | 88 | | prevent unauthorized persons from initiating the Oauth flow. |
| 89 | 89 | | |
| 90 | 90 | */ |
| 91 | - 'auth_route' => [ |
|
| 91 | + 'auth_route' => [ |
|
| 92 | 92 | |
| 93 | - 'name' => 'revolut-authorization', |
|
| 93 | + 'name' => 'revolut-authorization', |
|
| 94 | 94 | |
| 95 | - /** |
|
| 96 | - * The 'web' middleware is required for sessions to work reliably, as such |
|
| 97 | - * it is set automatically and does not need to be specified. |
|
| 98 | - */ |
|
| 99 | - 'middleware' => [ |
|
| 100 | - // 'auth' |
|
| 101 | - ] |
|
| 102 | - ], |
|
| 95 | + /** |
|
| 96 | + * The 'web' middleware is required for sessions to work reliably, as such |
|
| 97 | + * it is set automatically and does not need to be specified. |
|
| 98 | + */ |
|
| 99 | + 'middleware' => [ |
|
| 100 | + // 'auth' |
|
| 101 | + ] |
|
| 102 | + ], |
|
| 103 | 103 | ]; |