Account Linking

ShopeePay offers the following functionalities for account linking and payment use cases:

Merchant Workflow

To accept the payment in this scenario, the merchant needs to complete the following steps

  1. Initiate Get Auth Code when customer chooses to link their ShopeePay account.
  2. Bring the user to SPP's frontend to complete the authorization
  3. Get access token by using returned partnerReferenceNo, and save token for future use cases (e.g. to obtain user information).
  4. Initiate a payment request (via Link & Pay, Subscription, and Authorization & Capture) when customer selects to pay or when payment is due.
  1. After customer chooses to link their ShopeePay account on merchant's application or website, the merchant calls the Get Auth Code endpoint to start the linking process.
  2. ShopeePay returns an authCode which should be appended to the provided static URL, allowing merchants to direct users to ShopeePay's linking agreement page.
  3. The customer agrees to link their account to the merchant.
  4. Upon successful linking, the customer returns back to the merchant's page as indicated in the redirectUrl in the Account Linking request, along with an authCode, partnerReferenceNo.
  5. Merchant can reply on the authCode or partnerReferenceNo passed by its frontend, to call the /registration-account binding endpoint
  6. Once the merchant obtains the account token, they should save it securely for future use.
  7. Should the customer choose 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 get information or charge the customer's ShopeePay account.

Initiate Account Linking

Specification

The following table is specification of this API:

HTTP MethodGET
Service Code10
Path.../v1.0/get-auth-code
Versionv1.0

Request Parameters

redirectUrlStringRequired
URL to redirect to after customer completes verification on ShopeePay.
  • For a common URL which starts with 'http' or 'https', ShopeePay merchants will open it with the default browser.
  • For others (for example, some_app://xxxxx), ShopeePay merchants will try to open the application registered with the schema.
scopesStringRequired
The scopes of the authorization.
  • Only accepts "ACCOUNT_BINDING" value.
stateStringRequired
Random string for CSRF protection.
  • Accepts up to 32 characters.
merchantIdStringRequired
Unique identifier of merchant in merchant system.
  • Accepts up to 64 characters.
seamlessDataStringOptional

Require if merchant want ShopeePay to validate whether the phone number matched with user ShopeePay account

Sample API Request

The following script is a sample to generate seamlessData and seamlessSign:

1. Generate seamlessData

EXAMPLE
seamlessData = URLEncode(message)


message = {"mobileNumber":"123456789"}
seamlessData = %7B%22mobileNumber%22%3A%22123456789%22%7D

2. Sign seamlessData using algorithm SHA256withRSA and your own private key.

EXAMPLE
rawSign = SHA256withRSA(seamlessData, privateKey)

3. Generate the seamlessSign by applying base64 encoding and URL encoding

EXAMPLE
seamlessSign = URLEncode(Base64Encode(rawSign))

Response Parameter

stateStringRequired

Random string for CSRF protection.

responseMessageStringRequired

Debug message to provide more information.

responseCodeStringRequired

Error code to specify the error returned.

authCodeStringRequired

This authorization code that merchant must append to the provided staticURL when redirecting user to Shopee mobile web or app for account binding

Response Code

Please refer to the following description for a general explanation of the responseCode returned during an API Response.

For a more detailed explanation, it is advisable to consult responseMessage. This field provides additional information that can offer valuable insights for troubleshooting.

Merchants may choose to display the responseMessage to their operators or staffs to facilitate prompt identification and resolution of the issue.

HTTP CodeService CodeSub-error CodeResponse CodeResponse MessagePartner Action
20010002001000SuccessfulMark AL(Account Linking) generate process to Success. Forward customer to Shopeepay page
40010004001000Bad RequestMark AL generate process to Failed. Retry request with proper parameter
40010014001001
  • Invalid field format {fieldName}
  • Invalid Field Format
Mark AL generate process to Failed. Retry request with proper parameter
40010024001002
  • Invalid mandatory field {fieldName}
  • Invalid mandatory field {merchantId}. Exceed maximum character length
  • Invalid Mandatory Field {seamlessSign}
  • Invalid Mandatory Field {merchantId}
  • Invalid Mandatory Field + {error message}
Mark AL generate process to Failed. Retry request with proper parameter
40110004011000Unauthorized.{error message}Mark AL generate process to Failed. Retry request with proper parameter
40110014011001Invalid TokenMark AL generate process to Failed. Retry request with proper parameter
40310014031001Feature Not Allowed. Account Binding Is Not SupportedMark AL generate process to Failed. Contact Shopeepay to check merchant/store supported product flow
40310054031005Do Not Honor. User Is Deleted Invalid Field Format {mobileNumber}. User Is Not Found Do Not Honor. User Is Banned Do Not Honor. User Is Locked Do Not Honor. User Is Not Active Do Not HonorMark AL generate process to Failed. Retry request periodically or contact Shopeepay to check the user/account status
40310154031015Transaction Not Permitted. Maximum Active Binding Count Treshold Is ReachedMark AL generate process to Failed. Retry request periodically or consult to Shopeepay
40410084041008Invalid Merchant, Status Is Not ActiveMark AL generate process to Failed. Contact Shopeepay to check merchant/store status
40910004091000ConflictMark AL generate process to Failed. Retry request periodically or consult to Shopeepay
50010005001000General ErrorMark AL generate process to Failed. Retry request periodically or consult to Shopeepay
50010015001001Internal Server ErrorMark AL generate process to Failed. Retry request periodically or consult to Shopeepay
50410005041000TimeoutMark AL generate process to Failed. Retry request periodically or consult to Shopeepay

Get Account Token

Specification

The following table is a specification of this API:

HTTP MethodPOST
Service Code07
Path.../v1.0/registration-account-binding
Versionv1.0

Request Parameters

merchantIdStringRequired
Unique identifier of merchant in merchant system.
  • Accepts up to 64 characters.
authCodeStringConditional
partnerReferenceNoStringConditional
Unique identifier of the account binding request.
  • The partnerReferenceNo is returned by ShopeePay when the user is redirected to the "redirectUrl" specified by Client in Get Auth Code
  • Either authCode or partnerReferenceNo should be provided in the request.
    • Result codes:
      • 100 - User Authentication Success
      • 201 - Account Binding Failed
  • Merchants must store this securely in their systems and pass this in the subsequent payment requests.

Response Parameter

responseCodeStringRequired

Error code to specify the error returned.

responseMessageStringRequired

Debug message to provide more information.

referenceNoStringConditional

Binding identifier in ShopeePay system.

accountTokenStringRequired
The accountToken used to identify the ShopeePay account to be linked.
  • Merchants must store this securely in their systems and pass this in the subsequent payment requests.
additionalInfoObjectOptional

Response Code

Please refer to the following description for a general explanation of the responseCode returned during an API Response.

For a more detailed explanation, it is advisable to consult responseMessage. This field provides additional information that can offer valuable insights for troubleshooting.

Merchants may choose to display the responseMessage to their operators or staffs to facilitate prompt identification and resolution of the issue.

HTTP codeService CodeSub-Error CodeResponse CodeResponse MessagePartner Action
20007002000700SuccessfulMark AL(Account Linking) binding process to Success. Store response.accountToken
40007004000700Bad RequestMark AL binding process to Pending. Retry request with proper parameter
40007024000702
  • Invalid Mandatory Field {authCode} or {partnerReferenceNo}
  • Invalid mandatory field {merchantId}. Exceed maximum character length
  • Invalid Mandatory Field {merchantId}
  • Invalid Mandatory Field {fieldName}
  • Invalid Mandatory Field + {error message}
Mark AL binding process to Pending. Retry request with proper parameter
40107004010700Unauthorized.{error message}Mark AL binding process to Pending. Retry request with proper parameter
40107014010701Invalid TokenMark AL binding process to Pending. Retry request with proper parameter
40307014030701Feature Not Allowed. Account Binding Is Not SupportedMark AL binding process to Failed. Contact Shopeepay to check merchant/store supported product flow
40307054030705
  • Invalid Field Format {mobileNumber}. User Is Not Found
  • Do Not Honor. User Is Deleted
  • Do Not Honor. User Is Banned
  • Do Not Honor. User Is Locked
  • Do Not Honor. User Is Not Active
  • Do Not Honor
Mark AL binding process to Failed. Retry create a new binding or contact Shopeepay to check the user/account status
40307154030715Transaction Not Permitted. Maximum Active Binding Count Treshold Is ReachedMark AL binding process to Failed.
40407084040708Invalid Merchant, Status Is Not ActiveMark AL binding process to Failed. Contact Shopeepay to check merchant/store status
40407114040711Account Information InvalidMark AL binding process to Pending. Retry request with proper parameter (authCode or partnerReferenceNo)
40907004090700ConflictMark AL binding process to Pending. Retry request periodically or consult to Shopeepay
50007005000700General ErrorMark AL binding process to Pending. Retry request periodically or consult to Shopeepay
50007015000701Internal Server ErrorMark AL binding process to Pending. Retry request periodically or consult to Shopeepay
50407005040700TimeoutMark AL binding process to Pending. Retry request periodically or consult to Shopeepay

Request for Account Unlinking

Specification

The following table is a specification of this API:

HTTP MethodPOST
Service Code09
Path.../v1.0/registration-account-unbinding
Versionv1.0

Request Parameter

merchantIdStringRequired
Unique identifier of merchant in client system.
  • Accepts up to 64 characters.
partnerReferenceNoStringConditional
Unique identifier of the account binding request.
  • Either accountToken or partnerReferenceNo should be provided in the request.
additionalInfoObject

Response Parameter

responseCodeStringRequired

Error code to specify the error returned.

responseMessageStringRequired

Debug message to provide more information.

partnerReferenceNoStringOptional

Unique identifier of the account binding request.

merchantIdStringOptional

Unique identifier of merchant in merchant system.

additionalInfoObjectOptional

Response Codes

Please refer to the following description for a general explanation of the responseCode returned during an API Response.

For a more detailed explanation, it is advisable to consult responseMessage. This field provides additional information that can offer valuable insights for troubleshooting.

Merchants may choose to display the responseMessage to their operators or staffs to facilitate prompt identification and resolution of the issue.

HTTP codeService CodeSub-error CodeResponse CodeResponse MessagePartner Action
20009002000900SuccessfulMark AL(Account Linking) unbinding process to Success
40009004000900Bad RequestMark AL unbinding process to Pending. Retry request with proper parameter
40009014000901Invalid Field FormatMark AL unbinding process to Pending. Retry request with proper parameter
40009024000902
  • Invalid Mandatory Field {accountToken or partnerReferenceNo}
  • Invalid Mandatory Field {merchantId}
  • Invalid mandatory field {fieldName}
  • Invalid mandatory field {merchantId}. Exceed maximum character length
  • Invalid Mandatory Field + {error message}
Mark AL unbinding process to Pending. Retry request with proper parameter
40109004010900Unauthorized.{error message}Mark AL unbinding process to Pending. Retry request with proper parameter
40109014010901Invalid TokenMark AL unbinding process to Pending. Retry request with proper parameter
40309014030901Feature Not AllowedMark AL unbinding process to Pending. Contact Shopeepay to check merchant/store supported product flow
40309054030905
  • Invalid Field Format {mobileNumber}. User Is Not Found
  • Do Not Honor. User Is Deleted
Mark AL unbinding process to Pending. Contact Shopeepay to check the user/account status
40309154030915Transaction Not Permitted. There Is An Ongoing Payment For This AccountMark AL unbinding process to Pending. Retry request periodically or consult to Shopeepay
40409114040911Account Information InvalidMark AL unbinding process to Pending. Retry request with proper parameter (authCode or partnerReferenceNo)
40409184040918Inconsistent RequestMark AL unbinding process to Pending. Retry request with proper parameter
40909004090900ConflictMark AL unbinding process to Pending. Retry request periodically or consult to Shopeepay
50009005000900General ErrorMark AL unbinding process to Pending. Retry request periodically or consult to Shopeepay
50009015000901Internal Server ErrorMark AL unbinding process to Pending. Retry request periodically or consult to Shopeepay
50409005040900TimeoutMark AL unbinding process to Pending. Retry request periodically or consult to Shopeepay

Get User Info

Specification

The following table is a specification of this API:

HTTP MethodPOST
Service Code08
Path.../v1.0/registration-account-inquiry
Versionv1.0

Request Parameter

partnerReferenceNoStringConditional
Unique identifier of the account binding request.
  • Either accountToken or partnerReferenceNo should be provided in the request.
additionalInfoObjectConditional

Response Parameter

responseCodeStringRequired

Error code to specify the error returned.

responseMessageStringRequired

Debug message to provide more information.

partnerReferenceNoStringOptional

Unique identifier of the account binding request.

referenceNoStringConditional
Transaction identifier in ShopeePay system.
  • This value will be returned upon successful request.
accountNoStringOptional

Masked phone number of the customer's linked ShopeePay account. Example: ********1234 This value is returned if permission is allowed via merchant's contract with ShopeePay

additionalInfoObjectOptional

Response Codes

Please refer to the following description for a general explanation of the responseCode returned during an API Response.

For a more detailed explanation, it is advisable to consult responseMessage. This field provides additional information that can offer valuable insights for troubleshooting.

Merchants may choose to display the responseMessage to their operators or staffs to facilitate prompt identification and resolution of the issue.

HTTP codeService CodeSub-error CodeResponse CodeResponse MessagePartner Action
20008002000800SuccessfulMark inquiry account process to Success. Get binding status from response.additionalInfo.bindingStatus
40008004000800Bad RequestMark inquiry account process to Failed. Retry request with proper parameter
40008014000801Invalid Field FormatMark inquiry account process to Failed. Retry request with proper parameter
40008024000802
  • Invalid Mandatory Field {accountToken or partnerReferenceNo}
  • Invalid Mandatory Field {merchantId}
  • Invalid Mandatory Field + {error message}
Mark inquiry account process to Failed. Retry request with proper parameter
40108004010800Unauthorized.{error message}Mark inquiry account process to Failed. Retry request with proper parameter
40108014010801Invalid TokenMark inquiry account process to Failed. Retry request with proper parameter
40308054030805
  • Do Not Honor. User Is Deleted
  • Do Not Honor. User Is Banned
  • Do Not Honor. User Is Locked
  • Do Not Honor. User Is Not Active
  • Invalid Field Format {mobileNumber}. User Is Not Found
Mark inquiry account process to Failed. Contact Shopeepay to check the user/account status
40408114040811Account Information InvalidMark inquiry account process to Failed. Retry request with proper parameter
40408134040813Invalid Amount. Currency Does Not Support CentsMark inquiry account process to Failed. Retry request with proper parameter
40908004090800ConflictMark inquiry account process to Failed. Retry request periodically or consult to Shopeepay
50008005000800General ErrorMark inquiry account process to Failed. Retry request periodically or consult to Shopeepay
50008015000801Internal Server ErrorMark inquiry account process to Failed. Retry request periodically or consult to Shopeepay
50408005040800TimeoutMark inquiry account process to Failed. Retry request periodically or consult to Shopeepay