Search in sources :

Example 1 with SubscriptionItem

use of com.stripe.model.SubscriptionItem 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 2 with SubscriptionItem

use of com.stripe.model.SubscriptionItem 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)

Example 3 with SubscriptionItem

use of com.stripe.model.SubscriptionItem in project stripe-java by stripe.

the class SubscriptionItemTest method testSubscriptionItemList.

@Test
public void testSubscriptionItemList() throws StripeException {
    Customer customer = Customer.create(defaultCustomerParams);
    Subscription subscription = createDefaultSubscription(customer);
    createDefaultSubscriptionItem(subscription);
    Map<String, Object> listParams = new HashMap<String, Object>();
    listParams.put("subscription", subscription.getId());
    SubscriptionItemCollection subscriptionItems = SubscriptionItem.list(listParams);
    List<SubscriptionItem> subscriptionItemsData = subscriptionItems.getData();
    assertEquals(subscriptionItemsData.size(), 2);
}
Also used : DeletedSubscriptionItem(com.stripe.model.DeletedSubscriptionItem) SubscriptionItem(com.stripe.model.SubscriptionItem) Customer(com.stripe.model.Customer) HashMap(java.util.HashMap) Subscription(com.stripe.model.Subscription) SubscriptionItemCollection(com.stripe.model.SubscriptionItemCollection) BaseStripeFunctionalTest(com.stripe.BaseStripeFunctionalTest) Test(org.junit.Test)

Example 4 with SubscriptionItem

use of com.stripe.model.SubscriptionItem in project stripe-java by stripe.

the class SubscriptionItemTest method testSubscriptionItemUpdate.

@Test
public void testSubscriptionItemUpdate() throws StripeException {
    Customer customer = Customer.create(defaultCustomerParams);
    Subscription subscription = createDefaultSubscription(customer);
    SubscriptionItem subscriptionItem = createDefaultSubscriptionItem(subscription);
    Map<String, Object> updateParams = new HashMap<String, Object>();
    updateParams.put("quantity", 4);
    SubscriptionItem updatedSubscriptionItem = subscriptionItem.update(updateParams);
    assertTrue(updatedSubscriptionItem.getQuantity() == 4);
}
Also used : DeletedSubscriptionItem(com.stripe.model.DeletedSubscriptionItem) SubscriptionItem(com.stripe.model.SubscriptionItem) Customer(com.stripe.model.Customer) HashMap(java.util.HashMap) Subscription(com.stripe.model.Subscription) BaseStripeFunctionalTest(com.stripe.BaseStripeFunctionalTest) Test(org.junit.Test)

Example 5 with SubscriptionItem

use of com.stripe.model.SubscriptionItem in project stripe-java by stripe.

the class SubscriptionItemTest method testSubscriptionItemRetrieve.

@Test
public void testSubscriptionItemRetrieve() throws StripeException {
    Customer customer = Customer.create(defaultCustomerParams);
    Subscription subscription = createDefaultSubscription(customer);
    SubscriptionItem subscriptionItem = createDefaultSubscriptionItem(subscription);
    SubscriptionItem retrievedSubscriptionItem = SubscriptionItem.retrieve(subscriptionItem.getId());
    assertEquals(subscriptionItem.getId(), retrievedSubscriptionItem.getId());
}
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

SubscriptionItem (com.stripe.model.SubscriptionItem)8 Test (org.junit.Test)8 BaseStripeFunctionalTest (com.stripe.BaseStripeFunctionalTest)6 Subscription (com.stripe.model.Subscription)6 Customer (com.stripe.model.Customer)5 DeletedSubscriptionItem (com.stripe.model.DeletedSubscriptionItem)5 HashMap (java.util.HashMap)5 BaseStripeTest (com.stripe.BaseStripeTest)2 Plan (com.stripe.model.Plan)1 SubscriptionItemCollection (com.stripe.model.SubscriptionItemCollection)1 UsageRecord (com.stripe.model.UsageRecord)1