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.
'gateways' => [\DuncanMcClean\SimpleCommerce\Gateways\Builtin\MollieGateway::class => ['key' => env('MOLLIE_KEY'),'profile' => env('MOLLIE_PROFILE'),],],
'gateways' => [\DuncanMcClean\SimpleCommerce\Gateways\Builtin\MollieGateway::class => ['key' => env('MOLLIE_KEY'),'profile' => env('MOLLIE_PROFILE'),],],
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.
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:
To redirect the customer off to Mollie's checkout page, you can use the sc:checkout:mollie
tag.
{{ sc:checkout:mollie redirect="/thanks" error_redirect="/payment-error" }}
{{ 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.
The Mollie gateway has a webhook which is hit by Mollie whenever a payment is made.
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
.
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.