Search in sources :

Example 1 with Invoice

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());
}
Also used : Invoice(com.stripe.model.Invoice) Customer(com.stripe.model.Customer) HashMap(java.util.HashMap) Plan(com.stripe.model.Plan) BaseStripeFunctionalTest(com.stripe.BaseStripeFunctionalTest) Test(org.junit.Test)

Example 2 with Invoice

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());
}
Also used : InvoiceItem(com.stripe.model.InvoiceItem) DeletedInvoiceItem(com.stripe.model.DeletedInvoiceItem) Invoice(com.stripe.model.Invoice) Customer(com.stripe.model.Customer) HashMap(java.util.HashMap) InvoiceLineItemCollection(com.stripe.model.InvoiceLineItemCollection) BaseStripeFunctionalTest(com.stripe.BaseStripeFunctionalTest) Test(org.junit.Test)

Example 3 with Invoice

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());
}
Also used : Invoice(com.stripe.model.Invoice) HashMap(java.util.HashMap) Plan(com.stripe.model.Plan) BaseStripeFunctionalTest(com.stripe.BaseStripeFunctionalTest) Test(org.junit.Test)

Example 4 with Invoice

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);
}
Also used : Invoice(com.stripe.model.Invoice) Customer(com.stripe.model.Customer) HashMap(java.util.HashMap) InvoiceLineItemCollection(com.stripe.model.InvoiceLineItemCollection) Plan(com.stripe.model.Plan) BaseStripeFunctionalTest(com.stripe.BaseStripeFunctionalTest) Test(org.junit.Test)

Example 5 with Invoice

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());
}
Also used : Invoice(com.stripe.model.Invoice) Customer(com.stripe.model.Customer) HashMap(java.util.HashMap) Plan(com.stripe.model.Plan) BaseStripeFunctionalTest(com.stripe.BaseStripeFunctionalTest) Test(org.junit.Test)

Aggregations

BaseStripeFunctionalTest (com.stripe.BaseStripeFunctionalTest)9 Invoice (com.stripe.model.Invoice)9 Test (org.junit.Test)9 HashMap (java.util.HashMap)8 Customer (com.stripe.model.Customer)7 Plan (com.stripe.model.Plan)5 DeletedInvoiceItem (com.stripe.model.DeletedInvoiceItem)3 InvoiceItem (com.stripe.model.InvoiceItem)3 InvoiceLineItemCollection (com.stripe.model.InvoiceLineItemCollection)2