Simple Commerce Logo

Mollie Payment Gateway

Configuration

First, you'll need to add Mollie to your simple-commerce.php config file. You will also need to pass in key and secret variables.

You can obtain your API keys from the Mollie Dashboard.

Mollie API Keys

1'gateways' => [
2 \DoubleThreeDigital\SimpleCommerce\Gateways\Builtin\MollieGateway::class => [
3 'key' => env('MOLLIE_KEY'),
4 'profile' => env('MOLLIE_PROFILE'),
5 ],
6],

It's best practice to use .env file for any API keys you need, rather than referencing them directly in your config file. Review Statamic Docs.

Payment flow

Mollie is an off-site gateway, which means the customer is redirected onto Mollie's checkout page to complete payment. Here's a quick run down of how the whole process works:

  1. After filling out shipping info etc, the store redirects the customer to Mollie
  2. The customer enters their payment information on Mollie's checkout
  3. If the payment is successful, a webhook is sent to your server.
  4. The customer is then redirected back to your site.

Handing the user off to Mollie's checkout

To redirect the customer off to Mollie's checkout page, you can use the sc:checkout:mollie tag.

1{{ sc:checkout:mollie redirect="/thanks" error_redirect="/payment-error" }}

However, bear in mind that where-ever you use that tag, the customer will be redirected away from your site. So it's probably best to have it sitting on it's own page.

Handling Mollie's webhook

The Mollie gateway has a webhook which is hit by Mollie whenever a payment is made.

Simple Commerce will configure the webhook on Mollie's end. However, you'll need to add the webhook URL to your list of CSRF exceptions, found in app/Http/Middleware/VerifyCsrfToken.php.

1protected $except = [
2 '/!/simple-commerce/gateways/mollie/webhook',
3];

When you're going through the payment flow in your development environment, you will need to use something like Expose or Ngrok to proxy request to your local server. Otherwise, Mollie wouldn't be able to hit the webhook. You will also need to update the APP_URL in your .env.

Handling the redirect back to your site

On the return back to your site from Mollie, you can have customers redirected to seperate URLs, depending on whether the payment was successful or failed/cancelled.

The redirect parameter on the sc:checkout:mollie tag will handle the successful payment redirects.

Where as error_redirect will handle any other payment states.

Need some help?

There's plenty of ways of getting help: either via opening a GitHub Issue, starting a conversation on the Statamic Discord or directly emailing me.