cancel
Showing results for 
Search instead for 
Did you mean: 

Update Billing Address using CIM Java SDK

I have a business requirement to allow users to update their billing address only, not having to reenter the credit card details.

 

I have similar functionality that updates the credit card only, leaving the old billing address, and it works.

 

When I execute the code below I get an error: E00027 - (TESTMODE) The credit card has expired.

 

Here's my code:

    // fetch current payment profile
    Transaction transaction = merchant.createCIMTransaction(TransactionType.GET_CUSTOMER_PAYMENT_PROFILE);

    transaction.setCustomerProfileId(customerProfileId);
    transaction.setCustomerPaymentProfileId(paymentProfileId);

    Result<Transaction> result = (Result<Transaction>) merchant.postTransaction(transaction);
    final net.authorize.data.cim.PaymentProfile currPaymentProfile = result.getCustomerPaymentProfile();

    currPaymentProfile.setBillTo(newBillingAddress);

    // save billing address updates
    transaction = merchant.createCIMTransaction(TransactionType.UPDATE_CUSTOMER_PAYMENT_PROFILE);
    transaction.setCustomerProfileId(customerProfileId);
    transaction.addPaymentProfile(currPaymentProfile);
    transaction.setValidationMode(ValidationModeType.TEST_MODE);

    result = (Result<Transaction>) merchant.postTransaction(transaction);
    result.printMessages();

 Is this a bug, or am I doing something wrong here?

 

I couldn't find a real documentation for the SDK, but according to the XML and SOAP docs, fetching the existing payment profile, and filling in the updates should be OK, even though the CC details are masked.

 

If it helps, I use the following SDK version:

    <dependency>
      <groupId>net.authorize</groupId>
      <artifactId>anet-java-sdk</artifactId>
      <version>1.4.5</version>
    </dependency>

 

eran
Contributor
22 REPLIES 22

I look thru the code and I think I found the problem

 

updateCustomerPaymentProfile()
  call addPaymentProfiles()
    call addPayment()
      Line cc_exp_el.appendChild(document.getDocument().createTextNode(net.authorize.util.DateUtil.getFormattedDate(credit_card.getExpirationDate(),
                    CreditCard.ARB_EXPIRY_DATE_FORMAT)));

getFormattedDate() not checking for Masked ExprationDate and return it as is("XXXX").

I found the bug:

 

net.authorize.util.DateUtil.getFormattedDate(Date, String), that gets called from net.authorize.cim.Transaction.addPayment(BasicXmlDocument, Payment, Element)

 

The getFormattedDate() method should format the masked date as 'XXXX' but instead renders it as '1970-01'.

lol, you beat me to it by 2 min :)

MOD / Admins,

 

I have a fix for this issue - changed the DateUtil code to parse Jan-1970 (1970-01) date as XXXX:

public class DateUtil{

  private static final String MASKED_DATE = "XXXX";

  public static Date getDateFromFormattedDate(final String dateStr, final String format) {
    try{
      final SimpleDateFormat sdf=new SimpleDateFormat(format);
      if (dateStr != null && !MASKED_DATE.equals(dateStr)) {
        final Date date=sdf.parse(dateStr);
        return date;
      }
    }
    catch(final ParseException pe){
      System.out.println("Exception: " + pe);
    }
    return new Date(0);
  }

  public static String getFormattedDate(final Date date, final String format) {
    try {
      if (date.getTime() == 0) {
        return MASKED_DATE;
      }
      final SimpleDateFormat sdf=new SimpleDateFormat(format);
      return sdf.format(date);
    }
    catch(final Exception e){
      System.out.println(e);
    }
    return null;
  }
}

 This makes the round trip getFormattedDate(getDateFromFormattedDate("XXXX", "yyyy-MM"), "yyyy-MM") correct, and coherent.

 

All tests pass except ReportingTest - I have no permission to call the Transaction Details API apprrently:

Result Code: Error
E00011 - Access denied. You do not have permission to call the Transaction Details API.

 Can this fix be pushed to the next version please?

 

Hey guys,

 

Thanks for the heads up on this. I've reported this to our developers so that they can get it fixed and included in an upcoming release. Appreciate it!

 

Thanks,

 

Michelle

Developer Community Manager

To address the other error that you mentioned (E00011), it generally indicates that a username and password was mistakenly used instead of the API login ID and Transaction key.

Trevor
Administrator Administrator
Administrator

@Trevor, everything else works for me except for the Transaction Details API

It might be the API is disable.

Login to authorize.net

Account - Settings - Security Settings - General Security Settings - Transaction Detail API

 

Michelle, when can we expect that this will be fixed in the official release?

Hey svetozar,

 

I don't have any date that I can give you as to when this bug will be fixed in the SDK. But once we do make any SDK updates, we will announce it in the News and Announcements board.

 

Thanks for your patience!

 

Michelle

Developer Community Manager