use of com.stripe.model.BankAccount 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.BankAccount 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()));
}
}
use of com.stripe.model.BankAccount in project stripe-java by stripe.
the class CustomerTest method testCustomerSourceList.
@Test
public void testCustomerSourceList() throws StripeException {
Customer customer = Customer.create(defaultCustomerParams);
Map<String, Object> creationParams = new HashMap<String, Object>();
creationParams.put("bank_account", defaultBankAccountParams);
customer.createBankAccount(creationParams);
HashMap<String, Object> listParams = new HashMap<String, Object>();
List<ExternalAccount> customerSourceList = customer.getSources().all(listParams).getData();
assertEquals(2, customerSourceList.size());
assert (customerSourceList.get(0) instanceof Card);
assertEquals("4242", ((Card) customerSourceList.get(0)).getLast4());
assert (customerSourceList.get(1) instanceof BankAccount);
assertEquals("6789", ((BankAccount) customerSourceList.get(1)).getLast4());
}
Aggregations