use of com.stripe.model.SubscriptionItem in project stripe-java by stripe.
the class UsageRecordTest method testUsageRecordCreate.
@Test
public void testUsageRecordCreate() throws StripeException {
Plan plan = createMeteredPlan();
Subscription sub = createSubscription(plan);
SubscriptionItem subItem = sub.getSubscriptionItems().getData().get(0);
Map<String, Object> params = new HashMap<>();
params.put("quantity", 1000);
long unixTime = System.currentTimeMillis() / 1000L;
params.put("timestamp", unixTime);
params.put("subscription_item", subItem.getId());
UsageRecord ur = UsageRecord.create(params, null);
assertEquals(new Long(1000), ur.getQuantity());
assertEquals(new Long(unixTime), ur.getTimestamp());
}
use of com.stripe.model.SubscriptionItem in project stripe-java by stripe.
the class SubscriptionItemTest method testDelete.
@Test
public void testDelete() throws StripeException {
SubscriptionItem item = new SubscriptionItem();
item.setId("test_item");
HashMap<String, Object> params = new HashMap<String, Object>();
params.put("prorate", false);
item.delete(params);
verifyDelete(DeletedSubscriptionItem.class, "https://api.stripe.com/v1/subscription_items/test_item", params);
verifyNoMoreInteractions(networkMock);
}
use of com.stripe.model.SubscriptionItem in project stripe-java by stripe.
the class SubscriptionItemTest method testUpdate.
@Test
public void testUpdate() throws StripeException {
SubscriptionItem item = new SubscriptionItem();
item.setId("test_item");
HashMap<String, Object> params = new HashMap<String, Object>();
params.put("plan", "gold");
item.update(params);
verifyPost(SubscriptionItem.class, "https://api.stripe.com/v1/subscription_items/test_item", params);
verifyNoMoreInteractions(networkMock);
}
Aggregations