Package net.authorize

Examples of net.authorize.ResponseReasonCode


    transaction.setCustomerProfileId(customerProfileId);
   
    Result<Transaction> result = executeTransaction("authorize", userId, amountToAuthorize, transaction);

    Map<ResponseField,String> responseMap = result.getDirectResponseList().get(0).getDirectResponseMap();
    ResponseReasonCode responseReasonCode = ResponseReasonCode.findByReasonCode(responseMap.get(ResponseField.RESPONSE_REASON_CODE));
    switch (responseReasonCode) {
      case RRC_1_1:
        log.info("successfully authorized payment of " + amountToAuthorize + " for " + userId + ": " + responseReasonCode);
        return responseMap.get(ResponseField.TRANSACTION_ID);
      case RRC_4_253:
        log.info("successfully authorized (but held for review) payment of " + amountToAuthorize + " for " + userId + ": " + responseReasonCode);
        return responseMap.get(ResponseField.TRANSACTION_ID);
      default :
        log.info("authorization failed in amount of " + amountToAuthorize + " for " + userId + ": " + responseReasonCode);
        throw new AuthorizeNetException(responseReasonCode.getReasonText());
    }
  }
View Full Code Here


    transaction.setCustomerProfileId(customerProfileId);
   
    Result<Transaction> result = executeTransaction("settle", userId, amountToSettle,transaction);

    Map<ResponseField,String> responseMap = result.getDirectResponseList().get(0).getDirectResponseMap();
    ResponseReasonCode responseReasonCode = ResponseReasonCode.findByReasonCode(responseMap.get(ResponseField.RESPONSE_REASON_CODE));
    if (responseReasonCode == ResponseReasonCode.RRC_1_1) {
      log.info("successfully settled payment of " + amountToSettle + " for " + userId);
      return responseMap.get(ResponseField.TRANSACTION_ID);
    }
    else
      throw new AuthorizeNetException(responseReasonCode.getReasonText());
  }
View Full Code Here

    List<DirectResponse> directResponses = result.getDirectResponseList();
    // check ResponseReasonCode to see if it means we should throw an exception
    if (directResponses != null && directResponses.size() > 0) {
      Map<ResponseField,String> directResponseMap = directResponses.get(0).getDirectResponseMap();
      ResponseCode responseCode = ResponseCode.findByResponseCode(directResponseMap.get(ResponseField.RESPONSE_CODE));
      ResponseReasonCode responseReasonCode = ResponseReasonCode.findByReasonCode(directResponseMap.get(ResponseField.RESPONSE_REASON_CODE));

      // check exceptionMap to see if we should throw specific exception
      Class<? extends AuthorizeNetException> exceptionClass = exceptionMap.get(responseReasonCode);
      if (exceptionClass != null) {
        log.info(logOperation + " failed in amount of " + amount + " for " + userId + ": " + responseReasonCode);
        try {
          Constructor<? extends AuthorizeNetException> constructor = exceptionClass.getConstructor(String.class);
          throw constructor.newInstance(responseReasonCode.getReasonText());
        }
        catch (NoSuchMethodException e) { /* fall through */ }
        catch (InvocationTargetException e) { /* fall through */ }
        catch (IllegalAccessException e) { /* fall through */ }
        catch (InstantiationException e) { /* fall through */ }
        log.warn("Exception class " + exceptionClass.getSimpleName() + " failed reflection instantiation");
        // we know we want an exception but failed to instantiate it.  Throw ANE as default
        throw new AuthorizeNetException(responseReasonCode.getReasonText());
      }

      // umbrella processing for DECLINED
      if (responseCode == ResponseCode.DECLINED) {
        log.info(logOperation + " failed in amount of " + amount + " for " + userId + ": " + responseReasonCode);
        throw new PaymentDeclinedException(responseReasonCode.getReasonText());
      }
    }
   
    // map all other failures (where no DirectResponseMap or RRC may not be in exceptionMap) into ANE
    if (!result.isOk()) {
View Full Code Here

TOP

Related Classes of net.authorize.ResponseReasonCode

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.