如何从 AuthorizeNetCIM_Response
对象中获取客户付款方式ID ?
AuthorizeNetCIM_Response
中的方法应该返回付款方式ID
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
数组作为
$响应 - > XML->简介 - > paymentProfiles;
但它只返回paymentProfiles
的第一个元素而不是数组。
答案 0 :(得分:0)
由于可能有多个,根据您的示例,您需要遍历每个配置文件以获取该信息:
$paymentProfileIds = array();
foreach ($response->xml->profile->paymentProfiles AS $profile) {
$paymentProfileIds[] = (string) $profile->customerPaymentProfileId;
}
print_r($paymentProfileIds);