ShopeePay Payment API V1.54
ShopeePay Payment API V1.54
ShopeePay Payment API V1.54
Payment API Document
Version 1.54 - 12 Oct 2020
Table of Contents
1. Introduction 3
1.1 About this Document 3
1.2 Intended Audience 3
1.3 Version Control 3
2. Definitions 4
2.1 Payment Methods 4
2.2 Term Definitions 5
3. System Requirements 6
3.1 Prerequisite 6
3.2 API Rules 7
3.2.1 Protocol Rules 7
3.2.2 Parameter Specifications 8
3.2.2.1 Request Header 8
3.2.2.2 Payment Amount 8
3.2.3 Security Specification 9
3.2.3.1 Signature 9
3.2.4 Access Nodes 11
Appendix 56
Appendix 1A - Transaction Types 56
Appendix 1B - Payment Status 56
Appendix 1C - Transaction Status 56
Appendix 2 - Point of Initiation 57
Appendix 3 - Merchant Category Codes (MCC) 58
Appendix 4 - National Identity Types 59
Appendix 5 - Error Codes 60
Version control 61
1. Introduction
1.1 About this Document
This document is the official manual for integration with ShopeePay Payment Application
Programming Interfaces (APIs).
It describes the APIs between ShopeePay and any client system which intends to offer
ShopeePay as a payment option in their system, such as merchant aggregator systems,
point-of-sale (POS) systems, Independent Software Vendor (ISV) system and online commerce
platforms.
2. Definitions
Term Definition
Merchant A business entity that can have one or more stores operating under it
Terminal ID If terminal ID information is contained in QR code scanned by the user, the
payment transaction will contain this identifier of the merchant’s terminal that
the payment was made at.
User ID For on-us payments, the user_id_hash is an alphanumeric string of the hashed
Hash ShopeePay userid making payment.
For off-us payments (ID only), the user_id_hash is a numeric string of the
primary account number of the user making payment.
Signature Signature is created based on shared secret key and algorithm, used by
ShopeePay and client to verify each other’s identity in every API request. The
signature algorithm is created and provided by ShopeePay. The common
signature modes used are HMAC, SHA-256, Base64
Secret Key A secret key that is shared between ShopeePay Server and the Client. This key
is used to generate the Signature to authenticate the client.
[ Note ] Never hard code the secret key in a frontend application. All API calls
should only be made from the Client’s servers.
3. System Requirements
3.1 Prerequisite
Once commercial agreement between ShopeePay and client is finalised, each merchant will be
assigned the following for integration testing purposes
Name Description
Client ID Unique identifier to identify the caller of each request, to be added to
the request header of each API call.
Secret Key Only ShopeePay and the Client should know the shared secret. Secret
Key will be shared offline.
Component Format/Method
Name Description
Signature Generated using the shared secret that is given by Shopee to
authenticate the API caller.
● Integer format
Example:
There will not be a default currency. The current supported currency will be:
3.2.3.1 Signature
A signature should be generated from the request body to authenticate the request. A secret key
is needed to sign the request body. Please request from our technical team if you do not have
one.
The signature is a hash-based message authentication code (HMAC) using the SHA256
cryptographic function and the aforementioned secret key, operated on the request JSON.
Golang import (
"crypto/hmac"
"crypto/sha256"
"encoding/base64"
)
// Sign - sign the `payload` with `key`
func Sign(payload, key []byte) string {
mac := hmac.New(sha256.New, key)
// Cannot return error
if _, err := mac.Write(payload); err != nil {
return ""
}
return base64.StdEncoding.EncodeToString(mac.Sum(nil))
}
The signature should be added in the HTTP header in the following format:
X-Airpay-ClientId: <clientid>
X-Airpay-Req-H: <request_signature>
Signature Example
Secret: p
z148x0gXyPCLHxnlhEydNLg55jni91i
5f5532bf23018674788770f43743522dff1af5782243fab06b1e8677a7391d4c
3. Encode to Base64
X1UyvyMBhnR4h3D0N0NSLf8a9XgiQ/qwax6Gd6c5HUw=
Upon receiving the API response, the Client should verify the signature of the response in the
following way:
1. Use the shared secret to sign the response body to obtain the response signature.
2. Compare the generated signature to the signature in the header of the API response.
3. Signatures from steps #1 and #2 must be identical. If they are different, the response
should not be trusted.
sandbox api.uat.wallet.airpay.<region>
live api.wallet.airpay.<region>
2) User clicks on “Scan” icon on ShopeePay homepage and scan the QR code, as shown in
figure 4.1.2
3) User confirms the payment amounts and apply any merchant voucher if applicable, as
shown in figure 4.1.3
4) The user enter PIN to proceed with the payment, as shown in figure 4.1.4
5) User is prompted of successful payment after completing the payment, as shown in
figure 4.1.5. Merchant delivers the products to user after receiving notification of
successful payment from ShopeePay system.
See screenshots on the following page for the front-end user flow on ShopeePay.
2) The user scan the QR code, checks payment amount and input PIN to proceed with the
payment
3) ShopeePay system returns the transaction result to user and the user is redirected to
payment successful page.
4) ShopeePay also sends asynchronous message via c allback URL (Notify transaction
status) to inform client backend regarding payment result
5) If no response from ShopeePay Server, Client can check transaction status by calling
ShopeePay Check Payment Status API
a) Success - Payment process stops and user walks out of the store with purchase
(1) 5 seconds
(2) 10 seconds
(3) 15 seconds
(4) 20 seconds
(5) 25 seconds
.
.
.
7) After 100 seconds of retry with no response from ShopeePay, client can consider
payment transaction to have timed out.
8) If buyer can show evidence of payment success on their payment app, merchant can
choose to consider payment as successful and wait for reconciliation process on T+1 to
settle discrepancies if any.
Use this API to generate a dynamic QR code containing the payment amount and unique
payment reference ID.
● URL: "/v3/merchant-host/qr/create"
Request Parameters
Response Parameters
Field Type Description
Sample Response
Please refer to N
otify Transaction Status.
Use this API to invalidate the payment reference in a QR code if the order in Client system is
closed/cancelled. Once QR is invalidated successfully, the QR code containing the payment
reference ID can no longer be used to make payment.
● URL: "/v3/merchant-host/qr/invalidate"
Request Parameters
Response Response
Please refer to C
heck Payment Status API
Please refer to C
reate Refund API
2) User is prompted to enter ShopeePay pin before showing the QR/barcode, as shown in
figure 4.2.2.
3) User QR is shown on ShopeePay, as shown in figure 4.2.3. Merchant scans user QR and
submits payment requests to ShopeePay system. User can choose to pay using
barcode, as shown in figure 4.2.4.
4) If payment is successful, User is shown the successful payment screen, as shown in
figure 4.2.5.
5) Payment Code expires when client does not scan User’s QR/barcode within the 1 minute
expiry time. User will have to click renew code and generate another Payment Code for
payment, as shown in figure 4.2.6.
See screenshots on the following page for the front-end user flow on ShopeePay.
1) User clicks on the “Pay” button on ShopeePay homepage to generate QR/barcode valid
for 1 minute
3) Client calls Create CPM Payment API on ShopeePay Server with the transaction value
4) ShopeePay system returns the transaction result to client, and informs user of the
successful payment on ShopeePay App
5) If there’s no response from ShopeePay Server before request timeout (time out duration
is determined by Client), Client can check payment status by calling ShopeePay C
heck
Payment Status API
6) If C
heck Payment Status API returns:
a) Success - Payment process stops and user walks out of the store with purchase
● 5 seconds
● 10 seconds
● 15 seconds
● 20 seconds
.
.
.
● 100 seconds
7) After 100 seconds, payment transaction will timeout (ShopeePay will issue timeout on
that request) and the merchant should void the original payment transaction before
attempting payment creation again.
b) Fail - transaction can be found but it does not meet the requirements for void
(same day 23:59 hours), merchant can try refund instead.
9) If the user making the payment can show evidence of payment success on their
payment app, merchant can choose to consider payment as successful and wait for
reconciliation process on T+1 to settle discrepancies if any.
4.2.3 APIs
4.2.3.1 Create CPM Payment
Use this API to initiate a payment request after scanning a user’s CPM QR.
● URL: "/v3/merchant-host/transaction/payment/create"
Request Parameters
● SGD
Response Parameters
Sample Request
Sample Response
Please refer to C
heck Payment Status API
Please refer to C
reate Void API
Please refer to C
reate Refund API
2) User clicks on the payment confirmation button in the Client’s application to confirm
they are paying with ShopeePay, as shown in Figure 4.3.2.
a) If not, notify or redirect the user to install Shopee App first before completing
payment.
b) If yes, redirect the user to the ShopeePay payment amount page on Shopee app,
as shown in Figure 4.3.3.
4) Upon selecting payment options/vouchers in ShopeePay (if any), User enters their
ShopeePay PIN to proceed with the payment, as shown in figure 4.3.4.
5) If the payment is successful, User is shown the successful payment screen, as shown in
figure 4.3.5.
6) User can jump back to the original Client’s application and view their order status, as
shown in Figure 4.3.6. External application can then release the order to the user after
receiving notification of a successful payment from ShopeePay system.
See screenshots on the following page for the front-end user flow on ShopeePay.
1) After User creates an order on the Client’s app and confirms to pay by ShopeePay,
Client’s app calls O
rder Create API to get the redirect URLs to ShopeePay.
2) User clicks on the redirect URL to jump to ShopeePay payment screen. Before the user
is redirected to ShopeePay, the Client’s app should check if the user’s device has
Shopee App installed.
a) If the Shopee App is not installed, it is recommended that the Client app redirects
the user to install the shopee app using the r edirect_url_http link returned in O
rder
Create API, for an optimal user experience.
b) If Shopee App is installed, the Client’s app can direct the user to the ShopeePay
payment page.
3) ShopeePay app displays order details using payment identifier in redirect URL.
4) User checks the payment amount and inputs Shopeepay PIN to complete the payment.
5) ShopeePay system returns the transaction result and the user is redirected to payment
successful page. From the payment success page in ShopeePay, user can jump back to
the Client’s app using the return_url to view their order status.
[ Note ] Never use the redirect to return_url as an indication of payment success. Client
should only rely on server request/response to check the final status of payment.
6) ShopeePay sends the transaction status update via c allback URL (Notify transaction
status) to inform client backend regarding payment result. Client can also check
transaction status by calling the ShopeePay Check Payment Status API.
a) Success - Payment process stops and user walks out of the store with purchase
(1) 5 seconds
(2) 10 seconds
.
.
.
(3) 30 seconds
8) After 30 seconds of retry with no response from ShopeePay, client can consider
payment transaction to have timed out. Differences can be settled during the T+1
reconciliation process with ShopeePay.
4.3.3 APIs
4.3.3.1 Create Order
● URL: "/v3/merchant-host/order/create"
Request Parameters
Response Parameters
Please refer to N
otify Transaction Status
Please refer to C
heck Payment Status API
Please refer to C
reate Void API
Please refer to C
reate Refund API
5. Common APIs
The Common API serves as the trivial API interface to be called for additional functions. Clients
can choose to integrate these functions based on their needs. The Common API includes Query
status, request void, create refund, set merchant, set store, get transactions
terminal_id string Terminal id from the MPM QR code. This field will
be empty if the payment method is not MPM.
Sample Callback
● URL: "/v3/merchant-host/transaction/payment/check"
[ Note ] It is essential for the Client to validate that payment amount and payment_reference_id
matches the original /qr/create request before considering the payment as successful.
Request Parameters
Response Parameters
Merchants can only use the payment reference ID of payment transactions to check status.
Note: Any payment transaction check that returns status as refunded or void will have 2
transactions in transaction_list object, which will include:
Sample Request
● URL: "/v3/merchant-host/transaction/refund/create"
Request Parameters
Sample Response
● URL: "/v3/merchant-host/transaction/void/create"
Request parameters
Response Parameters
Sample Request
Sample Response
● URL: “/v3/merchant-host/merchant/set”
Periodic Update: It is highly recommended for Clients to sync the latest Store information in
their system to ShopeePay, to ensure all users can enjoy a smooth payment experience at newly
added/updated Stores.
The following diagram represents the structure of Merchants and Stores in ShopeePay that ISVs
should adhere to during onboarding and sending payment requests. Payments are only
accepted on the Store level.
Request parameters
extinfo object
● business_tax_id string
Clients can update information of previously added merchants via the Set Merchant API, using
“merchant_ext_id” as the identifier for each merchant.
Fields that are not filled in in the Set Merchant API during updating will not be updated.
Fields that are mandatory during merchant onboarding cannot be updated to empty values.
● URL: “/v3/merchant-host/store/set”
Request parameters
ward string N The district that this store operates in, if
applicable
Response parameters
extinfo object
Clients can update information of previously added merchants via the Set Store API, using
“merchant_ext_id” and “store_ext_id as the identifier for each merchant.
The only mandatory fields are “merchant_ext_id” and “store_ext_id”. No other mandatory fields
are required for Update Stores’ Information. Fields that are not filled in in the Set Store API
during updating will not be updated.
Fields that are mandatory during store creation cannot be updated to empty values.
The maximum number of transactions returned for each API request is 5000. API requests
should be made multiple times in succession until the response body is empty, indicating that
all transactions within the time range have been returned.
For every new API request made within the specified time range, the request should indicate a
last_reference_id value, which is the reference_id of the last transaction returned in the response
of a previous API request.
The transactions will be returned in Descending order by update time (i.e. the latest transaction
will be returned first).
● URL: “/v3/merchant-host/transaction/list”
Request parameters
Response Parameters
● amount int64 Amount used for the payment, inflated by a factor of 100
Appendix
Void 26
Payment successful 1
Payment refunded 3
Payment void 4
Payment processing 5
Payment failed 6
Transaction processing 2
Transaction successful 3
Transaction failed 4
Bakeries 5462
ID 1 KTP
ID 2 KITAS
MY 1 IC
MY 2 Passport
SG 1 NRIC
SG 2 FIN
Value Description
0 Success
2 Permission denied
6 The user making the payment has not activated their wallet
7 Expired
601 Request to refund/void a payment transaction does not meet rules. This error
is also returned during refund block periods, set at midnight to 6am by default.
Version control
V1.49 26.5.2020 G.Z. 1 - Add details for essential fields to validate in
Check Status API request and Notify Transaction
Status callback
2 - Add time ranges where refund/void requests
are blocked for settlement processing