連接子特店
授權要求
爲確保子特店資訊安全可靠,平台在代理子特店進行 API 介面操作需要經過子特店的授權,可通過「連接」功能進行授權後獲得子特店 merchantId
系統連接流程
1、發起授權
1.1.建立授權鏈接
攜帶參數:
client_idString必填
平台可聯繫 SLP 串接窗口獲取
response_typeString必填
固定傳:code
scopeString必填
固定傳:read_write
stateString必填
為了防止 CSRF 攻擊,請新增 state 參數,並傳遞唯一令牌作為值。當我們將使用者重新導向回您的網站時,我們將包括您提供給我們的資訊。您應確認該 state 參數未被修改。
redirect_uriString必填
子特店確認授權後重新導向回平台的網址,需事先聯絡SHOPLINE Payments將網址設定為白名單
請求範例
https://connect-sandbox.shoplinepayments.com/oauth/authorize?response_type=%s&client_id=%s&scope=%s&state=%s&redirect_uri=%s
1.2.子特店被重新導向回您的網址
如果子特店進行授權確認成功,會被重新導向回您設定的網址
攜帶參數:
codeString必填
授權碼,僅短暫有效,只能在下一步描述的 POST 請求中使用一次
scopeString必填
授權範圍
stateString必填
為了防止 CSRF 攻擊,請加入 state 參數,並傳遞唯一令牌作為值。當我們將使用者重新導向回您的網站時,我們將包括您提供給我們的資訊。您的站點應確認該 state 參數未被修改。
https://yourserver.com/oauth/return?scope=read_write&code={AUTHORIZATION_CODE}&state=state
如果子特店拒絕授權,會被重新導向回您設定的網址,但 URL 包含錯誤而不是授權程式碼:
攜帶參數:
errorString必填
錯誤碼
error_descriptionString必填
錯誤描述
https://yourserver.com/oauth/return?error=access_denied&error_description=The%20user%20denied%20your%20request
2、平台連接子特店
完成後可獲取顧客的子特店的 merchantId
請求 Header
apiKeyString必填
金鑰,可聯繫串接窗口獲取
請求參數
codeString必填
授權碼,譬如 ac_123456789
grant_typeString必填
固定傳: authorization_code
回應
scopeString必填
授權範圍,譬如 read_write
merchant_idString必填
子特店 ID
請求範例
curl https://connect-sandbox.shoplinepayments.com/connect-merchant \
-H apiKey:sk_sandbox_jljsoc9wnnsdlfjolljksjdf \
-d code=ac_123456789 \
-d grant_type=authorization_code
如果出現問題,我們會回應錯誤:
{
"error": "invalid_grant",
"error_description": "Authorization code does not exist: {AUTHORIZATION_CODE}"
}