Since I doubt “pretty” URLs are important here, it’s incredibly easy to create an endpoint/handler using the AJAX api (the other option is to use the rewrite API and listen out for a hit).
Don’t be put off by the term “AJAX” – this is simply a script within your WordPress install that will fire a matching hook for whatever is passed as the action
parameter (either via GET or POST).
For example, example.com/wp-admin/admin-ajax.php?action=gateway
:
function wpse_225366_gateway_response() {
// Do your thang
exit;
}
// The wp_ajax_nopriv_{action} hook fires for non-authenticated users
add_action( 'wp_ajax_nopriv_gateway', 'wpse_225366_gateway_response' );
// The wp_ajax_{action} hook fires for authenticated users
add_action( 'wp_ajax_gateway', 'wpse_225366_gateway_response' );
You’ll probably want to call the action something less generic than gateway
, but I hope this illustrates how things work.
You can use the following to get the response URL programmatically:
$response_url = admin_url( 'admin-ajax.php?action=gateway' );