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