Skip to content
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

微信支付时不对传入金额进行*100操作 #7

Merged
merged 1 commit into from
Sep 4, 2017
Merged

微信支付时不对传入金额进行*100操作 #7

merged 1 commit into from
Sep 4, 2017

Conversation

taobig
Copy link
Contributor

@taobig taobig commented Sep 3, 2017

此次为不兼容的修改!

现有版本会直接对传入的金额进行*100操作转换为分,意味着传入金额的单位为元,且有可能为带小数的浮点数。
一旦出现浮点数,那么intval($this->config['total_fee'] * 100)这样的操作就是不安全的,至少也要使用bcmath等扩展保证浮点数操作的准确性。
所以希望直接按照微信API的要求,不要对外封装成使用元为单位。

@yansongda
Copy link
Owner

言之有理,感谢指出。!

之所以使用元,是因为

  1. 和支付宝进行统一,都使用「元」为单位
  2. 我开发微信的时候被坑过。

结合您的意见,我更倾向于 bcmul 请问您的意见如何?

@yansongda yansongda merged commit d5f1984 into yansongda:master Sep 4, 2017
@yansongda
Copy link
Owner

考虑到 bc 需要依赖 lib,暂时使用「分」

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants