mirror of
https://gitee.com/binary/weixin-java-tools.git
synced 2025-04-30 12:47:46 +08:00
优化部分代码
This commit is contained in:
parent
5bd2d209db
commit
48d3163b33
@ -13,8 +13,11 @@ import me.chanjar.weixin.common.util.RandomUtils;
|
||||
import me.chanjar.weixin.common.util.crypto.SHA1;
|
||||
import me.chanjar.weixin.common.util.http.*;
|
||||
import me.chanjar.weixin.mp.api.*;
|
||||
import me.chanjar.weixin.mp.bean.*;
|
||||
import me.chanjar.weixin.mp.bean.result.*;
|
||||
import me.chanjar.weixin.mp.bean.WxMpSemanticQuery;
|
||||
import me.chanjar.weixin.mp.bean.result.WxMpCurrentAutoReplyInfo;
|
||||
import me.chanjar.weixin.mp.bean.result.WxMpOAuth2AccessToken;
|
||||
import me.chanjar.weixin.mp.bean.result.WxMpSemanticQueryResult;
|
||||
import me.chanjar.weixin.mp.bean.result.WxMpUser;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
@ -22,7 +25,7 @@ import org.slf4j.LoggerFactory;
|
||||
import java.io.IOException;
|
||||
import java.util.concurrent.locks.Lock;
|
||||
|
||||
public abstract class WxMpServiceAbstractImpl<H, P> implements WxMpService, RequestHttp<H, P> {
|
||||
public abstract class WxMpServiceBaseImpl<H, P> implements WxMpService, RequestHttp<H, P> {
|
||||
|
||||
private static final JsonParser JSON_PARSER = new JsonParser();
|
||||
|
||||
@ -92,14 +95,14 @@ public abstract class WxMpServiceAbstractImpl<H, P> implements WxMpService, Requ
|
||||
@Override
|
||||
public WxJsapiSignature createJsapiSignature(String url) throws WxErrorException {
|
||||
long timestamp = System.currentTimeMillis() / 1000;
|
||||
String noncestr = RandomUtils.getRandomStr();
|
||||
String randomStr = RandomUtils.getRandomStr();
|
||||
String jsapiTicket = getJsapiTicket(false);
|
||||
String signature = SHA1.genWithAmple("jsapi_ticket=" + jsapiTicket,
|
||||
"noncestr=" + noncestr, "timestamp=" + timestamp, "url=" + url);
|
||||
"noncestr=" + randomStr, "timestamp=" + timestamp, "url=" + url);
|
||||
WxJsapiSignature jsapiSignature = new WxJsapiSignature();
|
||||
jsapiSignature.setAppId(this.getWxMpConfigStorage().getAppId());
|
||||
jsapiSignature.setTimestamp(timestamp);
|
||||
jsapiSignature.setNonceStr(noncestr);
|
||||
jsapiSignature.setNonceStr(randomStr);
|
||||
jsapiSignature.setUrl(url);
|
||||
jsapiSignature.setSignature(signature);
|
||||
return jsapiSignature;
|
||||
@ -111,10 +114,10 @@ public abstract class WxMpServiceAbstractImpl<H, P> implements WxMpService, Requ
|
||||
}
|
||||
|
||||
@Override
|
||||
public String shortUrl(String long_url) throws WxErrorException {
|
||||
public String shortUrl(String longUrl) throws WxErrorException {
|
||||
JsonObject o = new JsonObject();
|
||||
o.addProperty("action", "long2short");
|
||||
o.addProperty("long_url", long_url);
|
||||
o.addProperty("long_url", longUrl);
|
||||
String responseContent = this.post(WxMpService.SHORTURL_API_URL, o.toString());
|
||||
JsonElement tmpJsonElement = JSON_PARSER.parse(responseContent);
|
||||
return tmpJsonElement.getAsJsonObject().get("short_url").getAsString();
|
||||
@ -161,12 +164,12 @@ public abstract class WxMpServiceAbstractImpl<H, P> implements WxMpService, Requ
|
||||
}
|
||||
|
||||
@Override
|
||||
public WxMpUser oauth2getUserInfo(WxMpOAuth2AccessToken oAuth2AccessToken, String lang) throws WxErrorException {
|
||||
public WxMpUser oauth2getUserInfo(WxMpOAuth2AccessToken token, String lang) throws WxErrorException {
|
||||
if (lang == null) {
|
||||
lang = "zh_CN";
|
||||
}
|
||||
|
||||
String url = String.format(WxMpService.OAUTH2_USERINFO_URL, oAuth2AccessToken.getAccessToken(), oAuth2AccessToken.getOpenId(), lang);
|
||||
String url = String.format(WxMpService.OAUTH2_USERINFO_URL, token.getAccessToken(), token.getOpenId(), lang);
|
||||
|
||||
try {
|
||||
RequestExecutor<String, String> executor = SimpleGetRequestExecutor.create(this);
|
||||
@ -178,8 +181,8 @@ public abstract class WxMpServiceAbstractImpl<H, P> implements WxMpService, Requ
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean oauth2validateAccessToken(WxMpOAuth2AccessToken oAuth2AccessToken) {
|
||||
String url = String.format(WxMpService.OAUTH2_VALIDATE_TOKEN_URL, oAuth2AccessToken.getAccessToken(), oAuth2AccessToken.getOpenId());
|
||||
public boolean oauth2validateAccessToken(WxMpOAuth2AccessToken token) {
|
||||
String url = String.format(WxMpService.OAUTH2_VALIDATE_TOKEN_URL, token.getAccessToken(), token.getOpenId());
|
||||
|
||||
try {
|
||||
SimpleGetRequestExecutor.create(this).execute(url, null);
|
||||
@ -226,7 +229,7 @@ public abstract class WxMpServiceAbstractImpl<H, P> implements WxMpService, Requ
|
||||
}
|
||||
|
||||
/**
|
||||
* 向微信端发送请求,在这里执行的策略是当发生access_token过期时才去刷新,然后重新执行请求,而不是全局定时请求
|
||||
* 向微信端发送请求,在这里执行的策略是当发生access_token过期时才去刷新,然后重新执行请求,而不是全局定时请求.
|
||||
*/
|
||||
@Override
|
||||
public <T, E> T execute(RequestExecutor<T, E> executor, String uri, E data) throws WxErrorException {
|
||||
@ -265,6 +268,7 @@ public abstract class WxMpServiceAbstractImpl<H, P> implements WxMpService, Requ
|
||||
if (uri.contains("access_token=")) {
|
||||
throw new IllegalArgumentException("uri参数中不允许有access_token: " + uri);
|
||||
}
|
||||
|
||||
String accessToken = getAccessToken(false);
|
||||
|
||||
String uriWithAccessToken = uri + (uri.contains("?") ? "&" : "?") + "access_token=" + accessToken;
|
||||
@ -296,7 +300,7 @@ public abstract class WxMpServiceAbstractImpl<H, P> implements WxMpService, Requ
|
||||
return null;
|
||||
} catch (IOException e) {
|
||||
this.log.error("\n【请求地址】: {}\n【请求参数】:{}\n【异常信息】:{}", uriWithAccessToken, data, e.getMessage());
|
||||
throw new RuntimeException(e);
|
||||
throw new WxErrorException(WxError.builder().errorMsg(e.getMessage()).build(), e);
|
||||
}
|
||||
}
|
||||
|
@ -19,9 +19,9 @@ import java.io.IOException;
|
||||
import java.util.concurrent.locks.Lock;
|
||||
|
||||
/**
|
||||
* apache-http方式实现
|
||||
* apache http client方式实现.
|
||||
*/
|
||||
public class WxMpServiceApacheHttpClientImpl extends WxMpServiceAbstractImpl<CloseableHttpClient, HttpHost> {
|
||||
public class WxMpServiceHttpClientImpl extends WxMpServiceBaseImpl<CloseableHttpClient, HttpHost> {
|
||||
private CloseableHttpClient httpClient;
|
||||
private HttpHost httpProxy;
|
||||
|
@ -8,5 +8,5 @@ package me.chanjar.weixin.mp.api.impl;
|
||||
*
|
||||
* @author <a href="https://github.com/binarywang">Binary Wang</a>
|
||||
*/
|
||||
public class WxMpServiceImpl extends WxMpServiceApacheHttpClientImpl {
|
||||
public class WxMpServiceImpl extends WxMpServiceHttpClientImpl {
|
||||
}
|
||||
|
@ -14,7 +14,7 @@ import java.util.concurrent.locks.Lock;
|
||||
/**
|
||||
* jodd-http方式实现
|
||||
*/
|
||||
public class WxMpServiceJoddHttpImpl extends WxMpServiceAbstractImpl<HttpConnectionProvider, ProxyInfo> {
|
||||
public class WxMpServiceJoddHttpImpl extends WxMpServiceBaseImpl<HttpConnectionProvider, ProxyInfo> {
|
||||
private HttpConnectionProvider httpClient;
|
||||
private ProxyInfo httpProxy;
|
||||
|
||||
|
@ -11,7 +11,10 @@ import okhttp3.*;
|
||||
import java.io.IOException;
|
||||
import java.util.concurrent.locks.Lock;
|
||||
|
||||
public class WxMpServiceOkHttpImpl extends WxMpServiceAbstractImpl<OkHttpClient, OkHttpProxyInfo> {
|
||||
/**
|
||||
* okhttp实现
|
||||
*/
|
||||
public class WxMpServiceOkHttpImpl extends WxMpServiceBaseImpl<OkHttpClient, OkHttpProxyInfo> {
|
||||
private OkHttpClient httpClient;
|
||||
private OkHttpProxyInfo httpProxy;
|
||||
|
||||
|
@ -3,7 +3,7 @@ package me.chanjar.weixin.mp.api;
|
||||
import me.chanjar.weixin.common.bean.result.WxError;
|
||||
import me.chanjar.weixin.common.exception.WxErrorException;
|
||||
import me.chanjar.weixin.common.util.http.RequestExecutor;
|
||||
import me.chanjar.weixin.mp.api.impl.WxMpServiceApacheHttpClientImpl;
|
||||
import me.chanjar.weixin.mp.api.impl.WxMpServiceHttpClientImpl;
|
||||
import org.testng.annotations.*;
|
||||
|
||||
import java.util.concurrent.ExecutionException;
|
||||
@ -16,7 +16,7 @@ public class WxMpBusyRetryTest {
|
||||
|
||||
@DataProvider(name = "getService")
|
||||
public Object[][] getService() {
|
||||
WxMpService service = new WxMpServiceApacheHttpClientImpl() {
|
||||
WxMpService service = new WxMpServiceHttpClientImpl() {
|
||||
|
||||
@Override
|
||||
public synchronized <T, E> T executeInternal(
|
||||
|
@ -5,7 +5,7 @@ import me.chanjar.weixin.mp.api.WxMpConfigStorage;
|
||||
import me.chanjar.weixin.mp.api.WxMpMessageHandler;
|
||||
import me.chanjar.weixin.mp.api.WxMpMessageRouter;
|
||||
import me.chanjar.weixin.mp.api.WxMpService;
|
||||
import me.chanjar.weixin.mp.api.impl.WxMpServiceApacheHttpClientImpl;
|
||||
import me.chanjar.weixin.mp.api.impl.WxMpServiceHttpClientImpl;
|
||||
import org.eclipse.jetty.server.Server;
|
||||
import org.eclipse.jetty.servlet.ServletHandler;
|
||||
import org.eclipse.jetty.servlet.ServletHolder;
|
||||
@ -47,7 +47,7 @@ public class WxMpDemoServer {
|
||||
.fromXml(is1);
|
||||
|
||||
wxMpConfigStorage = config;
|
||||
wxMpService = new WxMpServiceApacheHttpClientImpl();
|
||||
wxMpService = new WxMpServiceHttpClientImpl();
|
||||
wxMpService.setWxMpConfigStorage(config);
|
||||
|
||||
WxMpMessageHandler logHandler = new DemoLogHandler();
|
||||
|
@ -24,7 +24,7 @@ import me.chanjar.weixin.common.util.ToStringUtils;
|
||||
public class EntPayRequest extends BaseWxPayRequest {
|
||||
/**
|
||||
* <pre>
|
||||
* 字段名:公众账号appid
|
||||
* 字段名:公众账号appid.
|
||||
* 变量名:mch_appid
|
||||
* 是否必填:是
|
||||
* 示例值:wx8888888888888888
|
||||
@ -37,7 +37,7 @@ public class EntPayRequest extends BaseWxPayRequest {
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 字段名:商户号
|
||||
* 字段名:商户号.
|
||||
* 变量名:mchid
|
||||
* 是否必填:是
|
||||
* 示例值:1900000109
|
||||
@ -50,7 +50,7 @@ public class EntPayRequest extends BaseWxPayRequest {
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 字段名:设备号
|
||||
* 字段名:设备号.
|
||||
* 变量名:device_info
|
||||
* 是否必填:否
|
||||
* 示例值:13467007045764
|
||||
@ -63,7 +63,7 @@ public class EntPayRequest extends BaseWxPayRequest {
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 字段名:商户订单号
|
||||
* 字段名:商户订单号.
|
||||
* 变量名:partner_trade_no
|
||||
* 是否必填:是
|
||||
* 示例值:10000098201411111234567890
|
||||
@ -77,7 +77,7 @@ public class EntPayRequest extends BaseWxPayRequest {
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 字段名:需保持唯一性 用户openid
|
||||
* 字段名:需保持唯一性 用户openid.
|
||||
* 变量名:openid
|
||||
* 是否必填:是
|
||||
* 示例值:oxTWIuGaIt6gTKsQRLau2M0yL16E
|
||||
@ -91,7 +91,7 @@ public class EntPayRequest extends BaseWxPayRequest {
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 字段名:校验用户姓名选项
|
||||
* 字段名:校验用户姓名选项.
|
||||
* 变量名:check_name
|
||||
* 是否必填:是
|
||||
* 示例值:OPTION_CHECK
|
||||
@ -107,7 +107,7 @@ public class EntPayRequest extends BaseWxPayRequest {
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 字段名:收款用户姓名
|
||||
* 字段名:收款用户姓名.
|
||||
* 变量名:re_user_name
|
||||
* 是否必填:可选
|
||||
* 示例值:马花花
|
||||
@ -121,7 +121,7 @@ public class EntPayRequest extends BaseWxPayRequest {
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 字段名:金额
|
||||
* 字段名:金额.
|
||||
* 变量名:amount
|
||||
* 是否必填:是
|
||||
* 示例值:10099
|
||||
@ -135,7 +135,7 @@ public class EntPayRequest extends BaseWxPayRequest {
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 字段名:企业付款描述信息
|
||||
* 字段名:企业付款描述信息.
|
||||
* 变量名:desc
|
||||
* 是否必填:是
|
||||
* 示例值:理赔
|
||||
@ -149,7 +149,7 @@ public class EntPayRequest extends BaseWxPayRequest {
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 字段名:Ip地址
|
||||
* 字段名:Ip地址.
|
||||
* 变量名:spbill_create_ip
|
||||
* 是否必填:是
|
||||
* 示例值:192.168.0.1
|
||||
@ -191,4 +191,8 @@ public class EntPayRequest extends BaseWxPayRequest {
|
||||
return ToStringUtils.toSimpleString(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean ignoreSignType() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -1,15 +0,0 @@
|
||||
package com.github.binarywang.wxpay.bean.request;
|
||||
|
||||
import com.github.binarywang.wxpay.bean.entpay.EntPayQueryRequest;
|
||||
import com.thoughtworks.xstream.annotations.XStreamAlias;
|
||||
import lombok.*;
|
||||
import me.chanjar.weixin.common.annotation.Required;
|
||||
import me.chanjar.weixin.common.util.ToStringUtils;
|
||||
|
||||
/**
|
||||
* 请使用 {@link EntPayQueryRequest}
|
||||
*/
|
||||
@XStreamAlias("xml")
|
||||
@Deprecated
|
||||
public class WxEntPayQueryRequest extends EntPayQueryRequest {
|
||||
}
|
@ -1,149 +0,0 @@
|
||||
package com.github.binarywang.wxpay.bean.request;
|
||||
|
||||
import com.github.binarywang.wxpay.bean.entpay.EntPayQueryRequest;
|
||||
import com.github.binarywang.wxpay.bean.entpay.EntPayRequest;
|
||||
import com.thoughtworks.xstream.annotations.XStreamAlias;
|
||||
import lombok.*;
|
||||
import me.chanjar.weixin.common.annotation.Required;
|
||||
import me.chanjar.weixin.common.util.ToStringUtils;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 企业付款请求对象
|
||||
* 请使用 {@link EntPayRequest}
|
||||
* </pre>
|
||||
*/
|
||||
@XStreamAlias("xml")
|
||||
@Deprecated
|
||||
public class WxEntPayRequest extends EntPayRequest {
|
||||
|
||||
private WxEntPayRequest(Builder builder) {
|
||||
setAppid(builder.appid);
|
||||
setMchId(builder.mchId);
|
||||
setSubAppId(builder.subAppId);
|
||||
setSubMchId(builder.subMchId);
|
||||
setNonceStr(builder.nonceStr);
|
||||
setSign(builder.sign);
|
||||
setSignType(builder.signType);
|
||||
setMchAppid(builder.mchAppid);
|
||||
setMchId(builder.mchId);
|
||||
setDeviceInfo(builder.deviceInfo);
|
||||
setPartnerTradeNo(builder.partnerTradeNo);
|
||||
setOpenid(builder.openid);
|
||||
setCheckName(builder.checkName);
|
||||
setReUserName(builder.reUserName);
|
||||
setAmount(builder.amount);
|
||||
setDescription(builder.description);
|
||||
setSpbillCreateIp(builder.spbillCreateIp);
|
||||
}
|
||||
|
||||
public static Builder builder() {
|
||||
return new Builder();
|
||||
}
|
||||
|
||||
public static final class Builder {
|
||||
private String appid;
|
||||
private String mchId;
|
||||
private String deviceInfo;
|
||||
private String partnerTradeNo;
|
||||
private String openid;
|
||||
private String checkName;
|
||||
private String reUserName;
|
||||
private Integer amount;
|
||||
private String description;
|
||||
private String spbillCreateIp;
|
||||
private String subAppId;
|
||||
private String subMchId;
|
||||
private String nonceStr;
|
||||
private String sign;
|
||||
private String signType;
|
||||
private String mchAppid;
|
||||
|
||||
private Builder() {
|
||||
}
|
||||
|
||||
public Builder appid(String appid) {
|
||||
this.appid = appid;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder mchId(String mchId) {
|
||||
this.mchId = mchId;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder deviceInfo(String deviceInfo) {
|
||||
this.deviceInfo = deviceInfo;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder partnerTradeNo(String partnerTradeNo) {
|
||||
this.partnerTradeNo = partnerTradeNo;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder openid(String openid) {
|
||||
this.openid = openid;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder checkName(String checkName) {
|
||||
this.checkName = checkName;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder reUserName(String reUserName) {
|
||||
this.reUserName = reUserName;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder amount(Integer amount) {
|
||||
this.amount = amount;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder description(String description) {
|
||||
this.description = description;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder spbillCreateIp(String spbillCreateIp) {
|
||||
this.spbillCreateIp = spbillCreateIp;
|
||||
return this;
|
||||
}
|
||||
|
||||
public WxEntPayRequest build() {
|
||||
return new WxEntPayRequest(this);
|
||||
}
|
||||
|
||||
public Builder subAppId(String subAppId) {
|
||||
this.subAppId = subAppId;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder subMchId(String subMchId) {
|
||||
this.subMchId = subMchId;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder nonceStr(String nonceStr) {
|
||||
this.nonceStr = nonceStr;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder sign(String sign) {
|
||||
this.sign = sign;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder signType(String signType) {
|
||||
this.signType = signType;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder mchAppid(String mchAppid) {
|
||||
this.mchAppid = mchAppid;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
}
|
@ -2,7 +2,6 @@ package com.github.binarywang.wxpay.service;
|
||||
|
||||
import com.github.binarywang.wxpay.bean.WxPayApiData;
|
||||
import com.github.binarywang.wxpay.bean.coupon.*;
|
||||
import com.github.binarywang.wxpay.bean.entpay.EntPayRequest;
|
||||
import com.github.binarywang.wxpay.bean.notify.WxPayOrderNotifyResult;
|
||||
import com.github.binarywang.wxpay.bean.notify.WxPayRefundNotifyResult;
|
||||
import com.github.binarywang.wxpay.bean.request.*;
|
||||
@ -208,18 +207,6 @@ public interface WxPayService {
|
||||
*/
|
||||
WxPayRedpackQueryResult queryRedpack(String mchBillNo) throws WxPayException;
|
||||
|
||||
/**
|
||||
* 请使用this.getEntPayService().entPay()方法{@link EntPayService#entPay(EntPayRequest)}
|
||||
*/
|
||||
@Deprecated
|
||||
WxEntPayResult entPay(WxEntPayRequest request) throws WxPayException;
|
||||
|
||||
/**
|
||||
* 请使用this.getEntPayService().queryEntPay()方法 {@link EntPayService#queryEntPay(String)}
|
||||
*/
|
||||
@Deprecated
|
||||
WxEntPayQueryResult queryEntPay(String partnerTradeNo) throws WxPayException;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 扫码支付模式一生成二维码的方法
|
||||
|
@ -345,18 +345,6 @@ public abstract class BaseWxPayServiceImpl implements WxPayService {
|
||||
return payInfo;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public WxEntPayResult entPay(WxEntPayRequest request) throws WxPayException {
|
||||
return WxEntPayResult.createFrom(this.getEntPayService().entPay(request));
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public WxEntPayQueryResult queryEntPay(String partnerTradeNo) throws WxPayException {
|
||||
return WxEntPayQueryResult.createFrom(this.getEntPayService().queryEntPay(partnerTradeNo));
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] createScanPayQrcodeMode1(String productId, File logoFile, Integer sideLength) {
|
||||
String content = this.createScanPayQrcodeMode1(productId);
|
||||
|
@ -1,18 +1,16 @@
|
||||
package com.github.binarywang.wxpay.service.impl;
|
||||
|
||||
import com.github.binarywang.wxpay.bean.entpay.EntPayRequest;
|
||||
import com.github.binarywang.wxpay.bean.entpay.EntPayBankRequest;
|
||||
import com.github.binarywang.wxpay.bean.entpay.EntPayBankResult;
|
||||
import com.github.binarywang.wxpay.bean.request.WxEntPayRequest;
|
||||
import com.github.binarywang.wxpay.constant.WxPayConstants;
|
||||
import com.github.binarywang.wxpay.bean.entpay.EntPayRequest;
|
||||
import com.github.binarywang.wxpay.constant.WxPayConstants.CheckNameOption;
|
||||
import com.github.binarywang.wxpay.exception.WxPayException;
|
||||
import com.github.binarywang.wxpay.service.WxPayService;
|
||||
import com.github.binarywang.wxpay.testbase.ApiTestModule;
|
||||
import com.google.inject.Inject;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.testng.annotations.Guice;
|
||||
import org.testng.annotations.Test;
|
||||
import org.testng.annotations.*;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
@ -30,37 +28,20 @@ public class EntPayServiceImplTest {
|
||||
@Inject
|
||||
private WxPayService payService;
|
||||
|
||||
@Test
|
||||
public void testEntPay_old() throws WxPayException {
|
||||
this.logger.info(this.payService.entPay(WxEntPayRequest.builder()
|
||||
.partnerTradeNo("Eb6Aep7uVTdbkJqrP4")
|
||||
.openid("ojOQA0y9o-Eb6Aep7uVTdbkJqrP4")
|
||||
.amount(1)
|
||||
.spbillCreateIp("10.10.10.10")
|
||||
.checkName(WxPayConstants.CheckNameOption.NO_CHECK)
|
||||
.description("描述信息")
|
||||
.build()).toString());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testEntPay() throws WxPayException {
|
||||
EntPayRequest request = EntPayRequest.newBuilder()
|
||||
.partnerTradeNo("Eb6Aep7uVTdbkJqrP4")
|
||||
.openid("ojOQA0y9o-Eb6Aep7uVTdbkJqrP4")
|
||||
.amount(1)
|
||||
.openid("ojOQA0y9o-Eb6Aep7uVTdbkJqrP5")
|
||||
.amount(100)
|
||||
.spbillCreateIp("10.10.10.10")
|
||||
.checkName(WxPayConstants.CheckNameOption.NO_CHECK)
|
||||
.checkName(CheckNameOption.NO_CHECK)
|
||||
.description("描述信息")
|
||||
.build();
|
||||
|
||||
this.logger.info(this.payService.getEntPayService().entPay(request).toString());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testQueryEntPay_old() throws WxPayException {
|
||||
this.logger.info(this.payService.queryEntPay("11212121").toString());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testQueryEntPay() throws WxPayException {
|
||||
this.logger.info(this.payService.getEntPayService().queryEntPay("11212121").toString());
|
||||
|
Loading…
Reference in New Issue
Block a user