What causes the error "The supplied variables are not according to specification"?

What causes the error "The supplied variables are not according to specification"?

This error is thrown if any of the POSTed values are incorrect, for instance, if the merchant_id or merchant_key is incorrect (possibly due to using a sandbox credentials on the live site), the following error will be thrown ‘The supplied variables are not according to specification: merchant_key: Merchant key is invalid’. The error will highlight which variables are incorrect or missing, you will then need to ensure that the POST form is adjusted accordingly.

When the error shows "cancel_url: must be a valid URL, notifyl_url: must be a valid URL, return_url: must be a valid URL", please bear in mind that PayFast does not accept local URLs, and will produce this error for a locally hosted site. This is because there is no server to server communication so the ITN will never hit the notify URL.  Once the site is web accessible then these errors will disappear.

In the meantime, you can try use "127.0.0.1" instead of "localhost" or set up a DNS host file for the local site so that the url becomes "http://www.mysite.local" instead of "http://localhost/mysite".

​A tunneling service like https://ngrok.com/ can also be used. It will allow you to connect your local host to the internet.