PaymentServlet代码

Posted jepson6669

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了PaymentServlet代码相关的知识,希望对你有一定的参考价值。

package ${enclosing_package};

import java.io.IOException;
import java.util.ResourceBundle;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

//导入所需要的PaymentUtils工具类包
import www.test.utils.PaymentUtils;

public class ${primary_type_name} extends HttpServlet {

    public void doGet(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        // 获得 支付必须基本数据
        String orderid = request.getParameter("orderid");
        String money = request.getParameter("money");
        // 银行
        String pd_FrpId = request.getParameter("pd_FrpId");

        // 发给支付公司需要哪些数据
        String p0_Cmd = "Buy";
        String p1_MerId = ResourceBundle.getBundle("merchantInfo").getString("p1_MerId");
        String p2_Order = orderid;
        String p3_Amt = money;
        String p4_Cur = "CNY";
        String p5_Pid = "";
        String p6_Pcat = "";
        String p7_Pdesc = "";
        // 支付成功回调地址 ---- 第三方支付公司会访问、用户访问
        // 第三方支付可以访问网址
        String p8_Url = ResourceBundle.getBundle("merchantInfo").getString("callback");
        String p9_SAF = "";
        String pa_MP = "";
        String pr_NeedResponse = "1";
        // 加密hmac 需要密钥
        String keyValue = ResourceBundle.getBundle("merchantInfo").getString(
                "keyValue");
        String hmac = PaymentUtils.buildHmac(p0_Cmd, p1_MerId, p2_Order, p3_Amt,
                p4_Cur, p5_Pid, p6_Pcat, p7_Pdesc, p8_Url, p9_SAF, pa_MP,
                pd_FrpId, pr_NeedResponse, keyValue);
        
        
        String url = "https://www.yeepay.com/app-merchant-proxy/node?pd_FrpId="+pd_FrpId+
                        "&p0_Cmd="+p0_Cmd+
                        "&p1_MerId="+p1_MerId+
                        "&p2_Order="+p2_Order+
                        "&p3_Amt="+p3_Amt+
                        "&p4_Cur="+p4_Cur+
                        "&p5_Pid="+p5_Pid+
                        "&p6_Pcat="+p6_Pcat+
                        "&p7_Pdesc="+p7_Pdesc+
                        "&p8_Url="+p8_Url+
                        "&p9_SAF="+p9_SAF+
                        "&pa_MP="+pa_MP+
                        "&pr_NeedResponse="+pr_NeedResponse+
                        "&hmac="+hmac;

        //重定向到第三方支付平台
        response.sendRedirect(url);
    }

    public void doPost(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        doGet(request, response);
    }

}

 

以上是关于PaymentServlet代码的主要内容,如果未能解决你的问题,请参考以下文章

谷歌浏览器调试jsp 引入代码片段,如何调试代码片段中的js

VSCode自定义代码片段——CSS选择器

VSCode自定义代码片段——.vue文件的模板

VSCode自定义代码片段6——CSS选择器

VSCode自定义代码片段——声明函数

片段和活动之间的核心区别是啥?哪些代码可以写成片段?