Ejemplo n.º 1
0
 @Test
 public void testTokenUsePerCallAPIKey() throws StripeException {
   Token createdToken = Token.create(defaultTokenParams, Stripe.apiKey);
   Map<String, Object> chargeWithTokenParams = new HashMap<String, Object>();
   chargeWithTokenParams.put("amount", 199);
   chargeWithTokenParams.put("currency", "usd");
   chargeWithTokenParams.put("card", createdToken.getId());
   Charge.create(chargeWithTokenParams, Stripe.apiKey);
   Token retrievedToken = Token.retrieve(createdToken.getId(), Stripe.apiKey);
   assertTrue(retrievedToken.getUsed());
 }
Ejemplo n.º 2
0
  @Test
  public void registerCustomer() throws Exception {

    Map<String, Object> tokenParams = new HashMap<String, Object>();
    Map<String, Object> cardParams = new HashMap<String, Object>();
    cardParams.put("number", "4242424242424242");
    cardParams.put("exp_month", 3);
    cardParams.put("exp_year", 2015);
    cardParams.put("cvc", "315");
    tokenParams.put("card", cardParams);

    String email = randomEmail();
    String password = "******";
    String card = Token.create(tokenParams).getId();

    mockMvc
        .perform(
            post("/api/register")
                .param("card", card)
                .param("email", email)
                .param("password", password))
        .andExpect(model().attribute("email", email))
        .andExpect(model().attribute("status", "success"));
  }
Ejemplo n.º 3
0
 @Test
 public void testTokenRetrievePerCallAPIKey() throws StripeException {
   Token createdToken = Token.create(defaultTokenParams, Stripe.apiKey);
   Token retrievedToken = Token.retrieve(createdToken.getId(), Stripe.apiKey);
   assertEquals(createdToken.getId(), retrievedToken.getId());
 }
Ejemplo n.º 4
0
 @Test
 public void testTokenCreatePerCallAPIKey() throws StripeException {
   Token token = Token.create(defaultTokenParams, Stripe.apiKey);
   assertFalse(token.getUsed());
 }
Ejemplo n.º 5
0
 @Test
 public void testTokenCreate() throws StripeException {
   Token token = Token.create(defaultTokenParams);
   assertFalse(token.getUsed());
 }