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.
5 Replies to “Easy Mollie payments with Laravel”
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…)?
Thanks for the interest. Please open a ticket at the repo.
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.
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.
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.