⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 worldpayevents.java

📁 Sequoia ERP是一个真正的企业级开源ERP解决方案。它提供的模块包括:电子商务应用(e-commerce), POS系统(point of sales),知识管理,存货与仓库管理
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
/* * $Id: WorldPayEvents.java 6642 2006-02-01 02:29:51Z sichen $ * * Copyright (c) 2001-2005 The Open For Business Project - www.ofbiz.org * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included * in all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT * OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR * THE USE OR OTHER DEALINGS IN THE SOFTWARE. * */package org.ofbiz.accounting.thirdparty.worldpay;import java.io.IOException;import java.util.List;import javax.servlet.ServletContext;import javax.servlet.http.HttpServletRequest;import javax.servlet.http.HttpServletResponse;import org.ofbiz.base.util.Debug;import org.ofbiz.base.util.UtilFormatOut;import org.ofbiz.base.util.UtilHttp;import org.ofbiz.base.util.UtilMisc;import org.ofbiz.base.util.UtilProperties;import org.ofbiz.entity.GenericDelegator;import org.ofbiz.entity.GenericEntityException;import org.ofbiz.entity.GenericValue;import org.ofbiz.entity.util.EntityUtil;import org.ofbiz.product.catalog.CatalogWorker;import org.ofbiz.product.store.ProductStoreWorker;import org.ofbiz.service.LocalDispatcher;import com.worldpay.core.ArgumentException;import com.worldpay.protocols.http.HTTPURL;import com.worldpay.protocols.http.URLParameters;import com.worldpay.select.PurchaseToken;import com.worldpay.select.Select;import com.worldpay.select.SelectCurrency;import com.worldpay.select.SelectDefs;import com.worldpay.select.SelectException;import com.worldpay.util.Currency;import com.worldpay.util.CurrencyAmount;/** * WorldPay Select Pro Events/Services * * @author     <a href="mailto:jaz@ofbiz.org">Andy Zeneski</a> * @version    $Rev: 6642 $ * @since      2.0 */public class WorldPayEvents {        public static final String module = WorldPayEvents.class.getName();        public static String worldPayRequest(HttpServletRequest request, HttpServletResponse response) {        ServletContext application = ((ServletContext) request.getAttribute("servletContext"));        GenericDelegator delegator = (GenericDelegator) request.getAttribute("delegator");        LocalDispatcher dispatcher = (LocalDispatcher) request.getAttribute("dispatcher");        GenericValue userLogin = (GenericValue) request.getSession().getAttribute("userLogin");                                         // we need the websiteId for the correct properties file        String webSiteId = CatalogWorker.getWebSiteId(request);                // get the orderId from the request, stored by previous event(s)        String orderId = (String) request.getAttribute("orderId");                if (orderId == null) {            Debug.logError("Problems getting orderId, was not found in request", module);            request.setAttribute("_ERROR_MESSAGE_", "<li>OrderID not found, please contact customer service.");            return "error";        }                // get the order header for total and other information        GenericValue orderHeader = null;        try {            orderHeader = delegator.findByPrimaryKey("OrderHeader", UtilMisc.toMap("orderId", orderId));        } catch (GenericEntityException e) {            Debug.logError(e, "Cannot not get OrderHeader from datasource", module);            request.setAttribute("_ERROR_MESSAGE_", "<li>Problems getting order information, please contact customer service.");            return "error";        }                // get the contact address to pass over        GenericValue contactAddress = null;        try {            List addresses = delegator.findByAnd("OrderContactMech", UtilMisc.toMap("orderId", orderId, "contactMechPurposeTypeId", "BILLING_LOCATION"));            if (addresses == null || addresses.size() == 0)                addresses = delegator.findByAnd("OrderContactMech", UtilMisc.toMap("orderId", orderId, "contactMechPurposeTypeId", "SHIPPING_LOCATION"));            GenericValue contactMech = EntityUtil.getFirst(addresses);             contactAddress = delegator.findByPrimaryKey("PostalAddress", UtilMisc.toMap("contactMechId", contactMech.getString("contactMechId")));                              } catch (GenericEntityException e) {            Debug.logWarning(e, "Problems getting order contact information", module);        }                // get the country geoID        GenericValue countryGeo = null;        if (contactAddress != null) {            try {                countryGeo = contactAddress.getRelatedOne("CountryGeo");            } catch (GenericEntityException e) {                Debug.logWarning(e, "Problems getting country geo entity", module);                            }        }                // string of customer's name        String name = null;        if (contactAddress != null) {            if (contactAddress.get("attnName") != null && contactAddress.getString("attnName").length() > 0)                name = contactAddress.getString("attnName");            else if (contactAddress.get("toName") != null && contactAddress.getString("toName").length() > 0)                name = contactAddress.getString("toName");        }                // build an address string        StringBuffer address = null;        if (contactAddress != null) {            address = new StringBuffer();            if (contactAddress.get("address1") != null) {                            address.append(contactAddress.getString("address1").trim());            }            if (contactAddress.get("address2") != null) {                if (address.length() > 0)                    address.append("&#10;");                address.append(contactAddress.getString("address2").trim());                            }            if (contactAddress.get("city") != null) {                if (address.length() > 0)                    address.append("&#10;");                address.append(contactAddress.getString("city").trim());                            }            if (contactAddress.get("stateProvinceGeoId") != null) {                if (contactAddress.get("city") != null)                    address.append(", ");                address.append(contactAddress.getString("stateProvinceGeoId").trim());            }                    }                // get the telephone number to pass over        String phoneNumber = null;        GenericValue phoneContact = null;                        // get the email address to pass over        String emailAddress = null;        GenericValue emailContact = null;        try {            List emails = delegator.findByAnd("OrderContactMech", UtilMisc.toMap("orderId", orderId, "contactMechPurposeTypeId", "ORDER_EMAIL"));            GenericValue firstEmail = EntityUtil.getFirst(emails);            emailContact = delegator.findByPrimaryKey("ContactMech", UtilMisc.toMap("contactMechId", firstEmail.getString("contactMechId")));                                    emailAddress = emailContact.getString("infoString");        } catch (GenericEntityException e) {            Debug.logWarning(e, "Problems getting order email address", module);        }                // get the product store

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -