/** * Update a card. */ @Override public Card update(Map<String, Object> params) throws StripeException { return update(params, (RequestOptions) null); }
/** * Delete a card. */ @Override public Card delete() throws StripeException { return delete((RequestOptions) null); }
@Override protected String getInstanceUrl() { String result = super.getInstanceUrl(); if (result != null) { return result; } else if (this.getRecipient() != null) { return String.format("%s/%s/cards/%s", classUrl(Recipient.class), this.getRecipient(), this.getId()); } else { return null; } } }
/** * Update a card. */ @Override public Card update(Map<String, Object> params, RequestOptions options) throws StripeException { return request(RequestMethod.POST, this.getInstanceUrl(), params, Card.class, options); } // </editor-fold>
@Test public void testUpdate() throws IOException, StripeException { final Customer customer = Customer.retrieve(CUSTOMER_ID); final Card card = getCardFixture(customer); final Map<String, Object> metadata = new HashMap<>(); metadata.put("key", "value"); final Map<String, Object> params = new HashMap<>(); params.put("metadata", metadata); final Card updatedCard = card.update(params); assertNotNull(updatedCard); verifyRequest( ApiResource.RequestMethod.POST, String.format("/v1/customers/%s/sources/%s", customer.getId(), card.getId()), params ); }
@Test public void testDelete() throws IOException, StripeException { final Customer customer = Customer.retrieve(CUSTOMER_ID); final Card card = getCardFixture(customer); final String deleteCardData = String.format( "{\"id\": \"%s\", \"object\": \"card\", \"deleted\": true}", card.getId() ); stubRequest( ApiResource.RequestMethod.DELETE, String.format("/v1/customers/%s/sources/%s", customer.getId(), card.getId()), null, Card.class, deleteCardData ); final Card deletedCard = card.delete(); assertNotNull(deletedCard); assertTrue(deletedCard.getDeleted()); verifyRequest( ApiResource.RequestMethod.DELETE, String.format("/v1/customers/%s/sources/%s", customer.getId(), card.getId()) ); } }
String addressResult = card.getAddressLine1Check(); String zipResult = card.getAddressZipCheck(); if(addressResult != null) { if(zipResult != null) { final String providerCvvResult = card.getCvcCheck(); final AuthorizationResult.CvvResult cvvResult;
public void setDefaultCardObject(Card c) { this.defaultCard = new ExpandableField<>(c.getId(), c); } // </editor-fold>
@Test public void testDeserialize() throws Exception { final String data = getFixture("/v1/customers/cus_123/cards/card_123"); final Card resource = ApiResource.GSON.fromJson(data, Card.class); assertNotNull(resource); assertNotNull(resource.getId()); } }
/** * Delete a card. */ @Override public Card delete(RequestOptions options) throws StripeException { return request(RequestMethod.DELETE, this.getInstanceUrl(), null, Card.class, options); } // </editor-fold>
@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 updateCreditCardExpiration( CreditCard creditCard, byte expirationMonth, short expirationYear ) throws IOException { // Update the default Card Map<String,Object> updateParams = new HashMap<String,Object>(); addParam(true, updateParams, "exp_month", expirationMonth); addParam(true, updateParams, "exp_year", expirationYear); try { Customer customer = Customer.retrieve(creditCard.getProviderUniqueId(), options); CustomerCardCollection cards = customer.getCards(); Card defaultCard = cards.retrieve(customer.getDefaultCard(), options); defaultCard.update(updateParams, options); } catch(StripeException e) { ConvertedError converted = convertError(e); // TODO: Throw ErrorCodeException to provide more details throw new LocalizedIOException(e, accessor, "MerchantServicesProvider.updateCreditCardExpiration.notSuccessful"); } }