Commit 58c3afee08a5d0632a8dd010c11fca29a89b5afa
1 parent
c4020779
【支付宝通知回调】: AbstractAlipayClient.java : 支付宝统一回调参数 str转map 通知回调参数 Map<String, String> params = notifyData.getParams(); Map<String, String> params = strToMap(notifyData.getBody());
Showing
1 changed file
with
24 additions
and
2 deletions
yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/alipay/AbstractAlipayClient.java
| ... | ... | @@ -18,6 +18,7 @@ import lombok.SneakyThrows; |
| 18 | 18 | import lombok.extern.slf4j.Slf4j; |
| 19 | 19 | |
| 20 | 20 | import java.nio.charset.StandardCharsets; |
| 21 | +import java.util.HashMap; | |
| 21 | 22 | import java.util.Map; |
| 22 | 23 | |
| 23 | 24 | import static cn.iocoder.yudao.framework.common.util.json.JsonUtils.toJsonString; |
| ... | ... | @@ -54,7 +55,7 @@ public abstract class AbstractAlipayClient extends AbstractPayClient<AlipayPayCl |
| 54 | 55 | */ |
| 55 | 56 | @Override |
| 56 | 57 | public PayOrderNotifyRespDTO parseOrderNotify(PayNotifyDataDTO data) throws Exception { |
| 57 | - Map<String, String> params = data.getParams(); | |
| 58 | + Map<String, String> params = strToMap(data.getBody()); | |
| 58 | 59 | return PayOrderNotifyRespDTO.builder().orderExtensionNo(params.get("out_trade_no")) |
| 59 | 60 | .channelOrderNo(params.get("trade_no")).channelUserId(params.get("seller_id")) |
| 60 | 61 | .tradeStatus(params.get("trade_status")) |
| ... | ... | @@ -64,7 +65,7 @@ public abstract class AbstractAlipayClient extends AbstractPayClient<AlipayPayCl |
| 64 | 65 | |
| 65 | 66 | @Override |
| 66 | 67 | public PayRefundNotifyDTO parseRefundNotify(PayNotifyDataDTO notifyData) { |
| 67 | - Map<String, String> params = notifyData.getParams(); | |
| 68 | + Map<String, String> params = strToMap(notifyData.getBody()); | |
| 68 | 69 | PayRefundNotifyDTO notifyDTO = PayRefundNotifyDTO.builder().channelOrderNo(params.get("trade_no")) |
| 69 | 70 | .tradeNo(params.get("out_trade_no")) |
| 70 | 71 | .reqNo(params.get("out_biz_no")) |
| ... | ... | @@ -128,4 +129,25 @@ public abstract class AbstractAlipayClient extends AbstractPayClient<AlipayPayCl |
| 128 | 129 | } |
| 129 | 130 | } |
| 130 | 131 | |
| 132 | + /** | |
| 133 | + * | |
| 134 | + * 支付宝统一回调参数 str转map | |
| 135 | + * | |
| 136 | + * @param s 支付宝支付通知回调参数 | |
| 137 | + * @return map 支付宝集合 | |
| 138 | + */ | |
| 139 | + public static Map<String, String> strToMap(String s) { | |
| 140 | + Map<String, String> stringStringMap = new HashMap<>(); | |
| 141 | + //调整时间格式 | |
| 142 | + String s3 = s.replaceAll("%3A", ":"); | |
| 143 | + //获取map | |
| 144 | + String s4 = s3.replace("+", " "); | |
| 145 | + String[] split = s4.split("&"); | |
| 146 | + for (String s1 : split) { | |
| 147 | + String[] split1 = s1.split("="); | |
| 148 | + stringStringMap.put(split1[0], split1[1]); | |
| 149 | + } | |
| 150 | + return stringStringMap; | |
| 151 | + } | |
| 152 | + | |
| 131 | 153 | } | ... | ... |