@@ -13,6 +13,23 @@ import java.util.Map; | |||||
*/ | */ | ||||
public interface WxMpPayService { | public interface WxMpPayService { | ||||
/** | |||||
* <pre> | |||||
* 查询订单(详见https://pay.weixin.qq.com/wiki/doc/api/jsapi.php?chapter=9_2) | |||||
* 该接口提供所有微信支付订单的查询,商户可以通过查询订单接口主动查询订单状态,完成下一步的业务逻辑。 | |||||
* 需要调用查询接口的情况: | |||||
◆ 当商户后台、网络、服务器等出现异常,商户系统最终未接收到支付通知; | |||||
◆ 调用支付接口后,返回系统错误或未知交易状态情况; | |||||
◆ 调用被扫支付API,返回USERPAYING的状态; | |||||
◆ 调用关单或撤销接口API之前,需确认支付状态; | |||||
* 接口地址:https://api.mch.weixin.qq.com/pay/orderquery | |||||
* </pre> | |||||
* @param transactionId 微信支付分配的商户号 | |||||
* @param outTradeNo 商户系统内部的订单号,当没提供transaction_id时需要传这个。 | |||||
* @throws WxErrorException | |||||
*/ | |||||
WxPayOrderQueryResult queryOrder(String transactionId, String outTradeNo) throws WxErrorException; | |||||
/** | /** | ||||
* 统一下单(详见http://pay.weixin.qq.com/wiki/doc/api/jsapi.php?chapter=9_1) | * 统一下单(详见http://pay.weixin.qq.com/wiki/doc/api/jsapi.php?chapter=9_1) | ||||
* 在发起微信支付前,需要调用统一下单接口,获取"预支付交易会话标识" | * 在发起微信支付前,需要调用统一下单接口,获取"预支付交易会话标识" | ||||
@@ -21,31 +38,21 @@ public interface WxMpPayService { | |||||
* @param request 请求对象 | * @param request 请求对象 | ||||
* | * | ||||
*/ | */ | ||||
WxUnifiedOrderResult unifiedOrder(WxUnifiedOrderRequest request) | |||||
throws WxErrorException; | |||||
WxPayUnifiedOrderResult unifiedOrder(WxPayUnifiedOrderRequest request) throws WxErrorException; | |||||
/** | /** | ||||
* 该接口调用“统一下单”接口,并拼装发起支付请求需要的参数 | * 该接口调用“统一下单”接口,并拼装发起支付请求需要的参数 | ||||
* 详见http://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1421141115&token=&lang=zh_CN | * 详见http://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1421141115&token=&lang=zh_CN | ||||
* @param request 请求对象 | * @param request 请求对象 | ||||
*/ | */ | ||||
Map<String, String> getPayInfo(WxUnifiedOrderRequest request) throws WxErrorException; | |||||
/** | |||||
* 该接口提供所有微信支付订单的查询,当支付通知处理异常戒丢失的情冴,商户可以通过该接口查询订单支付状态。 | |||||
* 详见http://pay.weixin.qq.com/wiki/doc/api/jsapi.php?chapter=9_2 | |||||
* @throws WxErrorException | |||||
* | |||||
*/ | |||||
WxMpPayResult getJSSDKPayResult(String transactionId, String outTradeNo) | |||||
throws WxErrorException; | |||||
Map<String, String> getPayInfo(WxPayUnifiedOrderRequest request) throws WxErrorException; | |||||
/** | /** | ||||
* 读取支付结果通知 | * 读取支付结果通知 | ||||
* 详见http://pay.weixin.qq.com/wiki/doc/api/jsapi.php?chapter=9_7 | * 详见http://pay.weixin.qq.com/wiki/doc/api/jsapi.php?chapter=9_7 | ||||
* | * | ||||
*/ | */ | ||||
WxMpPayCallback getJSSDKCallbackData(String xmlData); | |||||
WxPayJsSDKCallback getJSSDKCallbackData(String xmlData); | |||||
/** | /** | ||||
* <pre> | * <pre> | ||||
@@ -57,7 +64,7 @@ public interface WxMpPayService { | |||||
* @param keyFile 证书文件对象 | * @param keyFile 证书文件对象 | ||||
* @return 退款操作结果 | * @return 退款操作结果 | ||||
*/ | */ | ||||
WxMpPayRefundResult refund(WxMpPayRefundRequest request, File keyFile) throws WxErrorException; | |||||
WxPayRefundResult refund(WxPayRefundRequest request, File keyFile) throws WxErrorException; | |||||
/** | /** | ||||
* <pre> | * <pre> | ||||
@@ -78,7 +85,7 @@ public interface WxMpPayService { | |||||
* @param request 请求对象 | * @param request 请求对象 | ||||
* @param keyFile 证书文件对象 | * @param keyFile 证书文件对象 | ||||
*/ | */ | ||||
WxRedpackResult sendRedpack(WxSendRedpackRequest request, File keyFile) throws WxErrorException; | |||||
WxPaySendRedpackResult sendRedpack(WxPaySendRedpackRequest request, File keyFile) throws WxErrorException; | |||||
/** | /** | ||||
* <pre> | * <pre> | ||||
@@ -46,64 +46,26 @@ public class WxMpPayServiceImpl implements WxMpPayService { | |||||
} | } | ||||
@Override | @Override | ||||
public WxMpPayResult getJSSDKPayResult(String transactionId, | |||||
String outTradeNo) throws WxErrorException { | |||||
String nonce_str = System.currentTimeMillis() + ""; | |||||
SortedMap<String, String> packageParams = new TreeMap<>(); | |||||
packageParams.put("appid", | |||||
this.wxMpService.getWxMpConfigStorage().getAppId()); | |||||
packageParams.put("mch_id", | |||||
this.wxMpService.getWxMpConfigStorage().getPartnerId()); | |||||
if (transactionId != null && !"".equals(transactionId.trim())) { | |||||
packageParams.put("transaction_id", transactionId); | |||||
} else if (outTradeNo != null && !"".equals(outTradeNo.trim())) { | |||||
packageParams.put("out_trade_no", outTradeNo); | |||||
} else { | |||||
throw new IllegalArgumentException( | |||||
"Either 'transactionId' or 'outTradeNo' must be given."); | |||||
} | |||||
packageParams.put("nonce_str", nonce_str); | |||||
packageParams.put("sign", this.createSign(packageParams, | |||||
this.wxMpService.getWxMpConfigStorage().getPartnerKey())); | |||||
StringBuilder request = new StringBuilder("<xml>"); | |||||
for (Map.Entry<String, String> para : packageParams.entrySet()) { | |||||
request.append(String.format("<%s>%s</%s>", para.getKey(), | |||||
para.getValue(), para.getKey())); | |||||
} | |||||
request.append("</xml>"); | |||||
String url = PAY_BASE_URL + "/pay/orderquery"; | |||||
String responseContent = this.wxMpService.post(url, request.toString()); | |||||
XStream xstream = XStreamInitializer.getInstance(); | |||||
xstream.alias("xml", WxMpPayResult.class); | |||||
return (WxMpPayResult) xstream.fromXML(responseContent); | |||||
} | |||||
@Override | |||||
public WxMpPayCallback getJSSDKCallbackData(String xmlData) { | |||||
public WxPayJsSDKCallback getJSSDKCallbackData(String xmlData) { | |||||
try { | try { | ||||
XStream xstream = XStreamInitializer.getInstance(); | XStream xstream = XStreamInitializer.getInstance(); | ||||
xstream.alias("xml", WxMpPayCallback.class); | |||||
return (WxMpPayCallback) xstream.fromXML(xmlData); | |||||
xstream.alias("xml", WxPayJsSDKCallback.class); | |||||
return (WxPayJsSDKCallback) xstream.fromXML(xmlData); | |||||
} catch (Exception e) { | } catch (Exception e) { | ||||
e.printStackTrace(); | e.printStackTrace(); | ||||
} | } | ||||
return new WxMpPayCallback(); | |||||
return new WxPayJsSDKCallback(); | |||||
} | } | ||||
@Override | @Override | ||||
public WxMpPayRefundResult refund(WxMpPayRefundRequest request, File keyFile) | |||||
public WxPayRefundResult refund(WxPayRefundRequest request, File keyFile) | |||||
throws WxErrorException { | throws WxErrorException { | ||||
checkParameters(request); | checkParameters(request); | ||||
XStream xstream = XStreamInitializer.getInstance(); | XStream xstream = XStreamInitializer.getInstance(); | ||||
xstream.processAnnotations(WxMpPayRefundResult.class); | |||||
xstream.processAnnotations(WxMpPayRefundRequest.class); | |||||
xstream.processAnnotations(WxPayRefundResult.class); | |||||
xstream.processAnnotations(WxPayRefundRequest.class); | |||||
request.setAppid(this.wxMpService.getWxMpConfigStorage().getAppId()); | request.setAppid(this.wxMpService.getWxMpConfigStorage().getAppId()); | ||||
String partnerId = this.wxMpService.getWxMpConfigStorage().getPartnerId(); | String partnerId = this.wxMpService.getWxMpConfigStorage().getPartnerId(); | ||||
@@ -115,7 +77,7 @@ public class WxMpPayServiceImpl implements WxMpPayService { | |||||
String url = PAY_BASE_URL + "/secapi/pay/refund"; | String url = PAY_BASE_URL + "/secapi/pay/refund"; | ||||
String responseContent = this.executeRequestWithKeyFile(url, keyFile, xstream.toXML(request), partnerId); | String responseContent = this.executeRequestWithKeyFile(url, keyFile, xstream.toXML(request), partnerId); | ||||
WxMpPayRefundResult wxMpPayRefundResult = (WxMpPayRefundResult) xstream.fromXML(responseContent); | |||||
WxPayRefundResult wxMpPayRefundResult = (WxPayRefundResult) xstream.fromXML(responseContent); | |||||
if (!"SUCCESS".equalsIgnoreCase(wxMpPayRefundResult.getResultCode()) | if (!"SUCCESS".equalsIgnoreCase(wxMpPayRefundResult.getResultCode()) | ||||
|| !"SUCCESS".equalsIgnoreCase(wxMpPayRefundResult.getReturnCode())) { | || !"SUCCESS".equalsIgnoreCase(wxMpPayRefundResult.getReturnCode())) { | ||||
@@ -132,7 +94,7 @@ public class WxMpPayServiceImpl implements WxMpPayService { | |||||
return wxMpPayRefundResult; | return wxMpPayRefundResult; | ||||
} | } | ||||
private void checkParameters(WxMpPayRefundRequest request) throws WxErrorException { | |||||
private void checkParameters(WxPayRefundRequest request) throws WxErrorException { | |||||
BeanUtils.checkRequiredFields(request); | BeanUtils.checkRequiredFields(request); | ||||
if (StringUtils.isNotBlank(request.getRefundAccount())) { | if (StringUtils.isNotBlank(request.getRefundAccount())) { | ||||
@@ -154,11 +116,11 @@ public class WxMpPayServiceImpl implements WxMpPayService { | |||||
} | } | ||||
@Override | @Override | ||||
public WxRedpackResult sendRedpack(WxSendRedpackRequest request, File keyFile) | |||||
public WxPaySendRedpackResult sendRedpack(WxPaySendRedpackRequest request, File keyFile) | |||||
throws WxErrorException { | throws WxErrorException { | ||||
XStream xstream = XStreamInitializer.getInstance(); | XStream xstream = XStreamInitializer.getInstance(); | ||||
xstream.processAnnotations(WxSendRedpackRequest.class); | |||||
xstream.processAnnotations(WxRedpackResult.class); | |||||
xstream.processAnnotations(WxPaySendRedpackRequest.class); | |||||
xstream.processAnnotations(WxPaySendRedpackResult.class); | |||||
request.setWxAppid(this.wxMpService.getWxMpConfigStorage().getAppId()); | request.setWxAppid(this.wxMpService.getWxMpConfigStorage().getAppId()); | ||||
String mchId = this.wxMpService.getWxMpConfigStorage().getPartnerId(); | String mchId = this.wxMpService.getWxMpConfigStorage().getPartnerId(); | ||||
@@ -176,7 +138,7 @@ public class WxMpPayServiceImpl implements WxMpPayService { | |||||
} | } | ||||
String responseContent = this.executeRequestWithKeyFile(url, keyFile, xstream.toXML(request), mchId); | String responseContent = this.executeRequestWithKeyFile(url, keyFile, xstream.toXML(request), mchId); | ||||
WxRedpackResult redpackResult = (WxRedpackResult) xstream | |||||
WxPaySendRedpackResult redpackResult = (WxPaySendRedpackResult) xstream | |||||
.fromXML(responseContent); | .fromXML(responseContent); | ||||
if ("FAIL".equals(redpackResult.getResultCode())) { | if ("FAIL".equals(redpackResult.getResultCode())) { | ||||
throw new WxErrorException(WxError.newBuilder() | throw new WxErrorException(WxError.newBuilder() | ||||
@@ -212,13 +174,49 @@ public class WxMpPayServiceImpl implements WxMpPayService { | |||||
} | } | ||||
@Override | @Override | ||||
public WxUnifiedOrderResult unifiedOrder(WxUnifiedOrderRequest request) | |||||
public WxPayOrderQueryResult queryOrder(String transactionId, String outTradeNo) throws WxErrorException { | |||||
if ((StringUtils.isBlank(transactionId) && StringUtils.isBlank(outTradeNo)) || | |||||
(StringUtils.isNotBlank(transactionId) && StringUtils.isNotBlank(outTradeNo))) { | |||||
throw new IllegalArgumentException("transaction_id 和 out_trade_no 不能同时存在或同时为空,必须二选一"); | |||||
} | |||||
XStream xstream = XStreamInitializer.getInstance(); | |||||
xstream.processAnnotations(WxPayOrderQueryRequest.class); | |||||
xstream.processAnnotations(WxPayOrderQueryResult.class); | |||||
WxPayOrderQueryRequest request = new WxPayOrderQueryRequest(); | |||||
request.setOutTradeNo(StringUtils.trimToNull(outTradeNo)); | |||||
request.setTransactionId(StringUtils.trimToNull(transactionId)); | |||||
request.setAppid(this.wxMpService.getWxMpConfigStorage().getAppId()); | |||||
request.setMchId(this.wxMpService.getWxMpConfigStorage().getPartnerId()); | |||||
request.setNonceStr(System.currentTimeMillis() + ""); | |||||
String sign = this.createSign(BeanUtils.xmlBean2Map(request), | |||||
this.wxMpService.getWxMpConfigStorage().getPartnerKey()); | |||||
request.setSign(sign); | |||||
String url = PAY_BASE_URL + "/pay/orderquery"; | |||||
String responseContent = this.wxMpService.post(url, xstream.toXML(request)); | |||||
WxPayOrderQueryResult result = (WxPayOrderQueryResult) xstream.fromXML(responseContent); | |||||
result.composeCoupons(responseContent); | |||||
if ("FAIL".equals(result.getResultCode())) { | |||||
throw new WxErrorException(WxError.newBuilder() | |||||
.setErrorMsg(result.getErrCode() + ":" + result.getErrCodeDes()) | |||||
.build()); | |||||
} | |||||
return result; | |||||
} | |||||
@Override | |||||
public WxPayUnifiedOrderResult unifiedOrder(WxPayUnifiedOrderRequest request) | |||||
throws WxErrorException { | throws WxErrorException { | ||||
checkParameters(request); | checkParameters(request); | ||||
XStream xstream = XStreamInitializer.getInstance(); | XStream xstream = XStreamInitializer.getInstance(); | ||||
xstream.processAnnotations(WxUnifiedOrderRequest.class); | |||||
xstream.processAnnotations(WxUnifiedOrderResult.class); | |||||
xstream.processAnnotations(WxPayUnifiedOrderRequest.class); | |||||
xstream.processAnnotations(WxPayUnifiedOrderResult.class); | |||||
request.setAppid(this.wxMpService.getWxMpConfigStorage().getAppId()); | request.setAppid(this.wxMpService.getWxMpConfigStorage().getAppId()); | ||||
request.setMchId(this.wxMpService.getWxMpConfigStorage().getPartnerId()); | request.setMchId(this.wxMpService.getWxMpConfigStorage().getPartnerId()); | ||||
@@ -231,7 +229,7 @@ public class WxMpPayServiceImpl implements WxMpPayService { | |||||
String url = PAY_BASE_URL + "/pay/unifiedorder"; | String url = PAY_BASE_URL + "/pay/unifiedorder"; | ||||
String responseContent = this.wxMpService.post(url, xstream.toXML(request)); | String responseContent = this.wxMpService.post(url, xstream.toXML(request)); | ||||
WxUnifiedOrderResult result = (WxUnifiedOrderResult) xstream | |||||
WxPayUnifiedOrderResult result = (WxPayUnifiedOrderResult) xstream | |||||
.fromXML(responseContent); | .fromXML(responseContent); | ||||
if ("FAIL".equals(result.getResultCode())) { | if ("FAIL".equals(result.getResultCode())) { | ||||
throw new WxErrorException(WxError.newBuilder() | throw new WxErrorException(WxError.newBuilder() | ||||
@@ -242,7 +240,7 @@ public class WxMpPayServiceImpl implements WxMpPayService { | |||||
return result; | return result; | ||||
} | } | ||||
private void checkParameters(WxUnifiedOrderRequest request) throws WxErrorException { | |||||
private void checkParameters(WxPayUnifiedOrderRequest request) throws WxErrorException { | |||||
BeanUtils.checkRequiredFields(request); | BeanUtils.checkRequiredFields(request); | ||||
if (! ArrayUtils.contains(TRADE_TYPES, request.getTradeType())) { | if (! ArrayUtils.contains(TRADE_TYPES, request.getTradeType())) { | ||||
@@ -259,8 +257,8 @@ public class WxMpPayServiceImpl implements WxMpPayService { | |||||
} | } | ||||
@Override | @Override | ||||
public Map<String, String> getPayInfo(WxUnifiedOrderRequest request) throws WxErrorException { | |||||
WxUnifiedOrderResult unifiedOrderResult = this.unifiedOrder(request); | |||||
public Map<String, String> getPayInfo(WxPayUnifiedOrderRequest request) throws WxErrorException { | |||||
WxPayUnifiedOrderResult unifiedOrderResult = this.unifiedOrder(request); | |||||
if (!"SUCCESS".equalsIgnoreCase(unifiedOrderResult.getReturnCode()) | if (!"SUCCESS".equalsIgnoreCase(unifiedOrderResult.getReturnCode()) | ||||
|| !"SUCCESS".equalsIgnoreCase(unifiedOrderResult.getResultCode())) { | || !"SUCCESS".equalsIgnoreCase(unifiedOrderResult.getResultCode())) { | ||||
@@ -20,20 +20,7 @@ import org.apache.commons.lang3.builder.ToStringStyle; | |||||
* @author binarywang (https://github.com/binarywang) | * @author binarywang (https://github.com/binarywang) | ||||
*/ | */ | ||||
@XStreamAlias("xml") | @XStreamAlias("xml") | ||||
public class WxEntPayQueryRequest { | |||||
/** | |||||
* <pre> | |||||
* Appid | |||||
* appid | |||||
* 是 | |||||
* wxe062425f740d30d8 | |||||
* String(32) | |||||
* 商户号的appid | |||||
* </pre> | |||||
*/ | |||||
@XStreamAlias("appid") | |||||
private String appid; | |||||
public class WxEntPayQueryRequest extends WxPayBaseRequest { | |||||
/** | /** | ||||
* <pre> | * <pre> | ||||
* 商户号 | * 商户号 | ||||
@@ -47,32 +34,6 @@ public class WxEntPayQueryRequest { | |||||
@XStreamAlias("mchid") | @XStreamAlias("mchid") | ||||
private String mchId; | private String mchId; | ||||
/** | |||||
* <pre> | |||||
* 随机字符串 | |||||
* nonce_str | |||||
* 是 | |||||
* 5K8264ILTKCH16CQ2502SI8ZNMTM67VS | |||||
* String(32) | |||||
* 随机字符串,不长于32位 | |||||
* </pre> | |||||
*/ | |||||
@XStreamAlias("nonce_str") | |||||
private String nonceStr; | |||||
/** | |||||
* <pre> | |||||
* 签名 | |||||
* sign | |||||
* 是 | |||||
* C380BEC2BFD727A4B6845133519F3AD6 | |||||
* String(32) | |||||
*签名,详见签名算法 | |||||
* </pre> | |||||
*/ | |||||
@XStreamAlias("sign") | |||||
private String sign; | |||||
/** | /** | ||||
* <pre> | * <pre> | ||||
* 商户订单号 | * 商户订单号 | ||||
@@ -1,8 +1,6 @@ | |||||
package me.chanjar.weixin.mp.bean.pay; | package me.chanjar.weixin.mp.bean.pay; | ||||
import com.thoughtworks.xstream.annotations.XStreamAlias; | import com.thoughtworks.xstream.annotations.XStreamAlias; | ||||
import org.apache.commons.lang3.builder.ToStringBuilder; | |||||
import org.apache.commons.lang3.builder.ToStringStyle; | |||||
/** | /** | ||||
* 企业付款查询返回结果 | * 企业付款查询返回结果 | ||||
@@ -10,37 +8,7 @@ import org.apache.commons.lang3.builder.ToStringStyle; | |||||
* @author binarywang (https://github.com/binarywang) | * @author binarywang (https://github.com/binarywang) | ||||
*/ | */ | ||||
@XStreamAlias("xml") | @XStreamAlias("xml") | ||||
public class WxEntPayQueryResult { | |||||
/** | |||||
* 返回状态码 | |||||
*/ | |||||
@XStreamAlias("return_code") | |||||
private String returnCode; | |||||
/** | |||||
* 返回信息 | |||||
*/ | |||||
@XStreamAlias("return_msg") | |||||
private String returnMsg; | |||||
//############以下字段在return_code为SUCCESS的时候有返回 | |||||
/** | |||||
* 业务结果 | |||||
*/ | |||||
@XStreamAlias("result_code") | |||||
private String resultCode; | |||||
/** | |||||
* 错误代码 | |||||
*/ | |||||
@XStreamAlias("err_code") | |||||
private String errCode; | |||||
/** | |||||
* 错误代码描述 | |||||
*/ | |||||
@XStreamAlias("err_code_des") | |||||
private String errCodeDes; | |||||
public class WxEntPayQueryResult extends WxPayBaseResult { | |||||
//############以下字段在return_code 和result_code都为SUCCESS的时候有返回############## | //############以下字段在return_code 和result_code都为SUCCESS的时候有返回############## | ||||
/** | /** | ||||
@@ -49,12 +17,6 @@ public class WxEntPayQueryResult { | |||||
@XStreamAlias("partner_trade_no") | @XStreamAlias("partner_trade_no") | ||||
private String partnerTradeNo; | private String partnerTradeNo; | ||||
/** | |||||
* 商户号 | |||||
*/ | |||||
@XStreamAlias("mchid") | |||||
private String mchId; | |||||
/** | /** | ||||
* 付款单号 | * 付款单号 | ||||
*/ | */ | ||||
@@ -103,11 +65,6 @@ public class WxEntPayQueryResult { | |||||
@XStreamAlias("desc") | @XStreamAlias("desc") | ||||
private String desc; | private String desc; | ||||
@Override | |||||
public String toString() { | |||||
return ToStringBuilder.reflectionToString(this, ToStringStyle.MULTI_LINE_STYLE); | |||||
} | |||||
public String getReturnCode() { | public String getReturnCode() { | ||||
return returnCode; | return returnCode; | ||||
} | } | ||||
@@ -124,30 +81,6 @@ public class WxEntPayQueryResult { | |||||
this.returnMsg = returnMsg; | this.returnMsg = returnMsg; | ||||
} | } | ||||
public String getResultCode() { | |||||
return resultCode; | |||||
} | |||||
public void setResultCode(String resultCode) { | |||||
this.resultCode = resultCode; | |||||
} | |||||
public String getErrCode() { | |||||
return errCode; | |||||
} | |||||
public void setErrCode(String errCode) { | |||||
this.errCode = errCode; | |||||
} | |||||
public String getErrCodeDes() { | |||||
return errCodeDes; | |||||
} | |||||
public void setErrCodeDes(String errCodeDes) { | |||||
this.errCodeDes = errCodeDes; | |||||
} | |||||
public String getPartnerTradeNo() { | public String getPartnerTradeNo() { | ||||
return partnerTradeNo; | return partnerTradeNo; | ||||
} | } | ||||
@@ -156,14 +89,6 @@ public class WxEntPayQueryResult { | |||||
this.partnerTradeNo = partnerTradeNo; | this.partnerTradeNo = partnerTradeNo; | ||||
} | } | ||||
public String getMchId() { | |||||
return mchId; | |||||
} | |||||
public void setMchId(String mchId) { | |||||
this.mchId = mchId; | |||||
} | |||||
public String getDetailId() { | public String getDetailId() { | ||||
return detailId; | return detailId; | ||||
} | } | ||||
@@ -1,8 +1,5 @@ | |||||
package me.chanjar.weixin.mp.bean.pay; | package me.chanjar.weixin.mp.bean.pay; | ||||
import org.apache.commons.lang3.builder.ToStringBuilder; | |||||
import org.apache.commons.lang3.builder.ToStringStyle; | |||||
import com.thoughtworks.xstream.annotations.XStreamAlias; | import com.thoughtworks.xstream.annotations.XStreamAlias; | ||||
/** | /** | ||||
@@ -11,21 +8,7 @@ import com.thoughtworks.xstream.annotations.XStreamAlias; | |||||
* @author binarywang (https://github.com/binarywang) | * @author binarywang (https://github.com/binarywang) | ||||
*/ | */ | ||||
@XStreamAlias("xml") | @XStreamAlias("xml") | ||||
public class WxEntPayResult { | |||||
/** | |||||
* 返回状态码 | |||||
*/ | |||||
@XStreamAlias("return_code") | |||||
private String returnCode; | |||||
/** | |||||
* 返回信息 | |||||
*/ | |||||
@XStreamAlias("return_msg") | |||||
private String returnMsg; | |||||
//############以下字段在return_code为SUCCESS的时候有返回 | |||||
public class WxEntPayResult extends WxPayBaseResult { | |||||
/** | /** | ||||
* 商户appid | * 商户appid | ||||
@@ -33,41 +16,12 @@ public class WxEntPayResult { | |||||
@XStreamAlias("mch_appid") | @XStreamAlias("mch_appid") | ||||
private String mchAppid; | private String mchAppid; | ||||
/** | |||||
* 商户号 | |||||
*/ | |||||
@XStreamAlias("mchid") | |||||
private String mchId; | |||||
/** | /** | ||||
* 设备号 | * 设备号 | ||||
*/ | */ | ||||
@XStreamAlias("device_info") | @XStreamAlias("device_info") | ||||
private String deviceInfo; | private String deviceInfo; | ||||
/** | |||||
* 随机字符串 | |||||
*/ | |||||
@XStreamAlias("nonce_str") | |||||
private String nonceStr; | |||||
/** | |||||
* 业务结果 | |||||
*/ | |||||
@XStreamAlias("result_code") | |||||
private String resultCode; | |||||
/** | |||||
* 错误代码 | |||||
*/ | |||||
@XStreamAlias("err_code") | |||||
private String errCode; | |||||
/** | |||||
* 错误代码描述 | |||||
*/ | |||||
@XStreamAlias("err_code_des") | |||||
private String errCodeDes; | |||||
//############以下字段在return_code 和result_code都为SUCCESS的时候有返回############## | //############以下字段在return_code 和result_code都为SUCCESS的时候有返回############## | ||||
/** | /** | ||||
* 商户订单号 | * 商户订单号 | ||||
@@ -87,27 +41,6 @@ public class WxEntPayResult { | |||||
@XStreamAlias("payment_time") | @XStreamAlias("payment_time") | ||||
private String paymentTime; | private String paymentTime; | ||||
@Override | |||||
public String toString() { | |||||
return ToStringBuilder.reflectionToString(this, ToStringStyle.MULTI_LINE_STYLE); | |||||
} | |||||
public String getReturnCode() { | |||||
return returnCode; | |||||
} | |||||
public void setReturnCode(String returnCode) { | |||||
this.returnCode = returnCode; | |||||
} | |||||
public String getReturnMsg() { | |||||
return returnMsg; | |||||
} | |||||
public void setReturnMsg(String returnMsg) { | |||||
this.returnMsg = returnMsg; | |||||
} | |||||
public String getMchAppid() { | public String getMchAppid() { | ||||
return mchAppid; | return mchAppid; | ||||
} | } | ||||
@@ -116,14 +49,6 @@ public class WxEntPayResult { | |||||
this.mchAppid = mchAppid; | this.mchAppid = mchAppid; | ||||
} | } | ||||
public String getMchId() { | |||||
return mchId; | |||||
} | |||||
public void setMchId(String mchId) { | |||||
this.mchId = mchId; | |||||
} | |||||
public String getDeviceInfo() { | public String getDeviceInfo() { | ||||
return deviceInfo; | return deviceInfo; | ||||
} | } | ||||
@@ -132,38 +57,6 @@ public class WxEntPayResult { | |||||
this.deviceInfo = deviceInfo; | this.deviceInfo = deviceInfo; | ||||
} | } | ||||
public String getNonceStr() { | |||||
return nonceStr; | |||||
} | |||||
public void setNonceStr(String nonceStr) { | |||||
this.nonceStr = nonceStr; | |||||
} | |||||
public String getResultCode() { | |||||
return resultCode; | |||||
} | |||||
public void setResultCode(String resultCode) { | |||||
this.resultCode = resultCode; | |||||
} | |||||
public String getErrCode() { | |||||
return errCode; | |||||
} | |||||
public void setErrCode(String errCode) { | |||||
this.errCode = errCode; | |||||
} | |||||
public String getErrCodeDes() { | |||||
return errCodeDes; | |||||
} | |||||
public void setErrCodeDes(String errCodeDes) { | |||||
this.errCodeDes = errCodeDes; | |||||
} | |||||
public String getPartnerTradeNo() { | public String getPartnerTradeNo() { | ||||
return partnerTradeNo; | return partnerTradeNo; | ||||
} | } | ||||
@@ -1,259 +0,0 @@ | |||||
package me.chanjar.weixin.mp.bean.pay; | |||||
import java.io.Serializable; | |||||
import org.apache.commons.lang3.builder.ToStringBuilder; | |||||
import org.apache.commons.lang3.builder.ToStringStyle; | |||||
/** | |||||
* <pre> | |||||
* 查询订单支付状态返回的结果 | |||||
* | |||||
* 查询订单(详见http://pay.weixin.qq.com/wiki/doc/api/jsapi.php?chapter=9_2) | |||||
* | |||||
* </pre> | |||||
* | |||||
* @author ukid | |||||
*/ | |||||
public class WxMpPayResult implements Serializable { | |||||
@Override | |||||
public String toString() { | |||||
return ToStringBuilder.reflectionToString(this, ToStringStyle.MULTI_LINE_STYLE); | |||||
} | |||||
private static final long serialVersionUID = -570934170727777190L; | |||||
private String return_code; | |||||
private String return_msg; | |||||
private String appid; | |||||
private String mch_id; | |||||
private String nonce_str; | |||||
private String sign; | |||||
private String result_code; | |||||
private String err_code; | |||||
private String err_code_des; | |||||
private String trade_state; | |||||
private String trade_state_desc; | |||||
private String device_info; | |||||
private String openid; | |||||
private String is_subscribe; | |||||
private String trade_type; | |||||
private String bank_type; | |||||
private String total_fee; | |||||
private String coupon_fee; | |||||
private String fee_type; | |||||
private String transaction_id; | |||||
private String out_trade_no; | |||||
private String attach; | |||||
private String time_end; | |||||
/** | |||||
* 现金支付金额 cash_fee 是 Int 100 现金支付金额订单现金支付金额,详见支付金额 | |||||
*/ | |||||
private String cash_fee; | |||||
/** | |||||
* 现金支付货币类型 cash_fee_type 否 | |||||
* | |||||
*/ | |||||
private String cash_fee_type; | |||||
public String getReturn_code() { | |||||
return this.return_code; | |||||
} | |||||
public String getReturn_msg() { | |||||
return this.return_msg; | |||||
} | |||||
public String getAppid() { | |||||
return this.appid; | |||||
} | |||||
public String getMch_id() { | |||||
return this.mch_id; | |||||
} | |||||
public String getNonce_str() { | |||||
return this.nonce_str; | |||||
} | |||||
public String getSign() { | |||||
return this.sign; | |||||
} | |||||
public String getResult_code() { | |||||
return this.result_code; | |||||
} | |||||
public String getErr_code() { | |||||
return this.err_code; | |||||
} | |||||
public String getErr_code_des() { | |||||
return this.err_code_des; | |||||
} | |||||
public String getTrade_state() { | |||||
return this.trade_state; | |||||
} | |||||
public String getDevice_info() { | |||||
return this.device_info; | |||||
} | |||||
public String getOpenid() { | |||||
return this.openid; | |||||
} | |||||
public String getIs_subscribe() { | |||||
return this.is_subscribe; | |||||
} | |||||
public String getTrade_type() { | |||||
return this.trade_type; | |||||
} | |||||
public String getBank_type() { | |||||
return this.bank_type; | |||||
} | |||||
public String getTotal_fee() { | |||||
return this.total_fee; | |||||
} | |||||
public String getCoupon_fee() { | |||||
return this.coupon_fee; | |||||
} | |||||
public String getFee_type() { | |||||
return this.fee_type; | |||||
} | |||||
public String getTransaction_id() { | |||||
return this.transaction_id; | |||||
} | |||||
public String getOut_trade_no() { | |||||
return this.out_trade_no; | |||||
} | |||||
public String getAttach() { | |||||
return this.attach; | |||||
} | |||||
public String getTime_end() { | |||||
return this.time_end; | |||||
} | |||||
public void setReturn_code(String return_code) { | |||||
this.return_code = return_code; | |||||
} | |||||
public void setReturn_msg(String return_msg) { | |||||
this.return_msg = return_msg; | |||||
} | |||||
public void setAppid(String appid) { | |||||
this.appid = appid; | |||||
} | |||||
public void setMch_id(String mch_id) { | |||||
this.mch_id = mch_id; | |||||
} | |||||
public void setNonce_str(String nonce_str) { | |||||
this.nonce_str = nonce_str; | |||||
} | |||||
public void setSign(String sign) { | |||||
this.sign = sign; | |||||
} | |||||
public void setResult_code(String result_code) { | |||||
this.result_code = result_code; | |||||
} | |||||
public void setErr_code(String err_code) { | |||||
this.err_code = err_code; | |||||
} | |||||
public void setErr_code_des(String err_code_des) { | |||||
this.err_code_des = err_code_des; | |||||
} | |||||
public void setTrade_state(String trade_state) { | |||||
this.trade_state = trade_state; | |||||
} | |||||
public void setDevice_info(String device_info) { | |||||
this.device_info = device_info; | |||||
} | |||||
public void setOpenid(String openid) { | |||||
this.openid = openid; | |||||
} | |||||
public void setIs_subscribe(String is_subscribe) { | |||||
this.is_subscribe = is_subscribe; | |||||
} | |||||
public void setTrade_type(String trade_type) { | |||||
this.trade_type = trade_type; | |||||
} | |||||
public void setBank_type(String bank_type) { | |||||
this.bank_type = bank_type; | |||||
} | |||||
public void setTotal_fee(String total_fee) { | |||||
this.total_fee = total_fee; | |||||
} | |||||
public void setCoupon_fee(String coupon_fee) { | |||||
this.coupon_fee = coupon_fee; | |||||
} | |||||
public void setFee_type(String fee_type) { | |||||
this.fee_type = fee_type; | |||||
} | |||||
public void setTransaction_id(String transaction_id) { | |||||
this.transaction_id = transaction_id; | |||||
} | |||||
public void setOut_trade_no(String out_trade_no) { | |||||
this.out_trade_no = out_trade_no; | |||||
} | |||||
public void setAttach(String attach) { | |||||
this.attach = attach; | |||||
} | |||||
public void setTime_end(String time_end) { | |||||
this.time_end = time_end; | |||||
} | |||||
public String getTrade_state_desc() { | |||||
return this.trade_state_desc; | |||||
} | |||||
public void setTrade_state_desc(String trade_state_desc) { | |||||
this.trade_state_desc = trade_state_desc; | |||||
} | |||||
public String getCash_fee() { | |||||
return this.cash_fee; | |||||
} | |||||
public void setCash_fee(String cash_fee) { | |||||
this.cash_fee = cash_fee; | |||||
} | |||||
public String getCash_fee_type() { | |||||
return this.cash_fee_type; | |||||
} | |||||
public void setCash_fee_type(String cash_fee_type) { | |||||
this.cash_fee_type = cash_fee_type; | |||||
} | |||||
} |
@@ -0,0 +1,107 @@ | |||||
package me.chanjar.weixin.mp.bean.pay; | |||||
import com.thoughtworks.xstream.annotations.XStreamAlias; | |||||
import org.apache.commons.lang3.builder.ToStringBuilder; | |||||
import org.apache.commons.lang3.builder.ToStringStyle; | |||||
/** | |||||
* <pre> | |||||
* Created by Binary Wang on 2016-10-24. | |||||
* 微信支付请求对象共用的参数存放类 | |||||
* 注释中各行每个字段描述对应如下: | |||||
* <li>字段名 | |||||
* <li>变量名 | |||||
* <li>是否必填 | |||||
* <li>类型 | |||||
* <li>示例值 | |||||
* <li>描述 | |||||
* </pre> | |||||
* @author <a href="https://github.com/binarywang">binarywang(Binary Wang)</a> | |||||
*/ | |||||
public abstract class WxPayBaseRequest { | |||||
/** | |||||
* <pre> | |||||
* 公众账号ID | |||||
* appid | |||||
* 是 | |||||
* String(32) | |||||
* wxd678efh567hg6787 | |||||
* 微信分配的公众账号ID(企业号corpid即为此appId) | |||||
* </pre> | |||||
*/ | |||||
@XStreamAlias("appid") | |||||
protected String appid; | |||||
/** | |||||
* <pre> | |||||
* 商户号 | |||||
* mch_id | |||||
* 是 | |||||
* String(32) | |||||
* 1230000109 | |||||
* 微信支付分配的商户号 | |||||
* </pre> | |||||
*/ | |||||
@XStreamAlias("mch_id") | |||||
protected String mchId; | |||||
/** | |||||
* <pre> | |||||
* 随机字符串 | |||||
* nonce_str | |||||
* 是 | |||||
* String(32) | |||||
* 5K8264ILTKCH16CQ2502SI8ZNMTM67VS | |||||
* 随机字符串,不长于32位。推荐随机数生成算法 | |||||
* </pre> | |||||
*/ | |||||
@XStreamAlias("nonce_str") | |||||
protected String nonceStr; | |||||
/** | |||||
* <pre> | |||||
* 签名 | |||||
* sign | |||||
* 是 | |||||
* String(32) | |||||
* C380BEC2BFD727A4B6845133519F3AD6 | |||||
* 签名,详见签名生成算法 | |||||
* </pre> | |||||
*/ | |||||
@XStreamAlias("sign") | |||||
protected String sign; | |||||
public String getAppid() { | |||||
return appid; | |||||
} | |||||
public void setAppid(String appid) { | |||||
this.appid = appid; | |||||
} | |||||
public String getMchId() { | |||||
return mchId; | |||||
} | |||||
public void setMchId(String mchId) { | |||||
this.mchId = mchId; | |||||
} | |||||
public String getNonceStr() { | |||||
return nonceStr; | |||||
} | |||||
public void setNonceStr(String nonceStr) { | |||||
this.nonceStr = nonceStr; | |||||
} | |||||
public String getSign() { | |||||
return sign; | |||||
} | |||||
public void setSign(String sign) { | |||||
this.sign = sign; | |||||
} | |||||
@Override | |||||
public String toString() { | |||||
return ToStringBuilder.reflectionToString(this, ToStringStyle.MULTI_LINE_STYLE); | |||||
} | |||||
} |
@@ -1,59 +1,78 @@ | |||||
package me.chanjar.weixin.mp.bean.pay; | package me.chanjar.weixin.mp.bean.pay; | ||||
import com.thoughtworks.xstream.annotations.XStreamAlias; | |||||
import org.apache.commons.lang3.builder.ToStringBuilder; | import org.apache.commons.lang3.builder.ToStringBuilder; | ||||
import org.apache.commons.lang3.builder.ToStringStyle; | import org.apache.commons.lang3.builder.ToStringStyle; | ||||
import com.thoughtworks.xstream.annotations.XStreamAlias; | |||||
/** | /** | ||||
* <pre> | * <pre> | ||||
* 在发起微信支付前,需要调用统一下单接口,获取"预支付交易会话标识"返回的结果 | |||||
* 统一下单(详见http://pay.weixin.qq.com/wiki/doc/api/jsapi.php?chapter=9_1) | |||||
* 微信支付结果共用属性类 | |||||
* Created by Binary Wang on 2016-10-24. | |||||
* @author <a href="https://github.com/binarywang">binarywang(Binary Wang)</a> | |||||
* </pre> | * </pre> | ||||
* | |||||
* @author chanjarster | |||||
*/ | */ | ||||
@XStreamAlias("xml") | |||||
public class WxUnifiedOrderResult { | |||||
public abstract class WxPayBaseResult { | |||||
@Override | |||||
public String toString() { | |||||
return ToStringBuilder.reflectionToString(this, ToStringStyle.MULTI_LINE_STYLE); | |||||
} | |||||
/** | |||||
* 返回状态码 | |||||
*/ | |||||
@XStreamAlias("return_code") | @XStreamAlias("return_code") | ||||
private String returnCode; | |||||
protected String returnCode; | |||||
/** | |||||
* 返回信息 | |||||
*/ | |||||
@XStreamAlias("return_msg") | @XStreamAlias("return_msg") | ||||
private String returnMsg; | |||||
protected String returnMsg; | |||||
/** | |||||
* 业务结果 | |||||
*/ | |||||
@XStreamAlias("result_code") | |||||
private String resultCode; | |||||
/** | |||||
* 错误代码 | |||||
*/ | |||||
@XStreamAlias("err_code") | |||||
private String errCode; | |||||
/** | |||||
* 错误代码描述 | |||||
*/ | |||||
@XStreamAlias("err_code_des") | |||||
private String errCodeDes; | |||||
/** | |||||
* 公众账号ID | |||||
*/ | |||||
@XStreamAlias("appid") | @XStreamAlias("appid") | ||||
private String appid; | private String appid; | ||||
/** | |||||
* 商户号 | |||||
*/ | |||||
@XStreamAlias("mch_id") | @XStreamAlias("mch_id") | ||||
private String mchId; | private String mchId; | ||||
/** | |||||
* 随机字符串 | |||||
*/ | |||||
@XStreamAlias("nonce_str") | @XStreamAlias("nonce_str") | ||||
private String nonceStr; | private String nonceStr; | ||||
/** | |||||
* 签名 | |||||
*/ | |||||
@XStreamAlias("sign") | @XStreamAlias("sign") | ||||
private String sign; | private String sign; | ||||
@XStreamAlias("result_code") | |||||
private String resultCode; | |||||
@XStreamAlias("prepay_id") | |||||
private String prepayId; | |||||
@XStreamAlias("trade_type") | |||||
private String tradeType; | |||||
@XStreamAlias("err_code") | |||||
private String errCode; | |||||
@XStreamAlias("err_code_des") | |||||
private String errCodeDes; | |||||
@XStreamAlias("code_url") | |||||
private String codeURL; | |||||
public String getReturnCode() { | public String getReturnCode() { | ||||
return this.returnCode; | |||||
return returnCode; | |||||
} | } | ||||
public void setReturnCode(String returnCode) { | public void setReturnCode(String returnCode) { | ||||
@@ -61,95 +80,66 @@ public class WxUnifiedOrderResult { | |||||
} | } | ||||
public String getReturnMsg() { | public String getReturnMsg() { | ||||
return this.returnMsg; | |||||
return returnMsg; | |||||
} | } | ||||
public void setReturnMsg(String returnMsg) { | public void setReturnMsg(String returnMsg) { | ||||
this.returnMsg = returnMsg; | this.returnMsg = returnMsg; | ||||
} | } | ||||
public String getAppid() { | |||||
return this.appid; | |||||
} | |||||
public void setAppid(String appid) { | |||||
this.appid = appid; | |||||
} | |||||
public String getMchId() { | |||||
return this.mchId; | |||||
} | |||||
public void setMchId(String mchId) { | |||||
this.mchId = mchId; | |||||
} | |||||
public String getNonceStr() { | |||||
return this.nonceStr; | |||||
} | |||||
public void setNonceStr(String nonceStr) { | |||||
this.nonceStr = nonceStr; | |||||
} | |||||
public String getSign() { | |||||
return this.sign; | |||||
} | |||||
public void setSign(String sign) { | |||||
this.sign = sign; | |||||
} | |||||
public String getResultCode() { | public String getResultCode() { | ||||
return this.resultCode; | |||||
return resultCode; | |||||
} | } | ||||
public void setResultCode(String resultCode) { | public void setResultCode(String resultCode) { | ||||
this.resultCode = resultCode; | this.resultCode = resultCode; | ||||
} | } | ||||
public String getPrepayId() { | |||||
return this.prepayId; | |||||
public String getErrCode() { | |||||
return errCode; | |||||
} | } | ||||
public void setPrepayId(String prepayId) { | |||||
this.prepayId = prepayId; | |||||
public void setErrCode(String errCode) { | |||||
this.errCode = errCode; | |||||
} | } | ||||
public String getTradeType() { | |||||
return this.tradeType; | |||||
public String getErrCodeDes() { | |||||
return errCodeDes; | |||||
} | } | ||||
public void setTradeType(String tradeType) { | |||||
this.tradeType = tradeType; | |||||
public void setErrCodeDes(String errCodeDes) { | |||||
this.errCodeDes = errCodeDes; | |||||
} | } | ||||
public String getErrCode() { | |||||
return this.errCode; | |||||
public String getAppid() { | |||||
return appid; | |||||
} | } | ||||
public void setErrCode(String errCode) { | |||||
this.errCode = errCode; | |||||
public void setAppid(String appid) { | |||||
this.appid = appid; | |||||
} | } | ||||
public String getErrCodeDes() { | |||||
return this.errCodeDes; | |||||
public String getMchId() { | |||||
return mchId; | |||||
} | } | ||||
public void setErrCodeDes(String errCodeDes) { | |||||
this.errCodeDes = errCodeDes; | |||||
public void setMchId(String mchId) { | |||||
this.mchId = mchId; | |||||
} | } | ||||
public String getCodeURL() { | |||||
return this.codeURL; | |||||
public String getNonceStr() { | |||||
return nonceStr; | |||||
} | } | ||||
public void setCodeURL(String codeURL) { | |||||
this.codeURL = codeURL; | |||||
public void setNonceStr(String nonceStr) { | |||||
this.nonceStr = nonceStr; | |||||
} | } | ||||
@Override | |||||
public String toString() { | |||||
return ToStringBuilder.reflectionToString(this, ToStringStyle.MULTI_LINE_STYLE); | |||||
public String getSign() { | |||||
return sign; | |||||
} | |||||
public void setSign(String sign) { | |||||
this.sign = sign; | |||||
} | } | ||||
} | } |
@@ -4,16 +4,16 @@ import java.io.Serializable; | |||||
/** | /** | ||||
* pre> 订单支付状态回调 | * pre> 订单支付状态回调 | ||||
* | |||||
* | |||||
* 支付结果通知(详见http://pay.weixin.qq.com/wiki/doc/api/jsapi.php?chapter=9_7) | * 支付结果通知(详见http://pay.weixin.qq.com/wiki/doc/api/jsapi.php?chapter=9_7) | ||||
* | * | ||||
* /pre> | * /pre> | ||||
* | * | ||||
* @author ukid | * @author ukid | ||||
*/ | */ | ||||
public class WxMpPayCallback implements Serializable { | |||||
public class WxPayJsSDKCallback implements Serializable { | |||||
/** | /** | ||||
* | |||||
* | |||||
*/ | */ | ||||
private static final long serialVersionUID = -4143804055690843641L; | private static final long serialVersionUID = -4143804055690843641L; | ||||
private String return_code; | private String return_code; | ||||
@@ -263,7 +263,7 @@ public class WxMpPayCallback implements Serializable { | |||||
@Override | @Override | ||||
public String toString() { | public String toString() { | ||||
return "WxMpPayCallback [return_code=" + this.return_code + ", return_msg=" | |||||
return "WxPayJsSDKCallback [return_code=" + this.return_code + ", return_msg=" | |||||
+ this.return_msg + ", appid=" + this.appid + ", mch_id=" + this.mch_id | + this.return_msg + ", appid=" + this.appid + ", mch_id=" + this.mch_id | ||||
+ ", device_info=" + this.device_info + ", nonce_str=" + this.nonce_str | + ", device_info=" + this.device_info + ", nonce_str=" + this.nonce_str | ||||
+ ", sign=" + this.sign + ", result_code=" + this.result_code | + ", sign=" + this.sign + ", result_code=" + this.result_code |
@@ -0,0 +1,63 @@ | |||||
package me.chanjar.weixin.mp.bean.pay; | |||||
import com.thoughtworks.xstream.annotations.XStreamAlias; | |||||
/** | |||||
* <pre> | |||||
* 订单查询请求对象 | |||||
* Created by Binary Wang on 2016-10-24. | |||||
* 注释中各行每个字段描述对应如下: | |||||
* <li>字段名 | |||||
* <li>变量名 | |||||
* <li>是否必填 | |||||
* <li>类型 | |||||
* <li>示例值 | |||||
* <li>描述 | |||||
* </pre> | |||||
* @author <a href="https://github.com/binarywang">binarywang(Binary Wang)</a> | |||||
*/ | |||||
@XStreamAlias("xml") | |||||
public class WxPayOrderQueryRequest extends WxPayBaseRequest { | |||||
/** | |||||
* <pre> | |||||
* 微信订单号 | |||||
* transaction_id | |||||
* 二选一 | |||||
* String(32) | |||||
* 1009660380201506130728806387 | |||||
* 微信的订单号,优先使用 | |||||
* </pre> | |||||
*/ | |||||
@XStreamAlias("transaction_id") | |||||
private String transactionId; | |||||
/** | |||||
* <pre> | |||||
* 商户订单号 | |||||
* out_trade_no | |||||
* 二选一 | |||||
* String(32) | |||||
* 20150806125346 | |||||
* 商户系统内部的订单号,当没提供transaction_id时需要传这个。 | |||||
* </pre> | |||||
*/ | |||||
@XStreamAlias("out_trade_no") | |||||
private String outTradeNo; | |||||
public String getTransactionId() { | |||||
return transactionId; | |||||
} | |||||
public void setTransactionId(String transactionId) { | |||||
this.transactionId = transactionId; | |||||
} | |||||
public String getOutTradeNo() { | |||||
return outTradeNo; | |||||
} | |||||
public void setOutTradeNo(String outTradeNo) { | |||||
this.outTradeNo = outTradeNo; | |||||
} | |||||
} |
@@ -0,0 +1,444 @@ | |||||
package me.chanjar.weixin.mp.bean.pay; | |||||
import com.google.common.collect.Lists; | |||||
import com.thoughtworks.xstream.annotations.XStreamAlias; | |||||
import java.util.List; | |||||
/** | |||||
* <pre> | |||||
* 查询订单 返回结果对象 | |||||
* Created by Binary Wang on 2016-10-24. | |||||
* 注释中各行每个字段描述对应如下: | |||||
* <li>字段名 | |||||
* <li>变量名 | |||||
* <li>是否必填 | |||||
* <li>类型 | |||||
* <li>示例值 | |||||
* <li>描述 | |||||
* </pre> | |||||
* @author <a href="https://github.com/binarywang">binarywang(Binary Wang)</a> | |||||
*/ | |||||
@XStreamAlias("xml") | |||||
public class WxPayOrderQueryResult extends WxPayBaseResult { | |||||
/** | |||||
* <pre>设备号 | |||||
* device_info | |||||
* 否 | |||||
* String(32) | |||||
* 013467007045764 | |||||
* 微信支付分配的终端设备号, | |||||
* </pre> | |||||
*/ | |||||
@XStreamAlias("device_info") | |||||
private String deviceInfo; | |||||
/** | |||||
* <pre>用户标识 | |||||
* openid | |||||
* 是 | |||||
* String(128) | |||||
* oUpF8uMuAJO_M2pxb1Q9zNjWeS6o | |||||
* 用户在商户appid下的唯一标识 | |||||
* </pre> | |||||
*/ | |||||
@XStreamAlias("openid") | |||||
private String openid; | |||||
/** | |||||
* <pre>是否关注公众账号 | |||||
* is_subscribe | |||||
* 否 | |||||
* String(1) | |||||
* Y | |||||
* 用户是否关注公众账号,Y-关注,N-未关注,仅在公众账号类型支付有效 | |||||
* </pre> | |||||
*/ | |||||
@XStreamAlias("is_subscribe") | |||||
private String isSubscribe; | |||||
/** | |||||
* <pre>交易类型 | |||||
* trade_type | |||||
* 是 | |||||
* String(16) | |||||
* JSAPI | |||||
* 调用接口提交的交易类型,取值如下:JSAPI,NATIVE,APP,MICROPAY,详细说明见参数规定 | |||||
* </pre> | |||||
*/ | |||||
@XStreamAlias("trade_type") | |||||
private String tradeType; | |||||
/** | |||||
* <pre>交易状态 | |||||
* trade_state | |||||
* 是 | |||||
* String(32) | |||||
* SUCCESS | |||||
* SUCCESS—支付成功,REFUND—转入退款,NOTPAY—未支付,CLOSED—已关闭,REVOKED—已撤销(刷卡支付),USERPAYING--用户支付中,PAYERROR--支付失败(其他原因,如银行返回失败) | |||||
* </pre> | |||||
*/ | |||||
@XStreamAlias("trade_state") | |||||
private String tradeState; | |||||
/** | |||||
* <pre>付款银行 | |||||
* bank_type | |||||
* 是 | |||||
* String(16) | |||||
* CMC | |||||
* 银行类型,采用字符串类型的银行标识 | |||||
* </pre> | |||||
*/ | |||||
@XStreamAlias("bank_type") | |||||
private String bankType; | |||||
/** | |||||
* <pre>订单金额 | |||||
* total_fee | |||||
* 是 | |||||
* Int | |||||
* 100 | |||||
* 订单总金额,单位为分 | |||||
* </pre> | |||||
*/ | |||||
@XStreamAlias("total_fee") | |||||
private Integer totalFee; | |||||
/** | |||||
* <pre>应结订单金额 | |||||
* settlement_total_fee | |||||
* 否 | |||||
* Int | |||||
* 100 | |||||
* 应结订单金额=订单金额-非充值代金券金额,应结订单金额<=订单金额。 | |||||
* </pre> | |||||
*/ | |||||
@XStreamAlias("settlement_total_fee") | |||||
private Integer settlementTotalFee; | |||||
/** | |||||
* <pre>货币种类 | |||||
* fee_type | |||||
* 否 | |||||
* String(8) | |||||
* CNY | |||||
* 货币类型,符合ISO 4217标准的三位字母代码,默认人民币:CNY,其他值列表详见货币类型 | |||||
* </pre> | |||||
*/ | |||||
@XStreamAlias("fee_type") | |||||
private String feeType; | |||||
/** | |||||
* <pre>现金支付金额 | |||||
* cash_fee | |||||
* 是 | |||||
* Int | |||||
* 100 | |||||
* 现金支付金额订单现金支付金额,详见支付金额 | |||||
* </pre> | |||||
*/ | |||||
@XStreamAlias("cash_fee") | |||||
private Integer cashFee; | |||||
/** | |||||
* <pre>现金支付货币类型 | |||||
* cash_fee_type | |||||
* 否 | |||||
* String(16) | |||||
* CNY | |||||
* 货币类型,符合ISO 4217标准的三位字母代码,默认人民币:CNY,其他值列表详见货币类型 | |||||
* </pre> | |||||
*/ | |||||
@XStreamAlias("cash_fee_type") | |||||
private String cashFeeType; | |||||
/** | |||||
* <pre>代金券金额 | |||||
* coupon_fee | |||||
* 否 | |||||
* Int | |||||
* 100 | |||||
* “代金券”金额<=订单金额,订单金额-“代金券”金额=现金支付金额,详见支付金额 | |||||
* </pre> | |||||
*/ | |||||
@XStreamAlias("coupon_fee") | |||||
private Integer couponFee; | |||||
/** | |||||
* <pre>代金券使用数量 | |||||
* coupon_count | |||||
* 否 | |||||
* Int | |||||
* 1 | |||||
* 代金券使用数量 | |||||
* </pre> | |||||
*/ | |||||
@XStreamAlias("coupon_count") | |||||
private Integer couponCount; | |||||
private List<Coupon> coupons; | |||||
public static class Coupon { | |||||
/** | |||||
* <pre>代金券类型 | |||||
* coupon_type_$n | |||||
* 否 | |||||
* String | |||||
* CASH | |||||
* <li>CASH--充值代金券 | |||||
* <li>NO_CASH---非充值代金券 | |||||
* 订单使用代金券时有返回(取值:CASH、NO_CASH)。$n为下标,从0开始编号,举例:coupon_type_$0 | |||||
* </pre> | |||||
*/ | |||||
private String couponType; | |||||
/** | |||||
* <pre>代金券ID | |||||
* coupon_id_$n | |||||
* 否 | |||||
* String(20) | |||||
* 10000 | |||||
* 代金券ID, $n为下标,从0开始编号 | |||||
* </pre> | |||||
*/ | |||||
private String couponId; | |||||
/** | |||||
* <pre>单个代金券支付金额 | |||||
* coupon_fee_$n | |||||
* 否 | |||||
* Int | |||||
* 100 | |||||
* 单个代金券支付金额, $n为下标,从0开始编号 | |||||
* </pre> | |||||
*/ | |||||
private Integer couponFee; | |||||
public Coupon(String couponType, String couponId, Integer couponFee) { | |||||
this.couponType = couponType; | |||||
this.couponId = couponId; | |||||
this.couponFee = couponFee; | |||||
} | |||||
} | |||||
/** | |||||
* <pre>微信支付订单号 | |||||
* transaction_id | |||||
* 是 | |||||
* String(32) | |||||
* 1009660380201506130728806387 | |||||
* 微信支付订单号 | |||||
* </pre> | |||||
*/ | |||||
@XStreamAlias("transaction_id") | |||||
private String transactionId; | |||||
/** | |||||
* <pre>商户订单号 | |||||
* out_trade_no | |||||
* 是 | |||||
* String(32) | |||||
* 20150806125346 | |||||
* 商户系统的订单号,与请求一致。 | |||||
* </pre> | |||||
*/ | |||||
@XStreamAlias("out_trade_no") | |||||
private String outTradeNo; | |||||
/** | |||||
* <pre>附加数据 | |||||
* attach | |||||
* 否 | |||||
* String(128) | |||||
* 深圳分店 | |||||
* 附加数据,原样返回 | |||||
* </pre> | |||||
*/ | |||||
@XStreamAlias("attach") | |||||
private String attach; | |||||
/** | |||||
* <pre>支付完成时间 | |||||
* time_end | |||||
* 是 | |||||
* String(14) | |||||
* 20141030133525 | |||||
* 订单支付时间,格式为yyyyMMddHHmmss,如2009年12月25日9点10分10秒表示为20091225091010。其他详见时间规则 | |||||
* </pre> | |||||
*/ | |||||
@XStreamAlias("time_end") | |||||
private String timeEnd; | |||||
/** | |||||
* <pre>交易状态描述 | |||||
* trade_state_desc | |||||
* 是 | |||||
* String(256) | |||||
* 支付失败,请重新下单支付 | |||||
* 对当前查询订单状态的描述和下一步操作的指引 | |||||
* </pre> | |||||
*/ | |||||
@XStreamAlias("trade_state_desc") | |||||
private String tradeStateDesc; | |||||
public String getDeviceInfo() { | |||||
return deviceInfo; | |||||
} | |||||
public void setDeviceInfo(String deviceInfo) { | |||||
this.deviceInfo = deviceInfo; | |||||
} | |||||
public String getOpenid() { | |||||
return openid; | |||||
} | |||||
public void setOpenid(String openid) { | |||||
this.openid = openid; | |||||
} | |||||
public String getIsSubscribe() { | |||||
return isSubscribe; | |||||
} | |||||
public void setIsSubscribe(String isSubscribe) { | |||||
this.isSubscribe = isSubscribe; | |||||
} | |||||
public String getTradeType() { | |||||
return tradeType; | |||||
} | |||||
public void setTradeType(String tradeType) { | |||||
this.tradeType = tradeType; | |||||
} | |||||
public String getTradeState() { | |||||
return tradeState; | |||||
} | |||||
public void setTradeState(String tradeState) { | |||||
this.tradeState = tradeState; | |||||
} | |||||
public String getBankType() { | |||||
return bankType; | |||||
} | |||||
public void setBankType(String bankType) { | |||||
this.bankType = bankType; | |||||
} | |||||
public Integer getTotalFee() { | |||||
return totalFee; | |||||
} | |||||
public void setTotalFee(Integer totalFee) { | |||||
this.totalFee = totalFee; | |||||
} | |||||
public Integer getSettlementTotalFee() { | |||||
return settlementTotalFee; | |||||
} | |||||
public void setSettlementTotalFee(Integer settlementTotalFee) { | |||||
this.settlementTotalFee = settlementTotalFee; | |||||
} | |||||
public String getFeeType() { | |||||
return feeType; | |||||
} | |||||
public void setFeeType(String feeType) { | |||||
this.feeType = feeType; | |||||
} | |||||
public Integer getCashFee() { | |||||
return cashFee; | |||||
} | |||||
public void setCashFee(Integer cashFee) { | |||||
this.cashFee = cashFee; | |||||
} | |||||
public String getCashFeeType() { | |||||
return cashFeeType; | |||||
} | |||||
public void setCashFeeType(String cashFeeType) { | |||||
this.cashFeeType = cashFeeType; | |||||
} | |||||
public Integer getCouponFee() { | |||||
return couponFee; | |||||
} | |||||
public void setCouponFee(Integer couponFee) { | |||||
this.couponFee = couponFee; | |||||
} | |||||
public Integer getCouponCount() { | |||||
return couponCount; | |||||
} | |||||
public void setCouponCount(Integer couponCount) { | |||||
this.couponCount = couponCount; | |||||
} | |||||
public List<Coupon> getCoupons() { | |||||
return coupons; | |||||
} | |||||
public void setCoupons(List<Coupon> coupons) { | |||||
this.coupons = coupons; | |||||
} | |||||
public String getTransactionId() { | |||||
return transactionId; | |||||
} | |||||
public void setTransactionId(String transactionId) { | |||||
this.transactionId = transactionId; | |||||
} | |||||
public String getOutTradeNo() { | |||||
return outTradeNo; | |||||
} | |||||
public void setOutTradeNo(String outTradeNo) { | |||||
this.outTradeNo = outTradeNo; | |||||
} | |||||
public String getAttach() { | |||||
return attach; | |||||
} | |||||
public void setAttach(String attach) { | |||||
this.attach = attach; | |||||
} | |||||
public String getTimeEnd() { | |||||
return timeEnd; | |||||
} | |||||
public void setTimeEnd(String timeEnd) { | |||||
this.timeEnd = timeEnd; | |||||
} | |||||
public String getTradeStateDesc() { | |||||
return tradeStateDesc; | |||||
} | |||||
public void setTradeStateDesc(String tradeStateDesc) { | |||||
this.tradeStateDesc = tradeStateDesc; | |||||
} | |||||
public void composeCoupons(String xmlString){ | |||||
if(this.couponCount > 0 ){ | |||||
this.coupons = Lists.newArrayList(); | |||||
//TODO 暂时待实现 | |||||
} | |||||
} | |||||
} |
@@ -19,7 +19,7 @@ import me.chanjar.weixin.common.annotation.Required; | |||||
* Created by Binary Wang on 2016-10-08. | * Created by Binary Wang on 2016-10-08. | ||||
*/ | */ | ||||
@XStreamAlias("xml") | @XStreamAlias("xml") | ||||
public class WxMpPayRefundRequest { | |||||
public class WxPayRefundRequest { | |||||
/** | /** | ||||
* <pre> | * <pre> | ||||
* 公众账号ID | * 公众账号ID |
@@ -1,8 +1,6 @@ | |||||
package me.chanjar.weixin.mp.bean.pay; | package me.chanjar.weixin.mp.bean.pay; | ||||
import com.thoughtworks.xstream.annotations.XStreamAlias; | import com.thoughtworks.xstream.annotations.XStreamAlias; | ||||
import org.apache.commons.lang3.builder.ToStringBuilder; | |||||
import org.apache.commons.lang3.builder.ToStringStyle; | |||||
import java.io.Serializable; | import java.io.Serializable; | ||||
@@ -15,39 +13,12 @@ import java.io.Serializable; | |||||
* | * | ||||
*/ | */ | ||||
@XStreamAlias("xml") | @XStreamAlias("xml") | ||||
public class WxMpPayRefundResult implements Serializable { | |||||
public class WxPayRefundResult extends WxPayBaseResult implements Serializable{ | |||||
private static final long serialVersionUID = 1L; | private static final long serialVersionUID = 1L; | ||||
@XStreamAlias("return_code") | |||||
private String returnCode; | |||||
@XStreamAlias("return_msg") | |||||
private String returnMsg; | |||||
@XStreamAlias("result_code") | |||||
private String resultCode; | |||||
@XStreamAlias("err_code") | |||||
private String errCode; | |||||
@XStreamAlias("err_code_des") | |||||
private String errCodeDes; | |||||
@XStreamAlias("appid") | |||||
private String appid; | |||||
@XStreamAlias("mch_id") | |||||
private String mchId; | |||||
@XStreamAlias("device_info") | @XStreamAlias("device_info") | ||||
private String deviceInfo; | private String deviceInfo; | ||||
@XStreamAlias("nonce_str") | |||||
private String nonceStr; | |||||
@XStreamAlias("sign") | |||||
private String sign; | |||||
@XStreamAlias("transaction_id") | @XStreamAlias("transaction_id") | ||||
private String transactionId; | private String transactionId; | ||||
@@ -103,46 +74,6 @@ public class WxMpPayRefundResult implements Serializable { | |||||
this.returnMsg = returnMsg; | this.returnMsg = returnMsg; | ||||
} | } | ||||
public String getResultCode() { | |||||
return this.resultCode; | |||||
} | |||||
public void setResultCode(String resultCode) { | |||||
this.resultCode = resultCode; | |||||
} | |||||
public String getErrCode() { | |||||
return this.errCode; | |||||
} | |||||
public void setErrCode(String errCode) { | |||||
this.errCode = errCode; | |||||
} | |||||
public String getErrCodeDes() { | |||||
return this.errCodeDes; | |||||
} | |||||
public void setErrCodeDes(String errCodeDes) { | |||||
this.errCodeDes = errCodeDes; | |||||
} | |||||
public String getAppid() { | |||||
return this.appid; | |||||
} | |||||
public void setAppid(String appid) { | |||||
this.appid = appid; | |||||
} | |||||
public String getMchId() { | |||||
return this.mchId; | |||||
} | |||||
public void setMchId(String mchId) { | |||||
this.mchId = mchId; | |||||
} | |||||
public String getDeviceInfo() { | public String getDeviceInfo() { | ||||
return this.deviceInfo; | return this.deviceInfo; | ||||
} | } | ||||
@@ -151,22 +82,6 @@ public class WxMpPayRefundResult implements Serializable { | |||||
this.deviceInfo = deviceInfo; | this.deviceInfo = deviceInfo; | ||||
} | } | ||||
public String getNonceStr() { | |||||
return this.nonceStr; | |||||
} | |||||
public void setNonceStr(String nonceStr) { | |||||
this.nonceStr = nonceStr; | |||||
} | |||||
public String getSign() { | |||||
return this.sign; | |||||
} | |||||
public void setSign(String sign) { | |||||
this.sign = sign; | |||||
} | |||||
public String getTransactionId() { | public String getTransactionId() { | ||||
return this.transactionId; | return this.transactionId; | ||||
} | } | ||||
@@ -271,9 +186,4 @@ public class WxMpPayRefundResult implements Serializable { | |||||
this.couponRefundId = couponRefundId; | this.couponRefundId = couponRefundId; | ||||
} | } | ||||
@Override | |||||
public String toString() { | |||||
return ToStringBuilder.reflectionToString(this, ToStringStyle.MULTI_LINE_STYLE); | |||||
} | |||||
} | } |
@@ -8,7 +8,7 @@ import com.thoughtworks.xstream.annotations.XStreamAlias; | |||||
* @author binarywang (https://github.com/binarywang) | * @author binarywang (https://github.com/binarywang) | ||||
*/ | */ | ||||
@XStreamAlias("xml") | @XStreamAlias("xml") | ||||
public class WxSendRedpackRequest { | |||||
public class WxPaySendRedpackRequest { | |||||
/** | /** | ||||
* mch_billno | * mch_billno | ||||
* 商户订单号(每个订单号必须唯一) 组成:mch_id+yyyymmdd+10位一天内不能重复的数字。 接口根据商户订单号支持重入,如出现超时可再调用。 | * 商户订单号(每个订单号必须唯一) 组成:mch_id+yyyymmdd+10位一天内不能重复的数字。 接口根据商户订单号支持重入,如出现超时可再调用。 | ||||
@@ -18,7 +18,7 @@ public class WxSendRedpackRequest { | |||||
/** | /** | ||||
* send_name | * send_name | ||||
* 商户名称 | |||||
* 商户名称 | |||||
* 红包发送者名称 | * 红包发送者名称 | ||||
*/ | */ | ||||
@XStreamAlias("send_name") | @XStreamAlias("send_name") | ||||
@@ -117,7 +117,7 @@ public class WxSendRedpackRequest { | |||||
* 场景id | * 场景id | ||||
* PRODUCT_1:商品促销 | * PRODUCT_1:商品促销 | ||||
* PRODUCT_2:抽奖 | * PRODUCT_2:抽奖 | ||||
* PRODUCT_3:虚拟物品兑奖 | |||||
* PRODUCT_3:虚拟物品兑奖 | |||||
* PRODUCT_4:企业内部福利 | * PRODUCT_4:企业内部福利 | ||||
* PRODUCT_5:渠道分润 | * PRODUCT_5:渠道分润 | ||||
* PRODUCT_6:保险回馈 | * PRODUCT_6:保险回馈 | ||||
@@ -135,7 +135,7 @@ public class WxSendRedpackRequest { | |||||
* 活动信息 | * 活动信息 | ||||
* posttime:用户操作的时间戳 | * posttime:用户操作的时间戳 | ||||
* mobile:业务系统账号的手机号,国家代码-手机号。不需要+号 | * mobile:业务系统账号的手机号,国家代码-手机号。不需要+号 | ||||
* deviceid :mac 地址或者设备唯一标识 | |||||
* deviceid :mac 地址或者设备唯一标识 | |||||
* clientversion :用户操作的客户端版本 | * clientversion :用户操作的客户端版本 | ||||
* 把值为非空的信息用key=value进行拼接,再进行urlencode | * 把值为非空的信息用key=value进行拼接,再进行urlencode | ||||
* urlencode(posttime=xx&mobile=xx&deviceid=xx) | * urlencode(posttime=xx&mobile=xx&deviceid=xx) | ||||
@@ -150,7 +150,7 @@ public class WxSendRedpackRequest { | |||||
* consume_mch_id | * consume_mch_id | ||||
* 资金授权商户号 | * 资金授权商户号 | ||||
* 资金授权商户号 | * 资金授权商户号 | ||||
* 服务商替特约商户发放时使用 | |||||
* 服务商替特约商户发放时使用 | |||||
* 非必填字段 | * 非必填字段 | ||||
* </pre> | * </pre> | ||||
*/ | */ |
@@ -0,0 +1,82 @@ | |||||
package me.chanjar.weixin.mp.bean.pay; | |||||
import com.thoughtworks.xstream.annotations.XStreamAlias; | |||||
import java.io.Serializable; | |||||
/** | |||||
* 向微信用户个人发现金红包返回结果 | |||||
* https://pay.weixin.qq.com/wiki/doc/api/cash_coupon.php?chapter=13_5 | |||||
* @author kane | |||||
* | |||||
*/ | |||||
@XStreamAlias("xml") | |||||
public class WxPaySendRedpackResult extends WxPayBaseResult implements Serializable { | |||||
private static final long serialVersionUID = -4837415036337132073L; | |||||
@XStreamAlias("mch_billno") | |||||
private String mchBillno; | |||||
@XStreamAlias("wxappid") | |||||
private String wxappid; | |||||
@XStreamAlias("re_openid") | |||||
private String reOpenid; | |||||
@XStreamAlias("total_amount") | |||||
private int totalAmount; | |||||
@XStreamAlias("send_time") | |||||
private String sendTime; | |||||
@XStreamAlias("send_listid") | |||||
private String sendListid; | |||||
public String getMchBillno() { | |||||
return mchBillno; | |||||
} | |||||
public void setMchBillno(String mchBillno) { | |||||
this.mchBillno = mchBillno; | |||||
} | |||||
public String getWxappid() { | |||||
return wxappid; | |||||
} | |||||
public void setWxappid(String wxappid) { | |||||
this.wxappid = wxappid; | |||||
} | |||||
public String getReOpenid() { | |||||
return reOpenid; | |||||
} | |||||
public void setReOpenid(String reOpenid) { | |||||
this.reOpenid = reOpenid; | |||||
} | |||||
public int getTotalAmount() { | |||||
return totalAmount; | |||||
} | |||||
public void setTotalAmount(int totalAmount) { | |||||
this.totalAmount = totalAmount; | |||||
} | |||||
public String getSendTime() { | |||||
return sendTime; | |||||
} | |||||
public void setSendTime(String sendTime) { | |||||
this.sendTime = sendTime; | |||||
} | |||||
public String getSendListid() { | |||||
return sendListid; | |||||
} | |||||
public void setSendListid(String sendListid) { | |||||
this.sendListid = sendListid; | |||||
} | |||||
} |
@@ -1,10 +1,6 @@ | |||||
package me.chanjar.weixin.mp.bean.pay; | package me.chanjar.weixin.mp.bean.pay; | ||||
import org.apache.commons.lang3.builder.ToStringBuilder; | |||||
import org.apache.commons.lang3.builder.ToStringStyle; | |||||
import com.thoughtworks.xstream.annotations.XStreamAlias; | import com.thoughtworks.xstream.annotations.XStreamAlias; | ||||
import me.chanjar.weixin.common.annotation.Required; | import me.chanjar.weixin.common.annotation.Required; | ||||
/** | /** | ||||
@@ -23,33 +19,7 @@ import me.chanjar.weixin.common.annotation.Required; | |||||
* @author binarywang (https://github.com/binarywang) | * @author binarywang (https://github.com/binarywang) | ||||
*/ | */ | ||||
@XStreamAlias("xml") | @XStreamAlias("xml") | ||||
public class WxUnifiedOrderRequest { | |||||
/** | |||||
* <pre> | |||||
* 公众账号ID | |||||
* appid | |||||
* 是 | |||||
* String(32) | |||||
* wxd678efh567hg6787 | |||||
* 微信分配的公众账号ID(企业号corpid即为此appId) | |||||
* </pre> | |||||
*/ | |||||
@XStreamAlias("appid") | |||||
private String appid; | |||||
/** | |||||
* <pre> | |||||
* 商户号 | |||||
* mch_id | |||||
* 是 | |||||
* String(32) | |||||
* 1230000109 | |||||
* 微信支付分配的商户号 | |||||
* </pre> | |||||
*/ | |||||
@XStreamAlias("mch_id") | |||||
private String mchId; | |||||
public class WxPayUnifiedOrderRequest extends WxPayBaseRequest { | |||||
/** | /** | ||||
* <pre> | * <pre> | ||||
@@ -64,32 +34,6 @@ public class WxUnifiedOrderRequest { | |||||
@XStreamAlias("device_info") | @XStreamAlias("device_info") | ||||
private String deviceInfo; | private String deviceInfo; | ||||
/** | |||||
* <pre> | |||||
* 随机字符串 | |||||
* nonce_str | |||||
* 是 | |||||
* String(32) | |||||
* 5K8264ILTKCH16CQ2502SI8ZNMTM67VS | |||||
* 随机字符串,不长于32位。推荐随机数生成算法 | |||||
* </pre> | |||||
*/ | |||||
@XStreamAlias("nonce_str") | |||||
private String nonceStr; | |||||
/** | |||||
* <pre> | |||||
* 签名 | |||||
* sign | |||||
* 是 | |||||
* String(32) | |||||
* C380BEC2BFD727A4B6845133519F3AD6 | |||||
* 签名,详见签名生成算法 | |||||
* </pre> | |||||
*/ | |||||
@XStreamAlias("sign") | |||||
private String sign; | |||||
/** | /** | ||||
* <pre> | * <pre> | ||||
* 商品描述 | * 商品描述 | ||||
@@ -482,11 +426,6 @@ public class WxUnifiedOrderRequest { | |||||
this.openid = openid; | this.openid = openid; | ||||
} | } | ||||
@Override | |||||
public String toString() { | |||||
return ToStringBuilder.reflectionToString(this, ToStringStyle.MULTI_LINE_STYLE); | |||||
} | |||||
public static WxUnifiedOrderRequestBuilder builder() { | public static WxUnifiedOrderRequestBuilder builder() { | ||||
return new WxUnifiedOrderRequestBuilder(); | return new WxUnifiedOrderRequestBuilder(); | ||||
} | } | ||||
@@ -613,7 +552,7 @@ public class WxUnifiedOrderRequest { | |||||
return this; | return this; | ||||
} | } | ||||
public WxUnifiedOrderRequestBuilder from(WxUnifiedOrderRequest origin) { | |||||
public WxUnifiedOrderRequestBuilder from(WxPayUnifiedOrderRequest origin) { | |||||
this.appid(origin.appid); | this.appid(origin.appid); | ||||
this.mchId(origin.mchId); | this.mchId(origin.mchId); | ||||
this.deviceInfo(origin.deviceInfo); | this.deviceInfo(origin.deviceInfo); | ||||
@@ -637,8 +576,8 @@ public class WxUnifiedOrderRequest { | |||||
return this; | return this; | ||||
} | } | ||||
public WxUnifiedOrderRequest build() { | |||||
WxUnifiedOrderRequest m = new WxUnifiedOrderRequest(); | |||||
public WxPayUnifiedOrderRequest build() { | |||||
WxPayUnifiedOrderRequest m = new WxPayUnifiedOrderRequest(); | |||||
m.appid = this.appid; | m.appid = this.appid; | ||||
m.mchId = this.mchId; | m.mchId = this.mchId; | ||||
m.deviceInfo = this.deviceInfo; | m.deviceInfo = this.deviceInfo; |
@@ -0,0 +1,48 @@ | |||||
package me.chanjar.weixin.mp.bean.pay; | |||||
import com.thoughtworks.xstream.annotations.XStreamAlias; | |||||
/** | |||||
* <pre> | |||||
* 在发起微信支付前,需要调用统一下单接口,获取"预支付交易会话标识"返回的结果 | |||||
* 统一下单(详见http://pay.weixin.qq.com/wiki/doc/api/jsapi.php?chapter=9_1) | |||||
* </pre> | |||||
* | |||||
* @author chanjarster | |||||
*/ | |||||
@XStreamAlias("xml") | |||||
public class WxPayUnifiedOrderResult extends WxPayBaseResult { | |||||
@XStreamAlias("prepay_id") | |||||
private String prepayId; | |||||
@XStreamAlias("trade_type") | |||||
private String tradeType; | |||||
@XStreamAlias("code_url") | |||||
private String codeURL; | |||||
public String getPrepayId() { | |||||
return this.prepayId; | |||||
} | |||||
public void setPrepayId(String prepayId) { | |||||
this.prepayId = prepayId; | |||||
} | |||||
public String getTradeType() { | |||||
return this.tradeType; | |||||
} | |||||
public void setTradeType(String tradeType) { | |||||
this.tradeType = tradeType; | |||||
} | |||||
public String getCodeURL() { | |||||
return this.codeURL; | |||||
} | |||||
public void setCodeURL(String codeURL) { | |||||
this.codeURL = codeURL; | |||||
} | |||||
} |
@@ -1,105 +0,0 @@ | |||||
package me.chanjar.weixin.mp.bean.pay; | |||||
import java.io.Serializable; | |||||
import org.apache.commons.lang3.builder.ToStringBuilder; | |||||
import org.apache.commons.lang3.builder.ToStringStyle; | |||||
import com.thoughtworks.xstream.annotations.XStreamAlias; | |||||
/** | |||||
* 向微信用户个人发现金红包返回结果 | |||||
* https://pay.weixin.qq.com/wiki/doc/api/cash_coupon.php?chapter=13_5 | |||||
* @author kane | |||||
* | |||||
*/ | |||||
@XStreamAlias("xml") | |||||
public class WxRedpackResult implements Serializable { | |||||
private static final long serialVersionUID = -4837415036337132073L; | |||||
@XStreamAlias("return_code") | |||||
private String returnCode; | |||||
@XStreamAlias("return_msg") | |||||
private String returnMsg; | |||||
@XStreamAlias("sign") | |||||
private String sign; | |||||
@XStreamAlias("result_code") | |||||
private String resultCode; | |||||
@XStreamAlias("err_code") | |||||
private String errCode; | |||||
@XStreamAlias("err_code_des") | |||||
private String errCodeDes; | |||||
@XStreamAlias("mch_billno") | |||||
private String mchBillno; | |||||
@XStreamAlias("mch_id") | |||||
private String mchId; | |||||
@XStreamAlias("wxappid") | |||||
private String wxappid; | |||||
@XStreamAlias("re_openid") | |||||
private String reOpenid; | |||||
@XStreamAlias("total_amount") | |||||
private int totalAmount; | |||||
@XStreamAlias("send_time") | |||||
private String sendTime; | |||||
@XStreamAlias("send_listid") | |||||
private String sendListid; | |||||
public String getErrCode() { | |||||
return this.errCode; | |||||
} | |||||
public String getErrCodeDes() { | |||||
return this.errCodeDes; | |||||
} | |||||
public String getReturnCode() { | |||||
return this.returnCode; | |||||
} | |||||
public String getReturnMsg() { | |||||
return this.returnMsg; | |||||
} | |||||
public String getSign() { | |||||
return this.sign; | |||||
} | |||||
public String getResultCode() { | |||||
return this.resultCode; | |||||
} | |||||
public String getMchBillno() { | |||||
return this.mchBillno; | |||||
} | |||||
public String getMchId() { | |||||
return this.mchId; | |||||
} | |||||
public String getWxappid() { | |||||
return this.wxappid; | |||||
} | |||||
public String getReOpenid() { | |||||
return this.reOpenid; | |||||
} | |||||
public int getTotalAmount() { | |||||
return this.totalAmount; | |||||
} | |||||
public String getSendTime() { | |||||
return this.sendTime; | |||||
} | |||||
public String getSendListid() { | |||||
return this.sendListid; | |||||
} | |||||
@Override | |||||
public String toString() { | |||||
return ToStringBuilder.reflectionToString(this, ToStringStyle.MULTI_LINE_STYLE); | |||||
} | |||||
} |
@@ -27,11 +27,6 @@ public class WxMpPayServiceImplTest { | |||||
} | } | ||||
@Test | |||||
public void testGetJSSDKPayResult() throws Exception { | |||||
} | |||||
@Test | @Test | ||||
public void testGetJSSDKCallbackData() throws Exception { | public void testGetJSSDKCallbackData() throws Exception { | ||||
@@ -39,13 +34,13 @@ public class WxMpPayServiceImplTest { | |||||
@Test | @Test | ||||
public void testRefund() throws Exception { | public void testRefund() throws Exception { | ||||
WxMpPayRefundRequest request = new WxMpPayRefundRequest(); | |||||
WxPayRefundRequest request = new WxPayRefundRequest(); | |||||
request.setOutRefundNo("aaa"); | request.setOutRefundNo("aaa"); | ||||
request.setOutTradeNo("1111"); | request.setOutTradeNo("1111"); | ||||
request.setTotalFee(1222); | request.setTotalFee(1222); | ||||
request.setRefundFee(111); | request.setRefundFee(111); | ||||
File keyFile = new File("E:\\dlt.p12"); | File keyFile = new File("E:\\dlt.p12"); | ||||
WxMpPayRefundResult result = this.wxService.getPayService().refund(request, keyFile); | |||||
WxPayRefundResult result = this.wxService.getPayService().refund(request, keyFile); | |||||
System.err.println(result); | System.err.println(result); | ||||
} | } | ||||
@@ -56,30 +51,41 @@ public class WxMpPayServiceImplTest { | |||||
@Test | @Test | ||||
public void testSendRedpack() throws Exception { | public void testSendRedpack() throws Exception { | ||||
WxSendRedpackRequest request = new WxSendRedpackRequest(); | |||||
WxPaySendRedpackRequest request = new WxPaySendRedpackRequest(); | |||||
request.setActName("abc"); | request.setActName("abc"); | ||||
request.setClientIp("aaa"); | request.setClientIp("aaa"); | ||||
request.setMchBillno("aaaa"); | request.setMchBillno("aaaa"); | ||||
request | request | ||||
.setReOpenid(((WxXmlMpInMemoryConfigStorage) this.wxService.getWxMpConfigStorage()).getOpenid()); | .setReOpenid(((WxXmlMpInMemoryConfigStorage) this.wxService.getWxMpConfigStorage()).getOpenid()); | ||||
File keyFile = new File("E:\\dlt.p12"); | File keyFile = new File("E:\\dlt.p12"); | ||||
WxRedpackResult redpackResult = this.wxService.getPayService().sendRedpack(request, keyFile); | |||||
WxPaySendRedpackResult redpackResult = this.wxService.getPayService().sendRedpack(request, keyFile); | |||||
System.err.println(redpackResult); | System.err.println(redpackResult); | ||||
} | } | ||||
/** | /** | ||||
* Test method for {@link me.chanjar.weixin.mp.api.impl.WxMpPayServiceImpl#unifiedOrder(me.chanjar.weixin.mp.bean.pay.WxUnifiedOrderRequest)}. | |||||
* Test method for {@link me.chanjar.weixin.mp.api.impl.WxMpPayServiceImpl#unifiedOrder(WxPayUnifiedOrderRequest)}. | |||||
* @throws WxErrorException | * @throws WxErrorException | ||||
*/ | */ | ||||
@Test | @Test | ||||
public void testUnifiedOrder() throws WxErrorException { | public void testUnifiedOrder() throws WxErrorException { | ||||
WxUnifiedOrderResult result = this.wxService.getPayService() | |||||
.unifiedOrder(WxUnifiedOrderRequest.builder().body("1111111") | |||||
WxPayUnifiedOrderResult result = this.wxService.getPayService() | |||||
.unifiedOrder(WxPayUnifiedOrderRequest.builder().body("1111111") | |||||
.totalFee(1).spbillCreateIp("111111").notifyURL("111111") | .totalFee(1).spbillCreateIp("111111").notifyURL("111111") | ||||
.tradeType("JSAPI").openid("122").outTradeNo("111111").build()); | .tradeType("JSAPI").openid("122").outTradeNo("111111").build()); | ||||
System.err.println(result); | System.err.println(result); | ||||
} | } | ||||
/** | |||||
* Test method for {@link me.chanjar.weixin.mp.api.impl.WxMpPayServiceImpl#queryOrder(String, String)} . | |||||
* @throws WxErrorException | |||||
*/ | |||||
@Test | |||||
public final void testQueryOrder() throws WxErrorException { | |||||
//System.err.println(this.wxService.getPayService().queryOrder(null, null)); | |||||
System.err.println(this.wxService.getPayService().queryOrder("11212121", null)); | |||||
System.err.println(this.wxService.getPayService().queryOrder(null, "11111")); | |||||
} | |||||
/** | /** | ||||
* Test method for {@link me.chanjar.weixin.mp.api.impl.WxMpPayServiceImpl#entPay(WxEntPayRequest, File)}. | * Test method for {@link me.chanjar.weixin.mp.api.impl.WxMpPayServiceImpl#entPay(WxEntPayRequest, File)}. | ||||
* @throws WxErrorException | * @throws WxErrorException | ||||
@@ -8,7 +8,7 @@ import org.junit.Test; | |||||
import com.thoughtworks.xstream.XStream; | import com.thoughtworks.xstream.XStream; | ||||
import me.chanjar.weixin.common.util.xml.XStreamInitializer; | import me.chanjar.weixin.common.util.xml.XStreamInitializer; | ||||
import me.chanjar.weixin.mp.bean.pay.WxRedpackResult; | |||||
import me.chanjar.weixin.mp.bean.pay.WxPaySendRedpackResult; | |||||
public class WxRedpackResultTest { | public class WxRedpackResultTest { | ||||
@@ -17,44 +17,44 @@ public class WxRedpackResultTest { | |||||
@Before | @Before | ||||
public void setup() { | public void setup() { | ||||
this.xstream = XStreamInitializer.getInstance(); | this.xstream = XStreamInitializer.getInstance(); | ||||
this.xstream.processAnnotations(WxRedpackResult.class); | |||||
this.xstream.processAnnotations(WxPaySendRedpackResult.class); | |||||
} | } | ||||
@Test public void loadSuccessResult() { | @Test public void loadSuccessResult() { | ||||
final String successSample = "<xml>\n" + | |||||
"<return_code><![CDATA[SUCCESS]]></return_code>\n" + | |||||
"<return_msg><![CDATA[发放成功.]]></return_msg>\n" + | |||||
"<result_code><![CDATA[SUCCESS]]></result_code>\n" + | |||||
"<err_code><![CDATA[0]]></err_code>\n" + | |||||
"<err_code_des><![CDATA[发放成功.]]></err_code_des>\n" + | |||||
"<mch_billno><![CDATA[0010010404201411170000046545]]></mch_billno>\n" + | |||||
"<mch_id>10010404</mch_id>\n" + | |||||
"<wxappid><![CDATA[wx6fa7e3bab7e15415]]></wxappid>\n" + | |||||
"<re_openid><![CDATA[onqOjjmM1tad-3ROpncN-yUfa6uI]]></re_openid>\n" + | |||||
"<total_amount>1</total_amount>\n" + | |||||
"<send_listid>100000000020150520314766074200</send_listid>\n" + | |||||
"<send_time>20150520102602</send_time>\n" + | |||||
final String successSample = "<xml>\n" + | |||||
"<return_code><![CDATA[SUCCESS]]></return_code>\n" + | |||||
"<return_msg><![CDATA[发放成功.]]></return_msg>\n" + | |||||
"<result_code><![CDATA[SUCCESS]]></result_code>\n" + | |||||
"<err_code><![CDATA[0]]></err_code>\n" + | |||||
"<err_code_des><![CDATA[发放成功.]]></err_code_des>\n" + | |||||
"<mch_billno><![CDATA[0010010404201411170000046545]]></mch_billno>\n" + | |||||
"<mch_id>10010404</mch_id>\n" + | |||||
"<wxappid><![CDATA[wx6fa7e3bab7e15415]]></wxappid>\n" + | |||||
"<re_openid><![CDATA[onqOjjmM1tad-3ROpncN-yUfa6uI]]></re_openid>\n" + | |||||
"<total_amount>1</total_amount>\n" + | |||||
"<send_listid>100000000020150520314766074200</send_listid>\n" + | |||||
"<send_time>20150520102602</send_time>\n" + | |||||
"</xml>"; | "</xml>"; | ||||
WxRedpackResult wxMpRedpackResult = (WxRedpackResult) this.xstream.fromXML(successSample); | |||||
WxPaySendRedpackResult wxMpRedpackResult = (WxPaySendRedpackResult) this.xstream.fromXML(successSample); | |||||
assertEquals("SUCCESS", wxMpRedpackResult.getReturnCode()); | assertEquals("SUCCESS", wxMpRedpackResult.getReturnCode()); | ||||
assertEquals("SUCCESS", wxMpRedpackResult.getResultCode()); | assertEquals("SUCCESS", wxMpRedpackResult.getResultCode()); | ||||
assertEquals("20150520102602", wxMpRedpackResult.getSendTime()); | assertEquals("20150520102602", wxMpRedpackResult.getSendTime()); | ||||
} | } | ||||
@Test public void loadFailureResult() { | @Test public void loadFailureResult() { | ||||
final String failureSample = "<xml>\n" + | |||||
"<return_code><![CDATA[FAIL]]></return_code>\n" + | |||||
"<return_msg><![CDATA[系统繁忙,请稍后再试.]]></return_msg>\n" + | |||||
"<result_code><![CDATA[FAIL]]></result_code>\n" + | |||||
"<err_code><![CDATA[268458547]]></err_code>\n" + | |||||
"<err_code_des><![CDATA[系统繁忙,请稍后再试.]]></err_code_des>\n" + | |||||
"<mch_billno><![CDATA[0010010404201411170000046542]]></mch_billno>\n" + | |||||
"<mch_id>10010404</mch_id>\n" + | |||||
"<wxappid><![CDATA[wx6fa7e3bab7e15415]]></wxappid>\n" + | |||||
"<re_openid><![CDATA[onqOjjmM1tad-3ROpncN-yUfa6uI]]></re_openid>\n" + | |||||
"<total_amount>1</total_amount>\n" + | |||||
final String failureSample = "<xml>\n" + | |||||
"<return_code><![CDATA[FAIL]]></return_code>\n" + | |||||
"<return_msg><![CDATA[系统繁忙,请稍后再试.]]></return_msg>\n" + | |||||
"<result_code><![CDATA[FAIL]]></result_code>\n" + | |||||
"<err_code><![CDATA[268458547]]></err_code>\n" + | |||||
"<err_code_des><![CDATA[系统繁忙,请稍后再试.]]></err_code_des>\n" + | |||||
"<mch_billno><![CDATA[0010010404201411170000046542]]></mch_billno>\n" + | |||||
"<mch_id>10010404</mch_id>\n" + | |||||
"<wxappid><![CDATA[wx6fa7e3bab7e15415]]></wxappid>\n" + | |||||
"<re_openid><![CDATA[onqOjjmM1tad-3ROpncN-yUfa6uI]]></re_openid>\n" + | |||||
"<total_amount>1</total_amount>\n" + | |||||
"</xml>"; | "</xml>"; | ||||
WxRedpackResult wxMpRedpackResult = (WxRedpackResult) this.xstream.fromXML(failureSample); | |||||
WxPaySendRedpackResult wxMpRedpackResult = (WxPaySendRedpackResult) this.xstream.fromXML(failureSample); | |||||
assertEquals("FAIL", wxMpRedpackResult.getReturnCode()); | assertEquals("FAIL", wxMpRedpackResult.getReturnCode()); | ||||
assertEquals("FAIL", wxMpRedpackResult.getResultCode()); | assertEquals("FAIL", wxMpRedpackResult.getResultCode()); | ||||
assertEquals("onqOjjmM1tad-3ROpncN-yUfa6uI", wxMpRedpackResult.getReOpenid()); | assertEquals("onqOjjmM1tad-3ROpncN-yUfa6uI", wxMpRedpackResult.getReOpenid()); | ||||