From 5b44df24abd1f744d9884e36815cf238f1bf4b40 Mon Sep 17 00:00:00 2001 From: IceToast Date: Mon, 27 Mar 2023 20:48:14 +0200 Subject: [PATCH] =?UTF-8?q?fix:=20=F0=9F=90=9B=20Mollie=20gateway=20route?= =?UTF-8?q?=20and=20settings?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Mollie/MollieExtension.php | 8 ++++---- .../PaymentGateways/Mollie/MollieSettings.php | 9 +++++++-- .../PaymentGateways/Mollie/web_routes.php | 9 +++++++-- storage/framework/cache/data/.gitignore | 2 -- themes/default/views/store/checkout.blade.php | 19 +++++++++++-------- 5 files changed, 29 insertions(+), 18 deletions(-) delete mode 100644 storage/framework/cache/data/.gitignore diff --git a/app/Extensions/PaymentGateways/Mollie/MollieExtension.php b/app/Extensions/PaymentGateways/Mollie/MollieExtension.php index 4c0920ea..11cf3c6e 100644 --- a/app/Extensions/PaymentGateways/Mollie/MollieExtension.php +++ b/app/Extensions/PaymentGateways/Mollie/MollieExtension.php @@ -67,9 +67,9 @@ class MollieExtension extends AbstractExtension 'currency' => $shopProduct->currency_code, 'value' => number_format($shopProduct->getTotalPrice(), 2, '.', ''), ], - 'description' => "Order #{$payment->id}", - 'redirectUrl' => route('payment.mollieSuccess', ['payment' => $payment->id]), - 'cancelUrl' => route('payment.cancel'), + 'description' => "Order #{$payment->id} - " . $shopProduct->name, + 'redirectUrl' => route('payment.MollieSuccess'), + 'cancelUrl' => route('payment.Cancel'), 'webhookUrl' => url('/extensions/payment/MollieWebhook'), 'metadata' => [ 'payment_id' => $payment->id, @@ -77,7 +77,7 @@ class MollieExtension extends AbstractExtension ]); if ($response->status() != 201) { - Log::error('Mollie Payment: ' . $response->json()['title']); + Log::error('Mollie Payment: ' . $response->body()); $payment->delete(); Redirect::route('store.index')->with('error', __('Payment failed'))->send(); diff --git a/app/Extensions/PaymentGateways/Mollie/MollieSettings.php b/app/Extensions/PaymentGateways/Mollie/MollieSettings.php index 976025d2..d98658f1 100644 --- a/app/Extensions/PaymentGateways/Mollie/MollieSettings.php +++ b/app/Extensions/PaymentGateways/Mollie/MollieSettings.php @@ -18,7 +18,7 @@ class MollieSettings extends Settings public static function encrypted(): array { return [ - "api_key", + 'api_key', ]; } @@ -30,7 +30,12 @@ class MollieSettings extends Settings 'type' => 'string', 'label' => 'API Key', 'description' => 'The API Key of your Mollie App', - ] + ], + 'enabled' => [ + 'type' => 'boolean', + 'label' => 'Enabled', + 'description' => 'Enable or disable this payment gateway', + ], ]; } } diff --git a/app/Extensions/PaymentGateways/Mollie/web_routes.php b/app/Extensions/PaymentGateways/Mollie/web_routes.php index 3d95e4b0..f5640b9a 100644 --- a/app/Extensions/PaymentGateways/Mollie/web_routes.php +++ b/app/Extensions/PaymentGateways/Mollie/web_routes.php @@ -1,7 +1,7 @@ group(function () { Route::get('payment/MolliePay/{shopProduct}', function () { @@ -9,9 +9,14 @@ Route::middleware(['web', 'auth'])->group(function () { })->name('payment.MolliePay'); Route::get( - 'payment/PayPalSuccess', + 'payment/MollieSuccess', function () { MollieExtension::success(request()); } )->name('payment.MollieSuccess'); }); + + +Route::post('payment/MollieWebhook', function () { + MollieExtension::webhook(request()); +})->name('payment.MollieWebhook'); diff --git a/storage/framework/cache/data/.gitignore b/storage/framework/cache/data/.gitignore deleted file mode 100644 index d6b7ef32..00000000 --- a/storage/framework/cache/data/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -* -!.gitignore diff --git a/themes/default/views/store/checkout.blade.php b/themes/default/views/store/checkout.blade.php index b5f62044..4f6d8776 100644 --- a/themes/default/views/store/checkout.blade.php +++ b/themes/default/views/store/checkout.blade.php @@ -84,14 +84,17 @@ @foreach ($paymentGateways as $gateway)
- + +
@endforeach