Home > Backend Development > PHP Tutorial > 微信支付 刷新以后找不到openid

微信支付 刷新以后找不到openid

WBOY
Release: 2016-06-06 20:40:26
Original
2085 people have browsed it

<code>if (!isset($_GET['code']))
        {
            //触发微信返回code码
            $url = $jsApi->createOauthUrlForCode(WxPayConf_pub::JS_API_CALL_URL);
            Header("Location: $url"); 
        }else
        {
            //获取code码,以获取openid
            $code = $_GET['code'];
            $jsApi->setCode($code);
            $openid = $jsApi->getOpenId();
        }

$unifiedOrder->setParameter("openid","$openid");
</code>
Copy after login
Copy after login

刷新或者错误返回提示:

统一支付接口中,缺少必填参数openidtrade_typeJSAPI时,openid为必填参数!

回复内容:

<code>if (!isset($_GET['code']))
        {
            //触发微信返回code码
            $url = $jsApi->createOauthUrlForCode(WxPayConf_pub::JS_API_CALL_URL);
            Header("Location: $url"); 
        }else
        {
            //获取code码,以获取openid
            $code = $_GET['code'];
            $jsApi->setCode($code);
            $openid = $jsApi->getOpenId();
        }

$unifiedOrder->setParameter("openid","$openid");
</code>
Copy after login
Copy after login

刷新或者错误返回提示:

统一支付接口中,缺少必填参数openidtrade_typeJSAPI时,openid为必填参数!

题主的第一步 已经做了Oauth认证了.
是可以获到openid的...TX跳转的链接是 XXXX.com&code=123
然后通过 code 换取 openid..
code 如果未使用过生存周期只有5分钟
题主的流程是直接生产了 prepay_id 显示支付页面的..

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template