I am implementing instamojo payment method into my website. Can I use a localhost URL as Webhook URL in order to test the process?
Can I use localhost URL as Webhook URL in Instamojo?
3.3k views Asked by Hormis Lona AtThere are 5 answers
I doubt if you can use local host URL but instead you can create new links, as below https://www.instamojo.com/api/1.1/links/
I'm from Instamojo.
You can't use a local URL. This is because a webhook request is a POST request that is made from our server. Therefore, the only URLs that we can make these requests to would be URLs that are publicly available.
For testing purposes, I would recommend using RequestBin. You can create a new bin and paste the URL for that bin in the webhook URL field of your Instamojo link. This will give you a link that is accessible by our server and you can inspect the POST requests to this link by appending ?inspect
at the end of the URL.
You cannot use the localhost URL as a webhook URL in order to test the process. But you can simply bypass it, open hosts file from C:\Windows\System32\Drivers\etc\hosts
At the end of the line write
127.0.0.1 yourname.com
And access localhost using yourname.com. Just change localhost/your-location url with yourname.com/your-location in the PHP file.
It is possible to forward Instamojo's webhooks to your local machine using tools like localtunnel
.
npm
is required to install localtunnel. [How to install node and npm]Install localtunnel
Suppose you are running your local server at port 8000, in a new terminal window, execute this:
lt --port 8000
It will show you output like:
your url is: https://whawgpctcs.localtunnel.me
This is a temporary webhook URL that will forward every HTTPS request sent to https://whawgpctcs.localtunnel.me
to your local server running on port 8000
.
Paste this temporary url into Instamojo's webhook field and continue testing.
Remember to remove the temporary webhook URL from Instamojo once you are done testing
The temporary webhook URL is valid as long as the lt --port 8000
command (and your Internet connection) is active.
We can't use localhost or as Webhook URL.If it is used the following error will show "Domain name should not be "localhost" or "127.0.0.1" ". So it must be a live URL.