Search in sources :

Example 1 with Subscription

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

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

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

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

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

the class SubscriptionTest method testUpdateSubscription.

@Test
public void testUpdateSubscription() throws StripeException {
    Plan plan = Plan.create(getUniquePlanParams());
    Customer customer = Customer.create(defaultCustomerParams);
    Map<String, Object> subscriptionParams = new HashMap<String, Object>();
    subscriptionParams.put("plan", plan.getId());
    Subscription sub = customer.updateSubscription(subscriptionParams);
    assertEquals(sub.getPlan().getId(), plan.getId());
    assertEquals(sub.getCustomer(), customer.getId());
}
Also used : Customer(com.stripe.model.Customer) HashMap(java.util.HashMap) Plan(com.stripe.model.Plan) Subscription(com.stripe.model.Subscription) BaseStripeFunctionalTest(com.stripe.BaseStripeFunctionalTest) Test(org.junit.Test)

Aggregations

BaseStripeFunctionalTest (com.stripe.BaseStripeFunctionalTest)16 Subscription (com.stripe.model.Subscription)16 Test (org.junit.Test)16 Customer (com.stripe.model.Customer)15 Plan (com.stripe.model.Plan)11 HashMap (java.util.HashMap)11 SubscriptionItem (com.stripe.model.SubscriptionItem)6 DeletedSubscriptionItem (com.stripe.model.DeletedSubscriptionItem)5 CustomerSubscriptionCollection (com.stripe.model.CustomerSubscriptionCollection)2 SubscriptionCollection (com.stripe.model.SubscriptionCollection)1 SubscriptionItemCollection (com.stripe.model.SubscriptionItemCollection)1 UsageRecord (com.stripe.model.UsageRecord)1