Mollie Payment gateway integration in Laravel 8

Before moving towards the topic I want to tell you what is a payment gateway and how it is beneficial for our website.

What is the Payment Gateway?

A payment gateway is a merchant service provided by an e-commerce application service provider that authorizes credit card or direct payments processing for e-businesses, online retailers. Payment gateway like Stripe, Razorpay, Mollie, Authorize are very popular nowadays.

Benefits of Mollie Payment Gateway

  • Secure transactions
  • Expanded customer base
  • Faster transaction processing


  • Mollie account
  • The Basic knowledge of PHP
  • The basic idea of Laravel Framework

Create a Mollie account by clicking on this link.

mollie account creation

Login to Mollie dashboard in the sidebar you will see developers, click on developers to get your API Key.

mollie api key

Don’t forget to activate your payment method, as it gives errors during the payment. To activate the payment method you have to go settings -> website profile, then under the website profile, you can see the payment methods. You have to activate them.

mollie payment method
mollie payment method list
After clicking on the payment method


Add Laravel-Mollie to your composer file via the composer require command:

 composer require mollie/laravel-mollie 

You can set the mollie API key in two way either by putting API key in you .env file like below


Or by calling it in your constructor function like below.

public function  __construct() {

Add on the top of web.php file

use App\Http\Controllers\MollieController;

Add routes in your web.php file

Route::get('payment-success',[MollieController::Class, 'paymentSuccess'])->name('payment.success');

Create a controller by using the following command

php artisan make:controller MollieController

Under your controller put the following code


namespace App\Http\Controllers;
use Mollie\Laravel\Facades\Mollie;

class MollieController extends Controller

    public function  __construct() {
        Mollie::api()->setApiKey('test_FbVACj7UbsdkHtAUWnCnmSNGFWMuuA'); // your mollie test api key

     * Redirect the user to the Payment Gateway.
     * @return Response
    public function preparePayment()

        $payment = Mollie::api()->payments()->create([
        'amount' => [
            'currency' => 'EUR', // Type of currency you want to send
            'value' => '10.00', // You must send the correct number of decimals, thus we enforce the use of strings
        'description' => 'Payment By codehunger', 
        'redirectUrl' => route('payment.success'), // after the payment completion where you to redirect
        $payment = Mollie::api()->payments()->get($payment->id);
        // redirect customer to Mollie checkout page
        return redirect($payment->getCheckoutUrl(), 303);

     * Page redirection after the successfull payment
     * @return Response
    public function paymentSuccess() {
        echo 'payment has been received';


Visit the below URL


After visiting on the URL, you are redirected to the Mollie payment page

mollie payment page
Mollie Payment Page

Here all your payment methods will be shown, which you activated in your profile. You can choose any payment method to make the payment.

mollie payment
After choosing any payment method, you can see the screen like above

Now you can click on paid for your successful payment. You can see your all payment details under your transaction details.

mollie payment dashboard
your payment details

Still have questions in mind feel free to ask, we are here to help you.

Shaiv Roy

Hy Myself shaiv roy, I am a passionate blogger and love to share ideas among people, I am having good experience with laravel, vue js, react, flutter and doing website and app development work from last 7 years.

Related Articles


  1. Could you also do one for Cashier Mollie (recurring payments). There are literally 0 tutorials on that besides the hard to understand github

    1. Yes, sure we will make a video on that soon. Till subscribed to our blog, so that you will get notified about that.

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button