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