支付宝扫码即时到账支付

时间:2022-08-06 03:23:39

String strResult1 = "";


// //////////////////////////////////请求参数//////////////////////////////////////

// 接口调用时间
String timestamp = UtilDate.getDateFormatter();
// 格式为:yyyy-MM-dd HH:mm:ss

// 动作
String method = "add";
// 创建商品二维码
// 业务类型
String biz_type = "10";
// 目前只支持1
// 业务数据
String biz_data = "";

// biz_data = new String(Struts2Utils.getRequest().getParameter(
// "WIDbiz_data").getBytes("ISO-8859-1"), "UTF-8");

JSONObject json1 = new JSONObject();
json1.put("trade_type", "1");
json1.put("need_address", "F");
JSONObject json2 = new JSONObject();
long i = (long) (Math.random() * 900000 + 1000000);
json2.put("id", "" + i);
json2.put("name", "车费" + orderid);
json2.put("price", totalFee);
json1.put("goods_info", json2);
// json1.put("return_url",
// "http://www.alipay/mobileReturnUrl1.action");
json1.put("notify_url",alipay.getS_mobile_return_url());

biz_data = json1.toString();

// 格式:JSON 大字符串,详见技术文档4.2.1章节
// String return_url =
// "http://www.alipay/mobileReturnUrl1.action";//
// 通知商户下单url
// String notify_url =
// "http://wwww.alipay/mobileNotify1.action";//
// alipay.getS_mobile_return_url();//
// 通知商户支付结果url
// ////////////////////////////////////////////////////////////////////////////////

// 把请求参数打包成数组
Map<String, String> sParaTemp = new HashMap<String, String>();
sParaTemp.put("service", "alipay.mobile.qrcode.manage");
sParaTemp.put("partner", alipay.getS_partner());
sParaTemp.put("_input_charset", AlipayConfig.input_charset);
sParaTemp.put("timestamp", timestamp);
sParaTemp.put("method", method);
sParaTemp.put("biz_type", biz_type);
sParaTemp.put("biz_data", biz_data);
// sParaTemp.put("return_url", return_url);// 通知商户下单url
// sParaTemp.put("notify_url", notify_url);// 通知商户支付结果url

// 建立请求

strResult1 = AlipaySubmit.buildRequest("", "", sParaTemp);
Map<String, String> map1 = new HashMap();
map1 = XMLUtil.doXMLParse(strResult1);
Map<String, String> map2 = new HashMap();
String ss = "<?xml version=\"1.0\" encoding=\"utf-8\"?> \n"
+ map1.get("response");
map2 = XMLUtil.doXMLParse(ss.replaceAll("&", "&"));

JSONObject r2 = new JSONObject();
r2.put("qrcode", map2.get("qrcode"));
r2.put("qrcode_img_url", map2.get("qrcode_img_url"));
AjaxUtil.ajaxResponse(Struts2Utils.getResponse(), r2.toString());
// AjaxUtil.ajaxResponse(Struts2Utils.getResponse(),
// "--------------");
//AjaxUtil.ajaxResponse(Struts2Utils.getResponse(), strResult1.toString());
return;