如何从AuthorizeNetCIM_Response
对象获取客户支付方法I?
AuthorizeNetCIM_Response
中有一个方法,它应该返回支付方法ids
public function getCustomerPaymentProfileIds()
{
$ids = (array)$this->xml->customerPaymentProfileIdList;
return $ids["numericString"];
}
但是调用此函数会导致错误。
注意:未定义索引: numericString
响应对象输出如下:
AuthorizeNet_AuthorizeNetCIMResponse Object
(
[xml] => SimpleXMLElement Object
(
[messages] => SimpleXMLElement Object
(
[resultCode] => Ok
[message] => SimpleXMLElement Object
(
[code] => I00001
[text] => Successful.
)
)
[profile] => SimpleXMLElement Object
(
[merchantCustomerId] => 10
[email] => user@nine.com
[customerProfileId] => 25441529
[paymentProfiles] => Array
(
[0] => SimpleXMLElement Object
(
[billTo] => SimpleXMLElement Object
(
[firstName] =>
[lastName] =>
[address] =>
[city] =>
[zip] =>
[country] =>
[phoneNumber] =>
)
[customerPaymentProfileId] => 23298664
[payment] => SimpleXMLElement Object
(
[creditCard] => SimpleXMLElement Object
(
[cardNumber] => XXXX2224
[expirationDate] => XXXX
)
)
)
[1] => SimpleXMLElement Object
(
[customerType] => individual
[billTo] => SimpleXMLElement Object
(
[firstName] => Test
[lastName] => Individual
[company] => SimpleXMLElement Object
(
)
[address] =>
[city] =>
[state] =>
[zip] =>
[country] =>
[phoneNumber] => SimpleXMLElement Object
(
)
[faxNumber] => SimpleXMLElement Object
(
)
)
[customerPaymentProfileId] => 23299421
[payment] => SimpleXMLElement Object
(
[creditCard] => SimpleXMLElement Object
(
[cardNumber] => XXXX0027
[expirationDate] => XXXX
)
)
)
)
)
)
我应该把paymentProfiles
数组作为
$response->xml->profile->paymentProfiles;
但是它只返回paymentProfiles
的第一个元素,而不是数组。
发布于 2014-04-16 06:03:21
由于可以有更多的配置文件(如您的示例所示),您需要遍历每个配置文件以获得该信息:
$paymentProfileIds = array();
foreach ($response->xml->profile->paymentProfiles AS $profile) {
$paymentProfileIds[] = (string) $profile->customerPaymentProfileId;
}
print_r($paymentProfileIds);
https://stackoverflow.com/questions/23111646
复制相似问题