Package com.stripe.model

Examples of com.stripe.model.Customer


    assertEquals(customerAfterDefaultCardUpdate.getCards().retrieve(addedCard.getId()).getId(), addedCard.getId());
  }

  @Test
  public void testCreateCardThroughCollection() throws StripeException {
    Customer createdCustomer = Customer.create(defaultCustomerParams);

    Map<String, Object> creationParams = new HashMap<String, Object>();
    creationParams.put("card", defaultCardParams);
    Card addedCard = createdCustomer.getCards().create(creationParams);

    assertEquals(createdCustomer.getId(), addedCard.getCustomer());

    Customer updatedCustomer = Customer.retrieve(createdCustomer.getId());
    assertEquals((Integer) updatedCustomer.getCards().getData().size(), (Integer) 2);
  }
View Full Code Here


  }


  @Test
  public void testCustomerCardUpdate() throws StripeException {
    Customer customer = Customer.create(defaultCustomerParams);
    Card originalCard = customer.getCards().getData().get(0);
    Map<String, Object> updateParams = new HashMap<String, Object>();
    updateParams.put("name", "J Bindings Cardholder, Jr.");
    Card updatedCard = originalCard.update(updateParams);
    assertEquals(updatedCard.getName(), "J Bindings Cardholder, Jr.");
  }
View Full Code Here

    assertEquals(updatedCard.getName(), "J Bindings Cardholder, Jr.");
  }

  @Test
  public void testCustomerCardDelete() throws StripeException {
    Customer customer = Customer.create(defaultCustomerParams);
    Map<String, Object> creationParams = new HashMap<String, Object>();
    creationParams.put("card", defaultCardParams);
    customer.createCard(creationParams);

    Card card = customer.getCards().getData().get(0);
    DeletedCard deletedCard = card.delete();
    Customer retrievedCustomer = Customer.retrieve(customer.getId());

    assertTrue(deletedCard.getDeleted());
    assertEquals(deletedCard.getId(), card.getId());
    for(Card retrievedCard : retrievedCustomer.getCards().getData()) {
        assertFalse("Card was not actually deleted: " + card.getId(), card.getId().equals(retrievedCard.getId()));
    }
  }
View Full Code Here

    }
  }

  @Test
  public void testCustomerDelete() throws StripeException {
    Customer createdCustomer = Customer.create(defaultCustomerParams);
    DeletedCustomer deletedCustomer = createdCustomer.delete();
    Customer deletedRetrievedCustomer = Customer.retrieve(createdCustomer
        .getId());
    assertTrue(deletedCustomer.getDeleted());
    assertEquals(deletedCustomer.getId(), createdCustomer.getId());
    assertTrue(deletedRetrievedCustomer.getDeleted());
  }
View Full Code Here

  }

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

  }

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

  }

  @Test
  public void testCancelSubscription() throws StripeException {
    Plan plan = Plan.create(getUniquePlanParams());
    Customer customer = createDefaultCustomerWithPlan(plan);
    assertEquals(customer.getSubscriptions().getData().get(0).getStatus(), "active");
    Subscription canceledSubscription = customer.cancelSubscription();
    assertEquals(canceledSubscription.getStatus(), "canceled");
  }
View Full Code Here

  }

  @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
        .cancelSubscription(cancelParams);
    assertEquals(canceledSubscription.getStatus(), "active");
    assertEquals(canceledSubscription.getCancelAtPeriodEnd(), true);
  }
View Full Code Here

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

  }

  @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

TOP

Related Classes of com.stripe.model.Customer

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.