cancel
Showing results for 
Search instead for 
Did you mean: 

CIM code to retrieve existing payment profiles

I know this is in here somewhere, but I've spent many hours trying to work this out on my own and figured it's time to ask for more help.   Using CIM php api, I can save a customer profile, and I can save multiple payment profiles to that customer. I know those go in because I can see them appear in my sandbox customer information manager.

 

I can't find the method to retrieve a list of payment profiles.

 

I think I have to retrieve the ids, then retrieve the profiles one at a time -- but there's probably a better way. One at a time would be awfully slow.  But I'm having no luck even retrieving the list of ids.

 

It seems like this is supposed to work:

$request = new AuthorizeNetCIM;
$response = $request->getCustomerProfile($customerProfileId);

$list = $response->getCustomerPaymentProfileIds();

 

I get the correct customerProfile, but $list is null.

alanm123
Contributor
1 ACCEPTED SOLUTION

Accepted Solutions

This should get you fairly close to where you need to go. Just use print_r() if you're not sure about the data structure at any point.

 

    $profile = $request->getCustomerProfile($profile_id);
    
    if (!$profile->isOk())
        $errors[] = $profile->xml->messages->message->text;

    else for ($i = 0; $pprofile = $profile->xml->profile->paymentProfiles[$i]; $i++) {
        if ($pprofile->payment->bankAccount)
            $display['profiles'][] = array($pprofile->customerPaymentProfileId, "Bank Account {$pprofile->payment->bankAccount->routingNumber}-{$pprofile->payment->bankAccount->accountNumber}");
        elseif ($pprofile->payment->creditCard)
            $display['profiles'][] = array($pprofile->customerPaymentProfileId, "Credit Card XXXXXXXX{$pprofile->payment->creditCard->cardNumber}");
    }

 

View solution in original post

TJPride
Expert
1 REPLY 1

This should get you fairly close to where you need to go. Just use print_r() if you're not sure about the data structure at any point.

 

    $profile = $request->getCustomerProfile($profile_id);
    
    if (!$profile->isOk())
        $errors[] = $profile->xml->messages->message->text;

    else for ($i = 0; $pprofile = $profile->xml->profile->paymentProfiles[$i]; $i++) {
        if ($pprofile->payment->bankAccount)
            $display['profiles'][] = array($pprofile->customerPaymentProfileId, "Bank Account {$pprofile->payment->bankAccount->routingNumber}-{$pprofile->payment->bankAccount->accountNumber}");
        elseif ($pprofile->payment->creditCard)
            $display['profiles'][] = array($pprofile->customerPaymentProfileId, "Credit Card XXXXXXXX{$pprofile->payment->creditCard->cardNumber}");
    }

 

TJPride
Expert