资源简介
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\.settings\org.eclipse.core.resources.prefs
文件 364 2017-04-27 14:55 weixin_pay\.settings\org.eclipse.jdt.core.prefs
文件 482 2016-12-16 10:10 weixin_pay\.settings\org.eclipse.wst.common.component
文件 345 2016-12-16 10:10 weixin_pay\.settings\org.eclipse.wst.common.project.facet.core.xm
文件 49 2016-12-16 10:10 weixin_pay\.settings\org.eclipse.wst.jsdt.ui.superType.container
文件 6 2016-12-16 10:10 weixin_pay\.settings\org.eclipse.wst.jsdt.ui.superType.name
目录 0 2017-04-27 14:54 weixin_pay\WebContent\
目录 0 2017-04-27 14:54 weixin_pay\WebContent\me
文件 39 2016-12-16 10:10 weixin_pay\WebContent\me
目录 0 2017-04-27 14:54 weixin_pay\WebContent\WEB-INF\
目录 0 2017-04-27 14:54 weixin_pay\WebContent\WEB-INF\lib\
文件 255182 2016-12-16 11:49 weixin_pay\WebContent\WEB-INF\lib\catalina-tribes.jar
文件 538199 2016-12-16 13:35 weixin_pay\WebContent\WEB-INF\lib\core-3.0.0.jar
文件 312181 2016-12-16 15:25 weixin_pay\WebContent\WEB-INF\lib\dom4j-2.0.0.jar
文件 151304 2016-12-16 11:54 weixin_pay\WebContent\WEB-INF\lib\jdom-1.1.3.jar
文件 1220 2016-12-16 16:29 weixin_pay\WebContent\WEB-INF\web.xm
文件 717 2017-04-27 17:11 weixin_pay\WebContent\index.jsp
文件 417 2016-12-16 16:17 weixin_pay\WebContent\pay.jsp
文件 393 2016-12-16 16:49 weixin_pay\WebContent\return.jsp
目录 0 2017-04-27 14:54 weixin_pay\build\
目录 0 2017-04-27 15:49 weixin_pay\build\classes\
目录 0 2017-04-27 15:49 weixin_pay\build\classes\com\
目录 0 2017-04-27 15:49 weixin_pay\build\classes\com\pangxie\
目录 0 2017-04-27 17:43 weixin_pay\build\classes\com\pangxie\controller\
文件 3416 2017-04-27 17:48 weixin_pay\build\classes\com\pangxie\controller\PayController.class
文件 1564 2017-04-27 17:32 weixin_pay\build\classes\com\pangxie\controller\QRCodeController.class
............此处省略24个文件信息
- 上一篇:LPC1788 USB驱动例程
- 下一篇:毕业设计 IM 聊天
相关资源
- ectouch最新版JSAPI微信支付V3插
- ectouch 微信支付插件
- ecshop微信支付含手机版ectouch
- 帝国CMS微信支付宝支付接口插件
- 微信支付预订单、查询、退款等接口
- net微信支付
- 梨花众创-微信支付宝收款二维码合
- 微信当面支付二维码,修改参数即可
- 易语言微信官方支付模块加DEMO1.65
- 微信支付源代码
- 微信支付一元夺宝demo
- 运行官方微信支付demo超详细
- Unity第三方微信支付安卓端工程
- 微信支付的demo,带完整的源码,可直
- 可直接用的微信h5支付dem0
- 微信支付宝万能交易截图神器v1.0免费
- 微信公众号/小程序整套程序源码含微
- 微信支付官方demo
- spring+mybatis接入微信支付支付宝支付包
- 阿狸子微信产品竞价单页 解密版
- IE_Spy.rar
- 2019最新.Net MVC微信授权登录及微信支
- 微信支付宝及时到账网站源码
- zzpay开源个人微信和支付宝免签收款系
- .netMVC框架微信公众号支付
- 微信支付扫一扫demo完整代码
- 喜来客微信支付宝二维码收款语音提
- 一个带有数据库的完整版本的旅游网
- 微信支付小程序视频教程资源信息.
- SpringBoot集成app微信支付.rar
评论
共有 条评论