Package com.worldpay.protocols.http

Examples of com.worldpay.protocols.http.HTTPURL


            }
        }

        // create the purchase link
        String purchaseURL = null;
        HTTPURL link = null;
        URLParameters linkParms = null;
        try {
            purchaseURL = Select.getPurchaseURL();
            link = new HTTPURL(purchaseURL);
            linkParms = link.getParameters();
        } catch (SelectException e) {
            Debug.logError(e, "Problems creating the purchase url", module);
            request.setAttribute("_ERROR_MESSAGE_", "<li>Problem creating link to WorldPay, please contact customer service.");
            return "error";
        } catch (ArgumentException e) {
            Debug.logError(e, "Problems creating HTTPURL link", module);
            request.setAttribute("_ERROR_MESSAGE_", "<li>Problem creating link to WorldPay, please contact customer service.");
            return "error";
        }

        // create the currency amount
        double orderTotal = orderHeader.getDouble("grandTotal").doubleValue();
        CurrencyAmount currencyAmount = null;
        try {
            Currency currency = SelectCurrency.getInstanceByISOCode(defCur);
            currencyAmount = new CurrencyAmount(orderTotal, currency);
        } catch (ArgumentException ae) {
            Debug.logError(ae, "Problems building CurrencyAmount", module);
            request.setAttribute("_ERROR_MESSAGE_", "<li>Merchant Configuration Error, please contact customer service.");
            return "error";
        }

        // create a purchase token
        PurchaseToken token = null;
        try {
            token = new PurchaseToken(instIdInt, currencyAmount, orderId);
        } catch (SelectException e) {
            Debug.logError(e, "Cannot create purchase token", module);
        } catch (ArgumentException e) {
            Debug.logError(e, "Cannot create purchase token", module);
        }
        if (token == null) {
            request.setAttribute("_ERROR_MESSAGE_", "<li>Problems creating a purchase token, please contact customer service.");
            return "error";
        }

        // set the auth/test modes
        try {
            token.setAuthorisationMode(authMode);
        } catch (SelectException e) {
            Debug.logWarning(e, "Problems setting the authorization mode", module);
        }
        token.setTestMode(testModeInt);

        // set the token to the purchase link
        try {
            linkParms.setValue(SelectDefs.SEL_purchase, token.produce());
        } catch (SelectException e) {
            Debug.logError(e, "Problems producing token", module);
            request.setAttribute("_ERROR_MESSAGE_", "<li>Problems producing purchase token, please contact customer service.");
            return "error";
        }

        // set the customer data in the link
        linkParms.setValue(SelectDefs.SEL_desc, description);
        linkParms.setValue(SelectDefs.SEL_name, name != null ? name : "");
        linkParms.setValue(SelectDefs.SEL_address, address != null ? address.toString() : "");
        linkParms.setValue(SelectDefs.SEL_postcode, contactAddress != null ? contactAddress.getString("postalCode") : "");
        linkParms.setValue(SelectDefs.SEL_country, countryGeo.getString("geoCode"));
        linkParms.setValue(SelectDefs.SEL_tel, phoneNumber != null ? phoneNumber : "");
        linkParms.setValue(SelectDefs.SEL_email, emailAddress != null ? emailAddress : "");

        // set some optional data
        if (fixContact != null && fixContact.toUpperCase().startsWith("Y")) {
            linkParms.setValue(SelectDefs.SEL_fixContact, "Y");
        }
        if (hideContact != null && hideContact.toUpperCase().startsWith("Y")) {
            linkParms.setValue("hideContact", "Y"); // why is this not in SelectDefs??
        }

        // now set some send-back parameters
        linkParms.setValue("M_controlPath", (String)request.getAttribute("_CONTROL_PATH_"));
        linkParms.setValue("M_userLoginId", userLogin.getString("userLoginId"));
        linkParms.setValue("M_dispatchName", dispatcher.getName());
        linkParms.setValue("M_delegatorName", delegator.getDelegatorName());
        linkParms.setValue("M_webSiteId", webSiteId);
        linkParms.setValue("M_localLocale", UtilHttp.getLocale(request).toString());
        linkParms.setValue("M_confirmTemplate", confirmTemplate != null ? confirmTemplate : "");

        // redirect to worldpay
        try {
            response.sendRedirect(link.produce());
        } catch (IOException e) {
            Debug.logError(e, "Problems redirecting to Worldpay", module);
            request.setAttribute("_ERROR_MESSAGE_", "<li>Problems connecting with WorldPay, please contact customer service.");
            return "error";
        }
View Full Code Here


            }           
        }
       
        // create the purchase link
        String purchaseURL = null;
        HTTPURL link = null;
        URLParameters linkParms = null;
        try {
            purchaseURL = Select.getPurchaseURL();
            link = new HTTPURL(purchaseURL);
            linkParms = link.getParameters();
        } catch (SelectException e) {
            Debug.logError(e, "Problems creating the purchase url", module);
            request.setAttribute("_ERROR_MESSAGE_", "<li>Problem creating link to WorldPay, please contact customer service.");
            return "error";
        } catch (ArgumentException e) {
            Debug.logError(e, "Problems creating HTTPURL link", module);
            request.setAttribute("_ERROR_MESSAGE_", "<li>Problem creating link to WorldPay, please contact customer service.");
            return "error";
        }                                                     
       
        // create the currency amount
        double orderTotal = orderHeader.getDouble("grandTotal").doubleValue();
        CurrencyAmount currencyAmount = null;        
        try {
            Currency currency = SelectCurrency.getInstanceByISOCode(defCur);
            currencyAmount = new CurrencyAmount(orderTotal, currency);
        } catch (ArgumentException ae) {
            Debug.logError(ae, "Problems building CurrencyAmount", module);
            request.setAttribute("_ERROR_MESSAGE_", "<li>Merchant Configuration Error, please contact customer service.");
            return "error";
        }
               
        // create a purchase token
        PurchaseToken token = null;  
        try {
            token = new PurchaseToken(instIdInt, currencyAmount, orderId);
        } catch (SelectException e) {
            Debug.logError(e, "Cannot create purchase token", module);
        } catch (ArgumentException e) {
            Debug.logError(e, "Cannot create purchase token", module);
        }
        if (token == null) {
            request.setAttribute("_ERROR_MESSAGE_", "<li>Problems creating a purchase token, please contact customer service.");
            return "error";
        }
       
        // set the auth/test modes       
        try {
            token.setAuthorisationMode(authMode);
        } catch (SelectException e) {
            Debug.logWarning(e, "Problems setting the authorization mode", module);
        }
        token.setTestMode(testModeInt);
                       
        // set the token to the purchase link
        try {
            linkParms.setValue(SelectDefs.SEL_purchase, token.produce());
        } catch (SelectException e) {
            Debug.logError(e, "Problems producing token", module);
            request.setAttribute("_ERROR_MESSAGE_", "<li>Problems producing purchase token, please contact customer service.");
            return "error";
        }
       
        // set the customer data in the link
        linkParms.setValue(SelectDefs.SEL_desc, description);
        linkParms.setValue(SelectDefs.SEL_name, name != null ? name : "");
        linkParms.setValue(SelectDefs.SEL_address, address != null ? address.toString() : "");
        linkParms.setValue(SelectDefs.SEL_postcode, contactAddress != null ? contactAddress.getString("postalCode") : "");
        linkParms.setValue(SelectDefs.SEL_country, countryGeo.getString("geoCode"));
        linkParms.setValue(SelectDefs.SEL_tel, phoneNumber != null ? phoneNumber : "");
        linkParms.setValue(SelectDefs.SEL_email, emailAddress != null ? emailAddress : "");
       
        // set some optional data
        if (fixContact != null && fixContact.toUpperCase().startsWith("Y")) {
            linkParms.setValue(SelectDefs.SEL_fixContact, "Y");
        }
        if (hideContact != null && hideContact.toUpperCase().startsWith("Y")) {
            linkParms.setValue("hideContact", "Y"); // why is this not in SelectDefs??
        }
       
        // now set some send-back parameters
        linkParms.setValue("M_controlPath", (String)request.getAttribute("_CONTROL_PATH_"));
        linkParms.setValue("M_userLoginId", userLogin.getString("userLoginId"));              
        linkParms.setValue("M_dispatchName", dispatcher.getName());
        linkParms.setValue("M_delegatorName", delegator.getDelegatorName());       
        linkParms.setValue("M_webSiteId", webSiteId);       
        linkParms.setValue("M_localLocale", UtilHttp.getLocale(request).toString());              
        linkParms.setValue("M_confirmTemplate", confirmTemplate != null ? confirmTemplate : "");
                   
        // redirect to worldpay
        try {
            response.sendRedirect(link.produce());
        } catch (IOException e) {
            Debug.logError(e, "Problems redirecting to Worldpay", module);
            request.setAttribute("_ERROR_MESSAGE_", "<li>Problems connecting with WorldPay, please contact customer service.");
            return "error";
        }
View Full Code Here

TOP

Related Classes of com.worldpay.protocols.http.HTTPURL

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.