Skip to content

Commit

Permalink
🐛 #1959 【微信支付】电商收付通修复请求分账接口异常问题
Browse files Browse the repository at this point in the history
Co-authored-by: aha <aha>
  • Loading branch information
guicw authored Jan 10, 2021
1 parent fd58b3f commit 04fadf6
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
package com.github.binarywang.wxpay.bean.ecommerce;

import com.github.binarywang.wxpay.v3.SpecEncrypt;
import com.google.gson.annotations.SerializedName;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;
import java.util.List;

/**
* 请求分账 对象
Expand Down Expand Up @@ -86,7 +88,8 @@ public class ProfitSharingRequest implements Serializable {
* </pre>
*/
@SerializedName(value = "receivers")
private Receiver[] receivers;
@SpecEncrypt
private List<Receiver> receivers;

/**
* <pre>
Expand Down Expand Up @@ -186,6 +189,7 @@ public static class Receiver implements Serializable {
* </pre>
*/
@SerializedName(value = "receiver_name")
@SpecEncrypt
private String receiverName;

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,8 @@ public FundBalanceResult subDayEndBalance(String subMchid, String date) throws W
@Override
public ProfitSharingResult profitSharing(ProfitSharingRequest request) throws WxPayException {
String url = String.format("%s/v3/ecommerce/profitsharing/orders", this.payService.getPayBaseUrl());
String response = this.payService.postV3(url, GSON.toJson(request));
RsaCryptoUtil.encryptFields(request, this.payService.getConfig().getVerifier().getValidCertificate());
String response = this.payService.postV3WithWechatpaySerial(url, GSON.toJson(request));
return GSON.fromJson(response, ProfitSharingResult.class);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import java.security.PrivateKey;
import java.security.cert.X509Certificate;
import java.util.Base64;
import java.util.Collection;

/**
* 微信支付敏感信息加密
Expand Down Expand Up @@ -53,8 +54,18 @@ private static void encryptField(Object encryptObject, X509Certificate certifica
} else {
field.setAccessible(true);
Object obj = field.get(encryptObject);
if (obj != null) {
encryptField(field.get(encryptObject), certificate);
if (obj == null) {
continue;
}
if (obj instanceof Collection) {
Collection collection = (Collection) obj;
for (Object o : collection) {
if (o != null) {
encryptField(o, certificate);
}
}
} else {
encryptField(obj, certificate);
}
}
}
Expand Down

0 comments on commit 04fadf6

Please sign in to comment.