@Test public void testCancelSubscriptionPerCallAPIKey() throws StripeException { Plan plan = Plan.create(getUniquePlanParams(), Stripe.apiKey); Customer customer = createDefaultCustomerWithPlan(plan); assertEquals(customer.getSubscription().getStatus(), "active"); Subscription canceledSubscription = customer.cancelSubscription(Stripe.apiKey); assertEquals(canceledSubscription.getStatus(), "canceled"); }
@Test public void testUpdateSubscriptionPerCallAPIKey() throws StripeException { Plan plan = Plan.create(getUniquePlanParams(), Stripe.apiKey); Customer customer = Customer.create(defaultCustomerParams, Stripe.apiKey); Map<String, Object> subscriptionParams = new HashMap<String, Object>(); subscriptionParams.put("plan", plan.getId()); Subscription sub = customer.updateSubscription(subscriptionParams, Stripe.apiKey); assertEquals(sub.getPlan().getId(), plan.getId()); assertEquals(sub.getCustomer(), customer.getId()); }
@Test public void testCancelSubscriptionAtPeriodEndPerCallAPIKey() throws StripeException { Plan plan = Plan.create(getUniquePlanParams(), Stripe.apiKey); Customer customer = createDefaultCustomerWithPlan(plan); assertEquals(customer.getSubscription().getStatus(), "active"); Map<String, Object> cancelParams = new HashMap<String, Object>(); cancelParams.put("at_period_end", true); Subscription canceledSubscription = customer.cancelSubscription(cancelParams, Stripe.apiKey); assertEquals(canceledSubscription.getStatus(), "active"); assertEquals(canceledSubscription.getCancelAtPeriodEnd(), true); }