Package com.stripe.model

Examples of com.stripe.model.Plan


    assertEquals(canceledSubscription.getStatus(), "canceled");
  }

  @Test
  public void testCancelSubscriptionAtPeriodEnd() throws StripeException {
    Plan plan = Plan.create(getUniquePlanParams());
    Customer customer = createDefaultCustomerWithPlan(plan);
    assertEquals(customer.getSubscriptions().getData().get(0).getStatus(), "active");
    Map<String, Object> cancelParams = new HashMap<String, Object>();
    cancelParams.put("at_period_end", true);
    Subscription canceledSubscription = customer
View Full Code Here


    assertEquals(canceledSubscription.getCancelAtPeriodEnd(), true);
  }

  @Test
  public void testNewStyleSubscriptionAPI() throws StripeException {
    Plan plan = Plan.create(getUniquePlanParams());
    Plan plan2 = Plan.create(getUniquePlanParams());
    Customer customer = Customer.create(defaultCustomerParams);

    // Create
    Map<String, Object> subCreateParams = new HashMap<String, Object>();
    subCreateParams.put("plan", plan.getId());
    Subscription sub = customer.createSubscription(subCreateParams);
    assertEquals(plan.getId(), sub.getPlan().getId());
    customer = Customer.retrieve(customer.getId());
    assertEquals(1, customer.getSubscriptions().getData().size());
    assertEquals(sub.getId(), customer.getSubscriptions().getData().get(0).getId());

    // Retrieve
    Subscription retrievedSub = customer.getSubscriptions().retrieve(sub.getId());
    assertEquals(sub.getId(), retrievedSub.getId());

    // List
    CustomerSubscriptionCollection list = customer.getSubscriptions().all(null);
    assertEquals(1, list.getData().size());
    assertEquals(sub.getId(), list.getData().get(0).getId());

    // Update
    Map<String, Object> subUpdateParams = new HashMap<String, Object>();
    subUpdateParams.put("plan", plan2.getId());
    sub = sub.update(subUpdateParams);
    assertEquals(plan2.getId(), sub.getPlan().getId());

    // Cancel
    sub = sub.cancel(null);
    assertNotNull(sub.getCanceledAt());
  }
View Full Code Here

    assertNotNull(sub.getCanceledAt());
  }

  @Test
  public void testCreateSubscriptionThroughCollection() throws StripeException {
    Plan plan = Plan.create(getUniquePlanParams());
    Customer customer = Customer.create(defaultCustomerParams);

    // Create
    Map<String, Object> subCreateParams = new HashMap<String, Object>();
    subCreateParams.put("plan", plan.getId());

    Subscription sub = customer.getSubscriptions().create(subCreateParams);
    assertEquals(plan.getId(), sub.getPlan().getId());

    // Verify
    customer = Customer.retrieve(customer.getId());
    assertEquals(1, customer.getSubscriptions().getData().size());
    assertEquals(sub.getId(), customer.getSubscriptions().getData().get(0).getId());
View Full Code Here

    assertEquals(deletedInvoiceItem.getId(), createdInvoiceItem.getId());
  }

  @Test
  public void testInvoiceListAndRetrieve() throws StripeException {
    Plan plan = Plan.create(getUniquePlanParams());
    createDefaultCustomerWithPlan(plan);
    Map<String, Object> listParams = new HashMap<String, Object>();
    listParams.put("count", 1);
    Invoice createdInvoice = Invoice.all(listParams).getData().get(0);
    Invoice retrievedInvoice = Invoice.retrieve(createdInvoice.getId());
View Full Code Here

    assertFalse(lines == null);
  }

  @Test
  public void testInvoiceRetrieveForCustomer() throws StripeException {
    Plan plan = Plan.create(getUniquePlanParams());
    Customer customer = createDefaultCustomerWithPlan(plan);
    Map<String, Object> listParams = new HashMap<String, Object>();
    listParams.put("customer", customer.getId());
    listParams.put("count", 1);
    Invoice invoice = Invoice.all(listParams).getData().get(0);
View Full Code Here

    assertTrue(deletedRetrievedCustomer.getDeleted());
  }

  @Test
  public void testPlanCreatePerCallAPIKey() throws StripeException {
    Plan plan = Plan.create(getUniquePlanParams(), Stripe.apiKey);
    assertEquals(plan.getInterval(), "month");
  }
View Full Code Here

    assertEquals(plan.getInterval(), "month");
  }

  @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");
  }
View Full Code Here

    assertEquals(updatedplan.getName(), "Updated Plan Name");
  }

  @Test
  public void testPlanRetrievePerCallAPIKey() throws StripeException {
    Plan createdPlan = Plan.create(getUniquePlanParams(), Stripe.apiKey);
    Plan retrievedPlan = Plan.retrieve(createdPlan.getId(), Stripe.apiKey);
    assertEquals(createdPlan.getId(), retrievedPlan.getId());
  }
View Full Code Here

    assertEquals(Plans.size(), 1);
  }

  @Test
  public void testPlanDeletePerCallAPIKey() throws StripeException {
    Plan createdPlan = Plan.create(getUniquePlanParams(), Stripe.apiKey);
    DeletedPlan deletedPlan = createdPlan.delete(Stripe.apiKey);
    assertTrue(deletedPlan.getDeleted());
    assertEquals(deletedPlan.getId(), createdPlan.getId());
  }
View Full Code Here

  }

  @Test
  public void testCustomerCreateWithPlanPerCallAPIKey()
      throws StripeException {
    Plan plan = Plan.create(getUniquePlanParams(), Stripe.apiKey);
    Customer customer = createDefaultCustomerWithPlan(plan);
    assertEquals(customer.getSubscriptions().getData().get(0).getPlan().getId(), plan.getId());
  }
View Full Code Here

TOP

Related Classes of com.stripe.model.Plan

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.