1

有没有人使用 stapi 与安全交易进行了一些集成?我目前正在尝试集成贝宝,并将以下 xml 响应返回到我的控制台:

<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> 

基本上,一旦我得到响应,我就会使用以下内容从 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);

但是当我 print_r 值时,我只从正在显示的 ORDERDETAILS 块中获取值,而不是从 auth 块中获取值。

对此的任何帮助将不胜感激。

谢谢

4

1 回答 1

0

我写了一个 PHP 类来包装 SimpleXML,这样使用起来会更清晰一些:

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"

有关更多 xpath 示例,请参阅:http ://www.w3schools.com/xpath/xpath_syntax.asp。

希望有帮助...

于 2011-11-15T03:05:30.717 回答