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

3.1.10 H5支付不晓得算不算BUG的BUG #968

Closed
zhfin opened this issue Oct 20, 2017 · 1 comment
Closed

3.1.10 H5支付不晓得算不算BUG的BUG #968

zhfin opened this issue Oct 20, 2017 · 1 comment

Comments

@zhfin
Copy link

zhfin commented Oct 20, 2017

我用的环境

PHP 版本:php7
overtrue/wechat 版本:3.1.10
是否使用了框架?框架名称:laravel 5.5

问题及现象

微信支付 创建订单时 传入MWEB类型 访问$app->payment->prepare($order)->mweb_url所产生的url会出现网络环境未能通过安全验证的提示

image

解决方案:
在new Order时的参数中加入键 spbill_create_ip 并将其值赋为下方代码所产生的ip地址

function getIP()
    {
        if (isset($_SERVER)) {
            if (isset($_SERVER["HTTP_X_FORWARDED_FOR"])) {
                $realip = $_SERVER["HTTP_X_FORWARDED_FOR"];
            } else if (isset($_SERVER["HTTP_CLIENT_IP"])) {
                $realip = $_SERVER["HTTP_CLIENT_IP"];
            } else {
                $realip = $_SERVER["REMOTE_ADDR"];
            }
        } else {
            if (getenv("HTTP_X_FORWARDED_FOR")) {
                $realip = getenv("HTTP_X_FORWARDED_FOR");
            } else if (getenv("HTTP_CLIENT_IP")) {
                $realip = getenv("HTTP_CLIENT_IP");
            } else {
                $realip = getenv("REMOTE_ADDR");
            }
        }
        return $realip;
    }
@mingyoung
Copy link
Collaborator

负载均衡?

@overtrue overtrue closed this as completed Dec 8, 2017
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

No branches or pull requests

3 participants