mirror of
				https://gitee.com/binary/weixin-java-tools.git
				synced 2025-10-31 10:38:42 +08:00 
			
		
		
		
	#1111 微信支付配置支持接口请求地址的可配置
This commit is contained in:
		| @ -18,6 +18,12 @@ import java.security.KeyStore; | |||||||
|  */ |  */ | ||||||
| @Data | @Data | ||||||
| public class WxPayConfig { | public class WxPayConfig { | ||||||
|  |   private static final String DEFAULT_PAY_BASE_URL = "https://api.mch.weixin.qq.com"; | ||||||
|  |  | ||||||
|  |   /** | ||||||
|  |    * 微信支付接口请求地址域名部分. | ||||||
|  |    */ | ||||||
|  |   private String payBaseUrl = DEFAULT_PAY_BASE_URL; | ||||||
|  |  | ||||||
|   /** |   /** | ||||||
|    * http请求连接超时时间. |    * http请求连接超时时间. | ||||||
| @ -96,6 +102,18 @@ public class WxPayConfig { | |||||||
|   private String httpProxyUsername; |   private String httpProxyUsername; | ||||||
|   private String httpProxyPassword; |   private String httpProxyPassword; | ||||||
|  |  | ||||||
|  |   /** | ||||||
|  |    * 返回所设置的微信支付接口请求地址域名. | ||||||
|  |    * @return 微信支付接口请求地址域名 | ||||||
|  |    */ | ||||||
|  |   public String getPayBaseUrl() { | ||||||
|  |     if (StringUtils.isEmpty(this.payBaseUrl)) { | ||||||
|  |       return DEFAULT_PAY_BASE_URL; | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     return this.payBaseUrl; | ||||||
|  |   } | ||||||
|  |  | ||||||
|   /** |   /** | ||||||
|    * 初始化ssl. |    * 初始化ssl. | ||||||
|    * |    * | ||||||
|  | |||||||
| @ -47,7 +47,6 @@ import static com.github.binarywang.wxpay.constant.WxPayConstants.TarType; | |||||||
|  * @author <a href="https://github.com/binarywang">Binary Wang</a> |  * @author <a href="https://github.com/binarywang">Binary Wang</a> | ||||||
|  */ |  */ | ||||||
| public abstract class BaseWxPayServiceImpl implements WxPayService { | public abstract class BaseWxPayServiceImpl implements WxPayService { | ||||||
|   private static final String PAY_BASE_URL = "https://api.mch.weixin.qq.com"; |  | ||||||
|   private static final String TOTAL_FUND_COUNT = "资金流水总笔数"; |   private static final String TOTAL_FUND_COUNT = "资金流水总笔数"; | ||||||
|  |  | ||||||
|   /** |   /** | ||||||
| @ -89,10 +88,10 @@ public abstract class BaseWxPayServiceImpl implements WxPayService { | |||||||
|   @Override |   @Override | ||||||
|   public String getPayBaseUrl() { |   public String getPayBaseUrl() { | ||||||
|     if (this.getConfig().isUseSandboxEnv()) { |     if (this.getConfig().isUseSandboxEnv()) { | ||||||
|       return PAY_BASE_URL + "/sandboxnew"; |       return this.getConfig().getPayBaseUrl() + "/sandboxnew"; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     return PAY_BASE_URL; |     return this.getConfig().getPayBaseUrl(); | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   @Override |   @Override | ||||||
| @ -101,7 +100,7 @@ public abstract class BaseWxPayServiceImpl implements WxPayService { | |||||||
|  |  | ||||||
|     String url = this.getPayBaseUrl() + "/secapi/pay/refund"; |     String url = this.getPayBaseUrl() + "/secapi/pay/refund"; | ||||||
|     if (this.getConfig().isUseSandboxEnv()) { |     if (this.getConfig().isUseSandboxEnv()) { | ||||||
|       url = PAY_BASE_URL + "/sandboxnew/pay/refund"; |       url = this.getConfig().getPayBaseUrl() + "/sandboxnew/pay/refund"; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     String responseContent = this.post(url, request.toXML(), true); |     String responseContent = this.post(url, request.toXML(), true); | ||||||
|  | |||||||
		Reference in New Issue
	
	Block a user
	 Binary Wang
					Binary Wang