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

📄 payflowpro.java

📁 Sequoia ERP是一个真正的企业级开源ERP解决方案。它提供的模块包括:电子商务应用(e-commerce), POS系统(point of sales),知识管理,存货与仓库管理
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
/* * $Id: PayflowPro.java 6755 2006-02-16 23:36:54Z jaz $ * * 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.verisign;import java.util.Iterator;import java.util.List;import java.util.Map;import java.util.Set;import com.Verisign.payment.PFProAPI;import org.apache.commons.collections.map.LinkedMap;import org.ofbiz.accounting.payment.PaymentGatewayServices;import org.ofbiz.base.util.Debug;import org.ofbiz.base.util.StringUtil;import org.ofbiz.base.util.UtilMisc;import org.ofbiz.base.util.UtilProperties;import org.ofbiz.base.util.UtilValidate;import org.ofbiz.entity.GenericValue;import org.ofbiz.service.DispatchContext;import org.ofbiz.service.ServiceUtil;/** * PayflowPro - Verisign PayFlow Pro <=> OFBiz Service Module * * @author     <a href="mailto:jaz@ofbiz.org">Andy Zeneski</a> * @version    $Rev: 6755 $ * @since      2.0 */public class PayflowPro {    public static final String module = PayflowPro.class.getName();    /**     * Authorize credit card payment service. Service wrapper around PayFlow Pro API.     * @param dctx Service Engine DispatchContext.     * @param context Map context of parameters.     * @return Response map, including RESPMSG, and RESULT keys.     */    public static Map ccProcessor(DispatchContext dctx, Map context) {        GenericValue paymentPref = (GenericValue) context.get("orderPaymentPreference");        GenericValue authTrans = (GenericValue) context.get("authTrans");        String orderId = (String) context.get("orderId");        String cvv2 = (String) context.get("cardSecurityCode");        Double processAmount = (Double) context.get("processAmount");        GenericValue party = (GenericValue) context.get("billToParty");        GenericValue cc = (GenericValue) context.get("creditCard");        GenericValue ps = (GenericValue) context.get("billingAddress");        String configString = (String) context.get("paymentConfig");        if (configString == null) {            configString = "payment.properties";        }        if (authTrans == null){        	authTrans = PaymentGatewayServices.getAuthTransaction(paymentPref);        }        // set the orderId as comment1 so we can query in PF Manager        boolean isReAuth = false;        Map data = UtilMisc.toMap("COMMENT1", orderId);        data.put("PONUM", orderId);        data.put("CUSTCODE", party.getString("partyId"));        // transaction type        if (UtilProperties.propertyValueEqualsIgnoreCase(configString, "payment.verisign.preAuth", "Y")) {            data.put("TRXTYPE", "A");            // only support re-auth for auth types; sale types don't do it            if (authTrans != null) {                String refNum = authTrans.getString("referenceNum");                data.put("ORIGID", refNum);                isReAuth = true;            }        } else {            data.put("TRXTYPE", "S");        }        // credit card tender        data.put("TENDER", "C");        // card security code        if (UtilValidate.isNotEmpty(cvv2)) {            data.put("CVV2", cvv2);        }        // set the amount        data.put("AMT", processAmount.toString());        // get the payment information        data.put("ACCT", cc.getString("cardNumber"));        // name on card        String name = cc.getString("firstNameOnCard") + " " + cc.getString("lastNameOnCard");        data.put("FIRSTNAME", cc.getString("firstNameOnCard"));        data.put("LASTNAME", cc.getString("lastNameOnCard"));        data.put("COMMENT2", name);        if (cc.get("expireDate") != null) {            String exp = cc.getString("expireDate");            String expDate = exp.substring(0, 2);            expDate = expDate + exp.substring(exp.length() - 2);            data.put("EXPDATE", expDate);        }        // gather the address info        if (ps != null) {            String street = ps.getString("address1") +                (ps.get("address2") != null && ps.getString("address2").length() > 0 ? " " +                    ps.getString("address2") : "");            data.put("STREET", street);            data.put("ZIP", ps.getString("postalCode"));        }        PFProAPI pn = init(configString);        // get the base params        StringBuffer params = makeBaseParams(configString);        // parse the context parameters        params.append("&" + parseContext(data));        // transmit the request        if (Debug.verboseOn()) Debug.logVerbose("Sending to Verisign: " + params.toString(), module);        String resp = pn.SubmitTransaction(params.toString());        if (Debug.verboseOn()) Debug.logVerbose("Response from Verisign: " + resp, module);        // reset for next use        pn.DestroyContext();        // check the response        Map result = ServiceUtil.returnSuccess();        parseAuthResponse(resp, result, configString, isReAuth);        result.put("processAmount", processAmount);        return result;    }    public static Map ccCapture(DispatchContext dctx, Map context) {        GenericValue paymentPref = (GenericValue) context.get("orderPaymentPreference");        GenericValue authTrans = (GenericValue) context.get("authTrans");        Double amount = (Double) context.get("captureAmount");        String configString = (String) context.get("paymentConfig");        if (configString == null) {            configString = "payment.properties";        }        if (authTrans == null){        	authTrans = PaymentGatewayServices.getAuthTransaction(paymentPref);        }        if (authTrans == null) {            return ServiceUtil.returnError("No authorization transaction found for the OrderPaymentPreference; cannot capture");        }        // auth ref number        String refNum = authTrans.getString("referenceNum");        Map data = UtilMisc.toMap("ORIGID", refNum);        // tx type (Delayed Capture)        data.put("TRXTYPE", "D");        // credit card tender        data.put("TENDER", "C");        // get the orderID        String orderId = paymentPref.getString("orderId");        data.put("COMMENT1", orderId);        // amount to capture        data.put("AMT", amount.toString());        PFProAPI pn = init(configString);        // get the base params        StringBuffer params = makeBaseParams(configString);        // parse the context parameters        params.append("&" + parseContext(data));        // transmit the request        if (Debug.verboseOn()) Debug.logVerbose("Sending to Verisign: " + params.toString(), module);        String resp = pn.SubmitTransaction(params.toString());        if (Debug.verboseOn()) Debug.logVerbose("Response from Verisign: " + resp, module);        // reset for next use        pn.DestroyContext();        // check the response        Map result = ServiceUtil.returnSuccess();        parseCaptureResponse(resp, result, configString);        result.put("captureAmount", amount);        return result;    }    public static Map ccVoid(DispatchContext dctx, Map context) {        GenericValue paymentPref = (GenericValue) context.get("orderPaymentPreference");        GenericValue authTrans = (GenericValue) context.get("authTrans");        Double amount = (Double) context.get("releaseAmount");        String configString = (String) context.get("paymentConfig");        if (configString == null) {            configString = "payment.properties";        }        if (authTrans == null){        	authTrans = PaymentGatewayServices.getAuthTransaction(paymentPref);        }        if (authTrans == null) {            return ServiceUtil.returnError("No authorization transaction found for the OrderPaymentPreference; cannot capture");        }        // auth ref number        String refNum = authTrans.getString("referenceNum");        Map data = UtilMisc.toMap("ORIGID", refNum);        // tx type (Void)        data.put("TRXTYPE", "V");        // credit card tender        data.put("TENDER", "C");        // get the orderID        String orderId = paymentPref.getString("orderId");        data.put("COMMENT1", orderId);        // amount to capture        data.put("AMT", amount.toString());        PFProAPI pn = init(configString);        // get the base params        StringBuffer params = makeBaseParams(configString);        // parse the context parameters        params.append("&" + parseContext(data));        // transmit the request        if (Debug.verboseOn()) Debug.logVerbose("Sending to Verisign: " + params.toString(), module);        String resp = pn.SubmitTransaction(params.toString());        if (Debug.verboseOn()) Debug.logVerbose("Response from Verisign: " + resp, module);        // reset for next use        pn.DestroyContext();        // check the response        Map result = ServiceUtil.returnSuccess();        parseVoidResponse(resp, result, configString);        result.put("releaseAmount", amount);        return result;

⌨️ 快捷键说明

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