天天看點

網站支付寶登入一、文檔位址二、開發前準備工作三、調用流程四、會員授權資訊查詢接口請求示例五、注意事項

網站支付寶登入是适用于網站頁面進行授權。

一、文檔位址

官方文檔位址:[url]https://docs.open.alipay.com/263/105809[/url]

二、開發前準備工作

調用步驟:[url]https://openclub.alipay.com/read.php?tid=12194&fid=69[/url]

注意事項:1、支援沙箱測試;2、不需簽約,但需要添加功能;3、支援第三方調用。

網站支付寶登入一、文檔位址二、開發前準備工作三、調用流程四、會員授權資訊查詢接口請求示例五、注意事項

三、調用流程

1、授權URL拼接,擷取access_token

具體調用步驟參考使用者資訊授權:[url]https://openclub.alipay.com/read.php?tid=14595&fid=68#anchor2[/url]

注:由于該産品是需要實作擷取會員資訊的功能,授權URL拼接的scope必須傳入auth_user。

如scope=auth_user,auth_base。

2、擷取使用者資訊

擷取使用者資訊必須通過alipay.user.info.share(支付寶會員授權資訊查詢接口) 調用擷取。

具體代碼調用方式參見支付寶會員授權資訊查詢接口請求示例。

四、會員授權資訊查詢接口請求示例

1、參數說明

auth_token:alipay.system.oauth.token(換取授權通路令牌) 接口調用傳回的響應參數access_token。

注:該接口不需要設定請求參數,隻需要在公共參數中必傳auth_token

2、JAVA版本請求示例

public static void main(String[] args) throws AlipayApiException {		AlipayClient alipayClient = new DefaultAlipayClient(AlipayConfig.gatewayUrl, AlipayConfig.app_id, AlipayConfig.merchant_private_key, AlipayConfig.format, AlipayConfig.charset, AlipayConfig.alipay_public_key, AlipayConfig.sign_type);		//調用接口擷取使用者資訊		AlipayUserInfoShareRequest request = new AlipayUserInfoShareRequest();		//需要使用者授權後,将auth_code換取accessToken,注入		String accessToken = "composeBd364827b102144cf992fb7ce6e327X89";		try {			AlipayUserInfoShareResponse response = alipayClient.execute(request, accessToken);			System.out.println(response.getBody());		} catch (AlipayApiException e) {		    //處理異常		    e.printStackTrace();		}}           

響應參數

{"alipay_user_info_share_response":{"code":"10000","msg":"Success","gender":"f","is_certified":"T","is_student_certified":"F","nick_name":"買家沙箱","user_id":"2088102175794899","user_status":"T","user_type":"2"},"sign":"GFOQ5SbhPPSkL1Dmf9snUJxTEeCxngsXOQubURBIDx5C9/sb7CnNmHdSXDru9NPDlvfSQPT+b+iUOVapARafpsdqP6XIdHqQfrLB2jE6YO2ql52J07/yGrUNAwjaaKd/ndBbpljhn9laQATD1sqrwwUGmttiGkyK6cPvW3lH/ndAvbDRkwnKdrLKZGSou3erf0thL6QzlS12XXryTnvEArCuteAsqqDFi81R/PVKyXdl15P9SdVQzhJski5yZ3A1VEO9Vv96bVjVlgUZaIALddjOX4rh100e/mxx7K8qOmjX12r72pFyPrVEAQChRTSx1OxiXureiCScscHKtZdOQg=="}           

3、PHP版本請求示例

$aop = new AopClient ();$aop->gatewayUrl = 'https://openapi.alipay.com/gateway.do';$aop->appId = 'your app_id';$aop->rsaPrivateKey = '請填寫開發者私鑰去頭去尾去回車,一行字元串';$aop->alipayrsaPublicKey='請填寫支付寶公鑰,一行字元串';$aop->apiVersion = '1.0';$aop->signType = 'RSA2';$aop->postCharset='GBK';$aop->format='json';$request = new AlipayUserInfoShareRequest ();$result = $aop->execute ( $request , 'composeBd364827b102144cf992fb7ce6e327X89'); echo json_encode($result);           
{"alipay_user_info_share_response":{"code":"10000","msg":"Success","gender":"f","is_certified":"T","is_student_certified":"F","nick_name":"買家沙箱","user_id":"2088102175794899","user_status":"T","user_type":"2"},"sign":"GFOQ5SbhPPSkL1Dmf9snUJxTEeCxngsXOQubURBIDx5C9/sb7CnNmHdSXDru9NPDlvfSQPT+b+iUOVapARafpsdqP6XIdHqQfrLB2jE6YO2ql52J07/yGrUNAwjaaKd/ndBbpljhn9laQATD1sqrwwUGmttiGkyK6cPvW3lH/ndAvbDRkwnKdrLKZGSou3erf0thL6QzlS12XXryTnvEArCuteAsqqDFi81R/PVKyXdl15P9SdVQzhJski5yZ3A1VEO9Vv96bVjVlgUZaIALddjOX4rh100e/mxx7K8qOmjX12r72pFyPrVEAQChRTSx1OxiXureiCScscHKtZdOQg=="}           

4、.NET版本請求示例

IAopClient client = new DefaultAopClient(config.gatewayUrl, config.app_id, config.private_key, "json", "1.0", "RSA2", config.alipay_public_key, config.charset, false);AlipayUserInfoShareRequest  request= new AlipayUserInfoShareRequest() ;AlipayUserInfoShareResponse response=client.execute(request,"composeBd364827b102144cf992fb7ce6e327X89");Console.WriteLine(response.Body);           
{"alipay_user_info_share_response":{"code":"10000","msg":"Success","gender":"f","is_certified":"T","is_student_certified":"F","nick_name":"買家沙箱","user_id":"2088102175794899","user_status":"T","user_type":"2"},"sign":"GFOQ5SbhPPSkL1Dmf9snUJxTEeCxngsXOQubURBIDx5C9/sb7CnNmHdSXDru9NPDlvfSQPT+b+iUOVapARafpsdqP6XIdHqQfrLB2jE6YO2ql52J07/yGrUNAwjaaKd/ndBbpljhn9laQATD1sqrwwUGmttiGkyK6cPvW3lH/ndAvbDRkwnKdrLKZGSou3erf0thL6QzlS12XXryTnvEArCuteAsqqDFi81R/PVKyXdl15P9SdVQzhJski5yZ3A1VEO9Vv96bVjVlgUZaIALddjOX4rh100e/mxx7K8qOmjX12r72pFyPrVEAQChRTSx1OxiXureiCScscHKtZdOQg=="}           

五、注意事項

1、使用場景

網站支付寶登入是适用于網站頁面的,并不适用于商戶app端進行支付寶登入。

若在商戶app端內建該産品,存在無法打開授權頁面、授權成功後無法回調app端的情況。

2、回調場景

由于網站支付寶登入是通過設定授權回調位址,進行授權成功後回調。

注:授權回調位址隻支援http和https的頁面路徑,不支援設定scheme位址,進行回調app用戶端。

3、如何實作商戶app端支付寶登入

該功能可內建app支付寶登入産品.

參考內建方式:[url]https://openclub.alipay.com/read.php?tid=7493&fid=60&ant_source=zsearch[/url]

4、PC端和H5頁面授權說明

(1)電腦網站(PC端)頁面授權擷取資訊

可直接通路拼接好的授權URL,進行後續的調用

(2)手機網站(H5)頁面授權擷取資訊

拼接好的授權URL必須在支付寶用戶端内通路,即在支付寶app内授權。

5、auth_token傳參方式

接口調用方式中,設定auth_token的代碼示例:

JAVA:

response = alipayClient.execute(request, accessToken);           

PHP:

$result = $aop->execute($request,$accessToken);            

.net:

response=client.execute(request,accessToken);           

如果還是報錯,請按如下方式進行提問:

正确提問方式:使用環境(沙箱還是正式環境)+接口名稱(中文+英文)+ 請求參數 + 報錯資訊詳情

繼續閱讀