specificTradeType, WxPayUnifiedOrderRequest request) throws WxPayException;
@@ -759,5 +757,18 @@ public interface WxPayService {
*/
WxPayFacepayResult facepay(WxPayFacepayRequest request) throws WxPayException;
-
+ /**
+ * 查询汇率
+ *
+ * 应用场景:商户网站的商品以外币标价时,通过该接口可以实时查询到微信使用的转换汇率。汇率更新时间为北京时间上午10:00,一天更新一次。
+ * 文档地址:https://pay.weixin.qq.com/wiki/doc/api/app/app_jw.php?chapter=9_15&index=12
+ * 接口链接:https://api.mch.weixin.qq.com/pay/queryexchagerate
+ *
+ *
+ * @param feeType 外币币种
+ * @param date 日期,格式为yyyyMMdd,如2009年12月25日表示为20091225。时区为GMT+8 beijing
+ * @return .
+ * @throws WxPayException .
+ */
+ WxPayQueryExchangeRateResult queryExchangeRate(String feeType, String date) throws WxPayException;
}
diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/BaseWxPayServiceImpl.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/BaseWxPayServiceImpl.java
index 826af6f3..4d61522f 100644
--- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/BaseWxPayServiceImpl.java
+++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/BaseWxPayServiceImpl.java
@@ -831,4 +831,18 @@ public abstract class BaseWxPayServiceImpl implements WxPayService {
return result;
}
+ @Override
+ public WxPayQueryExchangeRateResult queryExchangeRate(String feeType, String date) throws WxPayException {
+ WxPayQueryExchangeRateRequest request = new WxPayQueryExchangeRateRequest();
+ request.setFeeType(feeType);
+ request.setDate(date);
+
+ request.checkAndSign(this.getConfig());
+
+ String url = this.getPayBaseUrl() + "/pay/queryexchagerate";
+ String responseContent = this.post(url, request.toXML(), false);
+ WxPayQueryExchangeRateResult result = BaseWxPayResult.fromXML(responseContent, WxPayQueryExchangeRateResult.class);
+ result.checkResult(this, request.getSignType(), true);
+ return result;
+ }
}
diff --git a/weixin-java-pay/src/test/java/com/github/binarywang/wxpay/service/impl/BaseWxPayServiceImplTest.java b/weixin-java-pay/src/test/java/com/github/binarywang/wxpay/service/impl/BaseWxPayServiceImplTest.java
index 6350828f..9e129bcb 100644
--- a/weixin-java-pay/src/test/java/com/github/binarywang/wxpay/service/impl/BaseWxPayServiceImplTest.java
+++ b/weixin-java-pay/src/test/java/com/github/binarywang/wxpay/service/impl/BaseWxPayServiceImplTest.java
@@ -626,7 +626,8 @@ public class BaseWxPayServiceImplTest {
}
@Test
- public void testFacepay() {
+ public void testFacepay() throws WxPayException {
+ final WxPayFacepayResult result = this.payService.facepay(WxPayFacepayRequest.newBuilder().build());
}
@Test
@@ -673,4 +674,16 @@ public class BaseWxPayServiceImplTest {
@Test
public void testTestQueryRedpack() {
}
+
+ @Test
+ public void testGetPayScoreService() {
+ // no need to test
+ }
+
+ @Test
+ public void testQueryExchangeRate() throws WxPayException {
+ final WxPayQueryExchangeRateResult result = this.payService.queryExchangeRate("USD", "20200425");
+ assertThat(result).isNotNull();
+ System.out.println(result);
+ }
}