fix issue #1
This commit is contained in:
parent
e54257f6e6
commit
c62a1b3213
@ -130,7 +130,7 @@ public class HttpRequest {
|
|||||||
public Response post(String url, String body) throws WeixinException {
|
public Response post(String url, String body) throws WeixinException {
|
||||||
HttpPost method = new HttpPost(url);
|
HttpPost method = new HttpPost(url);
|
||||||
method.setEntity(new StringEntity(body, ContentType.create(
|
method.setEntity(new StringEntity(body, ContentType.create(
|
||||||
ContentType.APPLICATION_JSON.getMimeType(), Consts.UTF_8)));
|
ContentType.DEFAULT_TEXT.getMimeType(), Consts.UTF_8)));
|
||||||
return doRequest(method);
|
return doRequest(method);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -222,8 +222,8 @@ public class HttpRequest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void checkJson(Response response) throws WeixinException {
|
private void checkJson(Response response) throws WeixinException {
|
||||||
response.setJsonResult(true);
|
|
||||||
JsonResult jsonResult = response.getAsJsonResult();
|
JsonResult jsonResult = response.getAsJsonResult();
|
||||||
|
response.setJsonResult(true);
|
||||||
if (jsonResult.getCode() != 0) {
|
if (jsonResult.getCode() != 0) {
|
||||||
if (StringUtils.isBlank(jsonResult.getDesc())) {
|
if (StringUtils.isBlank(jsonResult.getDesc())) {
|
||||||
jsonResult = response.getTextError(jsonResult.getCode());
|
jsonResult = response.getTextError(jsonResult.getCode());
|
||||||
@ -234,7 +234,6 @@ public class HttpRequest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void checkXml(Response response) throws WeixinException {
|
private void checkXml(Response response) throws WeixinException {
|
||||||
response.setXmlResult(true);
|
|
||||||
XmlResult xmlResult = null;
|
XmlResult xmlResult = null;
|
||||||
try {
|
try {
|
||||||
xmlResult = response.getAsXmlResult();
|
xmlResult = response.getAsXmlResult();
|
||||||
@ -250,6 +249,7 @@ public class HttpRequest {
|
|||||||
response.setText(newXml);
|
response.setText(newXml);
|
||||||
xmlResult = response.getAsXmlResult();
|
xmlResult = response.getAsXmlResult();
|
||||||
}
|
}
|
||||||
|
response.setXmlResult(true);
|
||||||
if (xmlResult.getReturnCode().equals("0")) {
|
if (xmlResult.getReturnCode().equals("0")) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -125,7 +125,7 @@ public class PayUtil {
|
|||||||
* md5签名(一般用于V3.x支付接口)
|
* md5签名(一般用于V3.x支付接口)
|
||||||
*
|
*
|
||||||
* @param obj
|
* @param obj
|
||||||
* 签名对象
|
* 签名对象
|
||||||
* @param paySignKey
|
* @param paySignKey
|
||||||
* 支付API的密钥
|
* 支付API的密钥
|
||||||
* @return
|
* @return
|
||||||
@ -192,7 +192,7 @@ public class PayUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 创建预支付对象
|
* 创建预支付对象</br> <font color="red">此方法并不包含签名,需要自己传入一个完整并且合法的PayPackage</font>
|
||||||
*
|
*
|
||||||
* @param payPackage
|
* @param payPackage
|
||||||
* 包含订单信息的对象
|
* 包含订单信息的对象
|
||||||
@ -200,19 +200,22 @@ public class PayUtil {
|
|||||||
* @see com.foxinmy.weixin4j.mp.payment.v3.PrePay
|
* @see com.foxinmy.weixin4j.mp.payment.v3.PrePay
|
||||||
* @return 预支付对象
|
* @return 预支付对象
|
||||||
*/
|
*/
|
||||||
public static PrePay createPrePay(PayPackageV3 payPackage) {
|
public static PrePay createPrePay(PayPackageV3 payPackage)
|
||||||
PrePay prePay = null;
|
throws PayException {
|
||||||
|
if (StringUtils.isBlank(payPackage.getSign())) {
|
||||||
|
// String paySignKey = weixinAccount.getPaySignKey();
|
||||||
|
// payPackage.setSign(paysignMd5(payPackage, paySignKey));
|
||||||
|
}
|
||||||
String payJsRequestXml = XStream.to(payPackage).replaceAll("__", "_");
|
String payJsRequestXml = XStream.to(payPackage).replaceAll("__", "_");
|
||||||
HttpRequest request = new HttpRequest();
|
HttpRequest request = new HttpRequest();
|
||||||
|
Response response = null;
|
||||||
try {
|
try {
|
||||||
Response response = request.post(Consts.UNIFIEDORDER,
|
response = request.post(Consts.UNIFIEDORDER, payJsRequestXml);
|
||||||
payJsRequestXml);
|
return response.getAsObject(new TypeReference<PrePay>() {
|
||||||
prePay = response.getAsObject(new TypeReference<PrePay>() {
|
|
||||||
});
|
});
|
||||||
} catch (WeixinException e) {
|
} catch (WeixinException e) {
|
||||||
prePay = new PrePay(e.getErrorCode(), e.getErrorMsg());
|
throw new PayException(e.getErrorCode(), e.getErrorMsg());
|
||||||
}
|
}
|
||||||
return prePay;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -106,10 +106,10 @@ public class PayAction {
|
|||||||
* bank_type=2032&discount=0&fee_type=1&input_charset=UTF-8&
|
* bank_type=2032&discount=0&fee_type=1&input_charset=UTF-8&
|
||||||
* notify_id=9fKbVf_qg6y-
|
* notify_id=9fKbVf_qg6y-
|
||||||
* wSjtSMV0PLXeEn2oGfTM1s9dWSvR2B9U6iFQRTzmjrMWKUxvh9mpBLvnh8aqFbC_OFk1pTvFnFUO00Lln4fh
|
* wSjtSMV0PLXeEn2oGfTM1s9dWSvR2B9U6iFQRTzmjrMWKUxvh9mpBLvnh8aqFbC_OFk1pTvFnFUO00Lln4fh
|
||||||
* & out_trade_no=D14102900031&partner=1221928801&product_fee=1&sign=
|
* & out_trade_no=D14102900031&partner=1221928801&product_fee=1&
|
||||||
* B9D6E772C271C9B86B8436FC9F5DFC1A&
|
* sign=B9D6E772C271C9B86B8436FC9F5DFC1A&
|
||||||
* sign_type=MD5&time_end=20141029183707
|
* sign_type=MD5&time_end=20141029183707&
|
||||||
* &total_fee=1&trade_mode=1&trade_state=0&
|
* total_fee=1&trade_mode=1&trade_state=0&
|
||||||
* transaction_id=1221928801201410296039230054&transport_fee=0
|
* transaction_id=1221928801201410296039230054&transport_fee=0
|
||||||
*/
|
*/
|
||||||
log.info("jspay_notify_orderinfo,{}", objMap);
|
log.info("jspay_notify_orderinfo,{}", objMap);
|
||||||
@ -216,8 +216,8 @@ public class PayAction {
|
|||||||
* <is_subscribe>1</is_subscribe></br>
|
* <is_subscribe>1</is_subscribe></br>
|
||||||
* <product_id>[CDATA[000000]]</product_id></br>
|
* <product_id>[CDATA[000000]]</product_id></br>
|
||||||
* <nonce_str><![CDATA[jALldRTHAFd5Tgs5]]></nonce_str></br>
|
* <nonce_str><![CDATA[jALldRTHAFd5Tgs5]]></nonce_str></br>
|
||||||
* <sign><![CDATA[bafe07f060f22dcda0bfdb4b5ff756f973aecffa]]></sign&
|
* <sign><![CDATA[bafe07f060f22dcda0bfdb4b5ff756f973aecffa]]>
|
||||||
* gt</br> </xml></br>
|
* </sign></br> </xml></br>
|
||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
* @throws PayException
|
* @throws PayException
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user