use of com.stripe.model.Customer in project stripe-java by stripe.
the class InvoiceTest method testInvoiceRetrieveForCustomer.
@Test
public void testInvoiceRetrieveForCustomer() throws StripeException {
Plan plan = Plan.create(getUniquePlanParams());
Customer customer = createDefaultCustomerWithPlan(plan);
Map<String, Object> listParams = new HashMap<String, Object>();
listParams.put("customer", customer.getId());
listParams.put("count", 1);
Invoice invoice = Invoice.all(listParams).getData().get(0);
assertEquals(invoice.getCustomer(), customer.getId());
}
use of com.stripe.model.Customer in project stripe-java by stripe.
the class InvoiceTest method testInvoiceCreate.
@Test
public void testInvoiceCreate() throws StripeException {
Plan plan = Plan.create(getUniquePlanParams());
Customer customer = createDefaultCustomerWithPlan(plan);
Map<String, Object> invoiceItem = ImmutableMap.<String, Object>builder().put("customer", customer.getId()).put("amount", 100).put("currency", "usd").put("description", "my item").build();
InvoiceItem createdItem = InvoiceItem.create(invoiceItem);
assertEquals("my item", createdItem.getDescription());
Invoice invoice = Invoice.create(ImmutableMap.<String, Object>builder().put("description", "my invoice").put("customer", customer.getId()).build());
assertEquals("my invoice", invoice.getDescription());
}
use of com.stripe.model.Customer in project stripe-java by stripe.
the class InvoiceTest method testUpcomingInvoice.
@Test
public void testUpcomingInvoice() throws Exception {
Customer customer = Customer.create(defaultCustomerParams);
createDefaultInvoiceItem(customer);
Map<String, Object> upcomingParams = new HashMap<String, Object>();
upcomingParams.put("customer", customer.getId());
Invoice upcomingInvoice = Invoice.upcoming(upcomingParams);
assertFalse(upcomingInvoice.getAttempted());
}
use of com.stripe.model.Customer in project stripe-java by stripe.
the class InvoiceTest method testUpcomingInvoicePerCallAPIKey.
@Test
public void testUpcomingInvoicePerCallAPIKey() throws Exception {
Customer customer = Customer.create(defaultCustomerParams, Stripe.apiKey);
createDefaultInvoiceItem(customer);
Map<String, Object> upcomingParams = new HashMap<String, Object>();
upcomingParams.put("customer", customer.getId());
Invoice upcomingInvoice = Invoice.upcoming(upcomingParams, Stripe.apiKey);
assertFalse(upcomingInvoice.getAttempted());
}
use of com.stripe.model.Customer in project stripe-java by stripe.
the class InvoiceTest method testInvoiceItemDelete.
@Test
public void testInvoiceItemDelete() throws StripeException {
Customer customer = Customer.create(defaultCustomerParams);
InvoiceItem createdInvoiceItem = createDefaultInvoiceItem(customer);
DeletedInvoiceItem deletedInvoiceItem = createdInvoiceItem.delete();
assertTrue(deletedInvoiceItem.getDeleted());
assertEquals(deletedInvoiceItem.getId(), createdInvoiceItem.getId());
}
Aggregations