Search in sources :

Example 1 with DeletedExternalAccount

use of com.stripe.model.DeletedExternalAccount 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()));
    }
}
Also used : Customer(com.stripe.model.Customer) DeletedCustomer(com.stripe.model.DeletedCustomer) HashMap(java.util.HashMap) ExternalAccount(com.stripe.model.ExternalAccount) DeletedExternalAccount(com.stripe.model.DeletedExternalAccount) DeletedExternalAccount(com.stripe.model.DeletedExternalAccount) BaseStripeFunctionalTest(com.stripe.BaseStripeFunctionalTest) Test(org.junit.Test)

Aggregations

BaseStripeFunctionalTest (com.stripe.BaseStripeFunctionalTest)1 Customer (com.stripe.model.Customer)1 DeletedCustomer (com.stripe.model.DeletedCustomer)1 DeletedExternalAccount (com.stripe.model.DeletedExternalAccount)1 ExternalAccount (com.stripe.model.ExternalAccount)1 HashMap (java.util.HashMap)1 Test (org.junit.Test)1