|
@@ -63,18 +63,38 @@ public class DefaultWechatPaymentHandler implements WechatPaymentHandler {
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public WechatPaymentCallback callback(@NonNull String name, @NonNull String content) {
|
|
public WechatPaymentCallback callback(@NonNull String name, @NonNull String content) {
|
|
|
|
+ // 首次处理(使用匹配的处理器)
|
|
|
|
+ StringBuilder error = null;
|
|
|
|
+ WechatPaymentCallback callback;
|
|
|
|
+ WechatPaymentProcessor primary = this.getProcessor(name, null);
|
|
|
|
+ try {
|
|
|
|
+ if (Objects.nonNull(callback = primary.callback(content))) {
|
|
|
|
+ return callback;
|
|
|
|
+ }
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ (error = new StringBuilder()).append(e);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // 兼容处理,防止在支付配置切换过程中导致支付回调失败的情况
|
|
for (WechatPaymentProcessor processor : this.processors) {
|
|
for (WechatPaymentProcessor processor : this.processors) {
|
|
- if (Objects.equals(name, processor.getName())) {
|
|
|
|
- try {
|
|
|
|
- WechatPaymentCallback callback = processor.callback(content);
|
|
|
|
- if (Objects.nonNull(callback)) {
|
|
|
|
- return callback;
|
|
|
|
- }
|
|
|
|
- } catch (Exception e) {
|
|
|
|
- log.error("Wechat payment callback process failed: {}", content, e);
|
|
|
|
|
|
+ if (processor == primary || !Objects.equals(name, processor.getName())) {
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+ try {
|
|
|
|
+ if (Objects.nonNull(callback = processor.callback(content))) {
|
|
|
|
+ return callback;
|
|
|
|
+ }
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ if (error == null) {
|
|
|
|
+ error = new StringBuilder();
|
|
|
|
+ }
|
|
|
|
+ if (error.length() > 0) {
|
|
|
|
+ error.append(" ");
|
|
}
|
|
}
|
|
|
|
+ error.append(e);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ log.error("Wechat payment callback process failed: {}\n{}", error, content);
|
|
return null;
|
|
return null;
|
|
}
|
|
}
|
|
}
|
|
}
|