private static Map<String,Object> makeCardParams( CreditCard creditCard, boolean update, String cardNumber, byte expirationMonth, short expirationYear, String cardCode ) { Map<String,Object> cardParams = new HashMap<String,Object>(); addParam(update, cardParams, "number", CreditCard.numbersOnly(cardNumber)); addParam(update, cardParams, "exp_month", expirationMonth); addParam(update, cardParams, "exp_year", expirationYear); addParam(update, cardParams, "cvc", cardCode); addCardParams(creditCard, update, cardParams); return cardParams; }
@Override public void updateCreditCard(CreditCard creditCard) throws IOException { // Update the Customer Map<String,Object> updateCustomerParams = new HashMap<String,Object>(); addCustomerParams(creditCard, true, updateCustomerParams); // Update the default Card Map<String,Object> updateCardParams = new HashMap<String,Object>(); addCardParams(creditCard, true, updateCardParams); try { Customer customer = Customer.retrieve(creditCard.getProviderUniqueId(), options); customer.update(updateCustomerParams, options); CustomerCardCollection cards = customer.getCards(); Card defaultCard = cards.retrieve(customer.getDefaultCard(), options); defaultCard.update(updateCardParams, options); } catch(StripeException e) { ConvertedError converted = convertError(e); // TODO: Throw ErrorCodeException to provide more details throw new LocalizedIOException(e, accessor, "MerchantServicesProvider.updateCreditCardNumberAndExpiration.notSuccessful"); } }