Search in sources :

Example 1 with InvoiceItem

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

Example 2 with InvoiceItem

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

the class InvoiceTest method testInvoiceItemUpdatePerCallAPIKey.

@Test
public void testInvoiceItemUpdatePerCallAPIKey() throws StripeException {
    Customer customer = Customer.create(defaultCustomerParams, Stripe.apiKey);
    InvoiceItem createdInvoiceItem = createDefaultInvoiceItem(customer);
    Map<String, Object> updateParams = new HashMap<String, Object>();
    updateParams.put("description", "Updated Description");
    updateParams.put("amount", 200);
    InvoiceItem updatedInvoiceItem = createdInvoiceItem.update(updateParams, Stripe.apiKey);
    assertTrue(updatedInvoiceItem.getAmount() == 200);
    assertEquals(updatedInvoiceItem.getDescription(), "Updated Description");
}
Also used : InvoiceItem(com.stripe.model.InvoiceItem) DeletedInvoiceItem(com.stripe.model.DeletedInvoiceItem) Customer(com.stripe.model.Customer) HashMap(java.util.HashMap) BaseStripeFunctionalTest(com.stripe.BaseStripeFunctionalTest) Test(org.junit.Test)

Example 3 with InvoiceItem

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

the class InvoiceTest method testInvoiceItemCreate.

// Invoice Tests:
@Test
public void testInvoiceItemCreate() throws StripeException {
    Customer customer = Customer.create(defaultCustomerParams);
    InvoiceItem invoiceItem = createDefaultInvoiceItem(customer);
    assertTrue(invoiceItem.getAmount() == 100);
}
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)

Example 4 with InvoiceItem

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

the class InvoiceTest method testInvoiceItemUpdate.

@Test
public void testInvoiceItemUpdate() throws StripeException {
    Customer customer = Customer.create(defaultCustomerParams);
    InvoiceItem createdInvoiceItem = createDefaultInvoiceItem(customer);
    Map<String, Object> updateParams = new HashMap<String, Object>();
    updateParams.put("description", "Updated Description");
    updateParams.put("amount", 200);
    InvoiceItem updatedInvoiceItem = createdInvoiceItem.update(updateParams);
    assertTrue(updatedInvoiceItem.getAmount() == 200);
    assertEquals(updatedInvoiceItem.getDescription(), "Updated Description");
}
Also used : InvoiceItem(com.stripe.model.InvoiceItem) DeletedInvoiceItem(com.stripe.model.DeletedInvoiceItem) Customer(com.stripe.model.Customer) HashMap(java.util.HashMap) BaseStripeFunctionalTest(com.stripe.BaseStripeFunctionalTest) Test(org.junit.Test)

Example 5 with InvoiceItem

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

Aggregations

BaseStripeFunctionalTest (com.stripe.BaseStripeFunctionalTest)12 DeletedInvoiceItem (com.stripe.model.DeletedInvoiceItem)12 InvoiceItem (com.stripe.model.InvoiceItem)12 Test (org.junit.Test)12 Customer (com.stripe.model.Customer)10 HashMap (java.util.HashMap)5 Invoice (com.stripe.model.Invoice)3 InvoiceLineItemCollection (com.stripe.model.InvoiceLineItemCollection)1 Plan (com.stripe.model.Plan)1