From 9127ab8d16bf9570e174e659ae283db3ad9b37df Mon Sep 17 00:00:00 2001 From: Steve <34465153+xxl4@users.noreply.github.com> Date: Fri, 19 Jul 2024 15:48:35 +0800 Subject: [PATCH] add base code for paypal --- README.md | 15 +++ composer.json | 40 +++++++ phpunit.xml | 34 ++++++ src/Config/Paypal.php | 14 +++ src/Config/acl.php | 12 ++ src/Config/menu.php | 21 ++++ src/Console/Commands/Install.php | 38 +++++++ src/Console/Commands/Publish.php | 0 src/Console/Commands/UnInstall.php | 37 +++++++ src/Console/Commands/Upload.php | 0 src/Http/Controllers/Admin/Controller.php | 30 +++++ .../Controllers/Admin/ExampleController.php | 23 ++++ src/Http/Controllers/Api/Controller.php | 19 ++++ .../Controllers/Api/ExampleController.php | 22 ++++ src/Http/Controllers/Web/Controller.php | 19 ++++ .../Controllers/Web/ExampleController.php | 23 ++++ src/Providers/PaypalServiceProvider.php | 103 ++++++++++++++++++ src/Resources/lang/en/app.php | 26 +++++ src/Resources/views/Admin/demo.blade.php | 1 + src/Resources/views/demo.blade.php | 1 + src/Routes/admin.php | 23 ++++ src/Routes/api.php | 23 ++++ src/Routes/web.php | 23 ++++ tests/bootstrap.php | 32 ++++++ 24 files changed, 579 insertions(+) create mode 100644 README.md create mode 100644 composer.json create mode 100644 phpunit.xml create mode 100644 src/Config/Paypal.php create mode 100644 src/Config/acl.php create mode 100644 src/Config/menu.php create mode 100644 src/Console/Commands/Install.php create mode 100644 src/Console/Commands/Publish.php create mode 100644 src/Console/Commands/UnInstall.php create mode 100644 src/Console/Commands/Upload.php create mode 100644 src/Http/Controllers/Admin/Controller.php create mode 100644 src/Http/Controllers/Admin/ExampleController.php create mode 100644 src/Http/Controllers/Api/Controller.php create mode 100644 src/Http/Controllers/Api/ExampleController.php create mode 100644 src/Http/Controllers/Web/Controller.php create mode 100644 src/Http/Controllers/Web/ExampleController.php create mode 100644 src/Providers/PaypalServiceProvider.php create mode 100644 src/Resources/lang/en/app.php create mode 100644 src/Resources/views/Admin/demo.blade.php create mode 100644 src/Resources/views/demo.blade.php create mode 100644 src/Routes/admin.php create mode 100644 src/Routes/api.php create mode 100644 src/Routes/web.php create mode 100644 tests/bootstrap.php diff --git a/README.md b/README.md new file mode 100644 index 0000000..824f502 --- /dev/null +++ b/README.md @@ -0,0 +1,15 @@ +# NexaMerchant/Paypal + +# How to Install + + +``` +NexaMerchant\Paypal\Providers\PaypalServiceProvider::class, +``` +Add it to config/app.php $providers + +# How to Publish + +``` +composer require nexa-merchant/paypal +``` \ No newline at end of file diff --git a/composer.json b/composer.json new file mode 100644 index 0000000..5e7a3a0 --- /dev/null +++ b/composer.json @@ -0,0 +1,40 @@ +{ + "name": "nexa-merchant/paypal", + "license": "MIT", + "type": "library", + "description" : "Paypal Apps", + "authors": [ + { + "name": "Steven", + "email": "nice.lizhi@gmail.com" + } + ], + "require": { + "laravel/framework": "~10.0||~11.0" + }, + "require-dev": { + "phpunit/phpcov": ">=6.0", + "phpunit/phpunit": ">=8.0", + "laravel/framework": "~10.0||~11.0" + }, + "autoload": { + "psr-4": { + "NexaMerchant\\Paypal\\": "src/" + } + }, + "autoload-dev": { + "psr-4": { + "NexaMerchant\\Paypal\\Tests\\": "tests/" + } + }, + "extra": { + "laravel": { + "providers": [ + "NexaMerchant\\Paypal\\Providers\\PaypalServiceProvider" + ], + "aliases": {} + } + }, + "homepage": "https://nexamerchant.github.io/docs/", + "minimum-stability": "dev" +} diff --git a/phpunit.xml b/phpunit.xml new file mode 100644 index 0000000..acb0f9b --- /dev/null +++ b/phpunit.xml @@ -0,0 +1,34 @@ + + + + + tests + + + + + + + + + + ./src/ + + + + + + + + + \ No newline at end of file diff --git a/src/Config/Paypal.php b/src/Config/Paypal.php new file mode 100644 index 0000000..91c21bb --- /dev/null +++ b/src/Config/Paypal.php @@ -0,0 +1,14 @@ + 'Paypal', + 'version' => '1.0.0', + 'versionNum' => '100', +]; \ No newline at end of file diff --git a/src/Config/acl.php b/src/Config/acl.php new file mode 100644 index 0000000..dae220d --- /dev/null +++ b/src/Config/acl.php @@ -0,0 +1,12 @@ + 'Paypal', + 'name' => 'paypal::app.paypal.demo', + 'route' => 'paypal.admin.example.demo', + 'sort' => 1, + 'icon' => 'icon-dashboard', + ] +]; \ No newline at end of file diff --git a/src/Console/Commands/Install.php b/src/Console/Commands/Install.php new file mode 100644 index 0000000..b39cc94 --- /dev/null +++ b/src/Console/Commands/Install.php @@ -0,0 +1,38 @@ +info("Install app: Paypal"); + if (!$this->confirm('Do you wish to continue?')) { + // ... + $this->error("App Paypal Install cannelled"); + return false; + } + } +} \ No newline at end of file diff --git a/src/Console/Commands/Publish.php b/src/Console/Commands/Publish.php new file mode 100644 index 0000000..e69de29 diff --git a/src/Console/Commands/UnInstall.php b/src/Console/Commands/UnInstall.php new file mode 100644 index 0000000..ceea887 --- /dev/null +++ b/src/Console/Commands/UnInstall.php @@ -0,0 +1,37 @@ +confirm('Do you wish to continue?')) { + // ... + $this->error("App Paypal UnInstall cannelled"); + return false; + } + } +} \ No newline at end of file diff --git a/src/Console/Commands/Upload.php b/src/Console/Commands/Upload.php new file mode 100644 index 0000000..e69de29 diff --git a/src/Http/Controllers/Admin/Controller.php b/src/Http/Controllers/Admin/Controller.php new file mode 100644 index 0000000..801fbdb --- /dev/null +++ b/src/Http/Controllers/Admin/Controller.php @@ -0,0 +1,30 @@ +route('admin.session.create'); + } +} diff --git a/src/Http/Controllers/Admin/ExampleController.php b/src/Http/Controllers/Admin/ExampleController.php new file mode 100644 index 0000000..302b78e --- /dev/null +++ b/src/Http/Controllers/Admin/ExampleController.php @@ -0,0 +1,23 @@ +json($data); + } +} diff --git a/src/Http/Controllers/Web/Controller.php b/src/Http/Controllers/Web/Controller.php new file mode 100644 index 0000000..3c5632e --- /dev/null +++ b/src/Http/Controllers/Web/Controller.php @@ -0,0 +1,19 @@ +group(__DIR__ . '/../Routes/web.php'); + Route::middleware('api')->group(__DIR__ . '/../Routes/api.php'); + + $this->loadTranslationsFrom(__DIR__ . '/../Resources/lang', 'Paypal'); + + $this->loadViewsFrom(__DIR__ . '/../Resources/views', 'Paypal'); + + $this->loadMigrationsFrom(__DIR__ . '/../Database/Migrations'); + + + /* + $this->app->register(EventServiceProvider::class); + */ + + if ($this->app->runningInConsole()) { + $this->publishes([ + __DIR__.'/../Resources/views' => $this->app->resourcePath('themes/default/views'), + ], 'Paypal'); + } + + } + + /** + * Register services. + * + * @return void + */ + public function register() + { + $this->registerCommands(); + $this->registerConfig(); + } + + /** + * Register package config. + * + * @return void + */ + protected function registerConfig() + { + + $this->mergeConfigFrom( + dirname(__DIR__) . '/Config/menu.php', 'menu.admin' + ); + + $this->mergeConfigFrom( + dirname(__DIR__) . '/Config/acl.php', + 'acl' + ); + + + $this->mergeConfigFrom( + dirname(__DIR__) . '/Config/Paypal.php', 'Paypal' + ); + + } + + /** + * Register the console commands of this package. + * + * @return void + */ + protected function registerCommands(): void + { + if ($this->app->runningInConsole()) { + $this->commands([ + \NexaMerchant\Paypal\Console\Commands\Install::class, + \NexaMerchant\Paypal\Console\Commands\UnInstall::class, + ]); + } + } +} diff --git a/src/Resources/lang/en/app.php b/src/Resources/lang/en/app.php new file mode 100644 index 0000000..3b01995 --- /dev/null +++ b/src/Resources/lang/en/app.php @@ -0,0 +1,26 @@ + [ + 'Paypal' => [ + 'demo' => 'Paypal Admin Demo', + ], + ], + 'Shop' => [ + 'Paypal' => [ + 'demo' => 'Paypal::app.shop.Paypal.demo', + ], + ], + 'Api' => [ + 'Paypal' => [ + 'demo' => 'Paypal::app.Api.Paypal.demo', + ], + ], +]; \ No newline at end of file diff --git a/src/Resources/views/Admin/demo.blade.php b/src/Resources/views/Admin/demo.blade.php new file mode 100644 index 0000000..ed0e587 --- /dev/null +++ b/src/Resources/views/Admin/demo.blade.php @@ -0,0 +1 @@ +{{$data['message']}} \ No newline at end of file diff --git a/src/Resources/views/demo.blade.php b/src/Resources/views/demo.blade.php new file mode 100644 index 0000000..ed0e587 --- /dev/null +++ b/src/Resources/views/demo.blade.php @@ -0,0 +1 @@ +{{$data['message']}} \ No newline at end of file diff --git a/src/Routes/admin.php b/src/Routes/admin.php new file mode 100644 index 0000000..a26e2e8 --- /dev/null +++ b/src/Routes/admin.php @@ -0,0 +1,23 @@ + ['admin','admin_option_log'], 'prefix' => config('app.admin_url')], function () { + Route::prefix('paypal')->group(function () { + + Route::controller(ExampleController::class)->prefix('example')->group(function () { + + Route::get('demo', 'demo')->name('paypal.admin.example.demo'); + + }); + + }); +}); \ No newline at end of file diff --git a/src/Routes/api.php b/src/Routes/api.php new file mode 100644 index 0000000..3c25177 --- /dev/null +++ b/src/Routes/api.php @@ -0,0 +1,23 @@ + ['api'], 'prefix' => 'api'], function () { + Route::prefix('paypal')->group(function () { + + Route::controller(ExampleController::class)->prefix('example')->group(function () { + + Route::get('demo', 'demo')->name('paypal.api.example.demo'); + + }); + + }); +}); \ No newline at end of file diff --git a/src/Routes/web.php b/src/Routes/web.php new file mode 100644 index 0000000..c718ddf --- /dev/null +++ b/src/Routes/web.php @@ -0,0 +1,23 @@ + ['locale', 'theme', 'currency'], 'prefix'=>'paypal'], function () { + + Route::controller(ExampleController::class)->prefix('example')->group(function () { + + Route::get('demo', 'demo')->name('paypal.web.example.demo'); + + }); + +}); + +include "admin.php"; \ No newline at end of file diff --git a/tests/bootstrap.php b/tests/bootstrap.php new file mode 100644 index 0000000..c26c8b2 --- /dev/null +++ b/tests/bootstrap.php @@ -0,0 +1,32 @@ +