mirror of
https://gitee.com/binary/weixin-java-tools.git
synced 2026-03-10 00:13:40 +08:00
实现刷卡支付提交API #101
This commit is contained in:
+14
-1
@@ -262,7 +262,7 @@ public interface WxPayService {
|
||||
* @return 生成的二维码的字节数组
|
||||
*/
|
||||
byte[] createScanPayQrcodeMode1(String productId, File logoFile, Integer sideLength);
|
||||
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 扫码支付模式一生成二维码的方法
|
||||
@@ -324,4 +324,17 @@ public interface WxPayService {
|
||||
* @return 保存到本地的临时文件
|
||||
*/
|
||||
File downloadBill(String billDate, String billType, String tarType, String deviceInfo) throws WxErrorException;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 提交刷卡支付
|
||||
* 应用场景:
|
||||
* 收银员使用扫码设备读取微信用户刷卡授权码以后,二维码或条码信息传送至商户收银台,由商户收银台或者商户后台调用该接口发起支付。
|
||||
* 提醒1:提交支付请求后微信会同步返回支付结果。当返回结果为“系统错误”时,商户系统等待5秒后调用【查询订单API】,查询支付实际交易结果;当返回结果为“USERPAYING”时,商户系统可设置间隔时间(建议10秒)重新查询支付结果,直到支付成功或超时(建议30秒);
|
||||
* 提醒2:在调用查询接口返回后,如果交易状况不明晰,请调用【撤销订单API】,此时如果交易失败则关闭订单,该单不能再支付成功;如果交易成功,则将扣款退回到用户账户。当撤销无返回或错误时,请再次调用。注意:请勿扣款后立即调用【撤销订单API】,建议至少15秒后再调用。撤销订单API需要双向证书。
|
||||
* 接口地址: https://api.mch.weixin.qq.com/pay/micropay
|
||||
* 是否需要证书:不需要。
|
||||
* </pre>
|
||||
*/
|
||||
WxPayMicropayResult micropay(WxPayMicropayRequest request) throws WxErrorException;
|
||||
}
|
||||
|
||||
+19
-6
@@ -122,19 +122,19 @@ public class WxPayServiceImpl implements WxPayService {
|
||||
|| !"SUCCESS".equalsIgnoreCase(result.getResultCode())) {
|
||||
StringBuilder errorMsg = new StringBuilder();
|
||||
if (result.getReturnCode() != null) {
|
||||
errorMsg.append("返回代码:" + result.getReturnCode());
|
||||
errorMsg.append("返回代码:").append(result.getReturnCode());
|
||||
}
|
||||
if (result.getReturnMsg() != null) {
|
||||
errorMsg.append(",返回信息:" + result.getReturnMsg());
|
||||
errorMsg.append(",返回信息:").append(result.getReturnMsg());
|
||||
}
|
||||
if (result.getResultCode() != null) {
|
||||
errorMsg.append(",结果代码:" + result.getResultCode());
|
||||
errorMsg.append(",结果代码:").append(result.getResultCode());
|
||||
}
|
||||
if (result.getErrCode() != null) {
|
||||
errorMsg.append(",错误代码:" + result.getErrCode());
|
||||
errorMsg.append(",错误代码:").append(result.getErrCode());
|
||||
}
|
||||
if (result.getErrCodeDes() != null) {
|
||||
errorMsg.append(",错误详情:" + result.getErrCodeDes());
|
||||
errorMsg.append(",错误详情:").append(result.getErrCodeDes());
|
||||
}
|
||||
|
||||
WxError error = WxError.newBuilder()
|
||||
@@ -389,7 +389,7 @@ public class WxPayServiceImpl implements WxPayService {
|
||||
|
||||
@Override
|
||||
public String createScanPayQrcodeMode1(String productId){
|
||||
//weixin://wxpay/bizpayurl?sign=XXXXX&appid=XXXXX&mch_id=XXXXX&product_id=XXXXXX&time_stamp=XXXXXX&nonce_str=XXXXX
|
||||
//weixin://wxpay/bizpayurl?sign=XXXXX&appid=XXXXX&mch_id=XXXXX&product_id=XXXXXX&time_stamp=XXXXXX&nonce_str=XXXXX
|
||||
StringBuilder codeUrl = new StringBuilder("weixin://wxpay/bizpayurl?");
|
||||
Map<String, String> params = Maps.newHashMap();
|
||||
params.put("appid", this.getConfig().getAppId());
|
||||
@@ -455,6 +455,19 @@ public class WxPayServiceImpl implements WxPayService {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public WxPayMicropayResult micropay(WxPayMicropayRequest request) throws WxErrorException {
|
||||
this.initRequest(request);
|
||||
BeanUtils.checkRequiredFields(request);
|
||||
request.setSign(this.createSign(request));
|
||||
|
||||
String url = this.getPayBaseUrl() + "/pay/micropay";
|
||||
String responseContent = this.post(url, request.toXML());
|
||||
WxPayMicropayResult result = WxPayBaseResult.fromXML(responseContent, WxPayMicropayResult.class);
|
||||
this.checkResult(result);
|
||||
return result;
|
||||
}
|
||||
|
||||
private String post(String url, String xmlParam) {
|
||||
String requestString = null;
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user