Skip to content

授权获取code

使用标准OAuth2.0协议接入微信支付,在用户授权的条件下,将可以做到访问用户资源,使用接口调用用户功能(如获取用户实名信息等)

🔐

本接口服务已于 2021.11.10 (北京时间)停止开放,文档仅做留存参考。

请求参数类型描述
base_uristring接入点
固定值https://payapp.weixin.qq.com/
queryobject声明请求的查询参数
mch_idstring商户号
appidstring应用ID
redirect_uristring重定向地址,需要urlencode,需在支付安全域下(商户平台上配置“支付授权目录”)。
response_typestring固定填code
code 枚举值
scopestring应用授权作用域
pay_identity | pay_realname 枚举值之一
statestring随机字符串,回调时将带上该参数
fragmentstring固定填#wechat_redirect
php
$entry = new \GuzzleHttp\Psr7\Uri('https://payapp.weixin.qq.com/appauth/authindex');

$query = \GuzzleHttp\Psr7\Query::build([
    'mch_id'        => '1230000109',
    'appid'         => 'wxd678efh567hg6787',
    'redirect_uri'  => 'https://weixin.qq.com/i-am-a-fake-uri',
    'response_type' => 'code',
    'scope'         => 'pay_identity',
    'state'         => \WeChatPay\Formatter::nonce(),
]);

// 30x返回此变量即可
$uri = $entry->withQuery($query)->withFragment('#wechat_redirect');
返回字典类型描述
30x跳转(无实际返回信息)

参阅 官方文档

Published on the GitHub by TheNorthMemory