use of com.stripe.model.Subscription 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());
}
Aggregations