Account Linking
ShopeePay offers the following functionalities for account linking and payment use cases:
- Initiate an Account Linking & Get Access Token
- Request for Account Unlinking
- Notify Account Linking/Unlinking Status
- Use Cases for Account Linking
Merchant Workflow
To accept the payment in this scenario, the merchant needs to complete the following steps
Initiate a account linking request when customer chooses to link their ShopeePay account.
Handle the redirect URL returned.
Get access token by using returned auth code, and save token for future use cases (e.g. to obtain user information).
Initiate a payment request (via Link & Pay or Subscription ) when customer selects to pay or when payment is due.
- After customer chooses to link their ShopeePay account on merchant's application or website, the merchant calls the Initiate an Account Link endpoint to start the linking process.
- ShopeePay returns a
redirect_urland this URL can be used by merchant to direct user to ShopeePay's linking agreement page. - The customer agrees to link their account to the merchant.
- Upon successful linking, the customer returns back to the merchant’s page as indicated in the
redirect_urlin the Account Link request, along with an auth code. ShopeePay also sends an asynchronous message via Notify Account Link Status endpoint to inform merchants of the successful linking. - Merchant may either rely on the notification callback from ShopeePay, or the auth code passed by its frontend, to call the Get Access Token endpoint.
- Once the merchant obtains the access token, they should save it securely for future use.
- Should the customer chooses to unlink ShopeePay in the future, the merchant should call the Account Unlink endpoint to invalidate the access token. Once the unlink request is successful, the merchant will not be able to query or charge the customer’s ShopeePay account. ShopeePay also sends an asynchronous message via Notify Account Link Status endpoint to inform merchants of the successful unblinking.
API Documentation
- Initiate an Account Linking
- Get Access Token
- Request for Account Unlinking
- Notify Account Linking / Unlinking Status
- Use Case for Get Access Token
Initiate an Account Linking
Use this endpoint to kick start the account linking process of a ShopeePay account to your platform.
- URL: "/v3/merchant-host/account/link"
Request Parameters
request_id
stringRequiredreturn_url
stringRequiredlinking_reference_id
string- Accepts up to 64 characters
merchant_ext_id
stringRequiredservice_name
stringservice_id
stringlinking_description
stringphone
stringRequiredplatform_type
stringadditional_info
stringPlease contact our team for more details
device_info
Objectdevice_id
Stringdevice_brand
Stringdevice_model
Stringos_version
Stringiosudid
Stringimei
Stringverification_completion_method
StringPotential enum:
- none
- biometric
- pin
- password
- pattern
- other
device_first_login_at
Stringrisk_tags
Objectjailbroken
Booleanenabled_emulator
Booleanenabled_remote_control
Booleanmodified_gps
Booleaninstalled_fake_gps_app
Booleangps
Objectlatitude
Floatlongitude
Floatlocation
Stringdevice_ip
Stringdevice_risk_score
StringPotential enum values: high, medium, low.
additional_info
Stringuser_account
Objectuser_id
Stringphone_number
Stringusername
Stringaccount_registration_time
Stringaccount_risk_score
StringPotential enum values: high, medium, low.
merchant_account
Objectmerchant_name
Stringmerchant_id
Stringmerchant_mcc
Stringmerchant_address
Objectregion
Stringstate
Stringcity
Stringaddress
Stringpostal_code
Stringstore
Objectstore_name
StringOtherwise leave blank.
store_id
StringOtherwise leave blank.
store_mcc
StringOtherwise leave blank.
store_address
Objectregion
StringOtherwise leave blank.
state
Stringcity
Stringaddress
Stringpostal_code
StringSample API Request
{"request_id": "input-unique-request-id-here","return_url":"https://isv-domain.com","linking_reference_id": "ref-id-tracking","merchant_ext_id": "external-merchant","service_name": "merchant-name","service_id": "input-service-id-here","linking_description": "input-linking-description-here","phone": "6282112345678","platform_type": "app"}
Copy
Response Parameters
request_id
stringerrcode
stringdebug_msg
stringredirect_url_web
stringSample API Response
{"request_id": "input-unique-request-id-here","errcode": 0,"debug_msg": "success","redirect_url_web": "https://app.uat.shopeepay.vn/universal-link/payment/account-linking/pre-link?ticket=131503566697895231",}
Copy
Response Code
Please refer to the following description for a general explanation of the errcode returned during an API Response.
For a more detailed explanation, it is advisable to consult debug_msg field. This field provides additional information that can offer valuable insights for troubleshooting.
Merchants may choose to display the debug_msg to their operators or staffs to facilitate prompt identification and resolution of the issue.
| Value | Description |
|---|---|
| -2 | A server dropped the connection |
| -1 | A server error occurred, merchant may initiate a new account linking request or request using same 'linking_reference_id' |
| 0 | Success |
| 1 | The request parameters is invalid or a mandatory parameter is empty |
| 2 | Permission denied, often due to invalid status |
| 11 | Duplicated request |
| 305 | Invalid merchant |
| 300026 | Invalid or expired QR |
Get Access Token
Use this API to get a ShopeePay access token using the linking_reference_id.
- URL: "/v3/merchant-host/access-token/get"
Request Parameters
request_id
stringRequiredlinking_reference_id
stringRequiredSample API Request
{"request_id": "input-unique-request-id-here","linking_reference_id": "ref-id-tracking"}
Copy
Response Parameters
request_id
stringrequest_id in the request.errcode
int32debug_msg
stringaccess_token
stringuser_id_hash
stringlinking_reference_id
stringmerchant_ext_id
stringlinking_status
int32create_time
stringupdate_time
stringSample API Response
{"request_id": "input-unique-request-id-here","errcode": 0,"debug_msg": "success","access_token": "2r4a56n7o3e56s473t8c2y78e","user_id_hash": "697863f9295aeddcb3db598ecbc74c59a13335abf4d8c41b40e33b28a9d7d63c","merchant_ext_id": "external-merchant","linking_reference_id": "ref-id-tracking","linking_status": 1,"create_time": 1708937423,"update_time": 1708937423}
Copy
Response Code
Please refer to the following description for a general explanation of the errcode returned during an API Response.
For a more detailed explanation, it is advisable to consult debug_msg field. This field provides additional information that can offer valuable insights for troubleshooting.
Merchants may choose to display the debug_msg to their operators or staffs to facilitate prompt identification and resolution of the issue.
| Value | Description |
|---|---|
| -2 | A server dropped the connection |
| -1 | A server error occurred |
| 0 | Success |
| 1 | The request parameters is invalid or a mandatory parameter is empty |
| 2 | Permission denied, often due to invalid status |
| 9 | Customer’s account is banned |
| 14 | Customer’s account is deleted |
| 24 | Customer’s account is frozen |
| 27 | Customer’s account is not activated |
| 105 | Invalid auth code |
| 150 | Active linking count threshold reached |
| 305 | Invalid merchant |
| 907 | Unable to verify customer |
| 300059 | Bank account not linked |
Request for Account Unlinking
Use this endpoint to unlink a ShopeePay account from a customer’s account on your platform.
- URL: "/v3/merchant-host/account/unlink"
Request Parameters
request_id
stringlinking_reference_id
stringSample API Request
{"request_id": "input-unique-request-id-here","linking_reference_id": "ref-id-tracking"}
Copy
Response Parameters
request_id
stringrequest_id in the request.errcode
int32debug_msg
stringmerchant_ext_id
stringlinking_status
int32create_time
stringupdate_time
stringaccess_token
stringuser_id_hash
stringlinking_reference_id
stringSample API Response
{"request_id": "input-unique-request-id-here","errcode": 0,"debug_msg": "success","access_token": "2r4a56n7o3e56s473t8c2y78e","user_id_hash": "697863f9295aeddcb3db598ecbc74c59a13335abf4d8c41b40e33b28a9d7d63c","merchant_ext_id": "external-merchant","linking_reference_id": "ref-id-tracking","linking_status":3,"create_time": 1708937423,"update_time": 1708937423}
Copy
Response Code
Please refer to the following description for a general explanation of the errcode returned during an API Response.
For a more detailed explanation, it is advisable to consult debug_msg field. This field provides additional information that can offer valuable insights for troubleshooting.
Merchants may choose to display the debug_msg to their operators or staffs to facilitate prompt identification and resolution of the issue.
| Value | Description |
|---|---|
| -2 | A server dropped the connection |
| -1 | A server error occurred, merchant may initiate a new account unlinking request or request using same 'linking_reference_id' |
| 0 | Success |
| 1 | The request parameters is invalid or a mandatory parameter is empty |
| 152 | Fail to unlink due to ongoing auth |
| 305 | Invalid merchant |
| 2000 | A server error occurred |
Notify Account Link Status
This request will send details of the specific linking lifecycle to the merchant server’s callback URL, which is configured in ShopeePay’s system at the time of onboarding.
Each callback request will contain a signature in the request header. This signature is generated using the ShopeePay-issued secret key, assigned to the merchant receiving the callback request. Merchant should use this signature to verify the authenticity of the callback content.
Multiple repeated notifications might be sent to the merchant and merchant shall be able to handle the repeated notifications with the same contents properly.
Merchants should not impose any check or limit on the sequence nor the length of each field of the callback request.
Note: It is recommended for the merchant using this Callback to validate that the linking_reference_id matches the original account or link request’s linking_reference_id before considering the customer’s action to be completed.
request_id
stringlinking_reference_id
stringmerchant_ext_id
stringupdate_type
int64- 1 = User successfully authorized the linking (and merchant should now call Get Access Token)
- 2 = User account is linked successfully
- 3 = User token status is invalidated by ShopeePay
- 4 = User has successfully unlinked with the merchant
- 5 = Merchant has successfully unlinked with the user
Sample Callback for Successful User Authorization on ShopeePay
When merchant gets this callback with update_type = 1, merchant should call the Get Access Token.
{"request_id": "input-unique-request-id-here","linking_reference_id": "ref-id-tracking","merchant_ext_id": "external-merchant","update_type": 1}
Copy
Sample Callback for Unlinking
JS EXAMPLE
{"request_id": "input-unique-request-id-here","linking_reference_id": "ref-id-tracking","merchant_ext_id": "external-merchant","update_type": 4}
Copy
Use Cases for Get Access Token
Get User Info
Use this endpoint to get customer’s ShopeePay account information for display purposes.
- URL: "/v3/merchant-host/user-info/get"
Request Parameters
request_id
stringRequiredaccess_token
stringRequiredSample API Request
{"request_id": "input-unique-request-id-here","access_token": "54673258746782637482",}
Copy
Response Parameters
request_id
stringrequest_id in the request.errcode
int32debug_msg
stringlinking_info
objectlinking_reference_id or access_token.linking_reference_id
stringlinking_status
int32- 1: Active
- 2: Inactive
- 3: Invalid
- 4: Pending user authorization
- 5: Authorization completed and pending Get Access Token
- 6: Expired
create_time
stringupdate_time
stringmerchant_ext_id
stringuser_id_hash
stringuser_info
objectphone_number
stringwallet_balance
int64spaylater_info
objectavailable_balance
int64status_info
int64coin_balance
booleanSample API Response
{"request_id": "input-unique-request-id-here","errcode": 0,"debug_msg": "success","user_info": {"wallet_balance": 0,"spaylater_info": {"available_balance": 45000000,"status_info": "active"},"kyc_passed": true},"linking_info": {"linking_status": 1,"create_time": 1708937423,"update_time": 1708937423,"user_id_hash": "697863f9295aeddcb3db598ecbc74c59a13335abf4d8c41b40e33b28a9d7d63c","linking_reference_id": "ref-id-tracking","merchant_ext_id": "external-merchant"}}
Copy
Response Code
| Value | Description |
|---|---|
| -2 | A server dropped the connection |
| -1 | A server error occurred |
| 0 | Success |
| 1 | The request parameters is invalid or a mandatory parameter is empty |
| 2 | Permission denied, often due to invalid status |
| 24 | Customer's account is frozen |
| 27 | Customer's account is not activated |
| 305 | Invalid merchant |
Get Coin Redemption Info
Use this endpoint to get the customer's maximum redeemable coin amount in percentage or in absolute amount.
- URL: "/v3/merchant-host/coin/potential-redemption"
Note: This API is temporarily unavailable for use in Thailand and Vietnam.
Request Parameters
request_id
stringaccess_token
stringpayment_amount
int64Sample API Request
{"request_id": "input-unique-request-id-here","access_token": "54673258746782637482","payment_amount": 10000}
Copy
Response Parameters
request_id
stringrequest_id in the request.errcode
int32debug_msg
stringmax_coin_percentage
int64potential_payment_amount
int64potential_coin_amount
int64Sample API Response
{"request_id": "input-unique-request-id-here","errcode": 0,"debug_msg": "success","max_coin_percentage": 10,"potential_payment_amount": 10000,"potential_coin_amount": 30}
Copy
Response Code
| Value | Description |
|---|---|
| -2 | A server dropped the connection |
| -1 | A server error occurred |
| 0 | Success |
| 1 | The request parameters is invalid or a mandatory parameter is empty |
| 2 | Permission denied, often due to invalid status |
| 27 | Customer's account is not activated |
| 305 | Invalid merchant |
| 702 | Coin redemption disabled |
| 705 | Coin redemption disabled |