Skip to content

Commit

Permalink
Add console command to install PayPal JS SDK.
Browse files Browse the repository at this point in the history
Signed-off-by: Raza Mehdi <[email protected]>
  • Loading branch information
srmklive committed Jun 24, 2024
1 parent 9faa4b5 commit bf1973f
Show file tree
Hide file tree
Showing 6 changed files with 59 additions and 63 deletions.
2 changes: 2 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
"php": "^8.1",
"ext-curl": "*",
"guzzlehttp/guzzle": "~7.0",
"illuminate/console": "~6.0|~7.0|~8.0|~9.0|^10.0|^11.0",
"illuminate/process": "~6.0|~7.0|~8.0|~9.0|^10.0|^11.0",
"illuminate/support": "~6.0|~7.0|~8.0|~9.0|^10.0|^11.0",
"nesbot/carbon": "~2.0|^3.0"
},
Expand Down
1 change: 1 addition & 0 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
<file>src/PayPalFacadeAccessor.php</file>
<file>src/Traits/PayPalVerifyIPN.php</file>
<file>src/Services/Str.php</file>
<directory suffix=".php">src/Commands/</directory>
<directory suffix=".php">src/Facades/</directory>
<directory suffix=".php">src/Providers/</directory>
</exclude>
Expand Down
35 changes: 0 additions & 35 deletions phpunit.xml.dist.php72

This file was deleted.

28 changes: 0 additions & 28 deletions phpunit.xml.dist.php8

This file was deleted.

40 changes: 40 additions & 0 deletions src/Commands/PublishAssetsCommand.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?php

namespace Srmklive\PayPal\Commands;

use Illuminate\Console\Command;
use Illuminate\Support\Facades\Process;

class PublishAssetsCommand extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'paypal:install';

/**
* The console command description.
*
* @var string
*/
protected $description = 'Install the PayPal JS SDK and related code detailing the API implementation';

/**
* Execute the console command.
*/
public function handle(): void
{
$this->comment("Installing the PayPal JS SDK through npm");

$result = Process::run("npm install --save @paypal/paypal-js");
if ($result->successful()) {
echo $result->output();
$this->comment("Installed the PayPal JS SDK.");
} else {
echo $result->errorOutput();
$this->error("Unable to install the PayPal JS SDK.");
}
}
}
16 changes: 16 additions & 0 deletions src/Providers/PayPalServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
*/

use Illuminate\Support\ServiceProvider;
use Srmklive\PayPal\Commands\PublishAssetsCommand;
use Srmklive\PayPal\Services\PayPal as PayPalClient;

class PayPalServiceProvider extends ServiceProvider
Expand All @@ -33,6 +34,9 @@ public function boot(): void

// Publish Lang Files
$this->loadTranslationsFrom(__DIR__.'/../../lang', 'paypal');

// Register artisan commands.
$this->registerCommands();
}

/**
Expand Down Expand Up @@ -71,4 +75,16 @@ private function mergeConfig(): void
'paypal'
);
}

/**
* Register the console .
*
* @return void
*/
private function registerCommands(): void
{
$this->commands([
PublishAssetsCommand::class
]);
}
}

0 comments on commit bf1973f

Please sign in to comment.