Search in sources :

Example 11 with Customer

use of com.stripe.model.Customer 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)

Example 12 with Customer

use of com.stripe.model.Customer 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());
}
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) BaseStripeFunctionalTest(com.stripe.BaseStripeFunctionalTest) Test(org.junit.Test)

Example 13 with Customer

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

the class CustomerTest method testCustomerDeletePerCallAPIKey.

@Test
public void testCustomerDeletePerCallAPIKey() throws StripeException {
    Customer createdCustomer = Customer.create(defaultCustomerParams, Stripe.apiKey);
    DeletedCustomer deletedCustomer = createdCustomer.delete(Stripe.apiKey);
    Customer deletedRetrievedCustomer = Customer.retrieve(createdCustomer.getId(), Stripe.apiKey);
    assertTrue(deletedCustomer.getDeleted());
    assertEquals(deletedCustomer.getId(), createdCustomer.getId());
    assertTrue(deletedRetrievedCustomer.getDeleted());
}
Also used : DeletedCustomer(com.stripe.model.DeletedCustomer) Customer(com.stripe.model.Customer) DeletedCustomer(com.stripe.model.DeletedCustomer) BaseStripeFunctionalTest(com.stripe.BaseStripeFunctionalTest) Test(org.junit.Test)

Example 14 with Customer

use of com.stripe.model.Customer 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 15 with Customer

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

the class InvoiceTest method testInvoiceItemRetrievePerCallAPIKey.

@Test
public void testInvoiceItemRetrievePerCallAPIKey() throws StripeException {
    Customer customer = Customer.create(defaultCustomerParams, Stripe.apiKey);
    InvoiceItem createdInvoiceItem = createDefaultInvoiceItem(customer);
    InvoiceItem retrievedInvoiceItem = InvoiceItem.retrieve(createdInvoiceItem.getId(), Stripe.apiKey);
    assertEquals(createdInvoiceItem.getId(), retrievedInvoiceItem.getId());
}
Also used : InvoiceItem(com.stripe.model.InvoiceItem) DeletedInvoiceItem(com.stripe.model.DeletedInvoiceItem) Customer(com.stripe.model.Customer) BaseStripeFunctionalTest(com.stripe.BaseStripeFunctionalTest) Test(org.junit.Test)

Aggregations

Customer (com.stripe.model.Customer)65 Test (org.junit.Test)63 BaseStripeFunctionalTest (com.stripe.BaseStripeFunctionalTest)60 HashMap (java.util.HashMap)40 DeletedCustomer (com.stripe.model.DeletedCustomer)24 ExternalAccount (com.stripe.model.ExternalAccount)16 Plan (com.stripe.model.Plan)16 Subscription (com.stripe.model.Subscription)15 DeletedExternalAccount (com.stripe.model.DeletedExternalAccount)13 DeletedInvoiceItem (com.stripe.model.DeletedInvoiceItem)10 InvoiceItem (com.stripe.model.InvoiceItem)10 Invoice (com.stripe.model.Invoice)7 Card (com.stripe.model.Card)6 DeletedSubscriptionItem (com.stripe.model.DeletedSubscriptionItem)5 SubscriptionItem (com.stripe.model.SubscriptionItem)5 BaseStripeTest (com.stripe.BaseStripeTest)3 BankAccount (com.stripe.model.BankAccount)3 DeletedBankAccount (com.stripe.model.DeletedBankAccount)3 ExternalAccountCollection (com.stripe.model.ExternalAccountCollection)3 Coupon (com.stripe.model.Coupon)2