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()));
}
}
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());
}
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());
}
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());
}
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());
}
Aggregations