Package com.eway

Examples of com.eway.GatewayConnector


    paymentMessage = MESSAGE_NOTIMPLEMENTED;
    throw new NotImplementedException("");
  }
 
  public void authorizeAndCapturePayment(InvoiceHeader invoiceHeader, HttpServletRequest request) throws AuthorizationException, PaymentException, Exception {
    GatewayConnector connector = new GatewayConnector();
    int mode = GatewayRequest.REQUEST_METHOD_CVN;
    if (isProduction()) {
      connector.setGatewayUrlCVN(SERVICE_URL_PRODUCTION);
    }
    else {
      connector.setGatewayUrlCVN(SERVICE_URL_SANDBOX);
    }
   
    OrderHeader orderHeader = invoiceHeader.getOrderHeader();
    OrderAddress billingAddress = orderHeader.getBillingAddress();
    if (billingAddress.getCustUseAddress().equals(Constants.CUST_ADDRESS_USE_CUST)) {
      billingAddress = orderHeader.getCustAddress();
    }
    OrderAddress shippingAddress = orderHeader.getBillingAddress();
    if (shippingAddress.getCustUseAddress().equals(Constants.CUST_ADDRESS_USE_BILL)) {
      shippingAddress = billingAddress;
    }
    if (shippingAddress.getCustUseAddress().equals(Constants.CUST_ADDRESS_USE_CUST)) {
      shippingAddress = orderHeader.getCustAddress();
    }
   
    GatewayRequest gwr = new GatewayRequest(mode);
      gwr.setCustomerID(customerId);
   
      gwr.setCardExpiryMonth(creditCardInfo.getCreditCardExpiryMonth());
      gwr.setCardExpiryYear(creditCardInfo.getCreditCardExpiryYear());
      gwr.setCardHoldersName(creditCardInfo.getCreditCardNum());
      gwr.setCardNumber(creditCardInfo.getCreditCardNum());
      String customerAddress = billingAddress.getCustAddressLine1();
      if (Format.isNullOrEmpty(billingAddress.getCustAddressLine2())) {
        customerAddress += billingAddress.getCustAddressLine2();
      }
      gwr.setCustomerAddress(customerAddress);
      gwr.setCustomerBillingCountry(billingAddress.getCustCountryCode());
      gwr.setCustomerEmailAddress(orderHeader.getCustEmail());
      gwr.setCustomerFirstName(billingAddress.getCustFirstName());
      gwr.setCustomerInvoiceRef(orderHeader.getOrderNum());
     
    String remoteAddress = request.getRemoteAddr();
    if (remoteAddress.split(":").length > 4) {
      logger.error("Remote address " + remoteAddress + " seems to be a IPv6 address.");
    }
   
      gwr.setCustomerIPAddress(remoteAddress);
      gwr.setCustomerLastName(billingAddress.getCustLastName());
      gwr.setCustomerPostcode(billingAddress.getCustZipCode());
      gwr.setCVN(creditCardInfo.getCreditCardVerNum());
      gwr.setTotalAmount((int) (orderHeader.getOrderTotal() * 100));
      //gwr.setTotalAmount(1000);
      GatewayResponse response = connector.sendRequest(gwr);
    if (!response.getTrxnStatus()) {
      logger.error("request = Not able to process credit card authorization for " + orderHeader.getCustAddress().getCustFirstName() + " " + orderHeader.getCustAddress().getCustLastName());
      logger.error("response = " + response.getTrxnError());
      paymentMessage = response.getTrxnError();
      throw new AuthorizationException(response.getTrxnError());
View Full Code Here


  }
 
  public void creditPayment(CreditHeader creditHeader)
      throws PaymentException, Exception {
      OrderHeader orderHeader = creditHeader.getOrderHeader();
    GatewayConnector connector = new GatewayConnector();
    int mode = GatewayRequest.REQUEST_METHOD_CVN;
    if (isProduction()) {
      connector.setGatewayUrlCVN(SERVICE_URL_PRODUCTION);
    }
    else {
      connector.setGatewayUrlCVN(SERVICE_URL_SANDBOX);
    }
   
    GatewayRequest gwr = new GatewayRequest(mode);
      gwr.setCustomerID(customerId);
     
      CustomerCreditCard custCreditCard = null;
      Iterator<?> iterator = orderHeader.getCustomer().getCustCreditCards().iterator();
      while (iterator.hasNext()) {
        custCreditCard = (CustomerCreditCard) iterator.next();
        break;
      }
      if (custCreditCard == null) {
        paymentMessage = "Unable to locate customer credit card to refund";
        throw new AuthorizationException("Unable to locate customer credit card to refund");
      }

      gwr.setCardExpiryMonth(custCreditCard.getCustCreditCardExpiryMonth());
      gwr.setCardExpiryYear(custCreditCard.getCustCreditCardExpiryYear());
      gwr.setCardHoldersName(custCreditCard.getCustCreditCardNum());
      gwr.setCardNumber(AESEncoder.getInstance().decode(custCreditCard.getCustCreditCardNum()));
      gwr.setCustomerInvoiceRef(orderHeader.getOrderNum());
     
      PaymentTran payment = orderHeader.getPaymentTran();
    if (payment == null) {
      for (InvoiceHeader invoiceHeader : orderHeader.getInvoiceHeaders()) {
        payment = invoiceHeader.getPaymentTran();
      }
    }
      gwr.setTrxnNumber(payment.getPaymentReference1());

      gwr.setCVN(custCreditCard.getCustCreditCardVerNum());
      gwr.setTotalAmount((int)(creditHeader.getCreditTotal() * 100));
      //gwr.setTotalAmount(1000);
   
      GatewayResponse response = connector.sendRequest(gwr);
    if (!response.getTrxnStatus()) {
      logger.error("request = Not able to process credit card authorization for " + orderHeader.getCustAddress().getCustFirstName() + " " + orderHeader.getCustAddress().getCustLastName());
      logger.error("response = " + response.getTrxnError());
      paymentMessage = response.getTrxnError();
      throw new AuthorizationException(response.getTrxnError());
View Full Code Here

TOP

Related Classes of com.eway.GatewayConnector

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.