From 553dc39aa8bbf01e79951cb246fa8f08a7c05199 Mon Sep 17 00:00:00 2001 From: Thomas van der Westen Date: Tue, 24 Dec 2024 13:43:28 +0100 Subject: [PATCH] Refactor codebase to replace 'lunar-api' references with 'dystore' and update related configurations --- .vscode/launch.json | 23 +++++++++++--------- README.md | 4 ++-- routes/api.php | 6 ++--- src/LunarApiMollieAdapterServiceProvider.php | 6 ++--- src/Managers/MollieManager.php | 8 +++---- src/MolliePaymentAdapter.php | 2 +- tests/Pest.php | 2 -- tests/Stubs/Lunar/TestShippingModifier.php | 5 ++++- tests/TestCase.php | 20 +++++++---------- tests/Utils/CartBuilder.php | 1 - 10 files changed, 38 insertions(+), 39 deletions(-) diff --git a/.vscode/launch.json b/.vscode/launch.json index 52ea6e1..e18500b 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -1,12 +1,15 @@ { - "version": "0.2.0", - "configurations": [ - { - "name": "Listen for XDebug on valet", - "type": "php", - "request": "launch", - "port": 9003, - "ignore": ["**/vender/**/*.php", "**/vendor/laravel/pint/**/*.php"] - } - ] + "version": "0.2.0", + "configurations": [ + { + "name": "Listen for XDebug on valet", + "type": "php", + "request": "launch", + "port": 9003, + "log": false, + // "skipFiles": ["**/vendor/**", "phar:/**", "**/bin/pint/**"], + // "skipEntryPaths": ["**/vendor/**", "phar:/**", "**/bin/pint/**"] + "skipEntryPaths": ["**/bin/pint/**"] + } + ] } diff --git a/README.md b/README.md index b521198..f3c47d3 100755 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ # Description -This package is designed to seamlessly integrate Mollie payments into your [Lunar](https://lunarphp.io/) storefront. By leveraging the [Lunar API](https://github.com/dystcz/lunar-api), this adapter makes it easy to accept and manage payments through Mollie, a popular payment service provider. +This package is designed to seamlessly integrate Mollie payments into your [Lunar](https://lunarphp.io/) storefront. By leveraging the [Dystore Lunar API](https://github.com/dystcz/dystore-api), this adapter makes it easy to accept and manage payments through Mollie, a popular payment service provider. Whether you're running an e-commerce platform or a subscription service, this adapter will help you handle payments efficiently and securely. With easy installation and configuration, you can have Mollie payments up and running on your Lunar storefront in no time. @@ -20,7 +20,7 @@ Please follow the installation and configuration instructions in the Installatio This package depends on the following packages: - [Lunar](https://lunarphp.io/) -- [Lunar API](https://github.com/dystcz/lunar-api) +- [Dystore Lunar API](https://github.com/dystcz/dystore-api) ## Features diff --git a/routes/api.php b/routes/api.php index d285879..e8d160e 100644 --- a/routes/api.php +++ b/routes/api.php @@ -5,6 +5,6 @@ use Illuminate\Support\Facades\Route; Route::group([ - 'prefix' => Config::get('lunar-api.general.route_prefix'), - 'middleware' => Config::get('lunar-api.general.route_middleware'), -], fn () => RegisterRoutesFromConfig::run('lunar-api.mollie.domains')); + 'prefix' => Config::get('dystore.general.route_prefix'), + 'middleware' => Config::get('dystore.general.route_middleware'), +], fn () => RegisterRoutesFromConfig::run('dystore.mollie.domains')); diff --git a/src/LunarApiMollieAdapterServiceProvider.php b/src/LunarApiMollieAdapterServiceProvider.php index 55122fd..4586149 100755 --- a/src/LunarApiMollieAdapterServiceProvider.php +++ b/src/LunarApiMollieAdapterServiceProvider.php @@ -20,7 +20,7 @@ class LunarApiMollieAdapterServiceProvider extends ServiceProvider public function register(): void { // Automatically apply the package configuration - $this->mergeConfigFrom(__DIR__.'/../config/mollie.php', 'lunar-api.mollie'); + $this->mergeConfigFrom(__DIR__.'/../config/mollie.php', 'dystore.mollie'); // Register schemas. $this->registerSchemas(); @@ -54,8 +54,8 @@ public function boot(): void // Publish the config file. if ($this->app->runningInConsole()) { $this->publishes([ - __DIR__.'/../config/mollie.php' => config_path('lunar-api/mollie.php'), - ], 'lunar-api.mollie.config'); + __DIR__.'/../config/mollie.php' => config_path('dystore/mollie.php'), + ], 'dystore.mollie.config'); } $this->loadRoutesFrom("{$this->root}/routes/api.php"); diff --git a/src/Managers/MollieManager.php b/src/Managers/MollieManager.php index adcb308..50d1b1e 100644 --- a/src/Managers/MollieManager.php +++ b/src/Managers/MollieManager.php @@ -110,7 +110,7 @@ public static function getWebhookUrl(): string // return a different webhook URL when Testing if (app()->environment('testing')) { - $webhookUrl = Config::get('lunar-api.mollie.webhook_url_testing', null); + $webhookUrl = Config::get('dystore.mollie.webhook_url_testing', null); } if ($webhookUrl === null) { @@ -134,7 +134,7 @@ public static function getWebhookUrl(): string */ public static function getRedirectUrl(Cart $cart): string { - $redirectUrlGeneratorClass = Config::get('lunar-api.mollie.redirect_url_generator'); + $redirectUrlGeneratorClass = Config::get('dystore.mollie.redirect_url_generator'); if (! $redirectUrlGeneratorClass && ! class_exists($redirectUrlGeneratorClass)) { throw new InvalidConfigurationException('Mollie redirect URL generator not set in config'); @@ -158,7 +158,7 @@ public static function getRedirectUrl(Cart $cart): string */ public static function getPaymentDescription(Cart $cart): string { - $paymentDescriptionGeneratorClass = Config::get('lunar-api.mollie.payment_description_generator'); + $paymentDescriptionGeneratorClass = Config::get('dystore.mollie.payment_description_generator'); if (! $paymentDescriptionGeneratorClass && ! class_exists($paymentDescriptionGeneratorClass)) { throw new InvalidConfigurationException('Mollie payment description generator not set in config'); @@ -182,7 +182,7 @@ public static function getPaymentDescription(Cart $cart): string */ public static function getCancelUrl(Cart $cart): string { - $cancelUrlGeneratorClass = Config::get('lunar-api.mollie.cancel_url_generator'); + $cancelUrlGeneratorClass = Config::get('dystore.mollie.cancel_url_generator'); if (! $cancelUrlGeneratorClass && ! class_exists($cancelUrlGeneratorClass)) { throw new InvalidConfigurationException('Mollie cancel URL generator not set in config'); diff --git a/src/MolliePaymentAdapter.php b/src/MolliePaymentAdapter.php index 6af69a9..39ff0fc 100755 --- a/src/MolliePaymentAdapter.php +++ b/src/MolliePaymentAdapter.php @@ -229,7 +229,7 @@ protected function updateTransactionStatus(Transaction $transaction, string $sta */ public static function initMollieManager(): void { - $mollieKey = Config::get('lunar-api.mollie.mollie_key'); + $mollieKey = Config::get('dystore.mollie.mollie_key'); Config::set('mollie.key', $mollieKey); } diff --git a/tests/Pest.php b/tests/Pest.php index 5949c61..9ec4a36 100644 --- a/tests/Pest.php +++ b/tests/Pest.php @@ -11,8 +11,6 @@ | */ -// uses(Tests\TestCase::class)->in('Feature'); - /* |-------------------------------------------------------------------------- | Expectations diff --git a/tests/Stubs/Lunar/TestShippingModifier.php b/tests/Stubs/Lunar/TestShippingModifier.php index 2238f58..4244be5 100644 --- a/tests/Stubs/Lunar/TestShippingModifier.php +++ b/tests/Stubs/Lunar/TestShippingModifier.php @@ -2,6 +2,7 @@ namespace Pixelpillow\LunarApiMollieAdapter\Tests\Stubs\Lunar; +use Closure; use Lunar\Base\ShippingModifier; use Lunar\DataTypes\Price; use Lunar\DataTypes\ShippingOption; @@ -18,7 +19,7 @@ class TestShippingModifier extends ShippingModifier public static string $identifier = 'FFCDEL'; - public function handle(Cart $cart) + public function handle(Cart $cart, Closure $next) { ShippingManifest::addOption( new ShippingOption( @@ -43,6 +44,8 @@ public function handle(Cart $cart) ) ); } + + return $next($cart); } /** diff --git a/tests/TestCase.php b/tests/TestCase.php index cdab2c7..a6f17d8 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -18,6 +18,7 @@ use Lunar\Models\CustomerGroup; use Lunar\Models\Order; use Lunar\Models\TaxClass; +use Orchestra\Testbench\Concerns\WithWorkbench; use Orchestra\Testbench\TestCase as Orchestra; use Pixelpillow\LunarApiMollieAdapter\Tests\Stubs\Lunar\TestShippingModifier; use Pixelpillow\LunarApiMollieAdapter\Tests\Stubs\Lunar\TestTaxDriver; @@ -27,6 +28,7 @@ class TestCase extends Orchestra { use MakesJsonApiRequests; + use WithWorkbench; /** * The order. @@ -110,9 +112,9 @@ protected function getPackageProviders($app): array // Livewire \Livewire\LivewireServiceProvider::class, - // Lunar API - \Dystcz\LunarApi\LunarApiServiceProvider::class, - \Dystcz\LunarApi\JsonApiServiceProvider::class, + // Dystore API + \Dystore\Api\ApiServiceProvider::class, + \Dystore\Api\JsonApiServiceProvider::class, // Lunar API Mollie Adapter \Pixelpillow\LunarApiMollieAdapter\LunarApiMollieAdapterServiceProvider::class, @@ -127,14 +129,9 @@ public function getEnvironmentSetUp($app): void $app->useEnvironmentPath(__DIR__.'/..'); $app->bootstrapWith([LoadEnvironmentVariables::class]); - Config::set('lunar-api.mollie.mollie_key', 'test_G3ys6guxc9Su7VJ2xctR4N4VqvGbQR'); - Config::set('lunar-api.mollie.redirect_url_generator', TestRedirectGenerator::class); - Config::set('lunar-api.mollie.cancel_url_generator', TestRedirectGenerator::class); - - // Config::set('auth.providers.users', [ - // 'driver' => 'eloquent', - // 'model' => User::class, - // ]); + Config::set('dystore.mollie.mollie_key', 'test_G3ys6guxc9Su7VJ2xctR4N4VqvGbQR'); + Config::set('dystore.mollie.redirect_url_generator', TestRedirectGenerator::class); + Config::set('dystore.mollie.cancel_url_generator', TestRedirectGenerator::class); /** * Lunar configuration @@ -150,7 +147,6 @@ public function getEnvironmentSetUp($app): void Config::set('database.connections.sqlite', [ 'driver' => 'sqlite', 'database' => ':memory:', - 'prefix' => '', ]); // Default payment driver diff --git a/tests/Utils/CartBuilder.php b/tests/Utils/CartBuilder.php index 0d1f25e..df3ead6 100755 --- a/tests/Utils/CartBuilder.php +++ b/tests/Utils/CartBuilder.php @@ -60,7 +60,6 @@ public static function build(array $cartParams = []) Price::factory()->create([ 'price' => 100, - 'tier' => 1, 'currency_id' => $currency->id, 'priceable_type' => get_class($purchasable), 'priceable_id' => $purchasable->id,