|
@@ -118,9 +118,9 @@ public class WxPayServiceImpl implements IWxPayService {
|
|
|
|
|
|
private WXPayConstants.SignType signType;
|
|
|
|
|
|
- // private String notifyUrl = "https://api.xyyxt.net/wx/pay/callback";
|
|
|
+ private String notifyUrl = "https://api.xyyxt.net/wx/pay/callback";
|
|
|
|
|
|
- private String notifyUrl = "http://42.192.164.187:19005/wx/pay/callback";
|
|
|
+ // private String notifyUrl = "http://42.192.164.187:19005/wx/pay/callback";
|
|
|
|
|
|
private WXPayRequest wxPayRequest;
|
|
|
|
|
@@ -155,8 +155,10 @@ public class WxPayServiceImpl implements IWxPayService {
|
|
|
private String gzh_tokenParam = "grant_type=client_credential&appid=%s&secret=%s";
|
|
|
|
|
|
@Override
|
|
|
- public Map<String, String> payment(String out_trade_no,String openid,String body,String price) {
|
|
|
+ public Map<String, String> payment(String out_trade_no,String openid,String body,BigDecimal price) {
|
|
|
WxSmallConfig config = new WxSmallConfig(appid,mchid,key);
|
|
|
+ BigDecimal unit = new BigDecimal(100);
|
|
|
+ price = price.multiply(unit);
|
|
|
try {
|
|
|
WXPay wxpay = new WXPay(config);
|
|
|
Map<String, String> data = new HashMap<String, String>();
|
|
@@ -164,15 +166,16 @@ public class WxPayServiceImpl implements IWxPayService {
|
|
|
data.put("out_trade_no", out_trade_no);
|
|
|
data.put("device_info", "");
|
|
|
data.put("fee_type", "CNY");
|
|
|
- data.put("total_fee", "1");
|
|
|
+ data.put("total_fee",price.intValue()+"");
|
|
|
data.put("openid", openid);
|
|
|
data.put("spbill_create_ip", IpUtils.getIpAddr(ServletUtils.getRequest()));
|
|
|
data.put("notify_url", notifyUrl);
|
|
|
data.put("trade_type", "JSAPI");
|
|
|
String TenantId = ServletUtils.getRequest().getHeader("TenantId");
|
|
|
data.put("attach", TenantId);
|
|
|
+ System.out.println(data);
|
|
|
Map<String, String> resp = wxpay.unifiedOrder(data);
|
|
|
-
|
|
|
+ System.out.println(resp);
|
|
|
Map<String, String> result = new HashMap<>();
|
|
|
// result.put("provider","wxpay");
|
|
|
result.put("appId",appid);
|
|
@@ -180,8 +183,9 @@ public class WxPayServiceImpl implements IWxPayService {
|
|
|
result.put("nonceStr",resp.get("nonce_str"));
|
|
|
result.put("package","prepay_id="+resp.get("prepay_id"));
|
|
|
result.put("signType","MD5");
|
|
|
+ System.out.println(result);
|
|
|
+ System.out.println(key);
|
|
|
result.put("sign", WXPayUtil.generateSignature(result, key, WXPayConstants.SignType.MD5));
|
|
|
- // System.out.println(resp);
|
|
|
return result;
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
@@ -435,6 +439,7 @@ public class WxPayServiceImpl implements IWxPayService {
|
|
|
result.put("signType","MD5");
|
|
|
result.put("sign", WXPayUtil.generateSignature(result, key, WXPayConstants.SignType.MD5));
|
|
|
Map rMap = wxpay.refund(data);
|
|
|
+ System.out.println(rMap);
|
|
|
return rMap;
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|