use of com.stripe.model.Plan in project stripe-java by stripe.
the class PlanTest method testPlanUpdatePerCallAPIKey.
@Test
public void testPlanUpdatePerCallAPIKey() throws StripeException {
Plan createdPlan = Plan.create(getUniquePlanParams(), Stripe.apiKey);
Map<String, Object> updateParams = new HashMap<String, Object>();
updateParams.put("name", "Updated Plan Name");
Plan updatedplan = createdPlan.update(updateParams, Stripe.apiKey);
assertEquals(updatedplan.getName(), "Updated Plan Name");
}
use of com.stripe.model.Plan in project stripe-java by stripe.
the class SubscriptionItemTest method createDefaultSubscription.
static Subscription createDefaultSubscription(Customer customer) throws StripeException {
Plan plan = Plan.create(getUniquePlanParams());
HashMap<String, Object> item = new HashMap<String, Object>();
item.put("plan", plan.getId());
item.put("quantity", 1);
HashMap<String, Object> items = new HashMap<String, Object>();
items.put("0", item);
Map<String, Object> subCreateParams = new HashMap<String, Object>();
subCreateParams.put("items", items);
subCreateParams.put("customer", customer.getId());
return Subscription.create(subCreateParams);
}
use of com.stripe.model.Plan in project stripe-java by stripe.
the class SubscriptionItemTest method createDefaultSubscriptionItem.
static SubscriptionItem createDefaultSubscriptionItem(Subscription subscription) throws StripeException {
Plan plan = Plan.create(getUniquePlanParams());
Map<String, Object> subItemParams = new HashMap<String, Object>();
subItemParams.put("plan", plan.getId());
subItemParams.put("subscription", subscription.getId());
return SubscriptionItem.create(subItemParams);
}
use of com.stripe.model.Plan 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());
}
use of com.stripe.model.Plan in project stripe-java by stripe.
the class SubscriptionTest method testInvoicingSubscription.
@Test
public void testInvoicingSubscription() throws StripeException {
Plan plan = Plan.create(getUniquePlanParams());
defaultCustomerParams.put("email", "test@stripe.com");
Customer customer = Customer.create(defaultCustomerParams);
Map<String, Object> subscriptionParams = new HashMap<String, Object>();
subscriptionParams.put("plan", plan.getId());
subscriptionParams.put("billing", "send_invoice");
subscriptionParams.put("days_until_due", 30);
subscriptionParams.put("customer", customer.getId());
Subscription sub = Subscription.create(subscriptionParams);
assertEquals(plan.getId(), sub.getPlan().getId());
assertEquals("send_invoice", sub.getBilling());
assertEquals((Integer) 30, sub.getDaysUntilDue());
Map<String, Object> updateParams = new HashMap<String, Object>();
updateParams.put("days_until_due", 10);
Subscription subUpdated = sub.update(updateParams);
assertEquals((Integer) 10, subUpdated.getDaysUntilDue());
}
Aggregations