use of com.stripe.model.ExternalAccount in project stripe-java by stripe.
the class CustomerTest method testCustomerCreatePerCallAPIKey.
@Test
public void testCustomerCreatePerCallAPIKey() throws StripeException {
Customer customer = Customer.create(defaultCustomerParams, supportedRequestOptions);
assertEquals(customer.getDescription(), "J Bindings Customer");
List<ExternalAccount> customerSources = customer.getSources().getData();
assertEquals(1, customerSources.size());
assertThat(customerSources.get(0), instanceOf(Card.class));
assertEquals("4242", ((Card) customerSources.get(0)).getLast4());
}
use of com.stripe.model.ExternalAccount 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.ExternalAccount 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.ExternalAccount in project stripe-java by stripe.
the class CustomerTest method testCustomerCardDelete.
@Test
public void testCustomerCardDelete() throws StripeException {
Customer customer = Customer.create(defaultCustomerParams, supportedRequestOptions);
Map<String, Object> creationParams = new HashMap<String, Object>();
creationParams.put("source", "tok_visa");
customer.createCard(creationParams);
ExternalAccount card = customer.getSources().getData().get(0);
DeletedExternalAccount deletedCard = card.delete();
Customer retrievedCustomer = Customer.retrieve(customer.getId(), supportedRequestOptions);
assertTrue(deletedCard.getDeleted());
assertEquals(deletedCard.getId(), card.getId());
for (ExternalAccount retrievedCard : retrievedCustomer.getSources().getData()) {
assertFalse("Card was not actually deleted: " + card.getId(), card.getId().equals(retrievedCard.getId()));
}
}
use of com.stripe.model.ExternalAccount in project stripe-java by stripe.
the class CustomerTest method testCreateCardThroughCollection.
@Test
public void testCreateCardThroughCollection() throws StripeException {
Customer createdCustomer = Customer.create(defaultCustomerParams, supportedRequestOptions);
Map<String, Object> creationParams = new HashMap<String, Object>();
creationParams.put("source", "tok_visa");
ExternalAccount addedCard = createdCustomer.getSources().create(creationParams);
assertEquals(createdCustomer.getId(), addedCard.getCustomer());
Customer updatedCustomer = Customer.retrieve(createdCustomer.getId(), supportedRequestOptions);
assertEquals(2, updatedCustomer.getSources().getData().size());
}
Aggregations