예제 #1
0
 private static String getUnencryptedToken(CreditCard creditCard, Float amount) throws Exception {
   if (amount != null && amount > 0) {
     Date now = new Date();
     return String.valueOf(creditCard.getNumber())
         + String.valueOf(creditCard.getCrypto())
         + creditCard.getDateExpiration()
         + String.valueOf(amount)
         + now.toString();
   } else {
     throw new Exception(amountInvalid);
   }
 }
예제 #2
0
  public TokenRequestReply(CreditCard creditCard, Float amount) {

    if (md == null) {
      try {
        md = MessageDigest.getInstance("MD5");
      } catch (NoSuchAlgorithmException e) {
        e.printStackTrace();
      }
    }

    try {
      creditCard.check();
      this.token = getCryptToken(creditCard, amount);
      this.succes = true;
    } catch (Exception e) {
      this.succes = false;
      this.message = e.getMessage();
    }
  }