Payment Webhooks
Payment webhooks are used to change the payment status of an order:
When using Mollie as payment provider, you set the webhook URL when creating the payment. Docs about mollie webhooks can be found at https://docs.mollie.com/reference/webhooks.
As you can see in the image above, the webhook URL is https://rockcommerce.ddev.site/rockcommerce/webhook/
, which will obviously not work, as this is not a publicly resolvable URL. It is only available on our local development machine and can therefore not be accessed by Mollie.
To overcome this technical limitation, you have two options:
- Send the webhook requests manually from your local machine.
- Use a service like NGROK to make your local development machine publicly accessible.
Sending webhook requests manually
One option is to send the webhook requests manually from your local machine. You can do that, for example, using PostCode for VSCode.
First, we create a new request:
Then we send a POST request to the webhook URL:
As you can see in the bottom section of the screenshot, the request was successful but it did not find an order. That's because we did not provide a payment ID, so let's add that to our request in the "Body" tab:
Now the request was successful and the payment status was updated:
Using NGROK
Another option is to use NGROK. If you have never heard of NGROK before, it is a tool that creates a secure URL to access your local machine from the public internet. See https://ngrok.com/ for more information.
If you are using DDEV for local development, all you have to do is run ddev share
and you'll get a public URL to access your local machine:
Next, place an order from your store, but be sure to access the store from the NGROK address! If you do that, the webhook should work and you should get the payment status updated by Mollie automatically and almost instantly: