<?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 Why is Customer Payment Profiles returned as a list? in Integration and Testing</title>
    <link>https://community.developer.cybersource.com/t5/Integration-and-Testing/Why-is-Customer-Payment-Profiles-returned-as-a-list/m-p/21811#M11854</link>
    <description>&lt;P&gt;I have recently download the Java API.&amp;nbsp; Have been making a higher level API for integration into a subscription service.&amp;nbsp; In trying to get the data to make a dropdown list of a customers payment profiles, I am performing a GET_CUSTOMER_PROFILE transaction.&amp;nbsp; From the Result, I am getting the payment profile list.&amp;nbsp; For each payment profile, I was getting the Payment, but find it is not returned by the API as single object, but a list.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My question is, if there is more than one Payment item, which one(s) do I use?&amp;nbsp; I do not actually have a way to test this code, since all I have so far is this forum account. Did not really see anyone else asking this question before.&amp;nbsp; Here is the nearly self-contained method:&lt;/P&gt;&lt;PRE&gt;    public static String[] getPaymentProfileDescs(final String cust_profile_id) throws Exception {
        final net.authorize.cim.Transaction transaction = instance.merchant.createCIMTransaction(TransactionType.GET_CUSTOMER_PROFILE);
        transaction.setCustomerProfileId(cust_profile_id);

        final Result&amp;lt;Transaction&amp;gt; result = (Result&amp;lt;Transaction&amp;gt;) instance.merchant.postTransaction(transaction);

        if (result.isOk() ){
            final ArrayList&amp;lt;PaymentProfile&amp;gt; paymentProfileList = result.getCustomerPaymentProfileList();
            final int sz = paymentProfileList.size();
            final String[] ret = new String[sz];
            
            CreditCard cc;
            BankAccount ba;
            // loop through each of the payment profiles in the list
            for (int i = 0, c = 0; i &amp;lt; sz; i++){
                final PaymentProfile pp = paymentProfileList.get(i);
                
                // Should it be assumed that there is only 1 payment per payment profile?
                // If so, then why is there a list?  If not, read first? Last?
                final Payment payment = pp.getPaymentList().get(0);
                
                // description depends on where it is a credit card (last 4), or bank account(Name)
                if ((cc = payment.getCreditCard()) != null){
                    final String ccn = cc.getCreditCardNumber();
                    if (ccn != null &amp;amp;&amp;amp; ccn.length() &amp;gt; 4)
                        ret[c++] = pp.getCustomerPaymentProfileId() + "|" + ccn.substring(ccn.length() - 4);
                
                }else if ((ba = payment.getBankAccount()) != null){
                    final String ban = ba.getBankAccountName();
                    if (ban != null &amp;amp;&amp;amp; ban.length() &amp;gt; 0)
                        ret[c++] = pp.getCustomerPaymentProfileId() + "|" + ban;
                }
            }
            return ret;
            
        }else throw new Exception(getResultMessages(result) );
    }&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 18 Jan 2012 17:37:54 GMT</pubDate>
    <dc:creator>WIS</dc:creator>
    <dc:date>2012-01-18T17:37:54Z</dc:date>
    <item>
      <title>Why is Customer Payment Profiles returned as a list?</title>
      <link>https://community.developer.cybersource.com/t5/Integration-and-Testing/Why-is-Customer-Payment-Profiles-returned-as-a-list/m-p/21811#M11854</link>
      <description>&lt;P&gt;I have recently download the Java API.&amp;nbsp; Have been making a higher level API for integration into a subscription service.&amp;nbsp; In trying to get the data to make a dropdown list of a customers payment profiles, I am performing a GET_CUSTOMER_PROFILE transaction.&amp;nbsp; From the Result, I am getting the payment profile list.&amp;nbsp; For each payment profile, I was getting the Payment, but find it is not returned by the API as single object, but a list.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My question is, if there is more than one Payment item, which one(s) do I use?&amp;nbsp; I do not actually have a way to test this code, since all I have so far is this forum account. Did not really see anyone else asking this question before.&amp;nbsp; Here is the nearly self-contained method:&lt;/P&gt;&lt;PRE&gt;    public static String[] getPaymentProfileDescs(final String cust_profile_id) throws Exception {
        final net.authorize.cim.Transaction transaction = instance.merchant.createCIMTransaction(TransactionType.GET_CUSTOMER_PROFILE);
        transaction.setCustomerProfileId(cust_profile_id);

        final Result&amp;lt;Transaction&amp;gt; result = (Result&amp;lt;Transaction&amp;gt;) instance.merchant.postTransaction(transaction);

        if (result.isOk() ){
            final ArrayList&amp;lt;PaymentProfile&amp;gt; paymentProfileList = result.getCustomerPaymentProfileList();
            final int sz = paymentProfileList.size();
            final String[] ret = new String[sz];
            
            CreditCard cc;
            BankAccount ba;
            // loop through each of the payment profiles in the list
            for (int i = 0, c = 0; i &amp;lt; sz; i++){
                final PaymentProfile pp = paymentProfileList.get(i);
                
                // Should it be assumed that there is only 1 payment per payment profile?
                // If so, then why is there a list?  If not, read first? Last?
                final Payment payment = pp.getPaymentList().get(0);
                
                // description depends on where it is a credit card (last 4), or bank account(Name)
                if ((cc = payment.getCreditCard()) != null){
                    final String ccn = cc.getCreditCardNumber();
                    if (ccn != null &amp;amp;&amp;amp; ccn.length() &amp;gt; 4)
                        ret[c++] = pp.getCustomerPaymentProfileId() + "|" + ccn.substring(ccn.length() - 4);
                
                }else if ((ba = payment.getBankAccount()) != null){
                    final String ban = ba.getBankAccountName();
                    if (ban != null &amp;amp;&amp;amp; ban.length() &amp;gt; 0)
                        ret[c++] = pp.getCustomerPaymentProfileId() + "|" + ban;
                }
            }
            return ret;
            
        }else throw new Exception(getResultMessages(result) );
    }&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 18 Jan 2012 17:37:54 GMT</pubDate>
      <guid>https://community.developer.cybersource.com/t5/Integration-and-Testing/Why-is-Customer-Payment-Profiles-returned-as-a-list/m-p/21811#M11854</guid>
      <dc:creator>WIS</dc:creator>
      <dc:date>2012-01-18T17:37:54Z</dc:date>
    </item>
    <item>
      <title>Re: Why is Customer Payment Profiles returned as a list?</title>
      <link>https://community.developer.cybersource.com/t5/Integration-and-Testing/Why-is-Customer-Payment-Profiles-returned-as-a-list/m-p/21821#M11859</link>
      <description>&lt;P&gt;Make it a bit more readable here:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;public static String[] getPaymentProfileDescs(final String cust_profile_id) throws Exception {
    final net.authorize.cim.Transaction transaction = instance.merchant.createCIMTransaction(TransactionType.GET_CUSTOMER_PROFILE);
    transaction.setCustomerProfileId(cust_profile_id);

    final Result&amp;lt;Transaction&amp;gt; result = (Result&amp;lt;Transaction&amp;gt;) instance.merchant.postTransaction(transaction);

    if (result.isOk() ){
        final ArrayList&amp;lt;PaymentProfile&amp;gt; paymentProfileList = result.getCustomerPaymentProfileList();
        final int sz = paymentProfileList.size();
        final String[] ret = new String[sz];
            
        CreditCard cc;
        BankAccount ba;
        // loop through each of the payment profiles in the list
        for (int i = 0, c = 0; i &amp;lt; sz; i++){
            final PaymentProfile pp = paymentProfileList.get(i);
                
            // Assumed only 1 payment per payment profile?
            // If so, then why a list?  If not, read first? Last?
            final Payment payment = pp.getPaymentList().get(0);
                
            // desc for credit card(last 4), or bank account(Name)
            if ((cc = payment.getCreditCard()) != null){
                final String ccn = cc.getCreditCardNumber();
                if (ccn != null &amp;amp;&amp;amp; ccn.length() &amp;gt; 4)
                    ret[c++] = pp.getCustomerPaymentProfileId() + "|" + ccn.substring(ccn.length() - 4);
                
            }else if ((ba = payment.getBankAccount()) != null){
                final String ban = ba.getBankAccountName();
                if (ban != null &amp;amp;&amp;amp; ban.length() &amp;gt; 0)
                    ret[c++] = pp.getCustomerPaymentProfileId() + "|" + ban;
            }
        }
        return ret;
            
    }else throw new Exception(getResultMessages(result) );
}&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 18 Jan 2012 18:41:53 GMT</pubDate>
      <guid>https://community.developer.cybersource.com/t5/Integration-and-Testing/Why-is-Customer-Payment-Profiles-returned-as-a-list/m-p/21821#M11859</guid>
      <dc:creator>WIS</dc:creator>
      <dc:date>2012-01-18T18:41:53Z</dc:date>
    </item>
    <item>
      <title>Re: Why is Customer Payment Profiles returned as a list?</title>
      <link>https://community.developer.cybersource.com/t5/Integration-and-Testing/Why-is-Customer-Payment-Profiles-returned-as-a-list/m-p/21849#M11871</link>
      <description>&lt;P&gt;Does seem a bit odd. Do you have a way to var dump the whole structure? How about trace this back to the XML and dump that as well? Might give a better idea as to how things are set up when there's more than one payment profile / payment method.&lt;/P&gt;</description>
      <pubDate>Thu, 19 Jan 2012 00:36:57 GMT</pubDate>
      <guid>https://community.developer.cybersource.com/t5/Integration-and-Testing/Why-is-Customer-Payment-Profiles-returned-as-a-list/m-p/21849#M11871</guid>
      <dc:creator>TJPride</dc:creator>
      <dc:date>2012-01-19T00:36:57Z</dc:date>
    </item>
    <item>
      <title>Re: Why is Customer Payment Profiles returned as a list?</title>
      <link>https://community.developer.cybersource.com/t5/Integration-and-Testing/Why-is-Customer-Payment-Profiles-returned-as-a-list/m-p/21905#M11899</link>
      <description>&lt;P&gt;Not sure what var dump is, but I am integrating at source code level.&amp;nbsp; This means I can control-click any of Authorize's method I am calling, and the Netbeans IDE opens up the source class in another tab &amp;amp; jumps to the spot of source of the method.&amp;nbsp; Been doing a lot of that.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Just got a developer account today, but all changes have not been roughed in, so cannot compile at this time.&amp;nbsp; When done though, the Authorize source reads that both input &amp;amp; raw outputs can be echoed to log file with either of their sandbox modes.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;One way to look at it is, I never have to worry about it, if I never permit multiple payments in a payment profile.&amp;nbsp; This is enforceable since I am only embedding it in a software license server for products developed in-house.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;BTW, how&amp;nbsp; is an expired card remedied? A create of new payment profile &amp;amp; delete of old, or update existing?&lt;/P&gt;</description>
      <pubDate>Thu, 19 Jan 2012 17:12:35 GMT</pubDate>
      <guid>https://community.developer.cybersource.com/t5/Integration-and-Testing/Why-is-Customer-Payment-Profiles-returned-as-a-list/m-p/21905#M11899</guid>
      <dc:creator>WIS</dc:creator>
      <dc:date>2012-01-19T17:12:35Z</dc:date>
    </item>
    <item>
      <title>Re: Why is Customer Payment Profiles returned as a list?</title>
      <link>https://community.developer.cybersource.com/t5/Integration-and-Testing/Why-is-Customer-Payment-Profiles-returned-as-a-list/m-p/21913#M11903</link>
      <description>&lt;P&gt;You can do it either way, but updating is probably more efficient.&lt;/P&gt;</description>
      <pubDate>Thu, 19 Jan 2012 19:17:40 GMT</pubDate>
      <guid>https://community.developer.cybersource.com/t5/Integration-and-Testing/Why-is-Customer-Payment-Profiles-returned-as-a-list/m-p/21913#M11903</guid>
      <dc:creator>TJPride</dc:creator>
      <dc:date>2012-01-19T19:17:40Z</dc:date>
    </item>
    <item>
      <title>Re: Why is Customer Payment Profiles returned as a list?</title>
      <link>https://community.developer.cybersource.com/t5/Integration-and-Testing/Why-is-Customer-Payment-Profiles-returned-as-a-list/m-p/22409#M12130</link>
      <description>&lt;P&gt;If I understand correctly, it looks like the "transaction" you are running is actually a request to get a customer profile.&amp;nbsp; In this case, it is quite possible that there will be multiple payment options on file.&amp;nbsp; As far as which of these payment options to select, this is something that depends on the history of how the customer profile was created. A common use case would be to present the customer with a list of the payment options you have on file for them and to let them select which one they want to use for a given transaction.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also, it's worth noting that an "update" request can be accomplished without knowing the full card number.&amp;nbsp; You can submit the redacted card number and a new expiration date.&amp;nbsp; This generally makes it the preferable option to update an expired card.&lt;/P&gt;</description>
      <pubDate>Tue, 31 Jan 2012 22:40:05 GMT</pubDate>
      <guid>https://community.developer.cybersource.com/t5/Integration-and-Testing/Why-is-Customer-Payment-Profiles-returned-as-a-list/m-p/22409#M12130</guid>
      <dc:creator>Trevor</dc:creator>
      <dc:date>2012-01-31T22:40:05Z</dc:date>
    </item>
  </channel>
</rss>

