Search in sources :

Example 21 with Customer

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

Example 22 with Customer

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

Example 23 with Customer

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

Example 24 with Customer

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());
}
Also used : DeletedSubscriptionItem(com.stripe.model.DeletedSubscriptionItem) SubscriptionItem(com.stripe.model.SubscriptionItem) Customer(com.stripe.model.Customer) DeletedSubscriptionItem(com.stripe.model.DeletedSubscriptionItem) Subscription(com.stripe.model.Subscription) BaseStripeFunctionalTest(com.stripe.BaseStripeFunctionalTest) Test(org.junit.Test)

Example 25 with Customer

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");
}
Also used : DeletedSubscriptionItem(com.stripe.model.DeletedSubscriptionItem) SubscriptionItem(com.stripe.model.SubscriptionItem) Customer(com.stripe.model.Customer) Subscription(com.stripe.model.Subscription) BaseStripeFunctionalTest(com.stripe.BaseStripeFunctionalTest) Test(org.junit.Test)

Aggregations

Customer (com.stripe.model.Customer)65 Test (org.junit.Test)63 BaseStripeFunctionalTest (com.stripe.BaseStripeFunctionalTest)60 HashMap (java.util.HashMap)40 DeletedCustomer (com.stripe.model.DeletedCustomer)24 ExternalAccount (com.stripe.model.ExternalAccount)16 Plan (com.stripe.model.Plan)16 Subscription (com.stripe.model.Subscription)15 DeletedExternalAccount (com.stripe.model.DeletedExternalAccount)13 DeletedInvoiceItem (com.stripe.model.DeletedInvoiceItem)10 InvoiceItem (com.stripe.model.InvoiceItem)10 Invoice (com.stripe.model.Invoice)7 Card (com.stripe.model.Card)6 DeletedSubscriptionItem (com.stripe.model.DeletedSubscriptionItem)5 SubscriptionItem (com.stripe.model.SubscriptionItem)5 BaseStripeTest (com.stripe.BaseStripeTest)3 BankAccount (com.stripe.model.BankAccount)3 DeletedBankAccount (com.stripe.model.DeletedBankAccount)3 ExternalAccountCollection (com.stripe.model.ExternalAccountCollection)3 Coupon (com.stripe.model.Coupon)2