🎨 【微信支付】增加服务商模式下分账通知的解析方法

This commit is contained in:
linyaqiang
2023-08-03 10:40:34 +00:00
committed by Binary Wang
parent 3576f53f42
commit bdafa81184
3 changed files with 171 additions and 0 deletions

View File

@@ -240,6 +240,23 @@ public interface ProfitSharingV3Service {
*/
ProfitSharingNotifyResult getProfitSharingNotifyResult(String notifyData, SignatureHeader header) throws WxPayException;
/**
* <pre>
* 分账动账通知-服务商
*
* 分账或分账回退成功后,微信会把相关变动结果发送给分账接收方(只支持商户)。
* 对后台通知交互时,如果微信收到应答不是成功或超时,微信认为通知失败,微信会通过一定的策略定期重新发起通知,尽可能提高通知的成功率,但微信不保证通知最终能成功。
* 文档详见: https://pay.weixin.qq.com/wiki/doc/apiv3/apis/chapter8_1_10.shtml
* </pre>
*
* @param notifyData 分账通知实体
* @param header 分账通知头 {@link SignatureHeader}
* @return {@link ProfitSharingNotifyData} 资源对象
* @throws WxPayException the wx pay exception
* @see <a href="https://pay.weixin.qq.com/wiki/doc/apiv3_partner/apis/chapter8_1_10.shtml">微信文档</a>
*/
ProfitSharingPartnerNotifyResult getProfitSharingPartnerNotifyResult(String notifyData, SignatureHeader header) throws WxPayException;
/**
* <pre>
* 申请分账账单

View File

@@ -135,6 +135,22 @@ public class ProfitSharingV3ServiceImpl implements ProfitSharingV3Service {
}
}
@Override
public ProfitSharingPartnerNotifyResult getProfitSharingPartnerNotifyResult(String notifyData, SignatureHeader header) throws WxPayException {
ProfitSharingNotifyData response = parseNotifyData(notifyData, header);
ProfitSharingNotifyData.Resource resource = response.getResource();
String cipherText = resource.getCipherText();
String associatedData = resource.getAssociatedData();
String nonce = resource.getNonce();
String apiV3Key = this.payService.getConfig().getApiV3Key();
try {
String result = AesUtils.decryptToString(associatedData, nonce, cipherText, apiV3Key);
return GSON.fromJson(result, ProfitSharingPartnerNotifyResult.class);
} catch (GeneralSecurityException | IOException e) {
throw new WxPayException("解析报文异常!", e);
}
}
@Override
public ProfitSharingBillResult getProfitSharingBill(ProfitSharingBillRequest request) throws WxPayException {
String url = String.format("%s/v3/profitsharing/bills?bill_date=%s", this.payService.getPayBaseUrl(),