🐛 #1959 【微信支付】电商收付通修复请求分账接口异常问题

Co-authored-by: aha <aha>
This commit is contained in:
guicw 2021-01-10 23:21:19 +08:00 committed by GitHub
parent fd58b3f212
commit 04fadf6f71
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 20 additions and 4 deletions

View File

@ -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;
/**
* 请求分账 对象
@ -86,7 +88,8 @@ public class ProfitSharingRequest implements Serializable {
* </pre>
*/
@SerializedName(value = "receivers")
private Receiver[] receivers;
@SpecEncrypt
private List<Receiver> receivers;
/**
* <pre>
@ -186,6 +189,7 @@ public class ProfitSharingRequest implements Serializable {
* </pre>
*/
@SerializedName(value = "receiver_name")
@SpecEncrypt
private String receiverName;
}

View File

@ -190,7 +190,8 @@ public class EcommerceServiceImpl implements EcommerceService {
@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);
}

View File

@ -15,6 +15,7 @@ import java.security.NoSuchAlgorithmException;
import java.security.PrivateKey;
import java.security.cert.X509Certificate;
import java.util.Base64;
import java.util.Collection;
/**
* 微信支付敏感信息加密
@ -53,8 +54,18 @@ public class RsaCryptoUtil {
} 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);
}
}
}