手机端APP调起支付宝客户端支付!!!!

需要商户登录支付宝后台,在“账户中心-密钥管理”下配置MAPI网关产品密钥,用支付宝官方提供的openssl-1.0.2m工具生成一对私钥和公钥,把公钥配置上去就可以了。不清楚的也可以咨询支付宝的在线客服技术人员,很好的客服

赋代码:

response.setContentType("text/plain; charset=UTF-8");
PrintWriter out = null;
try {
out = response.getWriter();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
请求参数//
// 支付类型
String payment_type = "1";
// 必填,不能修改
// 服务器异步通知页面路径
String notify_url = "xxxxxxx";
// 需http://格式的完整路径,不能加?id=123这类自定义参数
// 页面跳转同步通知页面路径
// 需http://格式的完整路径,不能加?id=123这类自定义参数,不能写成http://localhost/
// 商户订单号
String out_trade_no = request.getParameter("orderId");
// 商户网站订单系统中唯一订单号,必填
// 订单名称
String subject = "";
try {
subject = URLDecoder.decode(request.getParameter("title"), "UTF-8");
} catch (UnsupportedEncodingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
;
// 必填
String total_fee = request.getParameter("totalFee");// 订单模块生成,传给支付宝支付模块
String title = URLDecoder.decode(request.getParameter("title"),
"UTF-8");
// 付款金额
// String total_fee = request.getParameter("totalFee");
// 必填
System.out.println("移动端传过来的orderId" + out_trade_no + ",total_fee = " + total_fee);
// 商品展示地址
String show_url = "xxxx";
// 必填,需以http://开头的完整路径,例如:http://www.商户网址.com/myorder.html
// 订单描述
String body = "商品介绍";
// 选填
// 超时时间
String it_b_pay = "1d";
// 选填
// 把请求参数打包成数组
Map<String, String> sParaTemp = new HashMap<String, String>();
sParaTemp.put("service", "mobile.securitypay.pay");
sParaTemp.put("partner", "XXXX");
sParaTemp.put("seller_id", "XXX");
sParaTemp.put("_input_charset", "UTF-8");
sParaTemp.put("payment_type", payment_type);
sParaTemp.put("notify_url", notify_url);
sParaTemp.put("out_trade_no", out_trade_no);
sParaTemp.put("subject", subject);
sParaTemp.put("total_fee", total_fee);
// sParaTemp.put("show_url", show_url);
sParaTemp.put("body", body);
// sParaTemp.put("it_b_pay", it_b_pay);
String sHtmlText = "";
for (Iterator iter = sParaTemp.keySet().iterator(); iter.hasNext();) {
String name = (String) iter.next();
String value = sParaTemp.get(name);
sHtmlText += name + "=\"" + value + "\"&";
}
// 建立请求
System.out.println("开始建立 请求!!!!!!!!!!!!!!!!!!!!!!!!!");
sHtmlText = sHtmlText.substring(0, sHtmlText.length() - 1);
System.out.println("待签名字符串sHtmlText=" + sHtmlText);
String sign = "";
try {
sign = RSA.sign(sHtmlText,
"这里填私钥",
"UTF-8");
System.out.println("URLEncoder.encode前的sign=" + sign);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
sign = URLEncoder.encode(sign, "UTF-8");

System.out.println("URLEncoder.encode后的 sign=" + sign);
System.out.println("URLEncoder.encode后的 sHtmlText=" + sHtmlText);
String buf = sHtmlText + "&sign=\"" + sign + "\"&sign_type=\"RSA\"";
// String
// buf2=c.get("http://demo.dcloud.net.cn/helloh5/payment/alipay.php?total=100");
System.out.println("发给移动端 = " + buf);
out.write(buf);
out.flush();
out.close();

buf2是网上公开的测试接口,可使用手机APP调用测试看返回数据。

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值