New file |
| | |
| | | package com.hx.mp.util; |
| | | |
| | | import com.hx.exception.ServiceException; |
| | | import com.hx.util.HttpUtil; |
| | | import com.hx.util.SimpleTool; |
| | | import com.hx.util.StringUtils; |
| | | import net.sf.json.JSONObject; |
| | | import org.apache.http.HttpEntity; |
| | | import org.apache.http.client.methods.CloseableHttpResponse; |
| | | import org.apache.http.client.methods.HttpPost; |
| | | import org.apache.http.conn.ssl.SSLConnectionSocketFactory; |
| | | import org.apache.http.entity.StringEntity; |
| | | import org.apache.http.impl.client.CloseableHttpClient; |
| | | import org.apache.http.impl.client.HttpClients; |
| | | import org.apache.http.ssl.SSLContexts; |
| | | import org.apache.http.util.EntityUtils; |
| | | import org.dom4j.Document; |
| | | import org.dom4j.Element; |
| | | import org.dom4j.io.SAXReader; |
| | | |
| | | import javax.net.ssl.SSLContext; |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import java.io.File; |
| | | import java.io.FileInputStream; |
| | | import java.security.KeyStore; |
| | | import java.util.*; |
| | | |
| | | |
| | | /** 服务商商户Native(二维码扫码支付) |
| | | * @author ChenJiaHe |
| | | */ |
| | | public class CorpWXPayQrUtil { |
| | | |
| | | |
| | | /**服务商-获取二维码支付数据*/ |
| | | private static final String PAY_NATIVE_URL = "https://api.mch.weixin.qq.com/v3/pay/partner/transactions/native"; |
| | | |
| | | /**获取支付二维码数据 |
| | | * @param sp_appid 服务商申请的公众号appid |
| | | * @param sp_mchid 服务商户号 |
| | | * @param sub_appid 子商户申请的公众号appid 不必填 |
| | | * @param sub_mchid 子商户的商户号 |
| | | * @param description 商品描述 |
| | | * @param out_trade_no 商户系统内部订单号 |
| | | * @param amount 金额(分) |
| | | * @param notify_url 回调地址 |
| | | * @return |
| | | * @throws Exception |
| | | */ |
| | | public static JSONObject nativeQr(String sp_appid , String sp_mchid , String sub_appid |
| | | , String sub_mchid , String description , String out_trade_no , Integer amount |
| | | ,String notify_url ) |
| | | throws Exception { |
| | | |
| | | JSONObject parameters = new JSONObject(); |
| | | parameters.put("sp_appid", sp_appid); |
| | | parameters.put("sp_mchid", sp_mchid); |
| | | parameters.put("sub_appid", sub_appid); |
| | | parameters.put("sub_mchid", sub_mchid); |
| | | parameters.put("description", description); |
| | | parameters.put("out_trade_no", out_trade_no); |
| | | parameters.put("notify_url", notify_url); |
| | | |
| | | JSONObject amountObj = new JSONObject(); |
| | | amountObj.put("total",amount); |
| | | amountObj.put("currency","CNY"); |
| | | parameters.put("amount", amountObj); |
| | | |
| | | JSONObject returnObj = HttpUtil.HttpURLUtilJson(PAY_NATIVE_URL,parameters.toString()); |
| | | |
| | | return returnObj; |
| | | } |
| | | } |