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