PHP code example of bvharen / mollie-laravel-7-plus-clone
1. Go to this page and download the library: Download bvharen/mollie-laravel-7-plus-clone 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/ */
bvharen / mollie-laravel-7-plus-clone example snippets
use Mollie\Laravel\Facades\Mollie;
public function preparePayment()
{
$payment = Mollie::api()->payments->create([
"amount" => [
"currency" => "EUR",
"value" => "10.00" // You must send the correct number of decimals, thus we enforce the use of strings
],
"description" => "Order #12345",
"redirectUrl" => route('order.success'),
"webhookUrl" => route('webhooks.mollie'),
"metadata" => [
"order_id" => "12345",
],
]);
$payment = Mollie::api()->payments->get($payment->id);
// 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.
* (See the webhook docs for more information.)
*/
if ($payment->isPaid())
{
echo 'Payment received.';
// Do your thing ...
}
// Using facade accessor
$payment = \Mollie\Laravel\Facades\Mollie::api()->payments->get($payment_id);
// Using global helper function
$payment = mollie()->payments->get($payment_id);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.