예제 #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());
 }
예제 #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"));
  }
예제 #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());
 }
예제 #4
0
 @Test
 public void testTokenCreatePerCallAPIKey() throws StripeException {
   Token token = Token.create(defaultTokenParams, Stripe.apiKey);
   assertFalse(token.getUsed());
 }
예제 #5
0
 @Test
 public void testTokenCreate() throws StripeException {
   Token token = Token.create(defaultTokenParams);
   assertFalse(token.getUsed());
 }