🆕 #3278【微信支付】 增加解析商家转账批次回调通知的方法
This commit is contained in:
@@ -841,6 +841,75 @@ public class BaseWxPayServiceImplTest {
|
||||
return WxPayNotifyV3Response.success("成功");
|
||||
}
|
||||
|
||||
/**
|
||||
* 商家转账批次回调通知
|
||||
* https://pay.weixin.qq.com/docs/merchant/apis/batch-transfer-to-balance/transfer-batch-callback-notice.html
|
||||
*
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
@Test
|
||||
public String parseTransferBatchesNotifyV3Result() throws Exception {
|
||||
|
||||
String body = "{\n" +
|
||||
" \"id\": \"1c8192d8-aba1-5898-a79c-7d3abb72eabe\",\n" +
|
||||
" \"create_time\": \"2023-08-16T16:43:27+08:00\",\n" +
|
||||
" \"resource_type\": \"encrypt-resource\",\n" +
|
||||
" \"event_type\": \"MCHTRANSFER.BATCH.FINISHED\",\n" +
|
||||
" \"summary\": \"商家转账批次完成通知\",\n" +
|
||||
" \"resource\": {\n" +
|
||||
" \"original_type\": \"mch_payment\",\n" +
|
||||
" \"algorithm\": \"AEAD_AES_256_GCM\",\n" +
|
||||
" \"ciphertext\": \"zTBf6DDPzZSoIBkoLFkC+ho97QrqnT6UU/ADM0tJP07ITaFPek4vofQjmclLUof78NqrPcJs5OIBl+gnKKJ4xCxcDmDnZZHvev5o1pk4gwtJIFIDxbq3piDr4Wq6cZpvGPPQTYC8YoVRTdVeeN+EcuklRrmaFzv8wCTSdI9wFJ9bsxtLedhq4gpkKqN5fbSguQg9JFsX3OJeT7KPfRd6SD1gu4Lpw5gwxthfOHcYsjM/eY5gaew8zzpN6mMUEJ1HqkNuQgOguHBxFnqFPiMz+Iadw7X38Yz+IgfUkOhN1iuvMhGYKbwKJ7rTiBVvGGpF6Wse1zFKgSiTLH2RnUAMkkHmxqk+JhbQKZpSWr6O8BfhHO1OKg7hpcHZtOJKNMjIF62WYDVf36w1h8h5fg==\",\n" +
|
||||
" \"associated_data\": \"mch_payment\",\n" +
|
||||
" \"nonce\": \"DdF3UJVNQaKT\"\n" +
|
||||
" }\n" +
|
||||
"}";
|
||||
WxPayTransferBatchesNotifyV3Result transferBatchesNotifyV3Body = GSON.fromJson(body, WxPayTransferBatchesNotifyV3Result.class);
|
||||
log.info(GSON.toJson(transferBatchesNotifyV3Body));
|
||||
|
||||
// 处理业务逻辑 ...
|
||||
|
||||
return WxPayNotifyV3Response.success("成功");
|
||||
}
|
||||
|
||||
// 测试
|
||||
public static void main(String[] args){
|
||||
String body = "{\n" +
|
||||
" \"id\": \"1c8192d8-aba1-5898-a79c-7d3abb72eabe\",\n" +
|
||||
" \"create_time\": \"2023-08-16T16:43:27+08:00\",\n" +
|
||||
" \"resource_type\": \"encrypt-resource\",\n" +
|
||||
" \"event_type\": \"MCHTRANSFER.BATCH.FINISHED\",\n" +
|
||||
" \"summary\": \"商家转账批次完成通知\",\n" +
|
||||
" \"resource\": {\n" +
|
||||
" \"original_type\": \"mch_payment\",\n" +
|
||||
" \"algorithm\": \"AEAD_AES_256_GCM\",\n" +
|
||||
" \"ciphertext\": \"zTBf6DDPzZSoIBkoLFkC+ho97QrqnT6UU/ADM0tJP07ITaFPek4vofQjmclLUof78NqrPcJs5OIBl+gnKKJ4xCxcDmDnZZHvev5o1pk4gwtJIFIDxbq3piDr4Wq6cZpvGPPQTYC8YoVRTdVeeN+EcuklRrmaFzv8wCTSdI9wFJ9bsxtLedhq4gpkKqN5fbSguQg9JFsX3OJeT7KPfRd6SD1gu4Lpw5gwxthfOHcYsjM/eY5gaew8zzpN6mMUEJ1HqkNuQgOguHBxFnqFPiMz+Iadw7X38Yz+IgfUkOhN1iuvMhGYKbwKJ7rTiBVvGGpF6Wse1zFKgSiTLH2RnUAMkkHmxqk+JhbQKZpSWr6O8BfhHO1OKg7hpcHZtOJKNMjIF62WYDVf36w1h8h5fg==\",\n" +
|
||||
" \"associated_data\": \"mch_payment\",\n" +
|
||||
" \"nonce\": \"DdF3UJVNQaKT\"\n" +
|
||||
" }\n" +
|
||||
"}";
|
||||
OriginNotifyResponse transferBatchesNotifyV3Body = GSON.fromJson(body, OriginNotifyResponse.class);
|
||||
log.info(GSON.toJson(transferBatchesNotifyV3Body));
|
||||
|
||||
String decryptNotifyResult = "{\n" +
|
||||
" \"out_batch_no\": \"bfatestnotify000033\",\n" +
|
||||
" \"batch_id\": \"131000007026709999520922023081519403795655\",\n" +
|
||||
" \"batch_status\": \"FINISHED\",\n" +
|
||||
" \"total_num\": 2,\n" +
|
||||
" \"total_amount\": 200,\n" +
|
||||
" \"success_amount\": 100,\n" +
|
||||
" \"success_num\": 1,\n" +
|
||||
" \"fail_amount\": 100,\n" +
|
||||
" \"fail_num\": 1,\n" +
|
||||
" \"mchid\": \"2483775951\",\n" +
|
||||
" \"update_time\": \"2023-08-15T20:33:22+08:00\"\n" +
|
||||
"}";
|
||||
WxPayTransferBatchesNotifyV3Result.DecryptNotifyResult notifyResult = GSON.fromJson(decryptNotifyResult, WxPayTransferBatchesNotifyV3Result.DecryptNotifyResult.class);
|
||||
log.info(GSON.toJson(notifyResult));
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testWxPayNotifyV3Response() {
|
||||
System.out.println(WxPayNotifyV3Response.success("success"));
|
||||
|
||||
Reference in New Issue
Block a user