-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Correct payment sandbox endpoint and add a method to get sandbox sign key #666
Conversation
Incomplete kit! |
@mingyoung 请阅读方案2: #665 (comment), 这个PR是实现这个方案。我目前测试成功。如果你不同意这个方案,或者认为还缺少哪里,请给出理由。 |
请参考: https://github.com/overtrue/wechat/blob/master/src/Core/AccessToken.php#L99 正确使用缓存类,按你的写法就是写死了只能使用文件系统缓存了。 |
不要使用Else而用Return? 第一次听说。但是为什么 codacy/pr 只对这一个 |
src/Payment/API.php
Outdated
} else { | ||
throw new Exception($result->return_msg); | ||
} | ||
} catch (Exception $e) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这样里面的 throw 没有意义吧?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里的throw目的是抓住$result->return_msg
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
抓住了也没处理啊?感觉不需要外层的 try 了吧
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
throw new Exception($result->return_msg);
这个是为了抓住微信业务上的错误信息,在这里throw,直接到了 } catch (Exception $e) {
如果没有这个throw new Exception($result->return_msg);
, 当微信返回 sandbox_signkey错误的时候,应用就收不到相对因的错误信息,并且继续 $this->sandboxSignKey 还是为空,然后就再次$request, 那么就会死循环。
这里的try
catch
可以省略
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
对啊,就是因为你外面 catch 了又啥事儿没做,所以我才说里面的是没有必要的嘛
@@ -76,11 +93,13 @@ class API extends AbstractAPI | |||
/** | |||
* API constructor. | |||
* | |||
* @param \EasyWeChat\Payment\Merchant $merchant | |||
* @param \EasyWeChat\Payment\Merchant $merchant | |||
* @param \EasyWeChat\Payment\Cache|null $cache |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
EasyWeChat\Payment\Cache
忘记 use 了吧
src/Payment/API.php
Outdated
} else { | ||
throw new Exception($result->return_msg); | ||
} | ||
} catch (Exception $e) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
抓住了也没处理啊?感觉不需要外层的 try 了吧
@skyred 方法名称为 |
Following #665, this PR implements the 2nd approach.