微信扫码支付模式二。配置参数就能用,不能用打死我!!!


1.配置PayConfig的参数就能用(里面注释写的很清楚。)。 2.通过填写订单号,商品名称、价格,生成二维码。扫码即可付款。 3.如发现商品名称中文乱码问题,请设置项目编码为utf-8。因为已经解决了中文乱码的其他问题。
资源截图
代码片段和文件信息
package com.pangxie.controller;

import java.io.IOException;
import java.util.Map;
import java.util.SortedMap;
import java.util.TreeMap;

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

import org.dom4j.Document;
import org.dom4j.DocumentException;
import org.dom4j.Element;
import org.dom4j.io.SAXReader;
import org.jdom.JDOMException;

import com.pangxie.utils.HttpUtil;
import com.pangxie.utils.PayCommonUtil;
import com.pangxie.utils.PayConfigUtil;
import com.pangxie.utils.xmlUtil;

/**
 * Servlet implementation class PayController
 */
@WebServlet(“/PayController“)
public class PayController extends HttpServlet {
private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public PayController() {
        super();
        // TODO Auto-generated constructor stub
    }

/**
 * @see HttpServlet#service(HttpServletRequest request HttpServletResponse response)
 */
protected void service(HttpServletRequest request HttpServletResponse response) throws ServletException IOException {
SortedMapjectobject> packageParams = new TreeMapjectobject>(); 
    packageParams.put(“appid“ PayConfigUtil.APP_ID); 
    packageParams.put(“mch_id“ PayConfigUtil.MCH_ID);
    packageParams.put(“nonce_str“ String.valueOf(PayCommonUtil.buildRandom(30)));
    packageParams.put(“body“ new String(request.getParameter(“body“).getBytes(“ISO-8859-1“)“utf-8“));//商品描述
    packageParams.put(“out_trade_no“ request.getParameter(“out_trade_no“)); //商品订单
    packageParams.put(“total_fee“ request.getParameter(“total_fee“)); //商品价格
    packageParams.put(“spbill_create_ip“ PayCommonUtil.getHostIP()); //终端IP
    packageParams.put(“notify_url“ PayConfigUtil.NOTIFY_URL); 
    packageParams.put(“trade_type“ PayConfigUtil.TRADE_TYPE);
    
    String sign = PayCommonUtil.createSign(“UTF-8“ packageParamsPayConfigUtil.API_KEY); 
    packageParams.put(“sign“ sign); 
//     System.out.println(request.getParameter(“body“));
//     String username=request.getParameter(“body“);
//     String username1=new String(username.getBytes(“ISO-8859-1“)“utf-8“);
//     System.out.println(username1);
    String requestxml = PayCommonUtil.getRequestxml(packageParams); 
  
    String resxml = HttpUtil.postData(PayConfigUtil.API_URL requestxml); 
 
    Map map = null;
try {
map = xmlUtil.doxmlParse(resxml);
} catch (JDOMException e) {
// TODO Auto-generated catch block
e.printStackTrace();

    //String return_code = (String) map.get(“return_code“); 
    //String prepay_id = (String) map.get(“prepay_id“);

    String urlCode = (String) map.get(“code_url“);
    request.getSession().setAttribute(“code_url“ urlCode);
    request.getRequestDispatcher(“pay.

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2017-04-27 14:54  weixin_pay
     文件         953  2017-04-27 14:56  weixin_pay.classpath
     文件        1052  2017-04-27 14:58  weixin_pay.project
     目录           0  2017-04-27 17:32  weixin_pay.settings
     文件         567  2016-12-16 10:10  weixin_pay.settings.jsdtscope
     文件         109  2017-04-27 17:37  weixin_pay.settingsorg.eclipse.core.resources.prefs
     文件         364  2017-04-27 14:55  weixin_pay.settingsorg.eclipse.jdt.core.prefs
     文件         482  2016-12-16 10:10  weixin_pay.settingsorg.eclipse.wst.common.component
     文件         345  2016-12-16 10:10  weixin_pay.settingsorg.eclipse.wst.common.project.facet.core.xml
     文件          49  2016-12-16 10:10  weixin_pay.settingsorg.eclipse.wst.jsdt.ui.superType.container
     文件           6  2016-12-16 10:10  weixin_pay.settingsorg.eclipse.wst.jsdt.ui.superType.name
     目录           0  2017-04-27 14:54  weixin_payWebContent
     目录           0  2017-04-27 14:54  weixin_payWebContentmeta-INF
     文件          39  2016-12-16 10:10  weixin_payWebContentmeta-INFMANIFEST.MF
     目录           0  2017-04-27 14:54  weixin_payWebContentWEB-INF
     目录           0  2017-04-27 14:54  weixin_payWebContentWEB-INFlib
     文件      255182  2016-12-16 11:49  weixin_payWebContentWEB-INFlibcatalina-tribes.jar
     文件      538199  2016-12-16 13:35  weixin_payWebContentWEB-INFlibcore-3.0.0.jar
     文件      312181  2016-12-16 15:25  weixin_payWebContentWEB-INFlibdom4j-2.0.0.jar
     文件      151304  2016-12-16 11:54  weixin_payWebContentWEB-INFlibjdom-1.1.3.jar
     文件        1220  2016-12-16 16:29  weixin_payWebContentWEB-INFweb.xml
     文件         717  2017-04-27 17:11  weixin_payWebContentindex.jsp
     文件         417  2016-12-16 16:17  weixin_payWebContentpay.jsp
     文件         393  2016-12-16 16:49  weixin_payWebContent
eturn.jsp
     目录           0  2017-04-27 14:54  weixin_payuild
     目录           0  2017-04-27 15:49  weixin_payuildclasses
     目录           0  2017-04-27 15:49  weixin_payuildclassescom
     目录           0  2017-04-27 15:49  weixin_payuildclassescompangxie
     目录           0  2017-04-27 17:43  weixin_payuildclassescompangxiecontroller
     文件        3416  2017-04-27 17:48  weixin_payuildclassescompangxiecontrollerPayController.class
     文件        1564  2017-04-27 17:32  weixin_payuildclassescompangxiecontrollerQRCodeController.class
............此处省略24个文件信息

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件举报,一经查实,本站将立刻删除。

发表评论

评论列表(条)