Question

Is there anyone who has done some integration with securetrading using stapi? I currently am trying to integrate paypal and have the following xml response being returned to my console:

<responseblock version="3.67"> 
<requestreference>X3556qikiki32155</requestreference> 
<response type="ORDERDETAILS"> 
<merchant> 
<merchantname>test account</merchantname> 
<orderreference>aaaa123</orderreference> 
</merchant> 
<customer> 
<town>PAYPAL City</town> 
<street>MORE STREET</street> 
<name> 
<last>PayPalShipToName</last> 
</name> 
<premise>1 PayPalStreet</premise> 
<country>US</country> 
<ip>127.0.0.1</ip> 
</customer> 
<transactionreference>412-32323222-2323235284</transactionreference> 
<billing> 
<name> 
<last>PAYPALLastName</last> 
<first>Andr©©</first> 
</name> 
<country>GB</country> 
<email>paypal.email@example.com</email> 
</billing> 
<paypal> 
<addressstatus>Confirmed</addressstatus> 
<payerstatus>verified</payerstatus> 
<payerid>c6e9460f5232uijijd2dweqa6591pid</payerid> 
</paypal> 
<live>0</live> 
<error> 
<message>Ok</message> 
<code>0</code> 
</error> 
<timestamp>2011-11-14 22:36:50</timestamp> 
<settlement> 
<settleduedate>2011-11-14</settleduedate> 
<settlestatus>0</settlestatus> 
</settlement> 
<operation> 
<parenttransactionreference>42332-323232-52332279</parenttransactionreference> 
<accounttypedescription>ECOM</accounttypedescription> 
</operation> 
</response> 


<response type="AUTH"> 
<merchant> 
<merchantname>test account</merchantname> 
<orderreference>aa72323</orderreference> 
</merchant> 
<transactionreference>4qwdwd-w323232-34fd5285</transactionreference> 
<billing> 
<amount currencycode="GBP">19995</amount> 
<payment type="PAYPAL"/> 
</billing> 
<authcode>41685-dwww233qwd</authcode> 
<timestamp>2011-11-14 22:36:50</timestamp> 
<settlement> 
<settleduedate>2011-11-14</settleduedate> 
<settlestatus>0</settlestatus> 
</settlement> 
<live>0</live> 
<error> 
<message>Ok</message> 
<code>0</code> 
</error> 
<acquirerresponsecode>None</acquirerresponsecode> 
<operation> 
<parenttransactionreference>4233-dae3232-5232284</parenttransactionreference> 
<accounttypedescription>ECOM</accounttypedescription> 
</operation> 
</response> 
</responseblock> 

basically once I get the response I am using the following to get the values from the xml:

$p = xml_parser_create();
xml_parser_set_option($p, XML_OPTION_CASE_FOLDING, 0);
xml_parser_set_option($p, XML_OPTION_SKIP_WHITE, 1);
xml_parse_into_struct($p, $return_xml, $vals, $index);
xml_parser_free($p);
print_r($vals);

but when I print_r the values I only get the values from the ORDERDETAILS block being displayed and not the ones from the auth block.

Any help with this would be appreciated.

Thanks

Was it helpful?

Solution

I wrote a PHP class to wrap SimpleXML, so that it's a little clearer to use:

https://github.com/homer6/altumo/blob/master/source/php/Xml/XmlElement.md

$xml_element = new \Altumo\Xml\XmlElement( $response_contents );
var_dump( $xml_element->xpath('response[@type=AUTH]/merchant/merchantname') );

string(12) "test account"

See: http://www.w3schools.com/xpath/xpath_syntax.asp for more xpath examples.

Hope that helps...

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top