Hi.
I have a bit of code where I am having huge problems with passing a variable that has been retrieved from some XML. If I hardcode the variable it all works as expected. I have checked to see if I am getting the expected results from the xml and I am. I have implemented dumping everything to text files and checking the responses and it all looks to be correct but I just can’t seem to get this to work as it should. I am sure I am missing something small but what!
Here is some code - please note its just snippets of code…
[xml]
<?xml version=“1.0”?>
<NewOrder>
<Token>104EPU4dAJsOVjofEguhB5p6</Token>
</NewOrder>
[/xml]
if($res['NewOrder'] && ($token = $res['NewOrder'][0]['Token'][0])){
file_put_contents($token.'.txt', trim(print_r($token,true)), FILE_APPEND);
//token="104EPU4dAJsOVjofEguhB5p6"; //this works as expected....
$order = $pl->get_order_info($token,"api");
//file_put_contents('orderResults.txt', trim(print_r($order,true)), FILE_APPEND);
// Build vars array:
$vars = array(
'OrderID' => $order['Response'][0]['OrderInfo'][0]['Id'][0],
'Amount' => $order['Response'][0]['OrderInfo'][0]['GrandTotal'][0],
'Status' => 'payment',
'AMemberID' => '',
'NextRebillDate'=> ''
);
$vars['PostbackPassword'] = $pl->config['postback_password'];
$str = join('', array_values($vars));
$md5 = md5($str);
$vars['VerifySign'] = $md5;
unset($vars['PostbackPassword']);
$pl->handle_postback($vars);
}
function get_order_info($order_id,$location)
{
file_put_contents('getOrderInfoTokenBefore'.$location.'.txt', trim(print_r($order_id,true)) . " " . time()."location: ".$location, FILE_APPEND);
$order = $this->xml_parsexml($this->api_call("amemberOrder", $order_id));
file_put_contents('getOrderInfoTokenAfter'.$location.'.txt', trim(print_r($order_id,true)) . " " . time()."location: ".$location, FILE_APPEND);
file_put_contents('getOrderInfo.txt', trim(print_r($order,true)) . " " . time(), FILE_APPEND);
return $order;
}
There is a lot more code than this but that’s the bones of what is failing…
As said when I hardcode the variable it works 100% perfectly all of the time. if I use the processed XML it fails 100% of the time which makes me think I am doing something daft.
Thanks
Chris