Home > Backend Development > PHP Tutorial > 统一支付接口中,缺少必填参数openid!trade_type为JSAPI时,openid为必填参数!

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

WBOY
Release: 2016-06-06 20:31:09
Original
4025 people have browsed it

<code>    $jsApi = new JsApi_pub();
    //=========步骤1:网页授权获取用户openid============
    //通过code获得openid
 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();
    echo $openid;   这里获取不到
    echo "<br>";
 }
    $unifiedOrder = new UnifiedOrder_pub();
    $unifiedOrder->setParameter("openid","$openid");//商品描述
    $unifiedOrder->setParameter("body","微信支付测试");//商品描述
</code>
Copy after login
Copy after login

回复内容:

<code>    $jsApi = new JsApi_pub();
    //=========步骤1:网页授权获取用户openid============
    //通过code获得openid
 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();
    echo $openid;   这里获取不到
    echo "<br>";
 }
    $unifiedOrder = new UnifiedOrder_pub();
    $unifiedOrder->setParameter("openid","$openid");//商品描述
    $unifiedOrder->setParameter("body","微信支付测试");//商品描述
</code>
Copy after login
Copy after login

BeeCloud对各种支付渠道的API做了封装,提供了一套REST API框架,你可以参考下

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