Package com.stripe.model

Examples of com.stripe.model.Customer


    @Override
    public OrderConfirmation processOrder(Order order) throws StripeException {
        Plan plan = planCreator.createPlan(order);

        Customer customer = customerCreator.createCustormer(plan, order);

        String confirmationNumber = confirmationNumberGenerator.generateConfirmationNumber(customer);

        emailSender.sendOrderEmail(confirmationNumber);
View Full Code Here


    private final ConfirmationNumberGeneratorImpl generator = new ConfirmationNumberGeneratorImpl();

    @Test
    public void generateConfirmationNumber_anyCustomer_willReturnCustomerId() {
        //given
        Customer customer = mock(Customer.class);
        given(customer.getId()).willReturn(SOME_ID);

        //when
        String confirmationNumber = generator.generateConfirmationNumber(customer);

        //then
View Full Code Here

    return uniqueParams;
  }

  static Map<String, Object> getInvoiceItemParams() throws StripeException {
    Map<String, Object> params = new HashMap<String, Object>();
      Customer customer = Customer.create(defaultCustomerParams);
    params.put("amount", 100);
    params.put("currency", "usd");
    params.put("customer", customer.getId());
    return params;
  }
View Full Code Here

  static Customer createDefaultCustomerWithPlan(Plan plan)
      throws StripeException {
    Map<String, Object> customerWithPlanParams = new HashMap<String, Object>();
    customerWithPlanParams.putAll(defaultCustomerParams);
    customerWithPlanParams.put("plan", plan.getId());
    Customer customer = Customer.create(customerWithPlanParams);
    return customer;
  }
View Full Code Here

  }
*/

  @Test
  public void testCustomerCreate() throws StripeException {
    Customer customer = Customer.create(defaultCustomerParams);
    assertEquals(customer.getDescription(), "J Bindings Customer");
    List<Card> customerCards = customer.getCards().getData();
    assertEquals(1, customerCards.size());
    assertEquals("4242", customerCards.get(0).getLast4());
  }
View Full Code Here

    assertEquals("4242", customerCards.get(0).getLast4());
  }

  @Test
  public void testCustomerRetrieve() throws StripeException {
    Customer createdCustomer = Customer.create(defaultCustomerParams);
    Customer retrievedCustomer = Customer.retrieve(createdCustomer.getId());
    assertEquals(createdCustomer.getCreated(),
        retrievedCustomer.getCreated());
    assertEquals(createdCustomer.getId(), retrievedCustomer.getId());
  }
View Full Code Here

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

  @Test
  public void testCustomerUpdate() throws StripeException {
    Customer createdCustomer = Customer.create(defaultCustomerParams);
    Map<String, Object> updateParams = new HashMap<String, Object>();
    updateParams.put("description", "Updated Description");
    Customer updatedCustomer = createdCustomer.update(updateParams);
    assertEquals(updatedCustomer.getDescription(), "Updated Description");
  }
View Full Code Here

    assertEquals(updatedCustomer.getDescription(), "Updated Description");
  }

  @Test(expected=InvalidRequestException.class)
  public void testCustomerUpdateToBlank() throws StripeException {
    Customer createdCustomer = Customer.create(defaultCustomerParams);
    Map<String, Object> updateParams = new HashMap<String, Object>();
    updateParams.put("description", "");
    createdCustomer.update(updateParams);
  }
View Full Code Here

    createdCustomer.update(updateParams);
  }

  @Test
  public void testCustomerUpdateToNull() throws StripeException {
    Customer createdCustomer = Customer.create(defaultCustomerParams);
    Map<String, Object> updateParams = new HashMap<String, Object>();
    updateParams.put("description", null);
    Customer updatedCustomer = createdCustomer.update(updateParams);
    assertEquals(updatedCustomer.getDescription(), null);
  }
View Full Code Here

    assertEquals(updatedCustomer.getDescription(), null);
  }

  @Test
  public void testCustomerCardAddition() throws StripeException {
    Customer createdCustomer = Customer.create(defaultCustomerParams);
    String originalDefaultCard = createdCustomer.getDefaultCard();

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

    Token token = Token.create(defaultTokenParams);
    createdCustomer.createCard(token.getId());

    Customer updatedCustomer = Customer.retrieve(createdCustomer.getId());
    assertEquals((Integer) updatedCustomer.getCards().getData().size(), (Integer) 3);
    assertEquals(updatedCustomer.getDefaultCard(), originalDefaultCard);

    Map<String, Object> updateParams = new HashMap<String, Object>();
    updateParams.put("default_card", addedCard.getId());
    Customer customerAfterDefaultCardUpdate = updatedCustomer.update(updateParams);
    assertEquals((Integer) customerAfterDefaultCardUpdate.getCards().getData().size(), (Integer) 3);
    assertEquals(customerAfterDefaultCardUpdate.getDefaultCard(), addedCard.getId());

    assertEquals(customerAfterDefaultCardUpdate.getCards().retrieve(originalDefaultCard).getId(), originalDefaultCard);
    assertEquals(customerAfterDefaultCardUpdate.getCards().retrieve(addedCard.getId()).getId(), addedCard.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.