How to create a callback URL in WooCommerce

I was working on a payment gateway for WooCommerce and had to create a special URL that will then load the specified class method. Sometimes the information does not reach all parties e.g. if you close the browser and the status of the payment between the payment’s and merchant’s server remains unclear. The WooCommerce API allows you to create a callback URL.

Creating a callback URL

Calling a callback URL

Before WooCommerce 2.0, you could use:
http://yoursite.com/?wc-api=wc_gateway_my_gateway

In WoCommerce 2.0+:
http://yoursite.com/wc-api/wc_gateway_my_gateway/