资源简介
微信扫码支付和支付宝扫码支付代码,在我自己的项目中用的,仅供参考,代码是java写的,action用的springMVC技术,这个代码只是项目中的其中两个action类
代码片段和文件信息
package com.yidian.web.weixin;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import java.util.SortedMap;
import java.util.TreeMap;
import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Namespace;
import org.apache.struts2.convention.annotation.Result;
import org.apache.struts2.convention.annotation.Results;
import org.jdom.JDOMException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springside.modules.utils.web.struts2.Struts2Utils;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONobject;
import com.yidian.common.util.AjaxUtil;
import com.yidian.common.weixinutil.CommonUtil;
import com.yidian.common.weixinutil.ConfigUtil;
import com.yidian.common.weixinutil.PayCommonUtil;
import com.yidian.common.weixinutil.QRCodeEncoder;
import com.yidian.common.weixinutil.xmlUtil;
import com.yidian.entity.vo.WinxinpayInfo;
import com.yidian.service.information.alipay.WinxinpayInfoManager;
import com.yidian.web.CrudActionSupport;
@Namespace(“/winxinpayaction“)
@Results( { @Result(name = CrudActionSupport.RELOAD location = “winxinpayaction.action“ type = “redirect“) })
public class WinxinPayAction {
private static final long serialVersionUID = 6850655845243748466L;
private String orderid;// 订单号
private String totalFee;// 总金额
private WinxinpayInfoManager winxinpayinfomanager;
public WinxinpayInfoManager getWinxinpayinfomanager() {
return winxinpayinfomanager;
}
@Autowired
public void setWinxinpayinfomanager(WinxinpayInfoManager winxinpayinfomanager) {
this.winxinpayinfomanager = winxinpayinfomanager;
}
public String getOrderid() {
return orderid;
}
public void setOrderid(String orderid) {
this.orderid = orderid;
}
public String getTotalFee() {
return totalFee;
}
public void setTotalFee(String totalFee) {
this.totalFee = totalFee;
}
/**
* 微信支付二维码生成
*/
@SuppressWarnings(“unchecked“)
@Action(“/weixinpayment“)
public void weixinpayment() {
//WinxinpayInfo winxinpayinfo=winxinpayinfomanager.getWinxinpayInfo(1L);.
WinxinpayInfo winxinpayinfo=winxinpayinfomanager.getWinxinpayInfoList().get(0);
SortedMapject object> parameters1 = new TreeMapject object>();
parameters1.put(“appid“ winxinpayinfo.getS_appid());//ConfigUtil.APPID);// 公众账号id
parameters1.put(“mch_id“ winxinpayinfo.getS_mch_id());//ConfigUtil.MCH_ID);// 商户号
parameters1.put(“nonce_str“ PayCommonUtil.CreateNoncestr());// 随机字符串
parameters1.put(“out_trade_no“ orderid);// 商户订单号
String sign1 = PayCommonUtil.createSign2(“UTF-8“ parameters1winxinpayinfo.getS_api_key());
parameters1.put(“sign“ sign1);// 签名
String requestxml1 = PayCommonUtil.getRequestxml(parameters1);
String result1 = CommonUtil.httpsRequest(ConfigUtil.CHECK_ORDER_URL
“POST“ requestxml1);
//System.out.println(“微信支付订单查询“ + result1);
Map
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2015-02-27 17:46 支付\
目录 0 2015-02-27 17:37 支付\微信支付\
文件 12519 2015-02-12 10:23 支付\微信支付\WinxinPayAction.java
目录 0 2015-02-27 17:36 支付\微信支付\weixinutil\
文件 3997 2015-01-27 15:02 支付\微信支付\weixinutil\CommonUtil.java
文件 3178 2015-01-31 19:47 支付\微信支付\weixinutil\ConfigUtil.java
文件 1164 2015-01-27 14:48 支付\微信支付\weixinutil\MD5Util.java
文件 711 2015-01-27 15:02 支付\微信支付\weixinutil\MyX509TrustManager.java
文件 3595 2015-01-31 19:44 支付\微信支付\weixinutil\PayCommonUtil.java
文件 3002 2015-01-28 12:06 支付\微信支付\weixinutil\QRCodeEncoder.java
文件 1843 2015-01-28 11:21 支付\微信支付\weixinutil\TestWinxin.java
文件 2129 2015-01-27 14:48 支付\微信支付\weixinutil\xm
目录 0 2015-02-27 17:38 支付\支付宝支付\
文件 31711 2015-02-27 16:14 支付\支付宝支付\AlipayAction.java
- 上一篇:java批量删除
- 下一篇:Android串口工具.apk
评论
共有 条评论