diff --git a/README.md b/README.md
index 228b7c3ba552f24a65ab833a66613748cb9c517c..4886488fdb1033ec79ca688456f0adb89449bc1d 100644
--- a/README.md
+++ b/README.md
@@ -68,17 +68,17 @@ android 例子 [pay-java-android](https://gitee.com/egzosn/pay-java-android)
非常欢迎和感谢对本项目发起Pull Request的同学,不过本项目基于git flow开发流程,因此在发起Pull Request的时候请选择develop分支。
-作者公众号(每周输出)
-![公众号](https://egzosn.gitee.io/pay-java-parent/gzh.png "gzh.png")
+作者公众号(未来输出)
+![公众号](https://gitee.com/egzosn/pay-java-parent/raw/develop/pay-java-demo/src/main/webapp/gzh.png "gzh.png")
E-Mail:egan@egzosn.com
**QQ群:**
-
1. pay-java(1群): 542193977(已满)
2. pay-java(2群):766275051
-微信群:
+微信群: 加我前拜托伸个小手关注公众号
+
![微信群](https://egzosn.gitee.io/pay-java-parent/wx.jpg "wx.jpg")
diff --git a/pay-java-ali/pom.xml b/pay-java-ali/pom.xml
index 24256302122e033d1447dbced2e4dca960243830..9985ca214df92a4e127d092321758096caec8011 100644
--- a/pay-java-ali/pom.xml
+++ b/pay-java-ali/pom.xml
@@ -5,7 +5,7 @@
pay-java-parent
com.egzosn
- 2.14.7
+ 2.14.8
4.0.0
pay-java-ali
diff --git a/pay-java-ali/src/main/java/com/egzosn/pay/ali/api/AliPayService.java b/pay-java-ali/src/main/java/com/egzosn/pay/ali/api/AliPayService.java
index f55316a4345e51acb35b1e21c107c9c34e9b2a8e..41ba432f4ded7478c5ccb0ae3e59a817253e77e8 100644
--- a/pay-java-ali/src/main/java/com/egzosn/pay/ali/api/AliPayService.java
+++ b/pay-java-ali/src/main/java/com/egzosn/pay/ali/api/AliPayService.java
@@ -282,9 +282,10 @@ public class AliPayService extends BasePayService implement
bizContent.put(PRODUCT_CODE, "QUICK_MSECURITY_PAY");
break;
case MINAPP:
- bizContent.put("extend_params", order.getAddition());
+ bizContent.put(PASSBACK_PARAMS, order.getAddition());
+ bizContent.put("op_app_id", order.getAttrForString("op_app_id"));
bizContent.put("buyer_id", order.getOpenid());
- bizContent.put(PRODUCT_CODE, "FACE_TO_FACE_PAYMENT");
+ bizContent.put(PRODUCT_CODE, "JSAPI_PAY");
break;
case BAR_CODE:
case WAVE_CODE:
@@ -299,14 +300,27 @@ public class AliPayService extends BasePayService implement
setExpirationTime(bizContent, order);
- bizContent.putAll(order.getAttrs());
+ loadAddition(bizContent, order);
orderInfo.put(BIZ_CONTENT, JSON.toJSONString(bizContent));
return preOrderHandler(orderInfo, order);
}
- private Map setExpirationTime(Map bizContent, PayOrder order) {
+ private void loadAddition(Map bizContent, PayOrder order) {
+ OrderParaStructure.loadParameters(bizContent, AliPayConst.EXTEND_PARAMS, order);
+ OrderParaStructure.loadParameters(bizContent, AliPayConst.BUSINESS_PARAMS, order);
+ OrderParaStructure.loadParameters(bizContent, AliPayConst.DISCOUNTABLE_AMOUNT, order);
+ OrderParaStructure.loadParameters(bizContent, AliPayConst.UNDISCOUNTABLE_AMOUNT, order);
+ OrderParaStructure.loadParameters(bizContent, AliPayConst.STORE_ID, order);
+ OrderParaStructure.loadParameters(bizContent, AliPayConst.ALIPAY_STORE_ID, order);
+ OrderParaStructure.loadParameters(bizContent, AliPayConst.ENABLE_PAY_CHANNELS, order);
+ OrderParaStructure.loadParameters(bizContent, AliPayConst.DISABLE_PAY_CHANNELS, order);
+ OrderParaStructure.loadParameters(bizContent, AliPayConst.QUERY_OPTIONS, order);
+ OrderParaStructure.loadParameters(bizContent, AliPayConst.AGREEMENT_SIGN_PARAMS, order);
+ }
+
+ private void setExpirationTime(Map bizContent, PayOrder order) {
if (null == order.getExpirationTime()) {
- return bizContent;
+ return;
}
bizContent.put("timeout_express", DateUtils.minutesRemaining(order.getExpirationTime()) + "m");
switch ((AliTransactionType) order.getTransactionType()) {
@@ -316,11 +330,11 @@ public class AliPayService extends BasePayService implement
case PAGE:
case WAP:
case APP:
+ case MINAPP:
bizContent.put("time_expire", DateUtils.formatDate(order.getExpirationTime(), DateUtils.YYYY_MM_DD_HH_MM_SS));
break;
default:
}
- return bizContent;
}
/**
@@ -441,6 +455,31 @@ public class AliPayService extends BasePayService implement
}
+ /**
+ * 小程序支付,返回小程序所需的订单构建信息
+ *
+ * @param order 发起支付的订单信息
+ * @return 返回支付结果
+ */
+ @Override
+ public Map jsApi(PayOrder order) {
+ if (null == order.getTransactionType()) {
+ order.setTransactionType(AliTransactionType.MINAPP);
+ }
+ Map orderInfo = orderInfo(order);
+ Map body = new LinkedHashMap<>();
+ body.put(BIZ_CONTENT, orderInfo.remove(BIZ_CONTENT));
+ OrderParaStructure.loadParameters(body, APP_AUTH_TOKEN, (String) orderInfo.remove(APP_AUTH_TOKEN));
+ //预订单
+ JSONObject result = getHttpRequestTemplate().postForObject(getReqUrl() + "?" + UriVariables.getMapToParameters(orderInfo), body, JSONObject.class);
+ JSONObject response = result.getJSONObject("alipay_trade_create_response");
+ if (!SUCCESS_CODE.equals(response.getString(CODE))) {
+ LOG.warn("下单失败:{}", response);
+ }
+
+ return response;
+ }
+
/**
* pos主动扫码付款(条码付)
*
@@ -461,7 +500,7 @@ public class AliPayService extends BasePayService implement
JSONObject result = getHttpRequestTemplate().postForObject(getReqUrl() + "?" + UriVariables.getMapToParameters(orderInfo), null, JSONObject.class);
JSONObject response = result.getJSONObject("alipay_trade_pay_response");
if (!SUCCESS_CODE.equals(response.getString(CODE))) {
- LOG.info("收款失败");
+ LOG.info("收款失败{}", response);
}
return result;
}
diff --git a/pay-java-ali/src/main/java/com/egzosn/pay/ali/bean/AliPayConst.java b/pay-java-ali/src/main/java/com/egzosn/pay/ali/bean/AliPayConst.java
index 7bce3cd117778d7b3c9476c0ff9cecb5593097b2..22dd82f1993f628434313848bb54903d859fb4db 100644
--- a/pay-java-ali/src/main/java/com/egzosn/pay/ali/bean/AliPayConst.java
+++ b/pay-java-ali/src/main/java/com/egzosn/pay/ali/bean/AliPayConst.java
@@ -64,9 +64,17 @@ public final class AliPayConst {
* 业务扩展参数
*/
public static final String EXTEND_PARAMS = "extend_params";
+ public static final String BUSINESS_PARAMS = "business_params";
+ public static final String DISCOUNTABLE_AMOUNT = "discountable_amount";
+ public static final String UNDISCOUNTABLE_AMOUNT = "undiscountable_amount";
+ public static final String STORE_ID = "store_id";
+ public static final String ENABLE_PAY_CHANNELS = "enable_pay_channels";
+ public static final String DISABLE_PAY_CHANNELS = "disable_pay_channels";
+ public static final String QUERY_OPTIONS = "query_options";
+ public static final String AGREEMENT_SIGN_PARAMS = "agreement_sign_params";
+ public static final String ALIPAY_STORE_ID = "alipay_store_id";
public static final String BIZ_TYPE = "biz_type";
public static final String REFUND_REASON = "refund_reason";
- public static final String QUERY_OPTIONS = "query_options";
public static final String OUT_REQUEST_NO = "out_request_no";
/**
* 用户付款中途退出返回商户网站的地址
diff --git a/pay-java-baidu/pom.xml b/pay-java-baidu/pom.xml
index 4d2ed8f325f41c34652782e28e887e9b6de0994d..650c6ccea4763c0a3b1f533b59c1efda4dda02ee 100644
--- a/pay-java-baidu/pom.xml
+++ b/pay-java-baidu/pom.xml
@@ -5,7 +5,7 @@
pay-java-parent
com.egzosn
- 2.14.7
+ 2.14.8
4.0.0
pay-java-baidu
diff --git a/pay-java-common/pom.xml b/pay-java-common/pom.xml
index 217b19268484867a3918053b66c811dc6a8876a0..93de96ee5f72b4945fbce141c742d531b509a8f4 100644
--- a/pay-java-common/pom.xml
+++ b/pay-java-common/pom.xml
@@ -5,7 +5,7 @@
pay-java-parent
com.egzosn
- 2.14.7
+ 2.14.8
4.0.0
jar
diff --git a/pay-java-common/src/main/java/com/egzosn/pay/common/api/BasePayConfigStorage.java b/pay-java-common/src/main/java/com/egzosn/pay/common/api/BasePayConfigStorage.java
index f813936396ccd546d78c24fe53ab7587bbb0fd3f..9b85072e23c633d1641b813bc5a3b9a576ca9478 100644
--- a/pay-java-common/src/main/java/com/egzosn/pay/common/api/BasePayConfigStorage.java
+++ b/pay-java-common/src/main/java/com/egzosn/pay/common/api/BasePayConfigStorage.java
@@ -22,6 +22,10 @@ public abstract class BasePayConfigStorage implements PayConfigStorage {
*/
private String keyPrivate;
+ /**
+ * 支付平台公钥Id(签名校验使用)
+ */
+ private String keyPublicId;
/**
* 支付平台公钥(签名校验使用)
*/
@@ -41,7 +45,7 @@ public abstract class BasePayConfigStorage implements PayConfigStorage {
/**
* 字符类型
*/
- private String inputCharset;
+ private String inputCharset = "utf-8";
/**
@@ -95,6 +99,14 @@ public abstract class BasePayConfigStorage implements PayConfigStorage {
this.keyPrivate = keyPrivate;
}
+ @Override
+ public String getKeyPublicId() {
+ return keyPublicId;
+ }
+
+ public void setKeyPublicId(String keyPublicId) {
+ this.keyPublicId = keyPublicId;
+ }
@Override
public String getKeyPublic() {
diff --git a/pay-java-common/src/main/java/com/egzosn/pay/common/api/BasePayService.java b/pay-java-common/src/main/java/com/egzosn/pay/common/api/BasePayService.java
index 1b54d95a8363d3e098432a4b52bdce491a24b676..c36cd89e74b7090de08c17fdb8175986d43f3a84 100644
--- a/pay-java-common/src/main/java/com/egzosn/pay/common/api/BasePayService.java
+++ b/pay-java-common/src/main/java/com/egzosn/pay/common/api/BasePayService.java
@@ -197,6 +197,17 @@ public abstract class BasePayService implements Pay
return MatrixToImageWriter.writeInfoToJpgBuff(getQrPay(order));
}
+ /**
+ * 小程序支付,返回小程序所需的订单构建信息
+ *
+ * @param order 发起支付的订单信息
+ * @return 返回支付结果
+ */
+ @Override
+ public Map jsApi(O order) {
+ return Collections.emptyMap();
+ }
+
/**
* 将请求参数或者请求流转化为 Map
*
diff --git a/pay-java-common/src/main/java/com/egzosn/pay/common/api/PayConfigStorage.java b/pay-java-common/src/main/java/com/egzosn/pay/common/api/PayConfigStorage.java
index b6bc6000251bb466d1612b779622ded767d5efe6..e207511fc0f2424cc8d4dfb026014216f5fef294 100644
--- a/pay-java-common/src/main/java/com/egzosn/pay/common/api/PayConfigStorage.java
+++ b/pay-java-common/src/main/java/com/egzosn/pay/common/api/PayConfigStorage.java
@@ -88,6 +88,13 @@ public interface PayConfigStorage extends Attrs {
*/
String getInputCharset();
+ /**
+ * 支付平台公钥ID(签名校验使用)
+ *
+ * @return 公钥
+ */
+ String getKeyPublicId();
+
/**
* 支付平台公钥(签名校验使用)
*
diff --git a/pay-java-common/src/main/java/com/egzosn/pay/common/api/PayService.java b/pay-java-common/src/main/java/com/egzosn/pay/common/api/PayService.java
index 28f41066afc0180c8b7f3fa413410d92a24d3cb2..f01b9b84e05b81942f35046c488cd17d7ce297e3 100644
--- a/pay-java-common/src/main/java/com/egzosn/pay/common/api/PayService.java
+++ b/pay-java-common/src/main/java/com/egzosn/pay/common/api/PayService.java
@@ -185,6 +185,14 @@ public interface PayService {
*/
String getQrPay(O order);
+ /**
+ * 小程序支付,返回小程序所需的订单构建信息
+ *
+ * @param order 发起支付的订单信息
+ * @param 预订单类型
+ * @return 返回支付结果
+ */
+ Map jsApi(O order);
/**
* 刷卡付,pos主动扫码付款(条码付)
* 刷脸付
diff --git a/pay-java-common/src/main/java/com/egzosn/pay/common/util/sign/SignUtils.java b/pay-java-common/src/main/java/com/egzosn/pay/common/util/sign/SignUtils.java
index 7d6aaa36c14638c980fee236e45ab804b66d96de..a73bab78238849a4603fa5f09aa4b446173ecaab 100644
--- a/pay-java-common/src/main/java/com/egzosn/pay/common/util/sign/SignUtils.java
+++ b/pay-java-common/src/main/java/com/egzosn/pay/common/util/sign/SignUtils.java
@@ -142,7 +142,6 @@ public enum SignUtils implements SignType {
};
-
@Override
public String getName() {
return this.name();
@@ -198,10 +197,14 @@ public enum SignUtils implements SignType {
* 初始化BC
*/
public static void initBc() {
- if (null == Security.getProvider("BC")) {
- Security.removeProvider("SunEC");
- Security.addProvider(new BouncyCastleProvider());
+ String javaVersion = System.getProperty("java.version");
+ if (javaVersion.contains("1.8") || javaVersion.startsWith("8")) {
+ if (null == Security.getProvider("BC")) {
+ Security.removeProvider("SunEC");
+ Security.addProvider(new BouncyCastleProvider());
+ }
}
+
}
diff --git a/pay-java-demo/pom.xml b/pay-java-demo/pom.xml
index 2e0b44b9c26c051bf13b79198c3b1842e80bca8d..dc143c4ce8e94b13b17e6f13419016ee3cc23f3c 100644
--- a/pay-java-demo/pom.xml
+++ b/pay-java-demo/pom.xml
@@ -5,7 +5,7 @@
pay-java-parent
com.egzosn
- 2.14.7
+ 2.14.8
4.0.0
war
@@ -72,6 +72,13 @@
compile
+
+ jakarta.annotation
+ jakarta.annotation-api
+ 1.3.5
+
+
+
javax.servlet
diff --git a/pay-java-demo/src/main/java/com/egzosn/pay/demo/controller/AliPayController.java b/pay-java-demo/src/main/java/com/egzosn/pay/demo/controller/AliPayController.java
index 4be22b6b90a40a025d9c6e3af83612cecdd9225b..7dac125f52bbbb827ab39f92855a57f7f82e8463 100644
--- a/pay-java-demo/src/main/java/com/egzosn/pay/demo/controller/AliPayController.java
+++ b/pay-java-demo/src/main/java/com/egzosn/pay/demo/controller/AliPayController.java
@@ -18,6 +18,7 @@ import org.springframework.beans.factory.config.AutowireCapableBeanFactory;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
+import com.alibaba.fastjson.JSONObject;
import com.egzosn.pay.ali.api.AliPayConfigStorage;
import com.egzosn.pay.ali.api.AliPayService;
import com.egzosn.pay.ali.bean.AliRefundResult;
@@ -32,6 +33,7 @@ import com.egzosn.pay.common.bean.PayOrder;
import com.egzosn.pay.common.bean.RefundOrder;
import com.egzosn.pay.common.http.HttpConfigStorage;
import com.egzosn.pay.common.http.UriVariables;
+import com.egzosn.pay.common.util.MapGen;
import com.egzosn.pay.common.util.sign.SignUtils;
import com.egzosn.pay.demo.request.QueryOrder;
import com.egzosn.pay.demo.service.handler.AliPayMessageHandler;
@@ -181,6 +183,29 @@ public class AliPayController {
}
+ /**
+ * 刷卡付,pos主动扫码付款(条码付)
+ *
+ * @param openid 授权码,条码等
+ * @param price 金额
+ * @return 支付结果
+ */
+ @RequestMapping(value = "minapp")
+ public Map minapp(BigDecimal price, String openid) {
+ //获取对应的支付账户操作工具(可根据账户id)
+ //条码付
+ PayOrder order = new PayOrder("egan order", "egan order", null == price ? BigDecimal.valueOf(0.01) : price, UUID.randomUUID().toString().replace("-", ""), AliTransactionType.BAR_CODE);
+ //声波付
+// PayOrder order = new PayOrder("egan order", "egan order", null == price ? BigDecimal.valueOf(0.01) : price, UUID.randomUUID().toString().replace("-", ""), AliTransactionType.WAVE_CODE);
+ //设置授权码,条码等
+ order.setOpenid(openid);
+ order.addAttr("op_app_id", "小程序支付中,商户实际经营主体的小程序应用的appid,也即最终唤起收银台支付所在的小程序的应用id");
+ //预订单结果
+ Map params = service.jsApi(order);
+ //这里开发者自行处理
+ return params;
+ }
+
/**
* 刷卡付,pos主动扫码付款(条码付)
*
@@ -210,6 +235,27 @@ public class AliPayController {
//这里开发者自行处理
return params;
}
+ /**
+ * 刷卡付,pos主动扫码付款(条码付)
+ *
+ * @param openid 授权码,条码等
+ * @param price 金额
+ * @return 支付结果
+ */
+ @RequestMapping(value = "jsapi")
+ public Map jsapi(BigDecimal price, String openid) {
+ //获取对应的支付账户操作工具(可根据账户id)
+ //条码付
+ PayOrder order = new PayOrder("egan order", "egan order", null == price ? BigDecimal.valueOf(0.01) : price, UUID.randomUUID().toString().replace("-", ""), AliTransactionType.BAR_CODE);
+
+ order.setOpenid(openid);
+ //支付结果
+ Map orderInfo = service.orderInfo(order);
+ Map bizContent = new MapGen<>("biz_content", orderInfo.get("biz_content")).getAttr();
+ JSONObject result = service.getHttpRequestTemplate().postForObject(service.getReqUrl() + "?" + UriVariables.getMapToParameters(orderInfo), bizContent, JSONObject.class);
+ //这里开发者自行处理
+ return result;
+ }
/**
* 支付回调地址 方式一
diff --git a/pay-java-demo/src/main/java/com/egzosn/pay/demo/controller/PayController.java b/pay-java-demo/src/main/java/com/egzosn/pay/demo/controller/PayController.java
index 93b09e70ab158a3a9fbd1938843904f17ea48d24..49b267aa85cf76fbc490d9432ffdc4d23c7cbf45 100644
--- a/pay-java-demo/src/main/java/com/egzosn/pay/demo/controller/PayController.java
+++ b/pay-java-demo/src/main/java/com/egzosn/pay/demo/controller/PayController.java
@@ -165,7 +165,7 @@ public class PayController {
PayOrder order = new PayOrder("订单title", "摘要", null == price ? BigDecimal.valueOf(0.01) : price, UUID.randomUUID().toString().replace("-", ""), PayType.valueOf(payResponse.getStorage().getPayType()).getTransactionType("JSAPI"));
order.setOpenid(openid);
- Map orderInfo = payResponse.getService().orderInfo(order);
+ Map orderInfo = payResponse.getService().jsApi(order);
orderInfo.put("code", 0);
return orderInfo;
@@ -211,9 +211,9 @@ public class PayController {
Map params = payResponse.getService().microPay(order);
PayConfigStorage storage = payResponse.getService().getPayConfigStorage();
//校验
- if (payResponse.getService().verify(params)) {
+ if (payResponse.getService().verify(new NoticeParams(params))) {
PayMessage message = new PayMessage(params, storage.getPayType());
- //支付校验通过后的处理
+ //支付校验通过后的处理,,路由的方式已经不建议使用了,
payResponse.getRouter().route(message);
}
//这里开发者自行处理
diff --git a/pay-java-demo/src/main/java/com/egzosn/pay/demo/controller/WxPayController.java b/pay-java-demo/src/main/java/com/egzosn/pay/demo/controller/WxPayController.java
index 879494e888b510509c3cbfd11ae3039dda992c0a..0670ab9ad87b25fab44c1326f2f3525077d289e8 100644
--- a/pay-java-demo/src/main/java/com/egzosn/pay/demo/controller/WxPayController.java
+++ b/pay-java-demo/src/main/java/com/egzosn/pay/demo/controller/WxPayController.java
@@ -124,7 +124,7 @@ public class WxPayController {
PayOrder order = new PayOrder("订单title", "摘要", null == price ? BigDecimal.valueOf(0.01) : price, UUID.randomUUID().toString().replace("-", ""), WxTransactionType.JSAPI);
order.setOpenid(openid);
- Map orderInfo = service.orderInfo(order);
+ Map orderInfo = service.jsApi(order);
orderInfo.put("code", 0);
return orderInfo;
diff --git a/pay-java-demo/src/main/java/com/egzosn/pay/demo/controller/WxV3CombinePayController.java b/pay-java-demo/src/main/java/com/egzosn/pay/demo/controller/WxV3CombinePayController.java
index 2724601c4508c4b9940adc4ac5171134cadeea09..7274f1d1dd52aed0f3f88b88bf9ec2f7b9d70c8c 100644
--- a/pay-java-demo/src/main/java/com/egzosn/pay/demo/controller/WxV3CombinePayController.java
+++ b/pay-java-demo/src/main/java/com/egzosn/pay/demo/controller/WxV3CombinePayController.java
@@ -126,7 +126,7 @@ public class WxV3CombinePayController {
subOrder.setSubMchid("服务商必填----二级商户商户号,由微信支付生成并下发。服务商子商户的商户号,被合单方。直连商户不用传二级商户号。 ");
subOrders.add(subOrder);
order.setSubOrders(subOrders);
- Map orderInfo = service.orderInfo(order);
+ Map orderInfo = service.jsApi(order);
orderInfo.put("code", 0);
return orderInfo;
}
diff --git a/pay-java-demo/src/main/java/com/egzosn/pay/demo/controller/WxV3PayController.java b/pay-java-demo/src/main/java/com/egzosn/pay/demo/controller/WxV3PayController.java
index f3d508822cc3ee10ac755b950830609eca16f547..d538309a28d3d338e0e95a7be9125d05f8be135d 100644
--- a/pay-java-demo/src/main/java/com/egzosn/pay/demo/controller/WxV3PayController.java
+++ b/pay-java-demo/src/main/java/com/egzosn/pay/demo/controller/WxV3PayController.java
@@ -56,14 +56,17 @@ public class WxV3PayController {
wxPayConfigStorage.setMchId("1602947765");
//V3密钥 https://pay.weixin.qq.com/wiki/doc/apiv3/wechatpay/wechatpay3_2.shtml
wxPayConfigStorage.setV3ApiKey("9bd8f0e7af4841299d782406b7774f57");
+ //验签、转账等接口使用,9月份开始不允许获取证书方式了,直接通过公钥字符来做,
+ wxPayConfigStorage.setKeyPublic("支付平台公钥(原为自动获取的证书)");
+ wxPayConfigStorage.setKeyPublicId("支付平台公钥ID");
wxPayConfigStorage.setNotifyUrl("http://sailinmu.iok.la/wxV3/payBack.json");
wxPayConfigStorage.setReturnUrl("http://sailinmu.iok.la/wxV3/payBack.json");
wxPayConfigStorage.setInputCharset("utf-8");
//使用证书时设置为true
// wxPayConfigStorage.setCertSign(true);
//商户API证书 https://pay.weixin.qq.com/wiki/doc/apiv3/wechatpay/wechatpay3_1.shtml
- wxPayConfigStorage.setApiClientKeyP12("yifenli_mall.p12");
- wxPayConfigStorage.setCertStoreType(CertStoreType.PATH);
+ wxPayConfigStorage.setApiClientKeyP12("http://pay.egzosn.com/yifenli_mall.p12");
+ wxPayConfigStorage.setCertStoreType(CertStoreType.URL);
service = new WxPayService(wxPayConfigStorage);
//微信海外支付:东南亚
// service.setApiServerUrl("https://apihk.mch.weixin.qq.com");
@@ -98,17 +101,18 @@ public class WxV3PayController {
/**
* 公众号支付
*
+ *
* @param openid openid
- * @param price 金额
+ * @param price 金额
* @return 返回jsapi所需参数
*/
- @RequestMapping(value = "jsapi")
+ @RequestMapping(value = "jsapi" )
public Map toPay(String openid, BigDecimal price) {
- PayOrder order = new PayOrder("订单title", "摘要", null == price ? BigDecimal.valueOf(0.01) : price, UUID.randomUUID().toString().replace("-", ""), WxTransactionType.JSAPI);
+ PayOrder order = new PayOrder("订单title", "摘要", null == price ? BigDecimal.valueOf(0.01) : price, UUID.randomUUID().toString().replace("-", ""), com.egzosn.pay.wx.bean.WxTransactionType.JSAPI);
order.setOpenid(openid);
- Map orderInfo = service.orderInfo(order);
+ Map orderInfo = service.jsApi(order);
orderInfo.put("code", 0);
return orderInfo;
diff --git a/pay-java-demo/src/main/java/com/egzosn/pay/demo/entity/PayType.java b/pay-java-demo/src/main/java/com/egzosn/pay/demo/entity/PayType.java
index dbfa77fd56379c654434ac36b42b9f347ab2f55f..3bfc236a4358676df47243ce56cc5c4565357953 100644
--- a/pay-java-demo/src/main/java/com/egzosn/pay/demo/entity/PayType.java
+++ b/pay-java-demo/src/main/java/com/egzosn/pay/demo/entity/PayType.java
@@ -8,7 +8,12 @@ import com.egzosn.pay.common.bean.BasePayType;
import com.egzosn.pay.common.bean.CertStoreType;
import com.egzosn.pay.common.bean.TransactionType;
import com.egzosn.pay.common.util.sign.SignUtils;
+import com.egzosn.pay.demo.service.handler.FuiouPayMessageHandler;
+import com.egzosn.pay.demo.service.handler.PayPalPayMessageHandler;
+import com.egzosn.pay.demo.service.handler.PayoneerMessageHandler;
+import com.egzosn.pay.demo.service.handler.UnionPayMessageHandler;
import com.egzosn.pay.demo.service.handler.WxPayMessageHandler;
+import com.egzosn.pay.demo.service.handler.YouDianPayMessageHandler;
import com.egzosn.pay.fuiou.api.FuiouPayConfigStorage;
import com.egzosn.pay.fuiou.api.FuiouPayService;
import com.egzosn.pay.fuiou.bean.FuiouTransactionType;
@@ -64,7 +69,9 @@ public enum PayType implements BasePayType {
aliPayConfigStorage.setInputCharset("utf-8");
//是否为测试账号,沙箱环境
aliPayConfigStorage.setTest(true);
- return new AliPayService(aliPayConfigStorage);
+ AliPayService aliPayService = new AliPayService(aliPayConfigStorage);
+ aliPayService.setPayMessageHandler(new WxPayMessageHandler(apyAccount.getPayId()));
+ return aliPayService;
}
@Override
@@ -102,7 +109,7 @@ public enum PayType implements BasePayType {
httpConfigStorage.setCertStoreType(CertStoreType.PATH);
return new WxPayService(wxPayConfigStorage, httpConfigStorage);*/
WxPayService wxPayService = new WxPayService(wxPayConfigStorage);
- wxPayService.setPayMessageHandler(new WxPayMessageHandler(1));
+ wxPayService.setPayMessageHandler(new WxPayMessageHandler(apyAccount.getPayId()));
return wxPayService;
}
@@ -131,7 +138,9 @@ public enum PayType implements BasePayType {
wxPayConfigStorage.setSeller(apyAccount.getSeller());
wxPayConfigStorage.setInputCharset(apyAccount.getInputCharset());
wxPayConfigStorage.setTest(apyAccount.isTest());
- return new WxYouDianPayService(wxPayConfigStorage);
+ final WxYouDianPayService wxYouDianPayService = new WxYouDianPayService(wxPayConfigStorage);
+ wxYouDianPayService.setPayMessageHandler(new YouDianPayMessageHandler(apyAccount.getPayId()));
+ return wxYouDianPayService;
}
/**
@@ -157,7 +166,9 @@ public enum PayType implements BasePayType {
fuiouPayConfigStorage.setPayType(apyAccount.getPayType().toString());
fuiouPayConfigStorage.setInputCharset(apyAccount.getInputCharset());
fuiouPayConfigStorage.setTest(apyAccount.isTest());
- return new FuiouPayService(fuiouPayConfigStorage);
+ final FuiouPayService fuiouPayService = new FuiouPayService(fuiouPayConfigStorage);
+ fuiouPayService.setPayMessageHandler(new FuiouPayMessageHandler(apyAccount.getPayId()));
+ return fuiouPayService;
}
@Override
@@ -192,7 +203,9 @@ public enum PayType implements BasePayType {
unionPayConfigStorage.setPayType(apyAccount.getPayType().toString());
unionPayConfigStorage.setInputCharset(apyAccount.getInputCharset());
unionPayConfigStorage.setTest(apyAccount.isTest());
- return new UnionPayService(unionPayConfigStorage);
+ final UnionPayService unionPayService = new UnionPayService(unionPayConfigStorage);
+ unionPayService.setPayMessageHandler(new UnionPayMessageHandler(apyAccount.getPayId()));
+ return unionPayService;
}
@Override
@@ -214,7 +227,9 @@ public enum PayType implements BasePayType {
configStorage.setApiPassword(apyAccount.getPrivateKey());
//是否为沙箱
configStorage.setTest(true);
- return new PayoneerPayService(configStorage);
+ final PayoneerPayService payoneerPayService = new PayoneerPayService(configStorage);
+ payoneerPayService.setPayMessageHandler(new PayoneerMessageHandler(apyAccount.getPayId()));
+ return payoneerPayService;
//以下不建议进行使用,会引起两次请求的问题
//Basic Auth
@@ -243,7 +258,9 @@ public enum PayType implements BasePayType {
storage.setReturnUrl(apyAccount.getReturnUrl());
//取消按钮转跳地址,这里兼容的做法
storage.setNotifyUrl(apyAccount.getNotifyUrl());
- return new PayPalPayService(storage);
+ final PayPalPayService payPalPayService = new PayPalPayService(storage);
+ payPalPayService.setPayMessageHandler(new PayPalPayMessageHandler(apyAccount.getPayId()));
+ return payPalPayService;
}
@Override
diff --git a/pay-java-demo/src/main/java/com/egzosn/pay/demo/service/PayResponse.java b/pay-java-demo/src/main/java/com/egzosn/pay/demo/service/PayResponse.java
index c085fe5ce376b27bf694647259430c584441cd75..f461bc5044c153d8f92b57a78494d6f3a74e9939 100644
--- a/pay-java-demo/src/main/java/com/egzosn/pay/demo/service/PayResponse.java
+++ b/pay-java-demo/src/main/java/com/egzosn/pay/demo/service/PayResponse.java
@@ -4,6 +4,7 @@ import javax.annotation.Resource;
import org.springframework.beans.factory.config.AutowireCapableBeanFactory;
+import com.egzosn.pay.common.api.BasePayService;
import com.egzosn.pay.common.api.PayConfigStorage;
import com.egzosn.pay.common.api.PayMessageHandler;
import com.egzosn.pay.common.api.PayMessageRouter;
@@ -52,9 +53,13 @@ public class PayResponse {
//根据不同的账户类型 初始化支付配置
this.service = apyAccount.getPayType().getPayService(apyAccount);
this.storage = service.getPayConfigStorage();
+
+
//这里设置http请求配置
// service.setRequestTemplateConfigStorage(getHttpConfigStorage());
buildRouter(apyAccount.getPayId());
+
+
}
/**
@@ -87,7 +92,9 @@ public class PayResponse {
* 配置路由
*
* @param payId 指定账户id,用户多微信支付多支付宝支付
+ * @deprecated 不再推荐使用路由方式,回调或拦截器,直接在payService中设置并获取使用,回调拦截器已提供对应的实现方式:{@link BasePayService#setPayMessageHandler(com.egzosn.pay.common.api.PayMessageHandler)} 与{@link BasePayService#addPayMessageInterceptor(com.egzosn.pay.common.api.PayMessageInterceptor)}
*/
+ @Deprecated
private void buildRouter(Integer payId) {
router = new PayMessageRouter(this.service);
router
@@ -142,6 +149,12 @@ public class PayResponse {
return service;
}
+ /**
+ * 不建议使用, 回调拦截器已提供对应的实现方式:{@link BasePayService#setPayMessageHandler(com.egzosn.pay.common.api.PayMessageHandler)} 与{@link BasePayService#addPayMessageInterceptor(com.egzosn.pay.common.api.PayMessageInterceptor)}
+ *
+ * @return
+ */
+ @Deprecated
public PayMessageRouter getRouter() {
return router;
}
diff --git a/pay-java-demo/src/main/java/com/egzosn/pay/demo/service/handler/PayPalPayMessageHandler.java b/pay-java-demo/src/main/java/com/egzosn/pay/demo/service/handler/PayPalPayMessageHandler.java
index 912df2e626fdb48e4ee0580f79839d376a122a71..4fe35d398d9c5af6683dea192343fccd48b9b52e 100644
--- a/pay-java-demo/src/main/java/com/egzosn/pay/demo/service/handler/PayPalPayMessageHandler.java
+++ b/pay-java-demo/src/main/java/com/egzosn/pay/demo/service/handler/PayPalPayMessageHandler.java
@@ -1,27 +1,23 @@
package com.egzosn.pay.demo.service.handler;
-import com.egzosn.pay.common.api.PayMessageHandler;
-import com.egzosn.pay.common.api.PayService;
+import java.util.Map;
+
import com.egzosn.pay.common.bean.PayMessage;
import com.egzosn.pay.common.bean.PayOutMessage;
import com.egzosn.pay.common.exception.PayErrorException;
import com.egzosn.pay.paypal.api.PayPalPayService;
-import org.springframework.stereotype.Component;
-
-import java.math.BigDecimal;
-import java.util.Map;
/**
* PayPal支付回调处理器
* Created by ZaoSheng on 2016/6/1.
- *
*/
-@Component
-public class PayPalPayMessageHandler implements PayMessageHandler {
-
+public class PayPalPayMessageHandler extends BasePayMessageHandler {
+ public PayPalPayMessageHandler(Integer payId) {
+ super(payId);
+ }
@Override
public PayOutMessage handle(PayMessage payMessage, Map context, PayPalPayService payService) throws PayErrorException {
diff --git a/pay-java-demo/src/main/webapp/gzh.png b/pay-java-demo/src/main/webapp/gzh.png
index e607cb9ba904d1ac409680f6d8e7c282a0607ff8..3ca140e3e1265387fb060c7d318614a94316784b 100644
Binary files a/pay-java-demo/src/main/webapp/gzh.png and b/pay-java-demo/src/main/webapp/gzh.png differ
diff --git a/pay-java-fuiou/pom.xml b/pay-java-fuiou/pom.xml
index 59192fead7cf21f669ac111b7c9116996ec50510..107215bca08f2b8518bb883266e869b9e8f6f56c 100644
--- a/pay-java-fuiou/pom.xml
+++ b/pay-java-fuiou/pom.xml
@@ -5,7 +5,7 @@
pay-java-parent
com.egzosn
- 2.14.7
+ 2.14.8
4.0.0
pay-java-fuiou
diff --git a/pay-java-payoneer/pom.xml b/pay-java-payoneer/pom.xml
index 683ac4982c48ff1790751e4ff39539fbff34e38e..7f208e3e4bec4aabba0616632f107687a8e0dbb1 100644
--- a/pay-java-payoneer/pom.xml
+++ b/pay-java-payoneer/pom.xml
@@ -5,7 +5,7 @@
pay-java-parent
com.egzosn
- 2.14.7
+ 2.14.8
4.0.0
pay-java-payoneer
diff --git a/pay-java-paypal/pom.xml b/pay-java-paypal/pom.xml
index d818075f211e73b33cf356f1dc7cc66eb787b213..83a906633c5419ec19f5d5659c4cc396d63a1371 100644
--- a/pay-java-paypal/pom.xml
+++ b/pay-java-paypal/pom.xml
@@ -5,7 +5,7 @@
pay-java-parent
com.egzosn
- 2.14.7
+ 2.14.8
4.0.0
diff --git a/pay-java-union/pom.xml b/pay-java-union/pom.xml
index a49a64b0f36060d53e95b768dd8992e35ab55c56..00721c6a98b03a8b065725177a4770feabccb1a3 100644
--- a/pay-java-union/pom.xml
+++ b/pay-java-union/pom.xml
@@ -5,7 +5,7 @@
pay-java-parent
com.egzosn
- 2.14.7
+ 2.14.8
4.0.0
diff --git a/pay-java-web-support/pom.xml b/pay-java-web-support/pom.xml
index a69e2c7a1ab1595c64ce13918e41707fc66829f9..2ddceda009e768a29635382afd9987c750157a77 100644
--- a/pay-java-web-support/pom.xml
+++ b/pay-java-web-support/pom.xml
@@ -5,7 +5,7 @@
pay-java-parent
com.egzosn
- 2.14.7
+ 2.14.8
4.0.0
jar
diff --git a/pay-java-wx-youdian/pom.xml b/pay-java-wx-youdian/pom.xml
index 01f935ba899a507782e850e0e56b1a0efce88774..5b78c0c201e9d4ac08a23f2239fa8f42065a61d5 100644
--- a/pay-java-wx-youdian/pom.xml
+++ b/pay-java-wx-youdian/pom.xml
@@ -5,7 +5,7 @@
pay-java-parent
com.egzosn
- 2.14.7
+ 2.14.8
4.0.0
pay-java-wx-youdian
diff --git a/pay-java-wx/pom.xml b/pay-java-wx/pom.xml
index 7a41e7472432d9b6890631eb4c0a63e3a098b668..b8549626281e6ff84a25427c86859cd7d35b49b5 100644
--- a/pay-java-wx/pom.xml
+++ b/pay-java-wx/pom.xml
@@ -5,7 +5,7 @@
pay-java-parent
com.egzosn
- 2.14.7
+ 2.14.8
4.0.0
pay-java-wx
diff --git a/pay-java-wx/src/main/java/com/egzosn/pay/wx/api/WxPayService.java b/pay-java-wx/src/main/java/com/egzosn/pay/wx/api/WxPayService.java
index fad36ae1cf469b0d94b17a6587b6ccbf4cb533c4..93a87f4b743a838ddab9f05164305a7405a3886b 100644
--- a/pay-java-wx/src/main/java/com/egzosn/pay/wx/api/WxPayService.java
+++ b/pay-java-wx/src/main/java/com/egzosn/pay/wx/api/WxPayService.java
@@ -502,6 +502,20 @@ public class WxPayService extends BasePayService implements
return (String) orderInfo.get("code_url");
}
+ /**
+ * 小程序支付,返回小程序所需的订单构建信息
+ *
+ * @param order 发起支付的订单信息
+ * @return 返回支付结果
+ */
+ @Override
+ public Map jsApi(PayOrder order) {
+ if (null == order.getTransactionType()) {
+ order.setTransactionType(WxTransactionType.JSAPI);
+ }
+ return orderInfo(order);
+ }
+
/**
* 刷卡付,pos主动扫码付款
*
diff --git a/pay-java-wx/src/main/java/com/egzosn/pay/wx/v3/api/WxCombinePayService.java b/pay-java-wx/src/main/java/com/egzosn/pay/wx/v3/api/WxCombinePayService.java
index de4a6e84771c1b88997da77f4a3e0adb201e3f48..7db14646ed10b03bbbf9582bdef98a27a8ab54af 100644
--- a/pay-java-wx/src/main/java/com/egzosn/pay/wx/v3/api/WxCombinePayService.java
+++ b/pay-java-wx/src/main/java/com/egzosn/pay/wx/v3/api/WxCombinePayService.java
@@ -105,6 +105,19 @@ public class WxCombinePayService extends WxPayService {
return getAssistService().doExecute(parameters, order);
}
+ /**
+ * 小程序支付,返回小程序所需的订单构建信息
+ *
+ * @param order 发起支付的订单信息
+ * @return 返回支付结果
+ */
+ @Override
+ public Map jsApi(PayOrder order) {
+ if (null == order.getTransactionType()) {
+ order.setTransactionType(WxTransactionType.COMBINE_JSAPI);
+ }
+ return super.jsApi(order);
+ }
/**
* 交易查询接口
@@ -117,6 +130,7 @@ public class WxCombinePayService extends WxPayService {
public Map query(String transactionId, String outTradeNo) {
return query(new AssistOrder(outTradeNo));
}
+
/**
* 交易查询接口
*
diff --git a/pay-java-wx/src/main/java/com/egzosn/pay/wx/v3/api/WxPayService.java b/pay-java-wx/src/main/java/com/egzosn/pay/wx/v3/api/WxPayService.java
index 31701552604a7b529388ea0fd73b16b16bbd9d14..505f41fea54ff6c924e48a019821551ffb57dd09 100644
--- a/pay-java-wx/src/main/java/com/egzosn/pay/wx/v3/api/WxPayService.java
+++ b/pay-java-wx/src/main/java/com/egzosn/pay/wx/v3/api/WxPayService.java
@@ -2,7 +2,9 @@ package com.egzosn.pay.wx.v3.api;
import java.io.IOException;
import java.io.InputStream;
+import java.security.GeneralSecurityException;
import java.security.PrivateKey;
+import java.security.PublicKey;
import java.security.cert.Certificate;
import java.util.ArrayList;
import java.util.Collections;
@@ -15,6 +17,7 @@ import java.util.Map;
import java.util.stream.Collectors;
import org.apache.http.HttpEntity;
+import org.apache.http.message.BasicHeader;
import static com.egzosn.pay.wx.api.WxConst.OUT_TRADE_NO;
import static com.egzosn.pay.wx.api.WxConst.SANDBOXNEW;
@@ -41,6 +44,7 @@ import com.egzosn.pay.common.bean.TransferOrder;
import com.egzosn.pay.common.bean.result.PayException;
import com.egzosn.pay.common.exception.PayErrorException;
import com.egzosn.pay.common.http.HttpConfigStorage;
+import com.egzosn.pay.common.http.HttpStringEntity;
import com.egzosn.pay.common.http.ResponseEntity;
import com.egzosn.pay.common.http.UriVariables;
import com.egzosn.pay.common.util.DateUtils;
@@ -49,6 +53,7 @@ import com.egzosn.pay.common.util.MapGen;
import com.egzosn.pay.common.util.Util;
import com.egzosn.pay.common.util.sign.SignTextUtils;
import com.egzosn.pay.common.util.sign.SignUtils;
+import com.egzosn.pay.common.util.sign.encrypt.RSA;
import com.egzosn.pay.common.util.sign.encrypt.RSA2;
import com.egzosn.pay.common.util.str.StringUtils;
import com.egzosn.pay.wx.bean.WxPayError;
@@ -128,8 +133,10 @@ public class WxPayService extends BasePayService implements
if (null == assistService) {
assistService = new DefaultWxPayAssistService(this);
}
- //在这预先进行初始化
- assistService.refreshCertificate();
+ if (StringUtils.isEmpty(payConfigStorage.getKeyPublic())) {
+ //在这预先进行初始化
+ assistService.refreshCertificate();
+ }
return assistService;
}
@@ -220,14 +227,15 @@ public class WxPayService extends BasePayService implements
//微信平台签名
String signature = noticeParams.getHeader("wechatpay-signature");
- Certificate certificate = getAssistService().getCertificate(serial);
-
//这里为微信回调时的请求内容体,原值数据
String body = noticeParams.getBodyStr();
//签名信息
String signText = StringUtils.joining("\n", timestamp, nonce, body);
-
+ if (StringUtils.isNotEmpty(payConfigStorage.getKeyPublic())) {
+ return RSA2.verify(signText, signature, payConfigStorage.getKeyPublic(), payConfigStorage.getInputCharset());
+ }
+ Certificate certificate = getAssistService().getCertificate(serial);
return RSA2.verify(signText, signature, certificate, payConfigStorage.getInputCharset());
}
@@ -334,6 +342,24 @@ public class WxPayService extends BasePayService implements
return RSA2.sign(content, privateKey, characterEncoding);
}
+ /**
+ * http 实体 钩子
+ *
+ * @param entity 实体
+ * @return 返回处理后的实体
+ */
+ @Override
+ public HttpStringEntity hookHttpEntity(HttpStringEntity entity) {
+ if (StringUtils.isNotEmpty(payConfigStorage.getKeyPublicId())) {
+ // 商户上送敏感信息时使用`微信支付平台公钥`加密
+ entity.addHeader(new BasicHeader(WxConst.WECHATPAY_SERIAL, payConfigStorage.getKeyPublicId()));
+ }
+ else{
+ entity.addHeader(new BasicHeader(WxConst.WECHATPAY_SERIAL, payConfigStorage.getCertEnvironment().getPlatformSerialNumber()));
+ }
+ return entity;
+ }
+
/**
* 将请求参数或者请求流转化为 Map
*
@@ -436,6 +462,20 @@ public class WxPayService extends BasePayService implements
return (String) orderInfo.get("code_url");
}
+ /**
+ * 小程序支付,返回小程序所需的订单构建信息
+ *
+ * @param order 发起支付的订单信息
+ * @return 返回支付结果
+ */
+ @Override
+ public Map jsApi(PayOrder order) {
+ if (null == order.getTransactionType()) {
+ order.setTransactionType(WxTransactionType.JSAPI);
+ }
+ return orderInfo(order);
+ }
+
/**
* 刷卡付,pos主动扫码付款
*
@@ -657,19 +697,32 @@ public class WxPayService extends BasePayService implements
return null;
}
- // 商户上送敏感信息时使用`微信支付平台公钥`加密
- String serialNumber = payConfigStorage.getCertEnvironment().getPlatformSerialNumber();
- Certificate certificate = getAssistService().getCertificate(serialNumber);
+ PublicKey publicKeyTmp = null;
+ if (StringUtils.isEmpty(payConfigStorage.getKeyPublic())) {
+ // 商户上送敏感信息时使用`微信支付平台公钥`加密
+ String serialNumber = payConfigStorage.getCertEnvironment().getPlatformSerialNumber();
+ Certificate certificate = getAssistService().getCertificate(serialNumber);
+ publicKeyTmp = certificate.getPublicKey();
+ }
+ else {
+ try {
+ publicKeyTmp = RSA.getPublicKey(payConfigStorage.getKeyPublic());
+ }
+ catch (IOException | GeneralSecurityException e) {
+ throw new PayErrorException(new WxPayError("", e.getMessage()));
+ }
+ }
+ PublicKey publicKey = publicKeyTmp;
return transferDetails.stream()
.peek(transferDetailListItem -> {
String userName = transferDetailListItem.getUserName();
if (StringUtils.isNotEmpty(userName)) {
- String encryptedUserName = AntCertificationUtil.encryptToString(userName, certificate);
+ String encryptedUserName = AntCertificationUtil.encryptToString(userName, publicKey);
transferDetailListItem.setUserName(encryptedUserName);
}
String userIdCard = transferDetailListItem.getUserIdCard();
if (StringUtils.isNotEmpty(userIdCard)) {
- String encryptedUserIdCard = AntCertificationUtil.encryptToString(userIdCard, certificate);
+ String encryptedUserIdCard = AntCertificationUtil.encryptToString(userIdCard, publicKey);
transferDetailListItem.setUserIdCard(encryptedUserIdCard);
}
}).collect(Collectors.toList());
diff --git a/pay-java-wx/src/main/java/com/egzosn/pay/wx/v3/api/WxProfitSharingService.java b/pay-java-wx/src/main/java/com/egzosn/pay/wx/v3/api/WxProfitSharingService.java
index d4bc919733dfe62b35f14f16bf2917ffe7917072..71d6abb905ebb3d002d87fbd2f2bdd4c66febfa5 100644
--- a/pay-java-wx/src/main/java/com/egzosn/pay/wx/v3/api/WxProfitSharingService.java
+++ b/pay-java-wx/src/main/java/com/egzosn/pay/wx/v3/api/WxProfitSharingService.java
@@ -120,17 +120,7 @@ public class WxProfitSharingService extends WxPayService implements ProfitSharin
return getAssistService().doExecute(parameters, order);
}
- /**
- * http 实体 钩子
- *
- * @param entity 实体
- * @return 返回处理后的实体
- */
- @Override
- public HttpStringEntity hookHttpEntity(HttpStringEntity entity) {
- entity.addHeader(new BasicHeader(WxConst.WECHATPAY_SERIAL, payConfigStorage.getCertEnvironment().getPlatformSerialNumber()));
- return entity;
- }
+
/**
* 返回创建的订单信息
diff --git a/pay-java-wx/src/main/java/com/egzosn/pay/wx/v3/utils/AntCertificationUtil.java b/pay-java-wx/src/main/java/com/egzosn/pay/wx/v3/utils/AntCertificationUtil.java
index e29e163940694acb700bd61df8719e2728679e2f..5e6a58fc94d550cbc095a495763c752766d4d05f 100644
--- a/pay-java-wx/src/main/java/com/egzosn/pay/wx/v3/utils/AntCertificationUtil.java
+++ b/pay-java-wx/src/main/java/com/egzosn/pay/wx/v3/utils/AntCertificationUtil.java
@@ -52,7 +52,7 @@ public final class AntCertificationUtil {
static {
String javaVersion = System.getProperty("java.version");
- if (javaVersion.contains("1.8") || javaVersion.startsWith("8")){
+ if (javaVersion.contains("1.8") || javaVersion.startsWith("8")) {
Security.setProperty("crypto.policy", "unlimited");
}
SignUtils.initBc();
@@ -170,9 +170,20 @@ public final class AntCertificationUtil {
* @return 加密后的内容
*/
public static String encryptToString(String message, Certificate certificate) {
+ return encryptToString(message, certificate.getPublicKey());
+ }
+
+ /**
+ * 对请求敏感字段进行加密
+ *
+ * @param message the message
+ * @param publicKey the certificate
+ * @return 加密后的内容
+ */
+ public static String encryptToString(String message, PublicKey publicKey) {
try {
Cipher cipher = Cipher.getInstance("RSA/ECB/OAEPWithSHA-1AndMGF1Padding", WxConst.BC_PROVIDER);
- cipher.init(Cipher.ENCRYPT_MODE, certificate.getPublicKey());
+ cipher.init(Cipher.ENCRYPT_MODE, publicKey);
byte[] data = message.getBytes(StandardCharsets.UTF_8);
byte[] cipherData = cipher.doFinal(data);
diff --git a/pay-java-wx/src/main/java/com/egzosn/pay/wx/v3/utils/WxConst.java b/pay-java-wx/src/main/java/com/egzosn/pay/wx/v3/utils/WxConst.java
index bbd311db7b94b7367bc879e6d42c7bfe2312e8c0..f8d274dec1170c144beb82fdef80dcd52afb4af5 100644
--- a/pay-java-wx/src/main/java/com/egzosn/pay/wx/v3/utils/WxConst.java
+++ b/pay-java-wx/src/main/java/com/egzosn/pay/wx/v3/utils/WxConst.java
@@ -39,7 +39,7 @@ public final class WxConst {
public static final String TYPE = "type";
public static final String ACCOUNT = "account";
public static final String NAME = "name";
- public static final String RELATION_TYPE = "relationType";
+ public static final String RELATION_TYPE = "relation_type";
public static final String CUSTOM_RELATION = "customRelation";
public static final String DESCRIPTION = "description";
public static final String BILL_DATE = "bill_date";
diff --git a/pay-java-yiji/pom.xml b/pay-java-yiji/pom.xml
index 8cb8f7f5bc84a8a8b8fe989eb6d2222fdab3db65..bdf6cae7a040eb3ef4707b5daa19f6c201594f46 100644
--- a/pay-java-yiji/pom.xml
+++ b/pay-java-yiji/pom.xml
@@ -5,7 +5,7 @@
pay-java-parent
com.egzosn
- 2.14.7
+ 2.14.8
4.0.0
diff --git a/pom.xml b/pom.xml
index 1220e08466bc96f6a40e1ced8aa9d0bf8ed44167..49afca89e88c27608372479f4b93196a12561279 100644
--- a/pom.xml
+++ b/pom.xml
@@ -7,7 +7,7 @@
com.egzosn
pay-java-parent
pom
- 2.14.7
+ 2.14.8
Pay Java - Parent
Pay Java Parent
@@ -64,7 +64,7 @@
- 2.14.7
+ 2.14.8
4.5.4
1.2.17
1.2.83