use of com.stripe.model.Customer in project stripe-java by stripe.
the class CustomerTest method testCustomerCardUpdate.
@Test
public void testCustomerCardUpdate() throws StripeException {
Customer customer = Customer.create(defaultCustomerParams, supportedRequestOptions);
ExternalAccount originalCard = customer.getSources().getData().get(0);
Map<String, Object> updateParams = new HashMap<String, Object>();
updateParams.put("name", "J Bindings Cardholder, Jr.");
ExternalAccount updatedCard = originalCard.update(updateParams);
assertThat(updatedCard, instanceOf(Card.class));
assertEquals(((Card) updatedCard).getName(), "J Bindings Cardholder, Jr.");
}
use of com.stripe.model.Customer in project stripe-java by stripe.
the class CustomerTest method testCustomerUpdateToNull.
@Test
public void testCustomerUpdateToNull() throws StripeException {
Customer createdCustomer = Customer.create(defaultCustomerParams);
Map<String, Object> updateParams = new HashMap<String, Object>();
updateParams.put("description", null);
Customer updatedCustomer = createdCustomer.update(updateParams);
assertEquals(updatedCustomer.getDescription(), null);
}
use of com.stripe.model.Customer in project stripe-java by stripe.
the class CustomerTest method testCustomerUpdate.
@Test
public void testCustomerUpdate() throws StripeException {
Customer createdCustomer = Customer.create(defaultCustomerParams);
Map<String, Object> updateParams = new HashMap<String, Object>();
updateParams.put("description", "Updated Description");
Customer updatedCustomer = createdCustomer.update(updateParams);
assertEquals(updatedCustomer.getDescription(), "Updated Description");
}
use of com.stripe.model.Customer in project stripe-java by stripe.
the class CustomerTest method testCustomerBankAccountAddition.
@Test
public void testCustomerBankAccountAddition() throws StripeException {
Customer createdCustomer = Customer.create(defaultCustomerParams, supportedRequestOptions);
final String originalDefaultCard = createdCustomer.getDefaultCard();
Map<String, Object> creationParams = new HashMap<String, Object>();
creationParams.put("bank_account", defaultBankAccountParams);
final BankAccount addedBankAccount = createdCustomer.createBankAccount(creationParams);
createdCustomer.createCard("tok_visa");
Customer updatedCustomer = Customer.retrieve(createdCustomer.getId(), supportedRequestOptions);
assertEquals((Integer) updatedCustomer.getSources().getData().size(), (Integer) 3);
assertEquals(updatedCustomer.getDefaultCard(), originalDefaultCard);
Map<String, Object> updateParams = new HashMap<String, Object>();
updateParams.put("default_source", addedBankAccount.getId());
Customer customerAfterDefaultSourceUpdate = updatedCustomer.update(updateParams, supportedRequestOptions);
assertEquals((Integer) customerAfterDefaultSourceUpdate.getSources().getData().size(), (Integer) 3);
assertEquals(customerAfterDefaultSourceUpdate.getDefaultSource(), addedBankAccount.getId());
}
use of com.stripe.model.Customer in project stripe-java by stripe.
the class CustomerTest method testCustomerBankAccountDelete.
@Test
public void testCustomerBankAccountDelete() throws StripeException {
Customer customer = Customer.create(defaultCustomerParams, supportedRequestOptions);
Map<String, Object> creationParams = new HashMap<String, Object>();
creationParams.put("bank_account", defaultBankAccountParams);
BankAccount addedBankAccount = customer.createBankAccount(creationParams);
DeletedBankAccount deletedBankAccount = addedBankAccount.delete();
Customer retrievedCustomer = Customer.retrieve(customer.getId(), supportedRequestOptions);
assertTrue(deletedBankAccount.getDeleted());
assertEquals(deletedBankAccount.getId(), addedBankAccount.getId());
for (ExternalAccount retrievedSource : retrievedCustomer.getSources().getData()) {
assertFalse("Card was not actually deleted: " + addedBankAccount.getId(), addedBankAccount.getId().equals(retrievedSource.getId()));
}
}
Aggregations