Skip to main content
All CollectionsIntegrationsCustom Integration
How to test Order Webhooks Locally?
How to test Order Webhooks Locally?

This article helps custom (3rd party) integrators test, replay and debug webhooks that are sent from Montonio about order status updates.

Laura from Montonio avatar
Written by Laura from Montonio
Updated over a week ago

Here is a small guide for developers to test Montonio's webhooks locally.

Prerequisites

  • Install ngrok - it's free!

Steps

  • Run ngrok on port 80 (for http) or 443 (for https) or any other port you have configured your local server to run on

$ ngrok http 80
  • When creating a Montonio Order, set the webhook url to the ngrok url. For example:

{
"notificationUrl": "http://1111-111-111-11-111.ngrok-free.app/my-webhook-endpoint" // <-- this is the ngRok url
"accessKey": "my-access-key-uuid"
"merchantReference": `my-merchant-reference`,
"returnUrl": http://localhost/return,
"grandTotal": 100,
"currency": "EUR",
"locale": "et",
"payment": {
"method": "cardPayments",
"methodDisplay": "Bank",
"amount": 100,
"currency": "EUR"
}
}
  • Open the ngrok dashboard at http://127.0.0.1:4040. Here you can see the requests that Montonio is sending to your webhook endpoint

  • Create a new order in Montonio Sandbox - make the POST https://sandbox-stargate.montonio.com/api/orders request. Redirect to the paymentUrl you were given in the response.

  • Go through the payment flow. Before you are redirected back to the store, you can close the browser tab.

    This will simulate a customer closing the browser tab before being redirected back to the merchant's website. Now only the webhook will be responsible for updating the order status in your system.

  • In the ngrok dashboard, you should see a request from Montonio to your webhook endpoint:

  • Now you can replay the request to your local server by clicking the Replay button. This will send the request to your local server and you can see the response in the ngrok dashboard.

That's it! Now you can test Montonio's webhooks locally.


FAQ

Why do I need to use ngrok?

Montonio's webhooks are sent from our servers to your server. This means that your server needs to be accessible from the internet. If you are running your server locally, we cannot make the webhook request as your localhost is normally not accessible from the internet. ngrok solves this problem by creating a tunnel from the internet to your local server.

Can't I just use CURL to send the request to my local server?

Yes, you can. But when using ngrok you can be sure that the request is sent from Montonio's servers and is always up to date. It also helps you debug the request and response with ease.

Are the Sandbox and Production webhooks the same?

Yes, they are the same. The only difference is that the Sandbox webhooks are sent from our Sandbox servers and the Production webhooks are sent from our Production servers. Make sure that you are using the correct access key for each environment and you make the requests towards the appropriate URL.

I see that the webhook has a query parameter ?order-token but also it has "orderToken" in the request body. Which one should I use?

Since POST requests normally don't have query parameters, we recommend using the "orderToken" from the request body. However, if you are using a framework that

  1. converts POST requests to GET requests or

  2. doesn't allow you to access the request body,

then you can use the query parameter. Use whichever is easier for you. They will both be available.

Did this answer your question?