I’m writing an application to receive and process an Instant Payment Notification message in wordpress. It is a POST request made to a “virtual” url with rewrite rules. The problem however is that only GET vars are acessible, I cannot access the post variable:
Both:
print_r($wp->query_vars['ccustfirstname']);
print_r($_POST);
Result in an empty array
I’ve modified existing code to match my case:
function ao_add_rewrite_rule() {
print_r($_REQUEST);
$ipn_parameters=array("ccustfullname","ccustfirstname", ... );
foreach ($ipn_parameters as $key => $value) {
add_rewrite_tag("%$value%",".");
}
add_rewrite_tag("%arevico_api%",".","");
add_rewrite_rule( 'ipn', 'index.php?&arevico_api=ipn', 'top');
add_rewrite_rule( 'hoplink', 'index.php?&arevico_api=hop', 'top');
add_rewrite_rule( 'pay', 'index.php?&arevico_api=pay', 'top');
flush_rewrite_rules();//TODO: call only when needed
}
add_action( 'parse_request', 'wpse9870_parse_request' );
function wpse9870_parse_request( &$wp )
{
if (!empty($wp->query_vars['arevico_api'])) {
switch ($wp->query_vars['arevico_api']){
case "ipn":
print_r($wp->query_vars['ccustfirstname']);
print_r($_POST);
die();
// require_once(AREVICO_PLG_BP . "ipn.php");
// $ArevicoIPN=new ArevicoIPN();
break ;
default:
break;
}
}
return;
}
Please note that the arevico_api get parameter does get trough, but the POST parameters don’t. I’m testing the application by sending a sample post data trough Simple Rest Client for chrome. How do I get to access thhe post parameters