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());
}
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());
}
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());
}
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());
}
Aggregations