Skip to content

Dev Webhooks

Christian Dangl edited this page Feb 17, 2021 · 1 revision

Webhooks locally

It's possible to receive real webhooks from Mollie, even if you develop locally.

This is especially useful when developing features that trigger workflows after a webhook has been received.

The Mollie plugin allows you to add a custom shop domain, which will then be used when building webhook URLs for a payment.

This domain should forward requests to your local development environment. So Mollie will push data to this domain, which is then received by your local instance.

We highly recommend services like NGROK for this.

Sign up for an account, download NGROK and run a command such as this:

./ngrok http --host-header=rewrite my-local-shopware-domain:443

This will start the NGROK service that forwards all requests to your local HTTPS port and rewrites the headers to match the one from your local Shopware shop configuration.

It gives you a public URL such as this: https://123456789.ngrok.io

All you need to do, is to add that domain to the root Shopware config.php

<?php return array(
    'db' ...
    'custom' => array(
        'mollie' => array(
            'shop_domain' => '123456789.ngrok.io'
        )
    ),
);

Now simply create a new order in your local Shopware shop, and you will see that webhooks are received immediately.

If you open the Mollie dashboard, you will recognize that your NGROK domain has been used for the Webhook URL.

You can also skip this for most use cases, but only do it, when you want to receive webhooks for a specific task you have. So no need, to have NGROK running all the time.

Please keep in mind, that your local environment will be public with this approach. NGROK has different authorization options, such as Basic Auth, IP restrictions and more. In this guide, we distance ourselves from security settings, as well as from promoting NGROK, due to the option to also use other services.

Clone this wiki locally