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); } }
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(); } }