Easy Mollie payments with Laravel

In the previous post you learned that Cashier is not always the best fit for payment processing in Laravel. And if that’s the case you will need to integrate payment processing manually into your application.

Personally I have been integrating the Mollie gateway into Laravel projects targeting a Dutch customer base. This way it is possible to accept iDeal payments – which is the preferred method of my customers.

The major take-away?

Fully integrating a payment gateway manually becomes tedious very fast.

You could use the official Mollie PHP client, the Omnipay Mollie client or the Mollie Laravel client, but these only help you redirect the customer to the Mollie payment page and redirect them back to you afterwards.

You will still have to do other things. The webhook route and controller still need to be written. Also you probably want to keep matching payment records in your own database and fire Laravel Events when the payment status changes. And as a best practice cover all this functionality using unit tests…

Yes that’s a lot of work, yet is the same for most  e-commerce projects.

That’s why I’ve created the laravel-payable-redirect-mollie package (yes that’s a mouthful) to integrate this all at once.

For your benefit I have open sourced it.

Take a look at the package’s github page for more details and installation instructions.

PS. As a last step in the payment process you probably want to generate an invoice (html/pdf) and provide it to the customer. There’s a package coming up for that as well. Stay tuned.

Create your first Laravel package

Laravel package development from scratch

Learning Laravel package development doesn't have to be hard. If you know how to create a basic Laravel app, you can write packages as well.

I've opened this course up for free to the first 100 subscribers only.

Join now and get the first lesson in your inbox right away.

We won't send you spam. Unsubscribe at any time. Powered by ConvertKit

5 Replies to “Easy Mollie payments with Laravel”

  1. Question about the PaymentEvents. How can I use them in code? I want to generate and send an invoice after (and only after) the payment is complete.
    When I create an event like ‘event(new PaymentPaid($payment));’ this doesn’t work.
    How can I make sure Mollie is getting back on my application telling the payment went okay (like with CC, it takes a while…)?

      1. Hi Sander,

        In the meantime I found out that the event works, but it seems to ALWAYS work. So ‘event(new PaymentPaid($payment));’ is always a success, even when the payment failed.

        It can be that it doesn’t work because I use a local development environment to test it…or….I just don’t know how to implement it.

        For me and probably for many others it might be nice to put a complete working code example in the article? I’m sure lots of people will appreciate it, especially the novice developers.

        Cheers, Sven

  2. Hi Sven,

    For issues like these, please open an issue in the repo.

    Also note that I’m currently working on a full-fletched Mollie Cashier package, which is likely to replace this package in the future.

    1. Hi Sander,

      I suppose it’s just the lack of knowledge combined with the lack of examples that I can’t me it work, so I don’t know what this issue would be then…
      Still being a novice developer I’m confused how to use the Laravel Events for the PaymentPaid event the package is firing.

      I leave this open for input. Maybe I’ll find the solution later. If so, I’ll post that here.

      Good luck with the Mollie Cashier package! Looking forward to it.

      Cheers, Sven

Leave a Reply

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