我正在使用Authorize.net的API并尝试获取客户付款资料信息。我可以获得所有客户ID的列表,我想循环查看这些客户ID以获取客户付款配置文件信息。对于每个客户ID,我可以转储包含客户信息的数组,其中包括支付配置文件ID,但我无法弄清楚如何提取是否进行后续搜索:
我的代码是:
$profileIds[] = $response->getIds();
$num_records = count($profileIds[0]);
echo "There are " . $num_records . " Customer Profile ID's for this Merchant Name and Transaction Key <br/>";
for ($i = 0; $i < count($profileIds[0]); $i++) {
$profile_id = $profileIds['0'][$i];
echo "<br/><br/>$profile_id <br/>";
// Retrieve an existing customer profile along with all the associated payment profiles and shipping addresses
$cust_request = new AnetAPI\GetCustomerProfileRequest();
$cust_request->setMerchantAuthentication($merchantAuthentication);
$cust_request->setCustomerProfileId($profile_id);
$cust_controller = new AnetController\GetCustomerProfileController($cust_request);
$cust_response = $cust_controller->executeWithApiResponse( \net\authorize\api\constants\ANetEnvironment::PRODUCTION);
if (($cust_response != null) && ($cust_response->getMessages()->getResultCode() == "Ok") ){
echo "GetCustomerProfile SUCCESS : " . "\n";
$profileSelected = $cust_response->getProfile();
$paymentProfilesSelected = $profileSelected->getPaymentProfiles();
echo "Profile Has " . count($paymentProfilesSelected). " Payment Profiles <br/>";
$paymentProfileID = $paymentProfilesSelected->customerPaymentProfileId;
echo "Payment Profile ID: $paymentProfileID<br/>";
print_r($paymentProfilesSelected);