Search in sources :

Example 11 with InvoiceItem

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

the class InvoiceTest method testSendInvoice.

@Test
public void testSendInvoice() throws StripeException {
    InvoiceItem invItem = InvoiceItem.create(getInvoiceItemParams());
    Map<String, Object> params = new HashMap<String, Object>();
    Long dueDate = (System.currentTimeMillis() / 1000) + 600;
    params.put("customer", invItem.getCustomer());
    params.put("billing", "send_invoice");
    params.put("due_date", dueDate);
    Invoice invoice = Invoice.create(params);
    assertEquals("send_invoice", invoice.getBilling());
    assertEquals(dueDate, invoice.getDueDate());
    Map<String, Object> updateParams = new HashMap<String, Object>();
    updateParams.put("paid", true);
    Invoice updatedInvoice = invoice.update(updateParams);
    assertTrue(updatedInvoice.getPaid());
}
Also used : InvoiceItem(com.stripe.model.InvoiceItem) DeletedInvoiceItem(com.stripe.model.DeletedInvoiceItem) Invoice(com.stripe.model.Invoice) HashMap(java.util.HashMap) BaseStripeFunctionalTest(com.stripe.BaseStripeFunctionalTest) Test(org.junit.Test)

Example 12 with InvoiceItem

use of com.stripe.model.InvoiceItem 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());
}
Also used : InvoiceItem(com.stripe.model.InvoiceItem) DeletedInvoiceItem(com.stripe.model.DeletedInvoiceItem) Customer(com.stripe.model.Customer) DeletedInvoiceItem(com.stripe.model.DeletedInvoiceItem) 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