fix: 🐛 Mollie gateway route and settings

This commit is contained in:
IceToast 2023-03-27 20:48:14 +02:00 committed by IceToast
parent c95cde5cde
commit 5b44df24ab
5 changed files with 29 additions and 18 deletions

View file

@ -67,9 +67,9 @@ class MollieExtension extends AbstractExtension
'currency' => $shopProduct->currency_code, 'currency' => $shopProduct->currency_code,
'value' => number_format($shopProduct->getTotalPrice(), 2, '.', ''), 'value' => number_format($shopProduct->getTotalPrice(), 2, '.', ''),
], ],
'description' => "Order #{$payment->id}", 'description' => "Order #{$payment->id} - " . $shopProduct->name,
'redirectUrl' => route('payment.mollieSuccess', ['payment' => $payment->id]), 'redirectUrl' => route('payment.MollieSuccess'),
'cancelUrl' => route('payment.cancel'), 'cancelUrl' => route('payment.Cancel'),
'webhookUrl' => url('/extensions/payment/MollieWebhook'), 'webhookUrl' => url('/extensions/payment/MollieWebhook'),
'metadata' => [ 'metadata' => [
'payment_id' => $payment->id, 'payment_id' => $payment->id,
@ -77,7 +77,7 @@ class MollieExtension extends AbstractExtension
]); ]);
if ($response->status() != 201) { if ($response->status() != 201) {
Log::error('Mollie Payment: ' . $response->json()['title']); Log::error('Mollie Payment: ' . $response->body());
$payment->delete(); $payment->delete();
Redirect::route('store.index')->with('error', __('Payment failed'))->send(); Redirect::route('store.index')->with('error', __('Payment failed'))->send();

View file

@ -18,7 +18,7 @@ class MollieSettings extends Settings
public static function encrypted(): array public static function encrypted(): array
{ {
return [ return [
"api_key", 'api_key',
]; ];
} }
@ -30,7 +30,12 @@ class MollieSettings extends Settings
'type' => 'string', 'type' => 'string',
'label' => 'API Key', 'label' => 'API Key',
'description' => 'The API Key of your Mollie App', 'description' => 'The API Key of your Mollie App',
] ],
'enabled' => [
'type' => 'boolean',
'label' => 'Enabled',
'description' => 'Enable or disable this payment gateway',
],
]; ];
} }
} }

View file

@ -1,7 +1,7 @@
<?php <?php
use App\Extensions\PaymentGateways\Mollie\MollieExtension;
use Illuminate\Support\Facades\Route; use Illuminate\Support\Facades\Route;
use App\Extensions\PaymentGateways\Mollie\MollieExtension;
Route::middleware(['web', 'auth'])->group(function () { Route::middleware(['web', 'auth'])->group(function () {
Route::get('payment/MolliePay/{shopProduct}', function () { Route::get('payment/MolliePay/{shopProduct}', function () {
@ -9,9 +9,14 @@ Route::middleware(['web', 'auth'])->group(function () {
})->name('payment.MolliePay'); })->name('payment.MolliePay');
Route::get( Route::get(
'payment/PayPalSuccess', 'payment/MollieSuccess',
function () { function () {
MollieExtension::success(request()); MollieExtension::success(request());
} }
)->name('payment.MollieSuccess'); )->name('payment.MollieSuccess');
}); });
Route::post('payment/MollieWebhook', function () {
MollieExtension::webhook(request());
})->name('payment.MollieWebhook');

View file

@ -1,2 +0,0 @@
*
!.gitignore

View file

@ -84,14 +84,17 @@
@foreach ($paymentGateways as $gateway) @foreach ($paymentGateways as $gateway)
<div class="ml-2"> <div class="ml-2">
<label class="text-center" for="{{ $gateway->name }}"> <span data-toggle="popover" data-trigger="hover" data-placement="bottom"
<img class="mb-3" height="50" data-content="{{ $gateway->name }}"> <label class="text-center"
src="{{ $gateway->image }}"></br> for="{{ $gateway->name }}">
<input x-on:click="console.log(payment_method)" <img class="mb-3" height="50" src="{{ $gateway->image }}">
x-model="payment_method" type="radio" </br>
id="{{ $gateway->name }}" value="{{ $gateway->name }}"> <input x-on:click="console.log(payment_method)"
</input> x-model="payment_method" type="radio"
</label> id="{{ $gateway->name }}" value="{{ $gateway->name }}">
</input>
</label>
</span>
</div> </div>
@endforeach @endforeach
</div> </div>