service.setStripeId(webUser.get().id, userStripeId); } else { customer.update(customerParams, requestOptions);
/** * Update a customer. */ @Override public Customer update(Map<String, Object> params) throws StripeException { return update(params, (RequestOptions) null); }
Customer cu = Customer.retrieve(stripeCustomerID); Map<String, Object> updateParams = new HashMap<String, Object>(); updateParams.put("source", token); cu.update(updateParams);
@Test public void testUpdate() throws StripeException { final Customer customer = getCustomerFixture(); final Map<String, String> metadata = new HashMap<>(); metadata.put("key", "value"); Map<String, Object> params = new HashMap<>(); params.put("metadata", metadata); final Customer updatedCustomer = customer.update(params); assertNotNull(updatedCustomer); verifyRequest( ApiResource.RequestMethod.POST, String.format("/v1/customers/%s", customer.getId()), params ); }
@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"); } }
@Override public void updateCreditCardNumberAndExpiration( CreditCard creditCard, String cardNumber, byte expirationMonth, short expirationYear, String cardCode ) throws IOException { // Replace the default Card Map<String,Object> cardParams = makeCardParams( creditCard, true, cardNumber, expirationMonth, expirationYear, cardCode!=null ? CreditCard.numbersOnly(cardCode) : creditCard.getCardCode() ); Map<String,Object> updateParams = new HashMap<String,Object>(); addParam(true, updateParams, "card", cardParams); try { Customer customer = Customer.retrieve(creditCard.getProviderUniqueId(), options); customer.update(updateParams, options); } catch(StripeException e) { ConvertedError converted = convertError(e); // TODO: Throw ErrorCodeException to provide more details throw new LocalizedIOException(e, accessor, "MerchantServicesProvider.updateCreditCardNumberAndExpiration.notSuccessful"); } }