42 lines
1.0 KiB
PHP
42 lines
1.0 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers\Frontend;
|
|
|
|
use App\Http\Controllers\Controller;
|
|
use Illuminate\Http\Request;
|
|
use Mollie\Laravel\Facades\Mollie;
|
|
|
|
class PaymentController extends Controller
|
|
{
|
|
public function createPayment()
|
|
{
|
|
$payment = Mollie::api()->payments()->create([
|
|
'amount' => [
|
|
'currency' => 'EUR',
|
|
'value' => '10.00', // The payment amount
|
|
],
|
|
'description' => 'Test payment',
|
|
'redirectUrl' => route('payment.status'),
|
|
]);
|
|
|
|
// Redirect the user to the Mollie payment page
|
|
return redirect($payment->getCheckoutUrl());
|
|
}
|
|
|
|
public function paymentStatus()
|
|
{
|
|
$paymentId = request()->input('id');
|
|
|
|
$payment = Mollie::api()->payments()->get($paymentId);
|
|
|
|
// Check the payment status
|
|
if ($payment->status === 'paid') {
|
|
// Payment is successful
|
|
return 'Payment successful';
|
|
} else {
|
|
// Payment failed
|
|
return 'Payment failed';
|
|
}
|
|
}
|
|
}
|