2

I am using the API for Authorize.net and trying to get customer payment profile info. I can get a list of all customer IDs, and I'd like to loop through those to get customer-payment-profile information. For each customer ID I am able to dump the array containing customer information which includes payment profile ID but I can't figure out how to extract if to do a subsequent search:

My code is:

$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);
SeanF
  • 21
  • 1

0 Answers0