<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Problem parsing payment methods from result of getCustomerProfile call in Integration and Testing</title>
    <link>https://community.developer.cybersource.com/t5/Integration-and-Testing/Problem-parsing-payment-methods-from-result-of/m-p/32613#M17165</link>
    <description>&lt;P&gt;This seems to be working for me. $pprofile is payment profile, and you'll have to do some twiddling with the specific values, but thiis works with one or multiple profiles.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;    $profile = $request-&amp;gt;getCustomerProfile($profile_id_here);
    
    if (!$profile-&amp;gt;isOk())
        $errors[] = $profile-&amp;gt;xml-&amp;gt;messages-&amp;gt;message-&amp;gt;text;

    else for ($i = 0; $pprofile = $profile-&amp;gt;xml-&amp;gt;profile-&amp;gt;paymentProfiles[$i]; $i++) {
        if ($pprofile-&amp;gt;payment-&amp;gt;bankAccount)
            $display['profiles'][] = array($pprofile-&amp;gt;customerPaymentProfileId, "Bank Account {$pprofile-&amp;gt;payment-&amp;gt;bankAccount-&amp;gt;routingNumber}-{$pprofile-&amp;gt;payment-&amp;gt;bankAccount-&amp;gt;accountNumber}");
        elseif ($pprofile-&amp;gt;payment-&amp;gt;creditCard)
            $display['profiles'][] = array($pprofile-&amp;gt;customerPaymentProfileId, "Credit Card XXXXXXXX{$pprofile-&amp;gt;payment-&amp;gt;creditCard-&amp;gt;cardNumber}");
    }&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 21 Jan 2013 13:30:22 GMT</pubDate>
    <dc:creator>TJPride</dc:creator>
    <dc:date>2013-01-21T13:30:22Z</dc:date>
    <item>
      <title>Problem parsing payment methods from result of getCustomerProfile call</title>
      <link>https://community.developer.cybersource.com/t5/Integration-and-Testing/Problem-parsing-payment-methods-from-result-of/m-p/32499#M17054</link>
      <description>&lt;P&gt;I'm using the PHP SDK to contact the gateway like so:&lt;/P&gt;&lt;PRE&gt;// create a request object
$request = new AuthorizeNetCIM(API_LOGIN_ID, TRANSACTION_KEY);
$request-&amp;gt;setSandbox(AUTHORIZENET_SANDBOX);
$request-&amp;gt;setLogFile(AUTHORIZENET_LOG_FILE);
$response = $request-&amp;gt;getCustomerProfile($authorizenet_customer_profile_id);

&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;This brings back a result, but the PHP SDK doesn't seem to be able to do anything very useful with it:&lt;/P&gt;&lt;P&gt;$response-&amp;gt;getCustomerProfileIds() returns NULL even with a valid response&lt;/P&gt;&lt;P&gt;$response-&amp;gt;getCustomerPaymentProfileIds() returns NULL even with a valid response&lt;/P&gt;&lt;P&gt;$response-&amp;gt;getCustomerShippingAddressIds() returns NULL even with a valid response&lt;/P&gt;&lt;P&gt;$response-&amp;gt;getCustomerAddressId() returns FALSE even with a valid response&lt;/P&gt;&lt;P&gt;$response-&amp;gt;getCustomerProfileId() actually does return a profile id but that's useless.&amp;nbsp; i had to have the profile id to call the original gateway function.&lt;/P&gt;&lt;P&gt;$response-&amp;gt;getPaymentProfileId() actually returns *one* of the payment profile ids regardless of how many are returned.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Given this sad peformance, I attempted to do some var_dumps on the object returned and some casting to sort things out.&amp;nbsp; This has turned out to be a nightmare because the response XML is totally different when a user has a single payment account versus when they have several.&amp;nbsp; This code works great when a user has several accounts.&amp;nbsp; When they have one, it creates a useless 3-element array:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;$prof_array = (array)$response-&amp;gt;xml-&amp;gt;profile;
$payment_profiles = $prof_array["paymentProfiles"];

$result = array();
foreach($payment_profiles as $prof){
    $arr = array();
    $arr["payment_profile_id"] = (int)$prof-&amp;gt;customerPaymentProfileId;
    
    if ($prof-&amp;gt;payment-&amp;gt;creditCard) {
        $arr["type"] = "creditCard";
        $arr["card_number"] = (string)$prof-&amp;gt;payment-&amp;gt;creditCard-&amp;gt;cardNumber;
    } elseif ($prof-&amp;gt;payment-&amp;gt;bankAccount) {
        $ba = $prof-&amp;gt;payment-&amp;gt;bankAccount;
        $arr["type"] = "bankAccount";
        $arr["account_type"] = (string)$ba-&amp;gt;accountType;
        $arr["routing_number"] = (string)$ba-&amp;gt;routingNumber;
        $arr["account_number"] = (string)$ba-&amp;gt;accountNumber;
        $arr["name_on_account"] = (string)$ba-&amp;gt;nameOnAccount;
        $arr["bank_name"] = (string)$ba-&amp;gt;bankName; 
    }
    
    $result[] = $arr;
}&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can anyone tell me the proper way to extract the masked card number (e.g., XXXX1234) and/or bank account details from a getCustomerProfile call?&amp;nbsp; I'm really disappointed with the PHP SDK.&lt;/P&gt;</description>
      <pubDate>Tue, 15 Jan 2013 04:58:45 GMT</pubDate>
      <guid>https://community.developer.cybersource.com/t5/Integration-and-Testing/Problem-parsing-payment-methods-from-result-of/m-p/32499#M17054</guid>
      <dc:creator>sneakyimp</dc:creator>
      <dc:date>2013-01-15T04:58:45Z</dc:date>
    </item>
    <item>
      <title>Re: Problem parsing payment methods from result of getCustomerProfile call</title>
      <link>https://community.developer.cybersource.com/t5/Integration-and-Testing/Problem-parsing-payment-methods-from-result-of/m-p/32532#M17087</link>
      <description>&lt;P&gt;Bump!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Seriously, can anyone tell me if I'm missing something in the PHP SDK?&amp;nbsp; Alternatively, can anyone recommend the most efficient technique for retrieving a well-structured data object listing of all the payment profiles that belong to a given customer profile id? The technique needs to work whether the customer has multiple profiles or just one.&lt;/P&gt;</description>
      <pubDate>Wed, 16 Jan 2013 17:15:40 GMT</pubDate>
      <guid>https://community.developer.cybersource.com/t5/Integration-and-Testing/Problem-parsing-payment-methods-from-result-of/m-p/32532#M17087</guid>
      <dc:creator>sneakyimp</dc:creator>
      <dc:date>2013-01-16T17:15:40Z</dc:date>
    </item>
    <item>
      <title>Re: Problem parsing payment methods from result of getCustomerProfile call</title>
      <link>https://community.developer.cybersource.com/t5/Integration-and-Testing/Problem-parsing-payment-methods-from-result-of/m-p/32613#M17165</link>
      <description>&lt;P&gt;This seems to be working for me. $pprofile is payment profile, and you'll have to do some twiddling with the specific values, but thiis works with one or multiple profiles.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;    $profile = $request-&amp;gt;getCustomerProfile($profile_id_here);
    
    if (!$profile-&amp;gt;isOk())
        $errors[] = $profile-&amp;gt;xml-&amp;gt;messages-&amp;gt;message-&amp;gt;text;

    else for ($i = 0; $pprofile = $profile-&amp;gt;xml-&amp;gt;profile-&amp;gt;paymentProfiles[$i]; $i++) {
        if ($pprofile-&amp;gt;payment-&amp;gt;bankAccount)
            $display['profiles'][] = array($pprofile-&amp;gt;customerPaymentProfileId, "Bank Account {$pprofile-&amp;gt;payment-&amp;gt;bankAccount-&amp;gt;routingNumber}-{$pprofile-&amp;gt;payment-&amp;gt;bankAccount-&amp;gt;accountNumber}");
        elseif ($pprofile-&amp;gt;payment-&amp;gt;creditCard)
            $display['profiles'][] = array($pprofile-&amp;gt;customerPaymentProfileId, "Credit Card XXXXXXXX{$pprofile-&amp;gt;payment-&amp;gt;creditCard-&amp;gt;cardNumber}");
    }&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 21 Jan 2013 13:30:22 GMT</pubDate>
      <guid>https://community.developer.cybersource.com/t5/Integration-and-Testing/Problem-parsing-payment-methods-from-result-of/m-p/32613#M17165</guid>
      <dc:creator>TJPride</dc:creator>
      <dc:date>2013-01-21T13:30:22Z</dc:date>
    </item>
  </channel>
</rss>

