Customer Presented Mode (CPM)

Merchant Workflow

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

  1. Identify and verify the QR code

  2. Initiate a payment request

  3. Handle the payment result returned

The following figure illustrates the workflow of accepting a payment in the Customer Presented Mode payment scenario:

  1. Customer opens a payment app, and presents a payment code (QR or barcode) to the merchant.
  2. Merchant scans the customer's payment code.
  3. Merchant sends a payment request to ShopeePay via Create CPM Payment endpoint.
  4. ShopeePay system returns the transaction result to the merchant. Meanwhile, customers will also see the updated payment result.
    • When ShopeePay returns "Processing" for a payment transaction, it indicates that the payment process is still ongoing and pending further customer action to select payment method to complete the payment. This case would most likely happen when customer selects SPayLater as payment method.
  5. ShopeePay also sends an asynchronous message via Notify Transaction Status endpoint to inform merchants on the payment result.
  6. Merchants can also call the Check Transaction Status endpoint to query the status of the transaction.
    • If the response code is "Success", the merchant can mark this transaction as successful.
    • If the response code is "Failed", the merchant can mark this transaction as failed.
    • If the transaction is in a "Processing" status or no response, please retry the request at an incremental time range of every 5 seconds (e.g., 5 seconds, 10 seconds, 15 seconds, and so on) up to a maximum of 100 seconds. If there is no response after 100 seconds, please retry the request at an incremental time range of every 5 minutes up to 24 hours.
    • If customer can show evidence of payment success on their payment app, merchant may choose to consider payment as successful and wait for reconciliation process on T+1 to settle discrepancies with ShopeePay, if any.

Create CPM Payment

Use this endpoint to initiate a payment request after scanning a customer’s payment code.

  • URL: "/v3/merchant-host/transaction/payment/create"

Request Parameters

FieldTypeMandatoryDescription
request_idstringYUnique identifier for request, accepts up to 64 characters.
amountuint64YAmount used for the payment as integer, inflated by a factor of 100. A positive integer in the smallest currency unit, with no decimal point.
merchant_ext_idstringYUnique identifier of merchant in merchant's system.
store_ext_idstringYUnique identifier of store in merchant's system.
payment_codestringYPayment code is the QR/barcode content from the customer’s QR code.

If there’s no national QR code standard defined on a national level, this code starts with “918” and contains 20 digits.
payment_reference_idstringYUnique identifier of transaction generated by merchant.
currencystringYCurrency that is associated with the payment amount.

Specify the three-letter ISO currency code following the ISO 4217 standard. Currently supports IDR, MYR, PHP, SGD, THB, and VND.
validity_perioduint32NBy default, the expiry time will be set to 120 seconds.

If this field is filled, the order associated with the corresponding payment_reference_id in this request will expire after the specified validity period (in seconds).

The minimum validity period is 120 seconds and the maximum allowable value is 5 days.

Note: The system will return an error if both validity_period andexpiry_time parameters are used simultaneously.
expiry_timeuint32NUnix timestamp.

By default, the expiry time will be set to 120 seconds.

If this field is filled, the order associated with the corresponding payment_reference_id in this request will be invalid after the specified timestamp. The minimum expiry time allowed will be 30 seconds from the request time and the maximum acceptable expiry time is 5 days.

Note: The system will return an error if both validity_period andexpiry_time parameters are used simultaneously.
terminal_idstringNTerminal ID refers to the Point of Sale terminal in a store.
promo_idsstringNComma separated eligible promo_ids of 100 characters or less (up to 20), if any.

These promo_ids will be checked against promotional campaigns configured in ShopeePay to determine the valid reward amount the customer can receive for this transaction.
additional_infostringNAdditional information will be in json format.

This field supports up to 3 fields and needs to be sent in this format: {"field1":"{Data1}","field2":"{Data2}" ,"field3":"{Data3}"}

Sample API Request

REQUEST

{
"request_id": "input-unique-request-id-here",
"amount": 10000,
"merchant_ext_id": "external-merchant",
"store_ext_id": "external-store",
"payment_code":"hQVDUFYwMWEzTwegAAAGAiAgUAdRUklTQ1BNWgqTYAkYMQEVOAYPXyAAnyUCgGBjC590CAAAAAAAAAAAYilkJ94UOTE4NDU3OTQyMTE2NDczNTE4NzDEBIABQA/HCVNob3BlZVBheQ==",
"payment_reference_id": "external-payment-reference-1",
"currency": "IDR",
"promo_ids": "1234567890, 0987654321",
"additional_info": "{\”field1\”:\”Name\”,\”field2\”:\”Address\” ,\”field3\”:\”Number\”}"
}
arrow-svg

Copy

Response Parameters

FieldTypeDescription
request_idstringUnique identifier for request.
errcodeint32Error code to specify the error returned.
debug_msgstringDebug message to provide more information.
transaction_listobjectList of transactions. Will return empty if transaction fails.

Note: in Thailand and Vietnam, the name of object transaction_list is returned as transaction.
  • reference_id
stringUnique identifier of payment transaction generated by merchant.
  • amount
int64Amount used for the payment as integer, inflated by a factor of 100. A positive integer in the smallest currency unit, with no decimal point.

Example:

  • Smallest amount will be 1, which represents 0.01.
  • For currencies that do not have denomination in cents, the smallest amount will be 100, which represents 1 IDR (Rp 1) or 1 VND (₫ 1).
.
  • create_time
uint32Create time of the transaction.
  • update_time
uint32Update time of the transaction.
  • transaction_sn
stringTransaction identifier in ShopeePay system.
  • status
uint32Refer to Transaction Status for specific transaction statuses.
  • transaction_type
uint32Refer to Transaction Types Transaction Types for specific transaction types.
  • merchant_ext_id
stringUnique identifier of merchant in merchant's system.
  • store_ext_id
stringUnique identifier of store in merchant's system.
  • terminal_id
stringTerminal ID refers to the Point of Sale terminal in a store.
  • user_id_hash
stringUsed to identify the unique customer.
  • promo_id_applied
stringpromo_ids applied to the payment transaction.
  • payment_channel
uint32Indicates the source of fund used. Refer to Payment Channels for the respective source of fund.
co_fundingobjectWill return empty if no co-funding involved.

Note: This field is currently used in Thailand and Vietnam only.
  • promotion_ext_name
stringName of the promotion for merchant’s reference.
  • redeemed_promotion_amount
int64Amount of the promotion benefit obtained by customer through co-funding, inflated by a factor of 100. A positive integer in the smallest currency unit, with no decimal point.

Note: for refund transaction types, this will be the amount of promotion benefit ShopeePay clawbacks from the customer in that refund transaction.

Example:

  • Smallest amount will be 1, which represents 0.01.
  • For currencies that do not have denomination in cents, the smallest amount will be 100, which represents 1 IDR (Rp 1) or 1 VND (₫ 1).
  • redeemed_promotion_type
uint32Refer to Promotion Types for specific transaction types.
  • co_funding_cost_amount
int64Amount of cost born by merchant for the promotion benefit, inflated by a factor of 100. A positive integer in the smallest currency unit, with no decimal point.

Note: for refund transaction types, this will be the amount of co-funding amount that the merchant will no longer be charged for due to that refund transaction.

Example:

  • Smallest amount will be 1, which represents 0.01.
  • For currencies that do not have denomination in cents, the smallest amount will be 100, which represents 1 IDR (Rp 1) or 1 VND (₫ 1).

Sample API Response

RESPONSE

{
"request_id": "input-unique-request-id-here",
"errcode": 0,
"debug_msg": "success",
"transaction_list":[
{
"reference_id": "external-payment-reference-id",
"amount": 10000,
"create_time": 1647351920,
"update_time": 1647351920,
"transaction_sn": "019703251690639893",
"status": 3,
"transaction_type": 13,
"user_id_hash": "15e455125fba426a4a2bb9145b3af2906813a7f222f6eab93b026ead62dc8d76",
"store_ext_id": "1234"
"promo_id_applied: "1234567890, 0987654321",
"merchant_ext_id": "external-merchant",
"store_ext_id": "external-store",
"payment_reference_id": "external-payment-reference-1",
"currency": "IDR",
"promo_id_applied": "1234567890, 0987654321",
"payment_channel": 1
}
]
}
arrow-svg

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. 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.

ValueDescription
-2A server dropped the connection
-1A server error occurred

Please use Check Transaction Status endpoint to query the updated status of the payment.
0Success
1The request parameters is invalid or a mandatory parameter is empty
2Permission denied, often due to invalid status
4Not found, often due to merchant/store/user/transaction not found
5Transaction is in processing status, use Check Transaction Status endpoint to query the updated status of the payment
7Expired payment code or QR
9Customer’s account is banned
11Duplicated request
14Customer’s account is deleted
15Payment amount exceeded payment limit
24Customer's account is frozen
27Customer's account is not activated
42Insufficient balance
43Insufficient balance
50The request parameters is invalid due to payload sent is not a valid JSON
126Customer’s transaction limit is reached
140Customer’s wallet limit is reached
301Invalid payment code or QR
303Unable to make payment to own user account
603Ineligible payment channel
604Ineligible voucher
630SKU ID not matched
702Unable to redeem coins
1001Customer is not allowed to make the transaction
1100ShopeePay internal payment module error
1101ShopeePay internal payment module error
1102Customer’s SPL credit limit is reached
1104Ineligible payment channel
1105Transaction failed due to unsuccessful authentication
1106Duplicated payment
1200ShopeePay internal payment module error
1500ShopeePay internal payment module error
1600ShopeePay internal payment module error
1800ShopeePay internal payment module error
1905Expired payment code or QR
1908Service is temporarily down for scheduled maintenance