统一支付接口中,缺少必填参数openid!trade_type为JSAPI时,openid为必填参数!
程序员文章站
2022-05-28 22:05:50
...
$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 "
";
}
$unifiedOrder = new UnifiedOrder_pub();
$unifiedOrder->setParameter("openid","$openid");//商品描述
$unifiedOrder->setParameter("body","微信支付测试");//商品描述
回复内容:
$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 "
";
}
$unifiedOrder = new UnifiedOrder_pub();
$unifiedOrder->setParameter("openid","$openid");//商品描述
$unifiedOrder->setParameter("body","微信支付测试");//商品描述
BeeCloud对各种支付渠道的API做了封装,提供了一套REST API框架,你可以参考下
上一篇: Symfony2.6.3 生成repository的问题
下一篇: 提取TXT里数据出错