Search in sources :

Example 6 with Invoice

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

Example 7 with Invoice

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

Example 8 with Invoice

use of com.stripe.model.Invoice 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 9 with Invoice

use of com.stripe.model.Invoice 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());
}
Also used : Invoice(com.stripe.model.Invoice) Customer(com.stripe.model.Customer) HashMap(java.util.HashMap) 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