use of com.stripe.model.Invoice in project stripe-java by stripe.
the class InvoiceTest method testInvoiceRetrieveForCustomerPerCallAPIKey.
@Test
public void testInvoiceRetrieveForCustomerPerCallAPIKey() throws StripeException {
Plan plan = Plan.create(getUniquePlanParams(), Stripe.apiKey);
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, Stripe.apiKey).getData().get(0);
assertEquals(invoice.getCustomer(), customer.getId());
}
use of com.stripe.model.Invoice in project stripe-java by stripe.
the class InvoiceTest method testUpcomingInvoiceLines.
@Test
public void testUpcomingInvoiceLines() throws Exception {
Customer customer = Customer.create(defaultCustomerParams);
final InvoiceItem item = createDefaultInvoiceItem(customer);
Map<String, Object> upcomingParams = new HashMap<String, Object>();
upcomingParams.put("customer", customer.getId());
Invoice upcomingInvoice = Invoice.upcoming(upcomingParams);
assertFalse(upcomingInvoice.getAttempted());
InvoiceLineItemCollection lines = upcomingInvoice.getLines().all(null);
assertFalse(lines.getData().isEmpty());
assertEquals(item.getId(), lines.getData().get(0).getId());
Map<String, Object> fetchParams = new HashMap<String, Object>();
fetchParams.put("starting_after", item.getId());
InvoiceLineItemCollection linesAfterFirst = upcomingInvoice.getLines().all(fetchParams);
assertTrue(linesAfterFirst.getData().isEmpty());
}
use of com.stripe.model.Invoice in project stripe-java by stripe.
the class InvoiceTest method testInvoiceListAndRetrievePerCallAPIKey.
@Test
public void testInvoiceListAndRetrievePerCallAPIKey() throws StripeException {
Plan plan = Plan.create(getUniquePlanParams(), Stripe.apiKey);
createDefaultCustomerWithPlan(plan);
Map<String, Object> listParams = new HashMap<String, Object>();
listParams.put("count", 1);
Invoice createdInvoice = Invoice.all(listParams, Stripe.apiKey).getData().get(0);
Invoice retrievedInvoice = Invoice.retrieve(createdInvoice.getId(), Stripe.apiKey);
assertEquals(createdInvoice.getId(), retrievedInvoice.getId());
}
use of com.stripe.model.Invoice in project stripe-java by stripe.
the class InvoiceTest method testInvoiceListAndRetrieve.
@Test
public void testInvoiceListAndRetrieve() throws StripeException {
Plan plan = Plan.create(getUniquePlanParams());
Customer customer = createDefaultCustomerWithPlan(plan);
Map<String, Object> listParams = new HashMap<String, Object>();
listParams.put("count", 1);
listParams.put("subscription", customer.getSubscriptions().getData().get(0).getId());
Invoice createdInvoice = Invoice.all(listParams).getData().get(0);
Invoice retrievedInvoice = Invoice.retrieve(createdInvoice.getId());
assertEquals(createdInvoice.getId(), retrievedInvoice.getId());
InvoiceLineItemCollection lines = retrievedInvoice.getLines().all(listParams);
assertNotNull(lines);
}
use of com.stripe.model.Invoice 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());
}
Aggregations