Search in sources :

Example 1 with ExternalAccountCollection

use of com.stripe.model.ExternalAccountCollection in project stripe-java by stripe.

the class CustomerTest method testCustomerSourceDelete.

@Test
public void testCustomerSourceDelete() throws StripeException {
    Customer customer = Customer.create(defaultCustomerParams);
    ExternalAccountCollection customerSources = customer.getSources();
    ExternalAccount paymentSource = customerSources.getData().get(0);
    paymentSource.delete();
    HashMap<String, Object> listParams = new HashMap<String, Object>();
    assertEquals(0, customerSources.all(listParams).getData().size());
}
Also used : Customer(com.stripe.model.Customer) DeletedCustomer(com.stripe.model.DeletedCustomer) HashMap(java.util.HashMap) ExternalAccountCollection(com.stripe.model.ExternalAccountCollection) ExternalAccount(com.stripe.model.ExternalAccount) DeletedExternalAccount(com.stripe.model.DeletedExternalAccount) BaseStripeFunctionalTest(com.stripe.BaseStripeFunctionalTest) Test(org.junit.Test)

Example 2 with ExternalAccountCollection

use of com.stripe.model.ExternalAccountCollection in project stripe-java by stripe.

the class CustomerTest method testCustomerSourceUpdate.

@Test
public void testCustomerSourceUpdate() throws StripeException {
    Customer customer = Customer.create(defaultCustomerParams);
    ExternalAccountCollection customerSources = customer.getSources();
    ExternalAccount paymentSource = customerSources.getData().get(0);
    assert (paymentSource instanceof Card);
    Card card = (Card) paymentSource;
    HashMap<String, Object> updateParams = new HashMap<String, Object>();
    updateParams.put("address_line1", "some address details");
    Card updatedCard = card.update(updateParams);
    assertEquals("some address details", updatedCard.getAddressLine1());
}
Also used : Customer(com.stripe.model.Customer) DeletedCustomer(com.stripe.model.DeletedCustomer) HashMap(java.util.HashMap) ExternalAccountCollection(com.stripe.model.ExternalAccountCollection) ExternalAccount(com.stripe.model.ExternalAccount) DeletedExternalAccount(com.stripe.model.DeletedExternalAccount) Card(com.stripe.model.Card) BaseStripeFunctionalTest(com.stripe.BaseStripeFunctionalTest) Test(org.junit.Test)

Example 3 with ExternalAccountCollection

use of com.stripe.model.ExternalAccountCollection in project stripe-java by stripe.

the class CustomerTest method testCustomerSourceRetrieveCard.

@Test
public void testCustomerSourceRetrieveCard() throws StripeException {
    Customer customer = Customer.create(defaultCustomerParams);
    ExternalAccountCollection customerSources = customer.getSources();
    String paymentSourceId = customerSources.getData().get(0).getId();
    ExternalAccount paymentSource = customerSources.retrieve(paymentSourceId);
    assertNotNull(paymentSource);
    assertEquals(paymentSourceId, paymentSource.getId());
}
Also used : Customer(com.stripe.model.Customer) DeletedCustomer(com.stripe.model.DeletedCustomer) ExternalAccountCollection(com.stripe.model.ExternalAccountCollection) ExternalAccount(com.stripe.model.ExternalAccount) DeletedExternalAccount(com.stripe.model.DeletedExternalAccount) BaseStripeFunctionalTest(com.stripe.BaseStripeFunctionalTest) Test(org.junit.Test)

Aggregations

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