use of com.stripe.model.Customer 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());
}
use of com.stripe.model.Customer in project stripe-java by stripe.
the class InvoiceTest method testInvoiceItemDeletePerCallAPIKey.
@Test
public void testInvoiceItemDeletePerCallAPIKey() throws StripeException {
Customer customer = Customer.create(defaultCustomerParams, Stripe.apiKey);
InvoiceItem createdInvoiceItem = createDefaultInvoiceItem(customer);
DeletedInvoiceItem deletedInvoiceItem = createdInvoiceItem.delete(Stripe.apiKey);
assertTrue(deletedInvoiceItem.getDeleted());
assertEquals(deletedInvoiceItem.getId(), createdInvoiceItem.getId());
}
use of com.stripe.model.Customer in project stripe-java by stripe.
the class PlanTest method testCustomerCreateWithPlan.
@Test
public void testCustomerCreateWithPlan() throws StripeException {
Plan plan = Plan.create(getUniquePlanParams());
Customer customer = createDefaultCustomerWithPlan(plan);
assertEquals(customer.getSubscriptions().getData().get(0).getPlan().getId(), plan.getId());
}
use of com.stripe.model.Customer in project stripe-java by stripe.
the class SubscriptionItemTest method testSubscriptionItemDelete.
@Test
public void testSubscriptionItemDelete() throws StripeException {
Customer customer = Customer.create(defaultCustomerParams);
Subscription subscription = createDefaultSubscription(customer);
SubscriptionItem subscriptionItem = createDefaultSubscriptionItem(subscription);
DeletedSubscriptionItem deletedSubscriptionItem = subscriptionItem.delete();
assertTrue(deletedSubscriptionItem.getDeleted());
assertEquals(deletedSubscriptionItem.getId(), subscriptionItem.getId());
}
use of com.stripe.model.Customer in project stripe-java by stripe.
the class SubscriptionItemTest method testSubscriptionItemCreate.
@Test
public void testSubscriptionItemCreate() throws StripeException {
Customer customer = Customer.create(defaultCustomerParams);
Subscription subscription = createDefaultSubscription(customer);
SubscriptionItem subscriptionItem = createDefaultSubscriptionItem(subscription);
assertEquals(subscriptionItem.getPlan().getName(), "J Bindings Plan");
}
Aggregations