Home >Backend Development >PHP Tutorial >统一支付接口中,缺少必填参数openid!trade_type为JSAPI时,openid为必填参数!
<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>
<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>
BeeCloud对各种支付渠道的API做了封装,提供了一套REST API框架,你可以参考下