mirror of
https://github.com/dromara/payment-spring-boot.git
synced 2026-03-14 05:43:46 +08:00
重启批次接口 营销回调接口
This commit is contained in:
@@ -8,12 +8,18 @@ import com.fasterxml.jackson.annotation.JsonInclude;
|
|||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
import com.fasterxml.jackson.databind.PropertyNamingStrategy;
|
import com.fasterxml.jackson.databind.PropertyNamingStrategy;
|
||||||
import lombok.SneakyThrows;
|
import lombok.SneakyThrows;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.util.Assert;
|
import org.springframework.util.Assert;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Dax
|
* @author Dax
|
||||||
* @since 10:21
|
* @since 10:21
|
||||||
*/
|
*/
|
||||||
|
@Slf4j
|
||||||
public class WechatPayCallback {
|
public class WechatPayCallback {
|
||||||
private static final ObjectMapper MAPPER = new ObjectMapper();
|
private static final ObjectMapper MAPPER = new ObjectMapper();
|
||||||
private final SignatureProvider signatureProvider;
|
private final SignatureProvider signatureProvider;
|
||||||
@@ -29,7 +35,7 @@ public class WechatPayCallback {
|
|||||||
|
|
||||||
|
|
||||||
@SneakyThrows
|
@SneakyThrows
|
||||||
public CouponConsumeData wechatPayCouponCallback(ResponseSignVerifyParams params) {
|
public Map<String, ?> wechatPayCouponCallback(ResponseSignVerifyParams params, Consumer<CouponConsumeData> couponConsumeDataConsumer) {
|
||||||
|
|
||||||
if (signatureProvider.responseSignVerify(params)) {
|
if (signatureProvider.responseSignVerify(params)) {
|
||||||
CallbackParams callbackParams = MAPPER.readValue(params.getBody(), CallbackParams.class);
|
CallbackParams callbackParams = MAPPER.readValue(params.getBody(), CallbackParams.class);
|
||||||
@@ -40,7 +46,12 @@ public class WechatPayCallback {
|
|||||||
String ciphertext = resource.getCiphertext();
|
String ciphertext = resource.getCiphertext();
|
||||||
String data = signatureProvider.decryptResponseBody(associatedData, nonce, ciphertext);
|
String data = signatureProvider.decryptResponseBody(associatedData, nonce, ciphertext);
|
||||||
Assert.hasText(data, "decryptData is required");
|
Assert.hasText(data, "decryptData is required");
|
||||||
return MAPPER.readValue(data, CouponConsumeData.class);
|
CouponConsumeData couponConsumeData = MAPPER.readValue(data, CouponConsumeData.class);
|
||||||
|
couponConsumeDataConsumer.accept(couponConsumeData);
|
||||||
|
Map<String, Object> responseBody = new HashMap<>();
|
||||||
|
responseBody.put("code", 200);
|
||||||
|
responseBody.put("message", "核销成功");
|
||||||
|
return responseBody;
|
||||||
}
|
}
|
||||||
throw new PayException("invalid wechat pay coupon callback");
|
throw new PayException("invalid wechat pay coupon callback");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import lombok.Data;
|
|||||||
* 微信的响应签名校验参数
|
* 微信的响应签名校验参数
|
||||||
*
|
*
|
||||||
* @author Dax
|
* @author Dax
|
||||||
* @see com.enongm.dianji.payment.wechat.v3.SignatureProvider#responseSignVerify(String, String, String, String, String)
|
* @see com.enongm.dianji.payment.wechat.v3.SignatureProvider#responseSignVerify(ResponseSignVerifyParams)
|
||||||
* @since 16:32
|
* @since 16:32
|
||||||
*/
|
*/
|
||||||
@Data
|
@Data
|
||||||
|
|||||||
Reference in New Issue
Block a user