🆕 #3327【微信支付】增加平台收付通(注销申请)相关接口

This commit is contained in:
zhuangzibin
2024-10-09 12:36:50 +08:00
committed by GitHub
parent 2226693f59
commit 5821710e07
7 changed files with 269 additions and 7 deletions

View File

@@ -6,6 +6,8 @@ import com.github.binarywang.wxpay.bean.ecommerce.enums.SpAccountTypeEnum;
import com.github.binarywang.wxpay.bean.ecommerce.enums.TradeTypeEnum;
import com.github.binarywang.wxpay.exception.WxPayException;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
/**
@@ -535,4 +537,39 @@ public interface EcommerceService {
*/
SubsidiesCancelResult subsidiesCancel(SubsidiesCancelRequest subsidiesCancelRequest) throws WxPayException;
/**
* <pre>
* 提交注销申请单
* 文档地址: https://pay.weixin.qq.com/docs/partner/apis/ecommerce-cancel/cancel-applications/create-cancel-application.html
* </pre>
*
* @param accountCancelApplicationsRequest 提交注销申请单
* @return 返回数据 return AccountCancelApplicationsResult
* @throws WxPayException the wx pay exception
*/
AccountCancelApplicationsResult createdAccountCancelApplication(AccountCancelApplicationsRequest accountCancelApplicationsRequest) throws WxPayException;
/**
* <pre>
* 查询注销单状态
* 文档地址: https://pay.weixin.qq.com/docs/partner/apis/ecommerce-cancel/cancel-applications/get-cancel-application.html
* </pre>
*
* @param outApplyNo 注销申请单号
* @return 返回数据 return AccountCancelApplicationsResult
* @throws WxPayException the wx pay exception
*/
AccountCancelApplicationsResult getAccountCancelApplication(String outApplyNo) throws WxPayException;
/**
* <pre>
* 注销单资料图片上传
* 文档地址: https://pay.weixin.qq.com/docs/partner/apis/ecommerce-cancel/media/upload-media.html
* </pre>
*
* @param imageFile 图片
* @return 返回数据 return AccountCancelApplicationsResult
* @throws WxPayException the wx pay exception
*/
AccountCancelApplicationsMediaResult uploadMediaAccountCancelApplication(File imageFile) throws WxPayException, IOException;;
}

View File

@@ -7,22 +7,27 @@ import com.github.binarywang.wxpay.bean.ecommerce.enums.TradeTypeEnum;
import com.github.binarywang.wxpay.exception.WxPayException;
import com.github.binarywang.wxpay.service.EcommerceService;
import com.github.binarywang.wxpay.service.WxPayService;
import com.github.binarywang.wxpay.v3.WechatPayUploadHttpPost;
import com.github.binarywang.wxpay.v3.util.AesUtils;
import com.github.binarywang.wxpay.v3.util.RsaCryptoUtil;
import com.google.common.base.CaseFormat;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import lombok.RequiredArgsConstructor;
import org.apache.commons.codec.digest.DigestUtils;
import org.apache.commons.lang3.StringUtils;
import java.beans.BeanInfo;
import java.beans.IntrospectionException;
import java.beans.Introspector;
import java.beans.PropertyDescriptor;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.net.URI;
import java.nio.charset.StandardCharsets;
import java.security.GeneralSecurityException;
import java.text.DateFormat;
@@ -395,6 +400,36 @@ public class EcommerceServiceImpl implements EcommerceService {
String response = this.payService.postV3(url, GSON.toJson(subsidiesCancelRequest));
return GSON.fromJson(response, SubsidiesCancelResult.class);
}
@Override
public AccountCancelApplicationsResult createdAccountCancelApplication(AccountCancelApplicationsRequest accountCancelApplicationsRequest) throws WxPayException {
String url = String.format("%s/v3/ecommerce/account/cancel-applications", this.payService.getPayBaseUrl());
String response = this.payService.postV3(url, GSON.toJson(accountCancelApplicationsRequest));
return GSON.fromJson(response, AccountCancelApplicationsResult.class);
}
@Override
public AccountCancelApplicationsResult getAccountCancelApplication(String outApplyNo) throws WxPayException {
String url = String.format("%s/v3/ecommerce/account/cancel-applications/out-apply-no/%s", this.payService.getPayBaseUrl(), outApplyNo);
String result = this.payService.getV3(url);
return GSON.fromJson(result, AccountCancelApplicationsResult.class);
}
@Override
public AccountCancelApplicationsMediaResult uploadMediaAccountCancelApplication(File imageFile) throws WxPayException, IOException {
String url = String.format("%s/v3/ecommerce/account/cancel-applications/media", this.payService.getPayBaseUrl());
try (FileInputStream s1 = new FileInputStream(imageFile)) {
String sha256 = DigestUtils.sha256Hex(s1);
try (InputStream s2 = new FileInputStream(imageFile)) {
WechatPayUploadHttpPost request = new WechatPayUploadHttpPost.Builder(URI.create(url))
.withImage(imageFile.getName(), sha256, s2)
.buildEcommerceAccount();
String result = this.payService.postV3(url, request);
return GSON.fromJson(result, AccountCancelApplicationsMediaResult.class);
}
}
}
/**
* 校验通知签名
*