Payfast source IP validation filter

Use this filter only when the Payfast log reports Error occurred: Bad source IP address and you have confirmed the issue is caused by the gateway’s source IP validation.

Note:

This is a Developer level doc. If you are unfamiliar working with code and resolving potential conflicts, we recommend you work with a Woo Agency Partner for larger projects, or find a WooCommerce developer on Codeable for smaller customizations. We are unable to provide support for customizations under our Support Policy.

Payfast source IP validation

↑ Back to top

In Payfast Payment Gateway 1.7.7, the extension validates the source IP address of incoming Instant Transaction Notifications (ITNs) when test mode is off. It resolves the published Payfast hostnames and compares the notification source against the resulting addresses. If a valid notification is rejected with a bad source IP error, check the Payfast settings and logs before using this filter.

The filter changes only the result of the source IP check. The gateway still performs its other notification validation, including signature and response-data checks.

add_filter( 'woocommerce_gateway_payfast_is_valid_ip', '__return_true' );

Before using the filter

↑ Back to top
  • Confirm that the Payfast log shows Error occurred: Bad source IP address.
  • Confirm that your Merchant ID, Merchant Key, Passphrase, and Notify URL are correct for the environment you are using.
  • Check that Instant Transaction Notifications are enabled in Payfast.
  • Understand that this filter disables the gateway’s Payfast source IP check and can reduce protection against forged notifications. Use it only when you have assessed that risk.

Add the filter through a child theme’s functions.php file or a code snippets plugin so it persists after updates. This Developer-level document covers the implementation; support for custom code is outside the scope of WooCommerce.com support.

Related Products

A seamless checkout with 35+ payment methods for global needs. Enjoy built-in security and simple integration for a smooth experience.

Accept payments on your WooCommerce store securely.

Use of your personal data
We and our partners process your personal data (such as browsing data, IP Addresses, cookie information, and other unique identifiers) based on your consent and/or our legitimate interest to optimize our website, marketing activities, and your user experience.