Cloudflare error on the Paystack API
Cloudflare is a web security company that provides infrastructure, security and caching services for some of the best online platforms globally, and we use Cloudflare to protect our systems from attacks from malicious actors.
If you receive an error that indicates Cloudflare is restricting your connection, it could be that Cloudflare sees your IP address as compromised.
Kindly follow this guide to fix the issue:
Send a user-agent in your request header. For example, you can use the Chrome UA like this:
User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.103 Safari/537.36
This means if your header was previously something like:
curl <https://api.paystack.co/xxxx> \\
-H "Authorization: Bearer SECRET_KEY" \\
-H "Content-Type: application/json" \\
-d '{
"reference": "7PVGX8MEk85tgeEpVDtD",
"amount": 500000
}' \\
-X POST
It should now be:
curl <https://api.paystack.co/xxxx> \\
-H "Authorization: Bearer SECRET_KEY" \\
-H "Content-Type: application/json" \\
-H "User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.103 Safari/537.36" \\
-d '{
"reference": "7PVGX8MEk85tgeEpVDtD",
"amount": 500000
}' \\
-X POST
If you are still getting blocked by Cloudflare after this, you will need to have a conversation with your host. This usually means that your IP address is blocked or blacklisted, and your host should be able to help you resolve this at no extra cost.