wechatpay-apiv3 / wechatpay-java

微信支付 APIv3 的官方 Java Library
Apache License 2.0
923 stars 206 forks source link

支付成功和退款成功通知,demo没看明白 #158

Closed jsl1992 closed 1 year ago

jsl1992 commented 1 year ago

错误描述

这边demo就是controller要如何接收参数 RequestParam requestParam = new RequestParam.Builder() .serialNumber(wechatPayCertificateSerialNumber) .nonce(nonce) .signature(signature) .timestamp(timestamp) .body(requestBody) .build();

还有这边退款通知有没相关demo。这个sdk能不能写详细点。功能都一起写的了。免得大家对接浪费一大推时间

重现bug的步骤

就是demo,示例。直接从controller怎么做,如何返回 。我们只是要调用下api。不要搞得大家都看不懂

预期行为

从controller层到返回你们要求的编码相关demo

导致错误的代码片段

No response

操作系统

window

Java 版本

8

wechatpay-java 版本

0.01

其他信息

No response

jsl1992 commented 1 year ago

private T getDecryptObject(RequestParam requestParam, Class decryptObjectClass) { Notification notification = gson.fromJson(requestParam.getBody(), Notification.class); validateNotification(notification); String algorithm = notification.getResource().getAlgorithm(); String associatedData = notification.getResource().getAssociatedData(); String nonce = notification.getResource().createNonce(); String ciphertext = notification.getResource().getCiphertext(); String plaintext = decryptData(algorithm, associatedData, nonce, ciphertext); return gson.fromJson(plaintext, decryptObjectClass); } 在这个方法里没有看到 "event_type": "TRANSACTION.SUCCESS",notification 对这个字段的校验。默认是只有成功才会通知吗。 看文档这个退款也会有,

oldbotman commented 1 year ago

private T getDecryptObject(RequestParam requestParam, Class decryptObjectClass) { Notification notification = gson.fromJson(requestParam.getBody(), Notification.class); validateNotification(notification); String algorithm = notification.getResource().getAlgorithm(); String associatedData = notification.getResource().getAssociatedData(); String nonce = notification.getResource().createNonce(); String ciphertext = notification.getResource().getCiphertext(); String plaintext = decryptData(algorithm, associatedData, nonce, ciphertext); return gson.fromJson(plaintext, decryptObjectClass); } 在这个方法里没有看到 "event_type": "TRANSACTION.SUCCESS",notification 对这个字段的校验。默认是只有成功才会通知吗。 看文档这个退款也会有,

回调解密的过程中没有说明需要使用这个字段的,看样子这个字段是交给开发者来使用的

xy-peng commented 1 year ago
  1. 如何接收回调的参数跟你使用的框架直接相关。不同框架,甚至同一框架的不同版本,实现都有可能是不一样的。所以,我们只演示了接收参数后的处理,而没有提供接收参数的部分代码。
  2. event_type 是回调类型。如果你的服务使用同一个地址接收不同业务的回调,可以通过该参数判断回调类型。