I'm fairly novice with PHP, but I can usually figure things out. But I'm stuck on working around this legacy code that we use on our sales form.
I have to shoehorn in another Card processing merchant that does things a little differently with their API.
This is processing the response from a cURL API where I receive a SOAP XML response. I'm having some issues with the actual response as well, so I have it sampled in what appears to be a proper xml format, then attempting to parse out the message objects.
1. I have the response XML converting into a "SimpleXMLElement" with the simplexml_load_string
2. Then the XML is "converted to an array", I think, with the $array = (array)$xml;
3. Then, the code should be able to look into the array values and process a Success or Failed based on the Status Value
1. You'll see in the PHP code that I have 2 testing sections to process the response. The first uses the $array and the second skips the array and just uses the $xml. One is commented out for testing the other, of course.
2. When using the $xml section to get the values, I get real close to what I need until it get json encoded, then the output just says Object Object in the JS Alert. It appears that the code is finding the proper value of the key, but it's not handled the same way for the json encoding in order to get a good alert.
3. When using the array process, I don't get anything but a full failure to extract the values, so it rolls to the end else statement "$data = array( 'message' => $xml->transaction->description, 'html' => 'Failed, Not seeing Success or TransactionID', 'date' => $curdate->format('m/d/Y h:i:s a') );"
What I really need help with is:
What is the proper way to use the array process to grab that Status value? is it $array->status == "Success" or do I need to go deeper?
I'm hoping that then I will get the proper json encoding to pass on.
Thank you for your time!
Here is what the SimpleXMLElement produces:
SimpleXMLElement Object( [transaction] => SimpleXMLElement Object ( [status] => Success [reasoncode] => N/A [transactionid] => J7DXXXX8U0 [description] => The credit card has been accepted. ))
Thank you, thank you!