I am coding a script to read the response given from a payment gateway after a transaction is done. http://docs.merchee.com/api/push-notifications/index.html
The example data I am getting is
$received_values = "
status_code PAID
subtotal 10
success_redirect http://site.com/thanks
tax_total 0
total_price 10
transaction_amount 10
transaction_date 07/24/2012
transaction_nmb 101888
transaction_time 12:43:52
zip 12345
";
I am specifically looking for the lines transaction_nmb
and status_code
.
I'm thinking I do something like so:
$received_values = (array) stripslashes_deep( $_POST );
But am stuck on how I should go about confirming it.. in_array
?
Thank you.
Since it looks like $received_values is a newline separated string, maybe you could use this regex (untested) to get the values?
preg_match_all('/status_code\s(\w+).+transaction_nmb\s(\d+)/',$received_values, $matches);
// PAID should be in $matches[1]
// 101888 should be in $matches[2]
Explode by newline (explode is not the most efficient but will help.
$array = explode('
', $received_values);
This will give you this each line an a array.
$array[0] //status_code PAID
Then you can just look for the answer by splitting it again or using one of php parsing functions.