提交 | 用户 | age
|
826b66
|
1 |
package com.hx.mp.util; |
C |
2 |
|
|
3 |
import com.hx.exception.ServiceException; |
|
4 |
import com.hx.util.HttpUtil; |
|
5 |
import com.hx.util.SimpleTool; |
|
6 |
import com.hx.util.StringUtils; |
|
7 |
import net.sf.json.JSONObject; |
|
8 |
import org.apache.http.HttpEntity; |
|
9 |
import org.apache.http.client.methods.CloseableHttpResponse; |
|
10 |
import org.apache.http.client.methods.HttpPost; |
|
11 |
import org.apache.http.conn.ssl.SSLConnectionSocketFactory; |
|
12 |
import org.apache.http.entity.StringEntity; |
|
13 |
import org.apache.http.impl.client.CloseableHttpClient; |
|
14 |
import org.apache.http.impl.client.HttpClients; |
|
15 |
import org.apache.http.ssl.SSLContexts; |
|
16 |
import org.apache.http.util.EntityUtils; |
|
17 |
import org.dom4j.Document; |
|
18 |
import org.dom4j.Element; |
|
19 |
import org.dom4j.io.SAXReader; |
|
20 |
|
|
21 |
import javax.net.ssl.SSLContext; |
|
22 |
import javax.servlet.http.HttpServletRequest; |
|
23 |
import java.io.File; |
|
24 |
import java.io.FileInputStream; |
|
25 |
import java.security.KeyStore; |
|
26 |
import java.util.*; |
|
27 |
|
|
28 |
|
|
29 |
/** 服务商商户Native(二维码扫码支付) |
|
30 |
* @author ChenJiaHe |
|
31 |
*/ |
|
32 |
public class CorpWXPayQrUtil { |
|
33 |
|
|
34 |
|
|
35 |
/**服务商-获取二维码支付数据*/ |
|
36 |
private static final String PAY_NATIVE_URL = "https://api.mch.weixin.qq.com/v3/pay/partner/transactions/native"; |
|
37 |
|
|
38 |
/**获取支付二维码数据 |
|
39 |
* @param sp_appid 服务商申请的公众号appid |
|
40 |
* @param sp_mchid 服务商户号 |
|
41 |
* @param sub_appid 子商户申请的公众号appid 不必填 |
|
42 |
* @param sub_mchid 子商户的商户号 |
|
43 |
* @param description 商品描述 |
|
44 |
* @param out_trade_no 商户系统内部订单号 |
|
45 |
* @param amount 金额(分) |
|
46 |
* @param notify_url 回调地址 |
|
47 |
* @return |
|
48 |
* @throws Exception |
|
49 |
*/ |
|
50 |
public static JSONObject nativeQr(String sp_appid , String sp_mchid , String sub_appid |
|
51 |
, String sub_mchid , String description , String out_trade_no , Integer amount |
|
52 |
,String notify_url ) |
|
53 |
throws Exception { |
|
54 |
|
|
55 |
JSONObject parameters = new JSONObject(); |
|
56 |
parameters.put("sp_appid", sp_appid); |
|
57 |
parameters.put("sp_mchid", sp_mchid); |
|
58 |
parameters.put("sub_appid", sub_appid); |
|
59 |
parameters.put("sub_mchid", sub_mchid); |
|
60 |
parameters.put("description", description); |
|
61 |
parameters.put("out_trade_no", out_trade_no); |
|
62 |
parameters.put("notify_url", notify_url); |
|
63 |
|
|
64 |
JSONObject amountObj = new JSONObject(); |
|
65 |
amountObj.put("total",amount); |
|
66 |
amountObj.put("currency","CNY"); |
|
67 |
parameters.put("amount", amountObj); |
|
68 |
|
|
69 |
JSONObject returnObj = HttpUtil.HttpURLUtilJson(PAY_NATIVE_URL,parameters.toString()); |
|
70 |
|
|
71 |
return returnObj; |
|
72 |
} |
|
73 |
} |