1. Go to this page and download the library: Download mollie/laravel-mollie library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
mollie / laravel-mollie example snippets
MOLLIE_KEY=test_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
use Mollie\Api\Http\Data\Money;
use Mollie\Laravel\Facades\Mollie;
use Mollie\Api\Http\Requests\GetPaymentRequest;
use Mollie\Api\Http\Requests\CreatePaymentRequest;
public function preparePayment()
{
$request = new CreatePaymentRequest(
description: 'Order #12345',
amount: new Money('EUR', '10.00'),
redirectUrl: route('order.success'),
webhookUrl: route('webhooks.mollie'),
metadata: [
"order_id" => "12345",
"customer_info" => [
"name" => "John Doe",
"email" => "[email protected]"
]
]
);
Mollie::send($request);
// redirect customer to Mollie checkout page
return redirect($payment->getCheckoutUrl(), 303);
}
/**
* After the customer has completed the transaction,
* you can fetch, check and process the payment.
* This logic typically goes into the controller handling the inbound webhook request.
* See the webhook docs in /docs and on mollie.com for more information.
*/
public function handleWebhookNotification(Request $request) {
$paymentId = $request->input('id');
$payment = Mollie::send(new GetPaymentRequest($paymentId));
if ($payment->isPaid())
{
echo 'Payment received.';
// Do your thing ...
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.