merge #107
This commit is contained in:
parent
c990ff5770
commit
3e68c5a400
42
pom.xml
42
pom.xml
@ -44,6 +44,7 @@
|
|||||||
<module>weixin4j-mp</module>
|
<module>weixin4j-mp</module>
|
||||||
<module>weixin4j-qy</module>
|
<module>weixin4j-qy</module>
|
||||||
<module>weixin4j-server</module>
|
<module>weixin4j-server</module>
|
||||||
|
<module>weixin4j-example</module>
|
||||||
</modules>
|
</modules>
|
||||||
<properties>
|
<properties>
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
@ -53,18 +54,6 @@
|
|||||||
</properties>
|
</properties>
|
||||||
<build>
|
<build>
|
||||||
<plugins>
|
<plugins>
|
||||||
<plugin>
|
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
|
||||||
<artifactId>maven-source-plugin</artifactId>
|
|
||||||
<version>2.4</version>
|
|
||||||
<executions>
|
|
||||||
<execution>
|
|
||||||
<goals>
|
|
||||||
<goal>jar</goal>
|
|
||||||
</goals>
|
|
||||||
</execution>
|
|
||||||
</executions>
|
|
||||||
</plugin>
|
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-compiler-plugin</artifactId>
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
@ -222,8 +211,8 @@
|
|||||||
<resource>
|
<resource>
|
||||||
<directory>src/main/resources</directory>
|
<directory>src/main/resources</directory>
|
||||||
<includes>
|
<includes>
|
||||||
<include>*.xml</include>
|
<include>**/*.xml</include>
|
||||||
<include>*.properties</include>
|
<include>**/*.properties</include>
|
||||||
</includes>
|
</includes>
|
||||||
</resource>
|
</resource>
|
||||||
</resources>
|
</resources>
|
||||||
@ -259,27 +248,14 @@
|
|||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</dependencyManagement>
|
</dependencyManagement>
|
||||||
|
|
||||||
<distributionManagement>
|
<distributionManagement>
|
||||||
<repository>
|
|
||||||
<id>Project Releases</id>
|
|
||||||
<name>Project Releases</name>
|
|
||||||
<url>http://repo.wyying.com/nexus/content/repositories/releases/</url>
|
|
||||||
</repository>
|
|
||||||
<snapshotRepository>
|
<snapshotRepository>
|
||||||
<id>Project Snapshots</id>
|
<id>oss-snapshot</id>
|
||||||
<name>Project Snapshots</name>
|
<url>https://oss.sonatype.org/content/repositories/snapshots/</url>
|
||||||
<url>http://repo.wyying.com/nexus/content/repositories/snapshots/</url>
|
|
||||||
</snapshotRepository>
|
</snapshotRepository>
|
||||||
|
<repository>
|
||||||
|
<id>oss-release</id>
|
||||||
|
<url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
|
||||||
|
</repository>
|
||||||
</distributionManagement>
|
</distributionManagement>
|
||||||
<!--<distributionManagement>-->
|
|
||||||
<!--<snapshotRepository>-->
|
|
||||||
<!--<id>oss-snapshot</id>-->
|
|
||||||
<!--<url>https://oss.sonatype.org/content/repositories/snapshots/</url>-->
|
|
||||||
<!--</snapshotRepository>-->
|
|
||||||
<!--<repository>-->
|
|
||||||
<!--<id>oss-release</id>-->
|
|
||||||
<!--<url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>-->
|
|
||||||
<!--</repository>-->
|
|
||||||
<!--</distributionManagement>-->
|
|
||||||
</project>
|
</project>
|
||||||
2
weixin4j-base/.gitignore
vendored
2
weixin4j-base/.gitignore
vendored
@ -30,3 +30,5 @@ target/*
|
|||||||
Thumbs.db
|
Thumbs.db
|
||||||
/target/
|
/target/
|
||||||
.DS_Store
|
.DS_Store
|
||||||
|
/target/
|
||||||
|
/target/
|
||||||
|
|||||||
@ -36,7 +36,7 @@ public class MchApi extends BaseApi {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected final WeixinPayAccount weixinAccount;
|
protected final WeixinPayAccount weixinAccount;
|
||||||
protected final WeixinPaymentSignature weixinSignature;
|
protected final WeixinSignature weixinSignature;
|
||||||
private volatile WeixinRequestExecutor weixinSSLExecutor;
|
private volatile WeixinRequestExecutor weixinSSLExecutor;
|
||||||
|
|
||||||
public MchApi(WeixinPayAccount weixinAccount) {
|
public MchApi(WeixinPayAccount weixinAccount) {
|
||||||
|
|||||||
@ -16,7 +16,6 @@ import java.util.Map;
|
|||||||
import com.alibaba.fastjson.JSON;
|
import com.alibaba.fastjson.JSON;
|
||||||
import com.alibaba.fastjson.TypeReference;
|
import com.alibaba.fastjson.TypeReference;
|
||||||
import com.foxinmy.weixin4j.exception.WeixinException;
|
import com.foxinmy.weixin4j.exception.WeixinException;
|
||||||
import com.foxinmy.weixin4j.exception.WeixinPayException;
|
|
||||||
import com.foxinmy.weixin4j.http.weixin.WeixinResponse;
|
import com.foxinmy.weixin4j.http.weixin.WeixinResponse;
|
||||||
import com.foxinmy.weixin4j.http.weixin.XmlResult;
|
import com.foxinmy.weixin4j.http.weixin.XmlResult;
|
||||||
import com.foxinmy.weixin4j.model.WeixinPayAccount;
|
import com.foxinmy.weixin4j.model.WeixinPayAccount;
|
||||||
@ -86,14 +85,8 @@ public class PayApi extends MchApi {
|
|||||||
String payJsRequestXml = XmlStream.toXML(payPackage);
|
String payJsRequestXml = XmlStream.toXML(payPackage);
|
||||||
WeixinResponse response = weixinExecutor.post(
|
WeixinResponse response = weixinExecutor.post(
|
||||||
getRequestUri("order_create_uri"), payJsRequestXml);
|
getRequestUri("order_create_uri"), payJsRequestXml);
|
||||||
boolean validatePaySign = weixinSignature.validatePaySign(response);
|
return response.getAsObject(new TypeReference<PrePay>() {
|
||||||
if(validatePaySign) {
|
});
|
||||||
PrePay prePay = response.getAsObject(new TypeReference<PrePay>() {
|
|
||||||
});
|
|
||||||
prePay.setResponse(response.getAsString());
|
|
||||||
return prePay;
|
|
||||||
}
|
|
||||||
throw new WeixinPayException("验证签名信息失败,返回数据可能被篡改");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -131,20 +124,19 @@ public class PayApi extends MchApi {
|
|||||||
MICROPayRequest microPayRequest = response
|
MICROPayRequest microPayRequest = response
|
||||||
.getAsObject(new TypeReference<MICROPayRequest>() {
|
.getAsObject(new TypeReference<MICROPayRequest>() {
|
||||||
});
|
});
|
||||||
microPayRequest.setResponse(response.getAsString());
|
|
||||||
microPayRequest.setPaymentAccount(weixinAccount);
|
microPayRequest.setPaymentAccount(weixinAccount);
|
||||||
return microPayRequest;
|
return microPayRequest;
|
||||||
}
|
}
|
||||||
PrePay prePay = createPrePay(payPackage);
|
PrePay prePay = createPrePay(payPackage);
|
||||||
if (TradeType.APP.name().equals(tradeType)) {
|
if (TradeType.APP.name().equals(tradeType)) {
|
||||||
return new APPPayRequest(prePay, weixinAccount);
|
return new APPPayRequest(prePay.getPrepayId(), weixinAccount);
|
||||||
} else if (TradeType.JSAPI.name().equals(tradeType)) {
|
} else if (TradeType.JSAPI.name().equals(tradeType)) {
|
||||||
return new JSAPIPayRequest(prePay, weixinAccount);
|
return new JSAPIPayRequest(prePay.getPrepayId(), weixinAccount);
|
||||||
} else if (TradeType.NATIVE.name().equals(tradeType)) {
|
} else if (TradeType.NATIVE.name().equals(tradeType)) {
|
||||||
return new NATIVEPayRequest(prePay,
|
return new NATIVEPayRequest(prePay.getPrepayId(),
|
||||||
prePay.getCodeUrl(), weixinAccount);
|
prePay.getCodeUrl(), weixinAccount);
|
||||||
} else if (TradeType.WAP.name().equals(tradeType)) {
|
} else if (TradeType.WAP.name().equals(tradeType)) {
|
||||||
return new WAPPayRequest(prePay, weixinAccount);
|
return new WAPPayRequest(prePay.getPrepayId(), weixinAccount);
|
||||||
} else {
|
} else {
|
||||||
throw new WeixinException("unknown tradeType:" + tradeType);
|
throw new WeixinException("unknown tradeType:" + tradeType);
|
||||||
}
|
}
|
||||||
@ -180,36 +172,6 @@ public class PayApi extends MchApi {
|
|||||||
return createPayRequest(payPackage);
|
return createPayRequest(payPackage);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 创建JSAPI支付请求对象
|
|
||||||
*
|
|
||||||
* @param openId
|
|
||||||
* 用户ID
|
|
||||||
* @param body
|
|
||||||
* 订单描述
|
|
||||||
* @param outTradeNo
|
|
||||||
* 订单号
|
|
||||||
* @param totalFee
|
|
||||||
* 订单总额(元)
|
|
||||||
* @param notifyUrl
|
|
||||||
* 支付通知地址
|
|
||||||
* @param createIp
|
|
||||||
* ip地址
|
|
||||||
* @param attach
|
|
||||||
* 附加数据 非必填
|
|
||||||
* @see com.foxinmy.weixin4j.payment.mch.JSAPIPayRequest
|
|
||||||
* @return JSAPI支付对象
|
|
||||||
* @throws WeixinException
|
|
||||||
*/
|
|
||||||
public MchPayRequest createJSPayRequest(String openId, String body,
|
|
||||||
String outTradeNo, long totalFee, String notifyUrl,
|
|
||||||
String createIp, String attach) throws WeixinException {
|
|
||||||
MchPayPackage payPackage = new MchPayPackage(body, outTradeNo,
|
|
||||||
totalFee, notifyUrl, createIp, TradeType.JSAPI, openId, null,
|
|
||||||
null, attach);
|
|
||||||
return createPayRequest(payPackage);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
* 生成编辑地址请求
|
* 生成编辑地址请求
|
||||||
@ -311,43 +273,6 @@ public class PayApi extends MchApi {
|
|||||||
return new NativePayResponse(weixinAccount, prePay.getPrepayId());
|
return new NativePayResponse(weixinAccount, prePay.getPrepayId());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 创建Native支付(扫码支付)回调对象【模式一】
|
|
||||||
*
|
|
||||||
* @param productId
|
|
||||||
* 商品ID
|
|
||||||
* @param body
|
|
||||||
* 商品描述
|
|
||||||
* @param outTradeNo
|
|
||||||
* 商户内部唯一订单号
|
|
||||||
* @param totalFee
|
|
||||||
* 商品总额 单位元
|
|
||||||
* @param notifyUrl
|
|
||||||
* 支付回调URL
|
|
||||||
* @param createIp
|
|
||||||
* 订单生成的机器 IP
|
|
||||||
* @param attach
|
|
||||||
* 附加数据 非必填
|
|
||||||
* @return Native回调对象
|
|
||||||
* @see com.foxinmy.weixin4j.payment.mch.NativePayResponse
|
|
||||||
* @see <a href=
|
|
||||||
* "https://pay.weixin.qq.com/wiki/doc/api/native.php?chapter=6_1">扫码支付
|
|
||||||
* </a>
|
|
||||||
* @see <a href=
|
|
||||||
* "https://pay.weixin.qq.com/wiki/doc/api/native.php?chapter=6_4">模式一
|
|
||||||
* </a>
|
|
||||||
* @throws WeixinException
|
|
||||||
*/
|
|
||||||
public NativePayResponse createNativePayResponse(String productId,
|
|
||||||
String body, String outTradeNo, long totalFee, String notifyUrl,
|
|
||||||
String createIp, String attach) throws WeixinException {
|
|
||||||
MchPayPackage payPackage = new MchPayPackage(body, outTradeNo,
|
|
||||||
totalFee, notifyUrl, createIp, TradeType.NATIVE, null, null,
|
|
||||||
productId, attach);
|
|
||||||
PrePay prePay = createPrePay(payPackage);
|
|
||||||
return new NativePayResponse(weixinAccount, prePay.getPrepayId());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 创建Native支付(扫码支付)链接【模式二】
|
* 创建Native支付(扫码支付)链接【模式二】
|
||||||
*
|
*
|
||||||
@ -384,42 +309,6 @@ public class PayApi extends MchApi {
|
|||||||
return createPayRequest(payPackage);
|
return createPayRequest(payPackage);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 创建Native支付(扫码支付)链接【模式二】
|
|
||||||
*
|
|
||||||
* @param productId
|
|
||||||
* 商品ID
|
|
||||||
* @param body
|
|
||||||
* 商品描述
|
|
||||||
* @param outTradeNo
|
|
||||||
* 商户内部唯一订单号
|
|
||||||
* @param totalFee
|
|
||||||
* 商品总额 单位元
|
|
||||||
* @param notifyUrl
|
|
||||||
* 支付回调URL
|
|
||||||
* @param createIp
|
|
||||||
* 订单生成的机器 IP
|
|
||||||
* @param attach
|
|
||||||
* 附加数据 非必填
|
|
||||||
* @return Native支付对象
|
|
||||||
* @see com.foxinmy.weixin4j.payment.mch.NATIVEPayRequest
|
|
||||||
* @see <a href=
|
|
||||||
* "https://pay.weixin.qq.com/wiki/doc/api/native.php?chapter=6_1">扫码支付
|
|
||||||
* </a>
|
|
||||||
* @see <a href=
|
|
||||||
* "https://pay.weixin.qq.com/wiki/doc/api/native.php?chapter=6_5">模式二
|
|
||||||
* </a>
|
|
||||||
* @throws WeixinException
|
|
||||||
*/
|
|
||||||
public MchPayRequest createNativePayRequest(String productId, String body,
|
|
||||||
String outTradeNo, long totalFee, String notifyUrl,
|
|
||||||
String createIp, String attach) throws WeixinException {
|
|
||||||
MchPayPackage payPackage = new MchPayPackage(body, outTradeNo,
|
|
||||||
totalFee, notifyUrl, createIp, TradeType.NATIVE, null, null,
|
|
||||||
productId, attach);
|
|
||||||
return createPayRequest(payPackage);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 创建APP支付请求对象
|
* 创建APP支付请求对象
|
||||||
*
|
*
|
||||||
@ -451,37 +340,6 @@ public class PayApi extends MchApi {
|
|||||||
return createPayRequest(payPackage);
|
return createPayRequest(payPackage);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 创建APP支付请求对象
|
|
||||||
*
|
|
||||||
* @param body
|
|
||||||
* 商品描述
|
|
||||||
* @param outTradeNo
|
|
||||||
* 商户内部唯一订单号
|
|
||||||
* @param totalFee
|
|
||||||
* 商品总额 单位元
|
|
||||||
* @param notifyUrl
|
|
||||||
* 支付回调URL
|
|
||||||
* @param createIp
|
|
||||||
* 订单生成的机器 IP
|
|
||||||
* @param attach
|
|
||||||
* 附加数据 非必填
|
|
||||||
* @return APP支付对象
|
|
||||||
* @see com.foxinmy.weixin4j.payment.mch.APPPayRequest
|
|
||||||
* @see <a href=
|
|
||||||
* "https://pay.weixin.qq.com/wiki/doc/api/app/app.php?chapter=8_1">
|
|
||||||
* APP支付</a>
|
|
||||||
* @throws WeixinException
|
|
||||||
*/
|
|
||||||
public MchPayRequest createAppPayRequest(String body, String outTradeNo,
|
|
||||||
long totalFee, String notifyUrl, String createIp, String attach)
|
|
||||||
throws WeixinException {
|
|
||||||
MchPayPackage payPackage = new MchPayPackage(body, outTradeNo,
|
|
||||||
totalFee, notifyUrl, createIp, TradeType.APP, null, null, null,
|
|
||||||
attach);
|
|
||||||
return createPayRequest(payPackage);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 创建WAP支付请求对象
|
* 创建WAP支付请求对象
|
||||||
*
|
*
|
||||||
@ -513,37 +371,6 @@ public class PayApi extends MchApi {
|
|||||||
return createPayRequest(payPackage);
|
return createPayRequest(payPackage);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 创建WAP支付请求对象
|
|
||||||
*
|
|
||||||
* @param body
|
|
||||||
* 商品描述
|
|
||||||
* @param outTradeNo
|
|
||||||
* 商户内部唯一订单号
|
|
||||||
* @param totalFee
|
|
||||||
* 商品总额 单位元
|
|
||||||
* @param notifyUrl
|
|
||||||
* 支付回调URL
|
|
||||||
* @param createIp
|
|
||||||
* 订单生成的机器 IP
|
|
||||||
* @param attach
|
|
||||||
* 附加数据 非必填
|
|
||||||
* @return WAP支付对象
|
|
||||||
* @see com.foxinmy.weixin4j.payment.mch.WAPPayRequest
|
|
||||||
* @see <a href=
|
|
||||||
* "https://pay.weixin.qq.com/wiki/doc/api/wap.php?chapter=15_1">WAP支付
|
|
||||||
* </a>
|
|
||||||
* @throws WeixinException
|
|
||||||
*/
|
|
||||||
public MchPayRequest createWapPayRequest(String body, String outTradeNo,
|
|
||||||
long totalFee, String notifyUrl, String createIp, String attach)
|
|
||||||
throws WeixinException {
|
|
||||||
MchPayPackage payPackage = new MchPayPackage(body, outTradeNo,
|
|
||||||
totalFee, notifyUrl, createIp, TradeType.WAP, null, null, null,
|
|
||||||
attach);
|
|
||||||
return createPayRequest(payPackage);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 提交被扫支付
|
* 提交被扫支付
|
||||||
*
|
*
|
||||||
@ -568,43 +395,11 @@ public class PayApi extends MchApi {
|
|||||||
* @throws WeixinException
|
* @throws WeixinException
|
||||||
*/
|
*/
|
||||||
public MchPayRequest createMicroPayRequest(String authCode, String body,
|
public MchPayRequest createMicroPayRequest(String authCode, String body,
|
||||||
String outTradeNo, double totalFee, String createIp, String attach)
|
String outTradeNo, double totalFee, String createIp, String attach)
|
||||||
throws WeixinException {
|
throws WeixinException {
|
||||||
MchPayPackage payPackage = new MchPayPackage(body, outTradeNo,
|
MchPayPackage payPackage = new MchPayPackage(body, outTradeNo,
|
||||||
totalFee, null, createIp, TradeType.MICROPAY, null, authCode,
|
totalFee, null, createIp, TradeType.MICROPAY, null, authCode,
|
||||||
null, attach);
|
null, attach);
|
||||||
return createPayRequest(payPackage);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 提交被扫支付
|
|
||||||
*
|
|
||||||
* @param authCode
|
|
||||||
* 扫码支付授权码 ,设备读取用户微信中的条码或者二维码信息
|
|
||||||
* @param body
|
|
||||||
* 商品描述
|
|
||||||
* @param outTradeNo
|
|
||||||
* 商户内部唯一订单号
|
|
||||||
* @param totalFee
|
|
||||||
* 商品总额 单位元
|
|
||||||
* @param createIp
|
|
||||||
* 订单生成的机器 IP
|
|
||||||
* @param attach
|
|
||||||
* 附加数据 非必填
|
|
||||||
* @return 支付的订单信息
|
|
||||||
* @see com.foxinmy.weixin4j.payment.mch.MICROPayRequest
|
|
||||||
* @see com.foxinmy.weixin4j.payment.mch.Order
|
|
||||||
* @see <a href=
|
|
||||||
* "http://pay.weixin.qq.com/wiki/doc/api/micropay.php?chapter=9_10">
|
|
||||||
* 提交被扫支付API</a>
|
|
||||||
* @throws WeixinException
|
|
||||||
*/
|
|
||||||
public MchPayRequest createMicroPayRequest(String authCode, String body,
|
|
||||||
String outTradeNo, long totalFee, String createIp, String attach)
|
|
||||||
throws WeixinException {
|
|
||||||
MchPayPackage payPackage = new MchPayPackage(body, outTradeNo,
|
|
||||||
totalFee, null, createIp, TradeType.MICROPAY, null, authCode,
|
|
||||||
null, attach);
|
|
||||||
return createPayRequest(payPackage);
|
return createPayRequest(payPackage);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -675,51 +470,13 @@ public class PayApi extends MchApi {
|
|||||||
double totalFee, double refundFee, CurrencyType refundFeeType,
|
double totalFee, double refundFee, CurrencyType refundFeeType,
|
||||||
String opUserId, RefundAccountType refundAccountType)
|
String opUserId, RefundAccountType refundAccountType)
|
||||||
throws WeixinException {
|
throws WeixinException {
|
||||||
return applyRefund(idQuery, outRefundNo, DateUtil.formatYuan2Fen(totalFee), DateUtil.formatYuan2Fen(refundFee), refundFeeType, opUserId,
|
|
||||||
refundAccountType);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 申请退款(请求需要双向证书)
|
|
||||||
* <p>
|
|
||||||
* 当交易发生之后一段时间内,由于买家或者卖家的原因需要退款时,卖家可以通过退款接口将支付款退还给买家,微信支付将在收到退款请求并且验证成功之后,
|
|
||||||
* 按照退款规则将支付款按原路退到买家帐号上。
|
|
||||||
* </p>
|
|
||||||
* <p style="color:red">
|
|
||||||
* 1.交易时间超过半年的订单无法提交退款;
|
|
||||||
* 2.微信支付退款支持单笔交易分多次退款,多次退款需要提交原支付订单的商户订单号和设置不同的退款单号。一笔退款失败后重新提交
|
|
||||||
* ,要采用原来的退款单号。总退款金额不能超过用户实际支付金额。
|
|
||||||
* </p>
|
|
||||||
*
|
|
||||||
* @param idQuery
|
|
||||||
* 商户系统内部的订单号, transaction_id 、 out_trade_no 二选一,如果同时存在优先级:
|
|
||||||
* transaction_id> out_trade_no
|
|
||||||
* @param outRefundNo
|
|
||||||
* 商户系统内部的退款单号,商 户系统内部唯一,同一退款单号多次请求只退一笔
|
|
||||||
* @param totalFee
|
|
||||||
* 订单总金额,单位为元
|
|
||||||
* @param refundFee
|
|
||||||
* 退款总金额,单位为元,可以做部分退款
|
|
||||||
* @param refundFeeType
|
|
||||||
* 货币类型,符合ISO 4217标准的三位字母代码,默认人民币:CNY
|
|
||||||
* @param opUserId
|
|
||||||
* 操作员帐号, 默认为商户号
|
|
||||||
* @param refundAccountType
|
|
||||||
* @return 退款申请结果
|
|
||||||
* @see com.foxinmy.weixin4j.payment.mch.RefundResult
|
|
||||||
* @see <a href=
|
|
||||||
* "http://pay.weixin.qq.com/wiki/doc/api/jsapi.php?chapter=9_4">
|
|
||||||
* 申请退款API</a>
|
|
||||||
* @since V3
|
|
||||||
* @throws WeixinException
|
|
||||||
*/
|
|
||||||
public RefundResult applyRefund(IdQuery idQuery, String outRefundNo, long totalFee, long refundFee, CurrencyType refundFeeType,
|
|
||||||
String opUserId, RefundAccountType refundAccountType) throws WeixinException {
|
|
||||||
WeixinResponse response = null;
|
WeixinResponse response = null;
|
||||||
Map<String, String> map = createBaseRequestMap(idQuery);
|
Map<String, String> map = createBaseRequestMap(idQuery);
|
||||||
map.put("out_refund_no", outRefundNo);
|
map.put("out_refund_no", outRefundNo);
|
||||||
map.put("total_fee", String.valueOf(totalFee));
|
map.put("total_fee",
|
||||||
map.put("refund_fee", String.valueOf(refundFee));
|
Integer.toString(DateUtil.formatYuan2Fen(totalFee)));
|
||||||
|
map.put("refund_fee",
|
||||||
|
Integer.toString(DateUtil.formatYuan2Fen(refundFee)));
|
||||||
if (StringUtil.isBlank(opUserId)) {
|
if (StringUtil.isBlank(opUserId)) {
|
||||||
opUserId = weixinAccount.getMchId();
|
opUserId = weixinAccount.getMchId();
|
||||||
}
|
}
|
||||||
@ -750,7 +507,7 @@ public class PayApi extends MchApi {
|
|||||||
* 商户系统内部的退款单号,商 户系统内部唯一,同一退款单号多次请求只退一笔
|
* 商户系统内部的退款单号,商 户系统内部唯一,同一退款单号多次请求只退一笔
|
||||||
* @param totalFee
|
* @param totalFee
|
||||||
* 订单总金额,单位为元
|
* 订单总金额,单位为元
|
||||||
* @see {@link #applyRefund(IdQuery, String, double, double,CurrencyType, String,RefundAccountType)}
|
* @see {@link #applyRefund(IdQuery, String, double, double,CurrencyType, String)}
|
||||||
*/
|
*/
|
||||||
public RefundResult applyRefund(IdQuery idQuery, String outRefundNo,
|
public RefundResult applyRefund(IdQuery idQuery, String outRefundNo,
|
||||||
double totalFee) throws WeixinException {
|
double totalFee) throws WeixinException {
|
||||||
@ -758,23 +515,6 @@ public class PayApi extends MchApi {
|
|||||||
null, null);
|
null, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 退款申请(全额退款)
|
|
||||||
*
|
|
||||||
* @param idQuery
|
|
||||||
* 商户系统内部的订单号, transaction_id 、 out_trade_no 二选一,如果同时存在优先级:
|
|
||||||
* transaction_id> out_trade_no
|
|
||||||
* @param outRefundNo
|
|
||||||
* 商户系统内部的退款单号,商 户系统内部唯一,同一退款单号多次请求只退一笔
|
|
||||||
* @param totalFee
|
|
||||||
* 订单总金额,单位为元
|
|
||||||
* @see {@link #applyRefund(IdQuery, String, double, double,CurrencyType, String,RefundAccountType)}
|
|
||||||
*/
|
|
||||||
public RefundResult applyRefund(IdQuery idQuery, String outRefundNo,
|
|
||||||
long totalFee) throws WeixinException {
|
|
||||||
return applyRefund(idQuery, outRefundNo, totalFee, totalFee, null, null, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 冲正订单(需要证书)</br> 当支付返回失败,或收银系统超时需要取消交易,可以调用该接口</br> 接口逻辑:支
|
* 冲正订单(需要证书)</br> 当支付返回失败,或收银系统超时需要取消交易,可以调用该接口</br> 接口逻辑:支
|
||||||
* 付失败的关单,支付成功的撤销支付</br> <font color="red">7天以内的单可撤销,其他正常支付的单
|
* 付失败的关单,支付成功的撤销支付</br> <font color="red">7天以内的单可撤销,其他正常支付的单
|
||||||
@ -1024,6 +764,4 @@ public class PayApi extends MchApi {
|
|||||||
return response.getAsObject(new TypeReference<OpenIdResult>() {
|
return response.getAsObject(new TypeReference<OpenIdResult>() {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2,82 +2,65 @@ package com.foxinmy.weixin4j.exception;
|
|||||||
|
|
||||||
import com.foxinmy.weixin4j.util.StringUtil;
|
import com.foxinmy.weixin4j.util.StringUtil;
|
||||||
import com.foxinmy.weixin4j.util.WeixinErrorUtil;
|
import com.foxinmy.weixin4j.util.WeixinErrorUtil;
|
||||||
import com.foxinmy.weixin4j.util.WeixinErrorUtil2;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 调用微信接口抛出的异常
|
* 调用微信接口抛出的异常
|
||||||
*
|
*
|
||||||
* @author jinyu(foxinmy@gmail.com)
|
|
||||||
* @className WeixinException
|
* @className WeixinException
|
||||||
|
* @author jinyu(foxinmy@gmail.com)
|
||||||
* @date 2014年4月10日
|
* @date 2014年4月10日
|
||||||
* @see
|
|
||||||
* @since JDK 1.6
|
* @since JDK 1.6
|
||||||
|
* @see
|
||||||
*/
|
*/
|
||||||
public class WeixinException extends Exception {
|
public class WeixinException extends Exception {
|
||||||
|
|
||||||
private static final long serialVersionUID = 7148145661883468514L;
|
private static final long serialVersionUID = 7148145661883468514L;
|
||||||
|
|
||||||
private String code;
|
private String code;
|
||||||
private String desc;
|
private String desc;
|
||||||
private String describeErrorMsg;
|
|
||||||
|
|
||||||
public WeixinException(String code, String desc) {
|
public WeixinException(String code, String desc) {
|
||||||
this(code, desc, null);
|
this.code = code;
|
||||||
}
|
this.desc = desc;
|
||||||
|
}
|
||||||
|
|
||||||
|
public WeixinException(String desc) {
|
||||||
|
this.code = "-1";
|
||||||
|
this.desc = desc;
|
||||||
|
}
|
||||||
|
|
||||||
public WeixinException(String errorCode, String errorMsg, String describeErrorMsg) {
|
public WeixinException(Throwable e) {
|
||||||
this.code = errorCode;
|
super(e);
|
||||||
this.desc = errorMsg;
|
}
|
||||||
if (describeErrorMsg == null) {
|
|
||||||
this.describeErrorMsg = errorMsg;
|
|
||||||
} else {
|
|
||||||
this.describeErrorMsg = describeErrorMsg;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public WeixinException(String desc) {
|
public WeixinException(String message, Throwable cause) {
|
||||||
this.code = "-1";
|
super(message, cause);
|
||||||
this.desc = desc;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public String getDescribeErrorMsg() {
|
public String getErrorCode() {
|
||||||
return describeErrorMsg;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getErrorDesc() {
|
||||||
|
return desc;
|
||||||
|
}
|
||||||
|
|
||||||
public WeixinException(Throwable e) {
|
public String getErrorText() {
|
||||||
super(e);
|
return WeixinErrorUtil.getText(code);
|
||||||
}
|
}
|
||||||
|
|
||||||
public WeixinException(String message, Throwable cause) {
|
@Override
|
||||||
super(message, cause);
|
public String getMessage() {
|
||||||
}
|
if (StringUtil.isNotBlank(code)) {
|
||||||
|
StringBuilder buf = new StringBuilder();
|
||||||
public String getErrorCode() {
|
buf.append(code).append(" >> ").append(desc);
|
||||||
return code;
|
String text = getErrorText();
|
||||||
}
|
if (StringUtil.isNotBlank(text)) {
|
||||||
|
buf.append(" >> ").append(text);
|
||||||
public String getErrorDesc() {
|
}
|
||||||
return desc;
|
return buf.toString();
|
||||||
}
|
} else {
|
||||||
|
return super.getMessage();
|
||||||
public String getErrorText() {
|
}
|
||||||
return WeixinErrorUtil2.getText(code);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getMessage() {
|
|
||||||
if (StringUtil.isNotBlank(code)) {
|
|
||||||
StringBuilder buf = new StringBuilder();
|
|
||||||
buf.append(code).append(" >> ").append(desc);
|
|
||||||
String text = getErrorText();
|
|
||||||
if (StringUtil.isNotBlank(text)) {
|
|
||||||
buf.append(" >> ").append(text);
|
|
||||||
}
|
|
||||||
return buf.toString();
|
|
||||||
} else {
|
|
||||||
return super.getMessage();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,26 +0,0 @@
|
|||||||
package com.foxinmy.weixin4j.exception;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 调用微信支付抛出的异常
|
|
||||||
*
|
|
||||||
* @className WeixinPayException
|
|
||||||
* @author jinyu(foxinmy@gmail.com)
|
|
||||||
* @date 2014年10月28日
|
|
||||||
* @since JDK 1.6
|
|
||||||
* @see
|
|
||||||
*/
|
|
||||||
public class WeixinPayException extends WeixinException {
|
|
||||||
private static final long serialVersionUID = 7148145661883468514L;
|
|
||||||
|
|
||||||
public WeixinPayException(String desc) {
|
|
||||||
super(desc);
|
|
||||||
}
|
|
||||||
|
|
||||||
public WeixinPayException(String code, String desc) {
|
|
||||||
super(code, desc);
|
|
||||||
}
|
|
||||||
|
|
||||||
public WeixinPayException(Throwable e) {
|
|
||||||
super(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -28,24 +28,21 @@ import com.foxinmy.weixin4j.http.message.XmlMessageConverter;
|
|||||||
import com.foxinmy.weixin4j.logging.InternalLogLevel;
|
import com.foxinmy.weixin4j.logging.InternalLogLevel;
|
||||||
import com.foxinmy.weixin4j.logging.InternalLogger;
|
import com.foxinmy.weixin4j.logging.InternalLogger;
|
||||||
import com.foxinmy.weixin4j.logging.InternalLoggerFactory;
|
import com.foxinmy.weixin4j.logging.InternalLoggerFactory;
|
||||||
|
|
||||||
|
|
||||||
import com.foxinmy.weixin4j.util.Consts;
|
import com.foxinmy.weixin4j.util.Consts;
|
||||||
import com.foxinmy.weixin4j.util.WeixinErrorUtil2;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 负责微信请求的执行
|
* 负责微信请求的执行
|
||||||
*
|
*
|
||||||
* @author jy
|
|
||||||
* @className WeixinRequestExecutor
|
* @className WeixinRequestExecutor
|
||||||
* @author jinyu(foxinmy@gmail.com)
|
* @author jinyu(foxinmy@gmail.com)
|
||||||
* @date 2015年8月15日
|
* @date 2015年8月15日
|
||||||
* @see
|
|
||||||
* @since JDK 1.6
|
* @since JDK 1.6
|
||||||
|
* @see
|
||||||
*/
|
*/
|
||||||
public class WeixinRequestExecutor {
|
public class WeixinRequestExecutor {
|
||||||
|
|
||||||
protected final InternalLogger logger = InternalLoggerFactory.getInstance(getClass());
|
protected final InternalLogger logger = InternalLoggerFactory
|
||||||
|
.getInstance(getClass());
|
||||||
|
|
||||||
private static final String SUCCESS_CODE = ",0,success,";
|
private static final String SUCCESS_CODE = ",0,success,";
|
||||||
|
|
||||||
@ -61,7 +58,7 @@ public class WeixinRequestExecutor {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Post方法执行微信请求
|
* Post方法执行微信请求
|
||||||
*
|
*
|
||||||
* @param url
|
* @param url
|
||||||
* 请求URL
|
* 请求URL
|
||||||
* @param body
|
* @param body
|
||||||
@ -78,7 +75,7 @@ public class WeixinRequestExecutor {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Post方法执行微信请求,用于文件上传
|
* Post方法执行微信请求,用于文件上传
|
||||||
*
|
*
|
||||||
* @param url
|
* @param url
|
||||||
* 请求URL
|
* 请求URL
|
||||||
* @param bodyParts
|
* @param bodyParts
|
||||||
@ -100,7 +97,7 @@ public class WeixinRequestExecutor {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Get方法执行微信请求
|
* Get方法执行微信请求
|
||||||
*
|
*
|
||||||
* @param url
|
* @param url
|
||||||
* 请求URL,如:https://api.weixin.qq.com/cgi-bin/token
|
* 请求URL,如:https://api.weixin.qq.com/cgi-bin/token
|
||||||
* @param parameters
|
* @param parameters
|
||||||
@ -121,7 +118,7 @@ public class WeixinRequestExecutor {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 执行微信请求
|
* 执行微信请求
|
||||||
*
|
*
|
||||||
* @param request
|
* @param request
|
||||||
* 微信请求
|
* 微信请求
|
||||||
* @return 微信响应
|
* @return 微信响应
|
||||||
@ -133,9 +130,6 @@ public class WeixinRequestExecutor {
|
|||||||
logger.debug("weixin request >> " + request.getMethod() + " "
|
logger.debug("weixin request >> " + request.getMethod() + " "
|
||||||
+ request.getURI().toString());
|
+ request.getURI().toString());
|
||||||
}
|
}
|
||||||
if(request.getEntity() instanceof StringEntity){
|
|
||||||
logger.debug("weixin request body >> " + ((StringEntity) request.getEntity()).getContentString());
|
|
||||||
}
|
|
||||||
HttpResponse httpResponse = httpClient.execute(request);
|
HttpResponse httpResponse = httpClient.execute(request);
|
||||||
WeixinResponse response = new WeixinResponse(httpResponse);
|
WeixinResponse response = new WeixinResponse(httpResponse);
|
||||||
handleResponse(response);
|
handleResponse(response);
|
||||||
@ -147,7 +141,7 @@ public class WeixinRequestExecutor {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 响应内容是否为流
|
* 响应内容是否为流
|
||||||
*
|
*
|
||||||
* @param response
|
* @param response
|
||||||
* 微信响应
|
* 微信响应
|
||||||
* @return true/false
|
* @return true/false
|
||||||
@ -165,7 +159,7 @@ public class WeixinRequestExecutor {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* handle the weixin response
|
* handle the weixin response
|
||||||
*
|
*
|
||||||
* @param response
|
* @param response
|
||||||
* 微信请求响应
|
* 微信请求响应
|
||||||
* @throws WeixinException
|
* @throws WeixinException
|
||||||
@ -188,7 +182,7 @@ public class WeixinRequestExecutor {
|
|||||||
if (!SUCCESS_CODE.contains(String.format(",%s,", result.getReturnCode()
|
if (!SUCCESS_CODE.contains(String.format(",%s,", result.getReturnCode()
|
||||||
.toLowerCase()))) {
|
.toLowerCase()))) {
|
||||||
throw new WeixinException(result.getReturnCode(),
|
throw new WeixinException(result.getReturnCode(),
|
||||||
result.getReturnMsg(),WeixinErrorUtil2.getText(result.getReturnCode()));
|
result.getReturnMsg());
|
||||||
}
|
}
|
||||||
if (XmlMessageConverter.GLOBAL.canConvert(XmlResult.class, response)) {
|
if (XmlMessageConverter.GLOBAL.canConvert(XmlResult.class, response)) {
|
||||||
try {
|
try {
|
||||||
@ -197,7 +191,7 @@ public class WeixinRequestExecutor {
|
|||||||
if (!SUCCESS_CODE.contains(String.format(",%s,", xmlResult
|
if (!SUCCESS_CODE.contains(String.format(",%s,", xmlResult
|
||||||
.getResultCode().toLowerCase()))) {
|
.getResultCode().toLowerCase()))) {
|
||||||
throw new WeixinException(xmlResult.getErrCode(),
|
throw new WeixinException(xmlResult.getErrCode(),
|
||||||
xmlResult.getErrCodeDes(),WeixinErrorUtil2.getText(xmlResult.getErrCode()));
|
xmlResult.getErrCodeDes());
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
;
|
;
|
||||||
@ -211,7 +205,7 @@ public class WeixinRequestExecutor {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 创建 SSL微信请求对象
|
* 创建 SSL微信请求对象
|
||||||
*
|
*
|
||||||
* @param password
|
* @param password
|
||||||
* 加载密钥
|
* 加载密钥
|
||||||
* @param inputStream
|
* @param inputStream
|
||||||
|
|||||||
@ -2,16 +2,14 @@
|
|||||||
<!-- 公众平台错误码:https://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1433747234&token=&lang=zh_CN -->
|
<!-- 公众平台错误码:https://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1433747234&token=&lang=zh_CN -->
|
||||||
<!-- 企业号错误码:http://qydev.weixin.qq.com/wiki/index.php?title=%E5%85%A8%E5%B1%80%E8%BF%94%E5%9B%9E%E7%A0%81%E8%AF%B4%E6%98%8E -->
|
<!-- 企业号错误码:http://qydev.weixin.qq.com/wiki/index.php?title=%E5%85%A8%E5%B1%80%E8%BF%94%E5%9B%9E%E7%A0%81%E8%AF%B4%E6%98%8E -->
|
||||||
<errors>
|
<errors>
|
||||||
|
<error>
|
||||||
|
<code>-1</code>
|
||||||
|
<text>系统繁忙,请稍后再试</text>
|
||||||
|
</error>
|
||||||
<error>
|
<error>
|
||||||
<code>0</code>
|
<code>0</code>
|
||||||
<text>请求成功</text>
|
<text>请求成功</text>
|
||||||
</error>
|
</error>
|
||||||
<error>
|
|
||||||
<code>-1</code>
|
|
||||||
<desc>system error</desc>
|
|
||||||
<text>微信系统繁忙,请稍候再试</text>
|
|
||||||
</error>
|
|
||||||
<!-- 公众平台&企业号API错误 -->
|
|
||||||
<error>
|
<error>
|
||||||
<code>40001</code>
|
<code>40001</code>
|
||||||
<text>获取access_token时AppSecret错误,或者access_token无效</text>
|
<text>获取access_token时AppSecret错误,或者access_token无效</text>
|
||||||
@ -38,8 +36,7 @@
|
|||||||
</error>
|
</error>
|
||||||
<error>
|
<error>
|
||||||
<code>40007</code>
|
<code>40007</code>
|
||||||
<desc>invalid media_id</desc>
|
<text>无效的media_id</text>
|
||||||
<text>请检查您的素材!</text>
|
|
||||||
</error>
|
</error>
|
||||||
<error>
|
<error>
|
||||||
<code>40008</code>
|
<code>40008</code>
|
||||||
@ -136,7 +133,7 @@
|
|||||||
</error>
|
</error>
|
||||||
<error>
|
<error>
|
||||||
<code>40031</code>
|
<code>40031</code>
|
||||||
<text>不合法的粉丝列表</text>
|
<text>不合法的openid列表</text>
|
||||||
</error>
|
</error>
|
||||||
<error>
|
<error>
|
||||||
<code>40032</code>
|
<code>40032</code>
|
||||||
@ -264,7 +261,7 @@
|
|||||||
</error>
|
</error>
|
||||||
<error>
|
<error>
|
||||||
<code>40073</code>
|
<code>40073</code>
|
||||||
<text>不合法的cardid</text>
|
<text>不合法的openid</text>
|
||||||
</error>
|
</error>
|
||||||
<error>
|
<error>
|
||||||
<code>40074</code>
|
<code>40074</code>
|
||||||
@ -342,10 +339,6 @@
|
|||||||
<code>40116</code>
|
<code>40116</code>
|
||||||
<text>不合法的Code码。</text>
|
<text>不合法的Code码。</text>
|
||||||
</error>
|
</error>
|
||||||
<error>
|
|
||||||
<code>40113</code>
|
|
||||||
<text>不支持的文件类型</text>
|
|
||||||
</error>
|
|
||||||
<error>
|
<error>
|
||||||
<code>40117</code>
|
<code>40117</code>
|
||||||
<text>分组名字不合法</text>
|
<text>分组名字不合法</text>
|
||||||
@ -382,15 +375,6 @@
|
|||||||
<code>40132</code>
|
<code>40132</code>
|
||||||
<text>微信号不合法</text>
|
<text>微信号不合法</text>
|
||||||
</error>
|
</error>
|
||||||
<error>
|
|
||||||
<code>40130</code>
|
|
||||||
<text>最少选择两名粉丝</text>
|
|
||||||
</error>
|
|
||||||
<error>
|
|
||||||
<code>40132</code>
|
|
||||||
<desc>invalid username</desc>
|
|
||||||
<text>无效的微信号</text>
|
|
||||||
</error>
|
|
||||||
<error>
|
<error>
|
||||||
<code>40137</code>
|
<code>40137</code>
|
||||||
<text>不支持的图片格式</text>
|
<text>不支持的图片格式</text>
|
||||||
@ -549,8 +533,7 @@
|
|||||||
</error>
|
</error>
|
||||||
<error>
|
<error>
|
||||||
<code>43004</code>
|
<code>43004</code>
|
||||||
<desc>require subscribe</desc>
|
<text>需要接收者关注</text>
|
||||||
<text>未关注公众号</text>
|
|
||||||
</error>
|
</error>
|
||||||
<error>
|
<error>
|
||||||
<code>43005</code>
|
<code>43005</code>
|
||||||
@ -610,23 +593,19 @@
|
|||||||
</error>
|
</error>
|
||||||
<error>
|
<error>
|
||||||
<code>45001</code>
|
<code>45001</code>
|
||||||
<desc>media size out of limit</desc>
|
<text>多媒体文件大小超过限制</text>
|
||||||
<text>多媒体文件大小超过微信限制</text>
|
|
||||||
</error>
|
</error>
|
||||||
<error>
|
<error>
|
||||||
<code>45002</code>
|
<code>45002</code>
|
||||||
<desc>content size out of limit</desc>
|
<text>消息内容超过限制</text>
|
||||||
<text>发送内容超过限制</text>
|
|
||||||
</error>
|
</error>
|
||||||
<error>
|
<error>
|
||||||
<code>45003</code>
|
<code>45003</code>
|
||||||
<desc>title size out of limit</desc>
|
<text>标题字段超过限制</text>
|
||||||
<text>标题超过限制</text>
|
|
||||||
</error>
|
</error>
|
||||||
<error>
|
<error>
|
||||||
<code>45004</code>
|
<code>45004</code>
|
||||||
<desc>description size out of limit</desc>
|
<text>描述字段超过限制</text>
|
||||||
<text>描述超过限制</text>
|
|
||||||
</error>
|
</error>
|
||||||
<error>
|
<error>
|
||||||
<code>45005</code>
|
<code>45005</code>
|
||||||
@ -672,10 +651,6 @@
|
|||||||
<code>45021</code>
|
<code>45021</code>
|
||||||
<text>字段超过长度限制,请参考相应接口的字段说明。</text>
|
<text>字段超过长度限制,请参考相应接口的字段说明。</text>
|
||||||
</error>
|
</error>
|
||||||
<error>
|
|
||||||
<code>45028</code>
|
|
||||||
<text>群发次数超过限制</text>
|
|
||||||
</error>
|
|
||||||
<error>
|
<error>
|
||||||
<code>45022</code>
|
<code>45022</code>
|
||||||
<text>应用名字长度不合法,合法长度为2-16个字</text>
|
<text>应用名字长度不合法,合法长度为2-16个字</text>
|
||||||
@ -740,32 +715,10 @@
|
|||||||
<code>45058</code>
|
<code>45058</code>
|
||||||
<text>不能修改0/1/2这三个系统默认保留的标签</text>
|
<text>不能修改0/1/2这三个系统默认保留的标签</text>
|
||||||
</error>
|
</error>
|
||||||
<error>
|
|
||||||
<code>48001</code>
|
|
||||||
<text>公众号没有调用该接口的权限</text>
|
|
||||||
</error>
|
|
||||||
<error>
|
|
||||||
<code>48002</code>
|
|
||||||
<text>公众号没有调用该接口的权限</text>
|
|
||||||
</error>
|
|
||||||
<error>
|
|
||||||
<code>48003</code>
|
|
||||||
<text>请登录公众号后台,打开“群发功能”,同意腾讯群发消息声明</text>
|
|
||||||
</error>
|
|
||||||
<!-- 多客服API错误 -->
|
|
||||||
<error>
|
<error>
|
||||||
<code>45059</code>
|
<code>45059</code>
|
||||||
<text>有粉丝身上的标签数已经超过限制</text>
|
<text>有粉丝身上的标签数已经超过限制</text>
|
||||||
</error>
|
</error>
|
||||||
<error>
|
|
||||||
<code>48005</code>
|
|
||||||
<text>此素材被自定义菜单引用,请先解除引用关系再编辑素材</text>
|
|
||||||
<desc>forbid to delete material used by auto-reply or menu hint: [JMOD7a0063e292]</desc>
|
|
||||||
</error>
|
|
||||||
<error>
|
|
||||||
<code>61450</code>
|
|
||||||
<text>系统错误(system error)</text>
|
|
||||||
</error>
|
|
||||||
<error>
|
<error>
|
||||||
<code>45157</code>
|
<code>45157</code>
|
||||||
<text>标签名非法,请注意不能和其他标签重名</text>
|
<text>标签名非法,请注意不能和其他标签重名</text>
|
||||||
@ -2467,8 +2420,8 @@
|
|||||||
<text>金额不匹配,报关的订单金额必须和支付的金额一致,请检查报关订单的金额是否正确</text>
|
<text>金额不匹配,报关的订单金额必须和支付的金额一致,请检查报关订单的金额是否正确</text>
|
||||||
</error>
|
</error>
|
||||||
<error>
|
<error>
|
||||||
<code>9001007</code>
|
<code>POST_DATA_EMPTY</code>
|
||||||
<text>上传文件无效</text>
|
<text>post数据为空,post数据不能为空,请检查post数据是否为空</text>
|
||||||
</error>
|
</error>
|
||||||
<error>
|
<error>
|
||||||
<code>REQUIRE_POST_METHOD</code>
|
<code>REQUIRE_POST_METHOD</code>
|
||||||
@ -2479,8 +2432,9 @@
|
|||||||
<text>输入的参数xml格式有误,检查输入的xml格式是否正确</text>
|
<text>输入的参数xml格式有误,检查输入的xml格式是否正确</text>
|
||||||
</error>
|
</error>
|
||||||
<error>
|
<error>
|
||||||
<code>9001010</code>
|
<code>SECOND_OVER_LIMITED</code>
|
||||||
<text>文件上传到微信失败</text>
|
<text>企业红包的按分钟发放受限,每分钟发送红包数量不得超过1800个;(可联系微信支付wxhongbao@tencent.com调高额度)
|
||||||
|
</text>
|
||||||
</error>
|
</error>
|
||||||
<error>
|
<error>
|
||||||
<code>SENDNUM_LIMIT</code>
|
<code>SENDNUM_LIMIT</code>
|
||||||
|
|||||||
@ -3,7 +3,6 @@ package com.foxinmy.weixin4j.model;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import com.alibaba.fastjson.annotation.JSONField;
|
|
||||||
import com.foxinmy.weixin4j.cache.Cacheable;
|
import com.foxinmy.weixin4j.cache.Cacheable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -26,12 +25,10 @@ public class Token implements Cacheable {
|
|||||||
/**
|
/**
|
||||||
* 获取到的凭证
|
* 获取到的凭证
|
||||||
*/
|
*/
|
||||||
@JSONField(name = "access_token")
|
|
||||||
private String accessToken;
|
private String accessToken;
|
||||||
/**
|
/**
|
||||||
* 凭证有效时间,单位:毫秒
|
* 凭证有效时间,单位:毫秒
|
||||||
*/
|
*/
|
||||||
@JSONField(name = "expires_in")
|
|
||||||
private long expires;
|
private long expires;
|
||||||
/**
|
/**
|
||||||
* token创建的时间,单位:毫秒
|
* token创建的时间,单位:毫秒
|
||||||
@ -42,11 +39,6 @@ public class Token implements Cacheable {
|
|||||||
*/
|
*/
|
||||||
private Map<String, String> extra;
|
private Map<String, String> extra;
|
||||||
|
|
||||||
/**
|
|
||||||
* 请求返回的原始结果
|
|
||||||
*/
|
|
||||||
private String originalResult;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 永不过期、创建时间为当前时间戳的token对象
|
* 永不过期、创建时间为当前时间戳的token对象
|
||||||
*
|
*
|
||||||
@ -63,7 +55,7 @@ public class Token implements Cacheable {
|
|||||||
* @param accessToken
|
* @param accessToken
|
||||||
* 凭证字符串
|
* 凭证字符串
|
||||||
* @param expires
|
* @param expires
|
||||||
* 过期时间 单位秒
|
* 过期时间 单位毫秒
|
||||||
*/
|
*/
|
||||||
public Token(String accessToken, long expires) {
|
public Token(String accessToken, long expires) {
|
||||||
this(accessToken, expires, System.currentTimeMillis());
|
this(accessToken, expires, System.currentTimeMillis());
|
||||||
@ -85,26 +77,6 @@ public class Token implements Cacheable {
|
|||||||
this.extra = new HashMap<String, String>();
|
this.extra = new HashMap<String, String>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setAccessToken(String accessToken) {
|
|
||||||
this.accessToken = accessToken;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setExpires(long expires) {
|
|
||||||
this.expires = expires;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setCreateTime(long createTime) {
|
|
||||||
this.createTime = createTime;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getOriginalResult() {
|
|
||||||
return originalResult;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setOriginalResult(String originalResult) {
|
|
||||||
this.originalResult = originalResult;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getAccessToken() {
|
public String getAccessToken() {
|
||||||
return accessToken;
|
return accessToken;
|
||||||
}
|
}
|
||||||
@ -128,8 +100,6 @@ public class Token implements Cacheable {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "Token [accessToken=" + accessToken + ", expires=" + expires
|
return "Token [accessToken=" + accessToken + ", expires=" + expires
|
||||||
|
|||||||
@ -469,7 +469,7 @@ public class WeixinPayProxy {
|
|||||||
*
|
*
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
*
|
*
|
||||||
* @see {@link #applyRefund(IdQuery, String, double, double,CurrencyType,String,RefundAccountType)}
|
* @see {@link #applyRefund(IdQuery, String, double, double, String,CurrencyType)}
|
||||||
*/
|
*/
|
||||||
public RefundResult applyRefund(IdQuery idQuery, String outRefundNo,
|
public RefundResult applyRefund(IdQuery idQuery, String outRefundNo,
|
||||||
double totalFee) throws WeixinException {
|
double totalFee) throws WeixinException {
|
||||||
|
|||||||
@ -20,8 +20,8 @@ import com.foxinmy.weixin4j.util.MapUtil;
|
|||||||
* href="https://pay.weixin.qq.com/wiki/doc/api/app/app.php?chapter=8_1">APP支付</a>
|
* href="https://pay.weixin.qq.com/wiki/doc/api/app/app.php?chapter=8_1">APP支付</a>
|
||||||
*/
|
*/
|
||||||
public class APPPayRequest extends AbstractPayRequest {
|
public class APPPayRequest extends AbstractPayRequest {
|
||||||
public APPPayRequest(PrePay prePay, WeixinPayAccount payAccount) {
|
public APPPayRequest(String prePayId, WeixinPayAccount payAccount) {
|
||||||
super(prePay.getPrepayId(),prePay.getResponse(), payAccount);
|
super(prePayId, payAccount);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@ -10,14 +10,10 @@ public abstract class AbstractPayRequest implements MchPayRequest {
|
|||||||
private final WeixinPayAccount paymentAccount;
|
private final WeixinPayAccount paymentAccount;
|
||||||
protected final WeixinSignature weixinSignature;
|
protected final WeixinSignature weixinSignature;
|
||||||
|
|
||||||
protected final String payResponse;
|
public AbstractPayRequest(String prePayId, WeixinPayAccount paymentAccount) {
|
||||||
|
|
||||||
public AbstractPayRequest(String prePayId, String payResponse, WeixinPayAccount paymentAccount) {
|
|
||||||
this.prePayId = prePayId;
|
this.prePayId = prePayId;
|
||||||
this.payResponse = payResponse;
|
|
||||||
this.paymentAccount = paymentAccount;
|
this.paymentAccount = paymentAccount;
|
||||||
this.weixinSignature = new WeixinPaymentSignature(paymentAccount.getPaySignKey());
|
this.weixinSignature = new WeixinPaymentSignature(paymentAccount.getPaySignKey());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -29,10 +25,4 @@ public abstract class AbstractPayRequest implements MchPayRequest {
|
|||||||
public WeixinPayAccount getPaymentAccount() {
|
public WeixinPayAccount getPaymentAccount() {
|
||||||
return this.paymentAccount;
|
return this.paymentAccount;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getResponseString() {
|
|
||||||
return payResponse;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@ -25,8 +25,8 @@ import com.foxinmy.weixin4j.type.TradeType;
|
|||||||
*/
|
*/
|
||||||
public class JSAPIPayRequest extends AbstractPayRequest {
|
public class JSAPIPayRequest extends AbstractPayRequest {
|
||||||
|
|
||||||
public JSAPIPayRequest(PrePay prePay, WeixinPayAccount payAccount) {
|
public JSAPIPayRequest(String prePayId, WeixinPayAccount payAccount) {
|
||||||
super(prePay.getPrepayId(), prePay.getResponse(), payAccount);
|
super(prePayId, payAccount);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@ -27,8 +27,6 @@ public class MICROPayRequest extends Order implements MchPayRequest {
|
|||||||
@JSONField(serialize = false)
|
@JSONField(serialize = false)
|
||||||
private WeixinPayAccount paymentAccount;
|
private WeixinPayAccount paymentAccount;
|
||||||
|
|
||||||
private String response;
|
|
||||||
|
|
||||||
protected MICROPayRequest() {
|
protected MICROPayRequest() {
|
||||||
// jaxb required
|
// jaxb required
|
||||||
}
|
}
|
||||||
@ -57,16 +55,6 @@ public class MICROPayRequest extends Order implements MchPayRequest {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void setResponse(String response) {
|
|
||||||
this.response = response;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getResponseString() {
|
|
||||||
return response;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <font color="red">返回null,请不要尝试作为支付请求</font>
|
* <font color="red">返回null,请不要尝试作为支付请求</font>
|
||||||
*/
|
*/
|
||||||
|
|||||||
@ -108,38 +108,6 @@ public class MchPayPackage extends PayPackage {
|
|||||||
null, null, null, null);
|
null, null, null, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 微信支付
|
|
||||||
*
|
|
||||||
* @param body
|
|
||||||
* 支付详情 必填
|
|
||||||
* @param outTradeNo
|
|
||||||
* 商户侧订单号 必填
|
|
||||||
* @param totalFee
|
|
||||||
* 支付金额(单位元) 必填
|
|
||||||
* @param notifyUrl
|
|
||||||
* 支付回调URL 必填
|
|
||||||
* @param createIp
|
|
||||||
* 发起支付的IP地址 必填
|
|
||||||
* @param tradeType
|
|
||||||
* 支付类型 必填
|
|
||||||
* @param openId
|
|
||||||
* 用户唯一标识 公众号JSAPI支付必填
|
|
||||||
* @param authCode
|
|
||||||
* 支付授权码 刷卡MICROPAY支付必填
|
|
||||||
* @param productId
|
|
||||||
* 商品ID 扫码NATIVE支付必填
|
|
||||||
* @param attach
|
|
||||||
* 支付时附加信息 非必填
|
|
||||||
*/
|
|
||||||
public MchPayPackage(String body, String outTradeNo, long totalFee,
|
|
||||||
String notifyUrl, String createIp, TradeType tradeType,
|
|
||||||
String openId, String authCode, String productId, String attach) {
|
|
||||||
this(body, null, outTradeNo, totalFee, notifyUrl, createIp, tradeType,
|
|
||||||
openId, authCode, productId, attach, null, null, null, null,
|
|
||||||
null);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 完整参数
|
* 完整参数
|
||||||
*
|
*
|
||||||
@ -179,12 +147,12 @@ public class MchPayPackage extends PayPackage {
|
|||||||
* 用户在子商户appid下的唯一标识 非必填
|
* 用户在子商户appid下的唯一标识 非必填
|
||||||
* openid和sub_openid可以选传其中之一,如果选择传sub_openid ,则必须传sub_appid
|
* openid和sub_openid可以选传其中之一,如果选择传sub_openid ,则必须传sub_appid
|
||||||
*/
|
*/
|
||||||
public MchPayPackage(String body, String detail, String outTradeNo,
|
public MchPayPackage(String body, String detial, String outTradeNo,
|
||||||
double totalFee, CurrencyType feeType, String notifyUrl,
|
double totalFee, CurrencyType feeType, String notifyUrl,
|
||||||
String createIp, TradeType tradeType, String openId,
|
String createIp, TradeType tradeType, String openId,
|
||||||
String authCode, String productId, String attach, Date timeStart,
|
String authCode, String productId, String attach, Date timeStart,
|
||||||
Date timeExpire, String goodsTag, String limitPay, String subOpenId) {
|
Date timeExpire, String goodsTag, String limitPay, String subOpenId) {
|
||||||
super(body, detail, outTradeNo, totalFee, notifyUrl, createIp, attach,
|
super(body, detial, outTradeNo, totalFee, notifyUrl, createIp, attach,
|
||||||
timeStart, timeExpire, goodsTag);
|
timeStart, timeExpire, goodsTag);
|
||||||
this.tradeType = tradeType != null ? tradeType.name() : null;
|
this.tradeType = tradeType != null ? tradeType.name() : null;
|
||||||
this.feeType = feeType == null ? CurrencyType.CNY.name() : feeType
|
this.feeType = feeType == null ? CurrencyType.CNY.name() : feeType
|
||||||
@ -196,58 +164,6 @@ public class MchPayPackage extends PayPackage {
|
|||||||
this.subOpenId = subOpenId;
|
this.subOpenId = subOpenId;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 完整参数
|
|
||||||
*
|
|
||||||
* @param body
|
|
||||||
* 商品描述 <font color="red">必填项</font>
|
|
||||||
* @param detail
|
|
||||||
* 商品名称明细列表 非必填项
|
|
||||||
* @param outTradeNo
|
|
||||||
* 商户内部唯一订单号 <font color="red">必填项</font>
|
|
||||||
* @param totalFee
|
|
||||||
* 商品总额 单位元 <font color="red">必填项</font>
|
|
||||||
* @param notifyUrl
|
|
||||||
* 支付回调URL <font color="red">必填项</font>
|
|
||||||
* @param createIp
|
|
||||||
* 订单生成的机器IP <font color="red">必填项</font>
|
|
||||||
* @param tradeType
|
|
||||||
* 交易类型 <font color="red">必填项</font>
|
|
||||||
* @param openId
|
|
||||||
* 用户ID <font color="red">tradeType=JSAPI时必填</font>
|
|
||||||
* @param authCode
|
|
||||||
* 刷卡支付授权码 <font color="red">tradeType=MICROPAY时必填</font>
|
|
||||||
* @param productId
|
|
||||||
* 产品ID <font color="red">tradeType=NATIVE时必填</font>
|
|
||||||
* @param attach
|
|
||||||
* 附加数据,在查询API和支付通知中原样返回,该字段主要用于商户携带订单的自定义数据 非必填项
|
|
||||||
* @param timeStart
|
|
||||||
* 订单生成时间,格式为yyyyMMddHHmmss 非必填项
|
|
||||||
* @param timeExpire
|
|
||||||
* 订单失效时间,格式为yyyyMMddHHmmss;注意:最短失效时间间隔必须大于5分钟 非必填项
|
|
||||||
* @param goodsTag
|
|
||||||
* 商品标记,代金券或立减优惠功能的参数 非必填项
|
|
||||||
* @param limitPay
|
|
||||||
* 指定支付方式:no_credit--指定不能使用信用卡支付 非必填项
|
|
||||||
* @param subOpenId
|
|
||||||
* 用户在子商户appid下的唯一标识 非必填
|
|
||||||
* openid和sub_openid可以选传其中之一,如果选择传sub_openid ,则必须传sub_appid
|
|
||||||
*/
|
|
||||||
public MchPayPackage(String body, String detail, String outTradeNo,
|
|
||||||
long totalFee, String notifyUrl, String createIp,
|
|
||||||
TradeType tradeType, String openId, String authCode,
|
|
||||||
String productId, String attach, Date timeStart, Date timeExpire,
|
|
||||||
String goodsTag, String limitPay, String subOpenId) {
|
|
||||||
super(body, detail, outTradeNo, totalFee, notifyUrl, createIp, attach,
|
|
||||||
timeStart, timeExpire, goodsTag);
|
|
||||||
this.tradeType = tradeType.name();
|
|
||||||
this.openId = openId;
|
|
||||||
this.authCode = authCode;
|
|
||||||
this.productId = productId;
|
|
||||||
this.limitPay = limitPay;
|
|
||||||
this.subOpenId = subOpenId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getTradeType() {
|
public String getTradeType() {
|
||||||
return tradeType;
|
return tradeType;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -52,10 +52,4 @@ public interface MchPayRequest {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public PayRequest toRequestObject();
|
public PayRequest toRequestObject();
|
||||||
|
|
||||||
/**
|
|
||||||
* 支付请求返回的结果
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public String getResponseString();
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -20,9 +20,9 @@ public class NATIVEPayRequest extends AbstractPayRequest {
|
|||||||
|
|
||||||
private final String codeUrl;
|
private final String codeUrl;
|
||||||
|
|
||||||
public NATIVEPayRequest(PrePay prePay, String codeUrl,
|
public NATIVEPayRequest(String prePayId, String codeUrl,
|
||||||
WeixinPayAccount payAccount) {
|
WeixinPayAccount payAccount) {
|
||||||
super(prePay.getPrepayId(), prePay.getResponse(), payAccount);
|
super(prePayId, payAccount);
|
||||||
this.codeUrl = codeUrl;
|
this.codeUrl = codeUrl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -6,7 +6,6 @@ import javax.xml.bind.annotation.XmlElement;
|
|||||||
import javax.xml.bind.annotation.XmlRootElement;
|
import javax.xml.bind.annotation.XmlRootElement;
|
||||||
|
|
||||||
import com.alibaba.fastjson.annotation.JSONField;
|
import com.alibaba.fastjson.annotation.JSONField;
|
||||||
import com.foxinmy.weixin4j.exception.WeixinPayException;
|
|
||||||
import com.foxinmy.weixin4j.model.WeixinPayAccount;
|
import com.foxinmy.weixin4j.model.WeixinPayAccount;
|
||||||
import com.foxinmy.weixin4j.sign.WeixinPaymentSignature;
|
import com.foxinmy.weixin4j.sign.WeixinPaymentSignature;
|
||||||
import com.foxinmy.weixin4j.util.Consts;
|
import com.foxinmy.weixin4j.util.Consts;
|
||||||
|
|||||||
@ -69,7 +69,7 @@ public class Order extends MerchantTradeResult {
|
|||||||
/**
|
/**
|
||||||
* 现金支付货币类型,符合 ISO 4217 标准的三位字母代码,默认人民币:CNY
|
* 现金支付货币类型,符合 ISO 4217 标准的三位字母代码,默认人民币:CNY
|
||||||
*
|
*
|
||||||
* @see com.foxinmy.weixin4j.type.CurrencyType
|
* @see com.foxinmy.weixin4j.mp.type.CurrencyType
|
||||||
*/
|
*/
|
||||||
@XmlElement(name = "cash_fee_type")
|
@XmlElement(name = "cash_fee_type")
|
||||||
@JSONField(name = "cash_fee_type")
|
@JSONField(name = "cash_fee_type")
|
||||||
|
|||||||
@ -40,8 +40,6 @@ public class PrePay extends MerchantResult {
|
|||||||
@XmlElement(name = "code_url")
|
@XmlElement(name = "code_url")
|
||||||
private String codeUrl;
|
private String codeUrl;
|
||||||
|
|
||||||
private String response;
|
|
||||||
|
|
||||||
protected PrePay() {
|
protected PrePay() {
|
||||||
// jaxb required
|
// jaxb required
|
||||||
}
|
}
|
||||||
@ -74,14 +72,6 @@ public class PrePay extends MerchantResult {
|
|||||||
this.codeUrl = codeUrl;
|
this.codeUrl = codeUrl;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getResponse() {
|
|
||||||
return response;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setResponse(String response) {
|
|
||||||
this.response = response;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "PrePay [tradeType=" + tradeType + ", prepayId=" + prepayId
|
return "PrePay [tradeType=" + tradeType + ", prepayId=" + prepayId
|
||||||
|
|||||||
@ -138,43 +138,6 @@ public class Redpacket extends MerchantResult {
|
|||||||
this.amtType = totalNum > 1 ? "ALL_RAND" : null;
|
this.amtType = totalNum > 1 ? "ALL_RAND" : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 红包
|
|
||||||
*
|
|
||||||
* @param outTradeNo
|
|
||||||
* 商户侧一天内不可重复的订单号 接口根据商户订单号支持重入 如出现超时可再调用 必填
|
|
||||||
* @param sendName
|
|
||||||
* 红包发送者名称 必填
|
|
||||||
* @param openId
|
|
||||||
* 接受收红包的用户的openid 必填
|
|
||||||
* @param totalAmount
|
|
||||||
* 付款金额 <font color="red">单位为分,自动格式化为分</font> 必填
|
|
||||||
* @param totalNum
|
|
||||||
* 红包发放总人数 大于1视为裂变红包 必填
|
|
||||||
* @param wishing
|
|
||||||
* 红包祝福语 必填
|
|
||||||
* @param clientIp
|
|
||||||
* Ip地址 必填
|
|
||||||
* @param actName
|
|
||||||
* 活动名称 必填
|
|
||||||
* @param remark
|
|
||||||
* 备注 必填
|
|
||||||
*/
|
|
||||||
public Redpacket(String outTradeNo, String sendName, String openId,
|
|
||||||
int totalAmount, int totalNum, String wishing, String clientIp,
|
|
||||||
String actName, String remark) {
|
|
||||||
this.outTradeNo = outTradeNo;
|
|
||||||
this.sendName = sendName;
|
|
||||||
this.openId = openId;
|
|
||||||
this.totalNum = totalNum;
|
|
||||||
this.wishing = wishing;
|
|
||||||
this.clientIp = clientIp;
|
|
||||||
this.actName = actName;
|
|
||||||
this.remark = remark;
|
|
||||||
this.totalAmount = totalAmount;
|
|
||||||
this.amtType = totalNum > 1 ? "ALL_RAND" : null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getOutTradeNo() {
|
public String getOutTradeNo() {
|
||||||
return outTradeNo;
|
return outTradeNo;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -22,8 +22,8 @@ import com.foxinmy.weixin4j.util.URLEncodingUtil;
|
|||||||
*/
|
*/
|
||||||
public class WAPPayRequest extends AbstractPayRequest {
|
public class WAPPayRequest extends AbstractPayRequest {
|
||||||
|
|
||||||
public WAPPayRequest(PrePay prePay, WeixinPayAccount payAccount) {
|
public WAPPayRequest(String prePayId, WeixinPayAccount payAccount) {
|
||||||
super(prePay.getPrepayId(),prePay.getResponse(), payAccount);
|
super(prePayId, payAccount);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@ -1,60 +1,36 @@
|
|||||||
package com.foxinmy.weixin4j.sign;
|
package com.foxinmy.weixin4j.sign;
|
||||||
|
|
||||||
import com.foxinmy.weixin4j.http.weixin.WeixinResponse;
|
|
||||||
import com.foxinmy.weixin4j.type.SignType;
|
import com.foxinmy.weixin4j.type.SignType;
|
||||||
import com.foxinmy.weixin4j.util.DigestUtil;
|
import com.foxinmy.weixin4j.util.DigestUtil;
|
||||||
import com.foxinmy.weixin4j.xml.XmlStream;
|
|
||||||
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 微信支付签名实现
|
* 微信支付签名实现
|
||||||
*
|
*
|
||||||
* @author jinyu(foxinmy@gmail.com)
|
|
||||||
* @className WeixinPaymentSignature
|
* @className WeixinPaymentSignature
|
||||||
|
* @author jinyu(foxinmy@gmail.com)
|
||||||
* @date 2016年3月26日
|
* @date 2016年3月26日
|
||||||
* @see <a
|
|
||||||
* href="https://pay.weixin.qq.com/wiki/doc/api/external/jsapi.php?chapter=4_3">支付签名说明</a>
|
|
||||||
* @since JDK 1.6
|
* @since JDK 1.6
|
||||||
|
* @see <a
|
||||||
|
* href="https://pay.weixin.qq.com/wiki/doc/api/external/jsapi.php?chapter=4_3">支付签名说明</a>
|
||||||
*/
|
*/
|
||||||
public class WeixinPaymentSignature extends AbstractWeixinSignature {
|
public class WeixinPaymentSignature extends AbstractWeixinSignature {
|
||||||
|
/**
|
||||||
|
* 支付密钥
|
||||||
|
*/
|
||||||
|
private final String paySignKey;
|
||||||
|
|
||||||
/**
|
public WeixinPaymentSignature(String paySignKey) {
|
||||||
* 支付密钥
|
this.paySignKey = paySignKey;
|
||||||
*/
|
}
|
||||||
private final String paySignKey;
|
|
||||||
|
|
||||||
public WeixinPaymentSignature(String paySignKey) {
|
|
||||||
this.paySignKey = paySignKey;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public SignType getSignType() {
|
|
||||||
return SignType.MD5;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String sign(Object obj) {
|
|
||||||
StringBuilder sb = join(obj).append("&key=").append(paySignKey);
|
|
||||||
return DigestUtil.MD5(sb.toString()).toUpperCase();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public boolean validatePaySign(WeixinResponse weixinResponse) {
|
|
||||||
return this.validatePaySign(weixinResponse.getAsString());
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean validatePaySign(String xmlResult) {
|
|
||||||
return this.validatePaySign(XmlStream.xml2map(xmlResult));
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean validatePaySign(Map<String, String> map) {
|
|
||||||
String sign1 = map.get("sign");
|
|
||||||
map.remove("sign");
|
|
||||||
String sign2 = this.sign(map);
|
|
||||||
return sign1.equals(sign2);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public SignType getSignType() {
|
||||||
|
return SignType.MD5;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String sign(Object obj) {
|
||||||
|
StringBuilder sb = join(obj).append("&key=").append(paySignKey);
|
||||||
|
return DigestUtil.MD5(sb.toString()).toUpperCase();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
2
weixin4j-example/.gitignore
vendored
2
weixin4j-example/.gitignore
vendored
@ -31,3 +31,5 @@ Thumbs.db
|
|||||||
/target/
|
/target/
|
||||||
.DS_Store
|
.DS_Store
|
||||||
bin
|
bin
|
||||||
|
/target/
|
||||||
|
/target/
|
||||||
|
|||||||
2
weixin4j-mp/.gitignore
vendored
2
weixin4j-mp/.gitignore
vendored
@ -30,3 +30,5 @@ target/*
|
|||||||
Thumbs.db
|
Thumbs.db
|
||||||
/target/
|
/target/
|
||||||
.DS_Store
|
.DS_Store
|
||||||
|
/target/
|
||||||
|
/target/
|
||||||
|
|||||||
@ -1,21 +1,19 @@
|
|||||||
package com.foxinmy.weixin4j.mp.api;
|
package com.foxinmy.weixin4j.mp.api;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import com.alibaba.fastjson.JSON;
|
import com.alibaba.fastjson.JSON;
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import com.foxinmy.weixin4j.exception.WeixinException;
|
import com.foxinmy.weixin4j.exception.WeixinException;
|
||||||
import com.foxinmy.weixin4j.http.weixin.ApiResult;
|
import com.foxinmy.weixin4j.http.weixin.ApiResult;
|
||||||
import com.foxinmy.weixin4j.http.weixin.WeixinResponse;
|
import com.foxinmy.weixin4j.http.weixin.WeixinResponse;
|
||||||
import com.foxinmy.weixin4j.model.Token;
|
import com.foxinmy.weixin4j.model.Token;
|
||||||
import com.foxinmy.weixin4j.model.paging.Pageable;
|
|
||||||
import com.foxinmy.weixin4j.model.paging.Pagedata;
|
import com.foxinmy.weixin4j.model.paging.Pagedata;
|
||||||
import com.foxinmy.weixin4j.mp.model.shakearound.Device;
|
import com.foxinmy.weixin4j.mp.model.shakearound.Device;
|
||||||
import com.foxinmy.weixin4j.mp.model.shakearound.DeviceAuditState;
|
import com.foxinmy.weixin4j.mp.model.shakearound.DeviceAuditState;
|
||||||
import com.foxinmy.weixin4j.mp.model.shakearound.ShakeUserInfo;
|
import com.foxinmy.weixin4j.mp.model.shakearound.ShakeUserInfo;
|
||||||
import com.foxinmy.weixin4j.token.TokenManager;
|
import com.foxinmy.weixin4j.token.TokenManager;
|
||||||
import com.sun.javafx.binding.StringFormatter;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 摇一摇周边
|
* 摇一摇周边
|
||||||
|
|||||||
2
weixin4j-qy/.gitignore
vendored
2
weixin4j-qy/.gitignore
vendored
@ -30,3 +30,5 @@ target/*
|
|||||||
Thumbs.db
|
Thumbs.db
|
||||||
/target/
|
/target/
|
||||||
.DS_Store
|
.DS_Store
|
||||||
|
/target/
|
||||||
|
/target/
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user