From d0324c6771842442c3f3b17be73dabde1e4ccf65 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=A6=99=E8=95=89=E4=BD=A0=E4=B8=AA=E5=B7=B4=E6=8B=89?= Date: Thu, 11 Jan 2024 02:29:21 +0000 Subject: [PATCH] =?UTF-8?q?:bug:=20!118=20=E3=80=90=E5=BE=AE=E4=BF=A1?= =?UTF-8?q?=E6=94=AF=E4=BB=98=E3=80=91=E4=BF=AE=E5=A4=8D=E8=8E=B7=E5=8F=96?= =?UTF-8?q?=E5=AF=B9=E7=A7=81=E9=93=B6=E8=A1=8C=E5=8D=A1=E5=8F=B7=E5=BC=80?= =?UTF-8?q?=E6=88=B7=E9=93=B6=E8=A1=8C=E6=8E=A5=E5=8F=A3=E8=A7=A3=E5=AF=86?= =?UTF-8?q?=E5=A4=B1=E8=B4=A5=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/github/binarywang/wxpay/service/BankService.java | 2 +- .../binarywang/wxpay/service/impl/BankServiceImpl.java | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/BankService.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/BankService.java index 095510d4f..54fceec58 100644 --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/BankService.java +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/BankService.java @@ -22,7 +22,7 @@ public interface BankService { * 文档地址:https://pay.weixin.qq.com/wiki/doc/apiv3_partner/Offline/apis/chapter11_2_1.shtml * * - * @param accountNumber 银行卡号 该字段需进行加密处理,加密方法详见敏感信息加密说明。(提醒:必须在HTTP头中上送Wechatpay-Serial) + * @param accountNumber 银行卡号 * @return BankAccountResult 对私银行卡号开户银行信息 * @throws WxPayException . */ diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/BankServiceImpl.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/BankServiceImpl.java index 623a787d9..b6344cba4 100644 --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/BankServiceImpl.java +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/BankServiceImpl.java @@ -4,10 +4,13 @@ import com.github.binarywang.wxpay.bean.bank.*; import com.github.binarywang.wxpay.exception.WxPayException; import com.github.binarywang.wxpay.service.BankService; import com.github.binarywang.wxpay.service.WxPayService; +import com.github.binarywang.wxpay.v3.util.RsaCryptoUtil; import com.google.gson.Gson; import com.google.gson.GsonBuilder; import lombok.RequiredArgsConstructor; +import java.net.URLEncoder; + /** * 微信支付-银行组件 * @@ -20,6 +23,12 @@ public class BankServiceImpl implements BankService { @Override public BankAccountResult searchBanksByBankAccount(String accountNumber) throws WxPayException { + try { + String encryptAccountNumber = RsaCryptoUtil.encryptOAEP(accountNumber, this.payService.getConfig().getVerifier().getValidCertificate()); + accountNumber = URLEncoder.encode(encryptAccountNumber, "UTF-8"); + } catch (Exception e) { + throw new RuntimeException("银行卡号加密异常!", e); + } String url = String.format("%s/v3/capital/capitallhh/banks/search-banks-by-bank-account?account_number=%s", this.payService.getPayBaseUrl(), accountNumber); String response = payService.getV3WithWechatPaySerial(url); return GSON.fromJson(response, BankAccountResult.class);