Subscription

Merchant Workflow

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

  1. Completed account linking request and store returned access token
  2. Initiate a payment request for Subscription when payment is due

The following figure illustrates the workflow of accepting a payment in the Subscription payment scenario:

  1. Merchant calls Create Payment Order: Subscription endpoint to charge from the customer’s ShopeePay account.
  2. ShopeePay will conduct a sequential attempt with each of the customer’s linked payment methods with ShopeePay, until the transaction is successful.
  3. ShopeePay will sends an asynchronous message via Notify Transaction Status endpoint to inform merchants on the payment result.
  4. Merchant can also call the Check Transaction Status endpoint to query the status of the transaction.
    • If the response code is "Success" and the latestTransactionStatus is 00, merchant can mark this transaction as successful.
    • If the response code = "Failed", the merchant can mark this transaction as failed.
    • If the transaction is in a “Processing” status, 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 30 minutes
    • If the transaction has 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 30 minutes.

Create Payment Order: Subscription

Specification

The following table is the specification of the API:

HTTP MethodPOST
Service Code54
Path.../v1.0.2/debit/payment-host-to-host
Versionv1.0.2

Request Parameters

FieldTypeMandatoryDescription
partnerReferenceNoStringMUnique identifier of payment transaction generated by merchant.
merchantIdStringMUnique identifier of merchant in merchant system.
  • Accepts up to 64 characters.
externalStoreIdStringMUnique identifier of store in merchant system.
  • Accepts up to 64 characters.
amountObjectM
  • value
StringMTransaction amount.
  • Sample: 10.000,00 will be placed with 10000.00
  • currency
StringMCurrency that is associated with the payment amount.
  • Accepted values: IDR
urlParamsArray of ObjectMArray of object
  • url
StringMIndicates the URL of the merchant's platform to return back to, once the payment on ShopeePay’s page is completed.
  • type
StringMIndicates the type of the sent url.
  • Only accepts ‘PAY_RETURN' value.
  • isDeepLink
StringMIndicates whether the url is a deep link or not.
  • Only accepts either ‘Y’ or ‘N’ value.
additionalInfoObjectO
  • accountToken
StringMThe accountToken used to represent the account binding between Merchant's platform and ShopeePay.
  • useCoin
BooleanOUse this field to indicate whether the customer prefers to use or not to use coins to offset their payment on the merchant’s platform. The default value is set to false.
  • True: attempt to use coins
  • False: do not use coins
  • promoIds
StringOComma separated eligible promoIds of 100 characters or less (up to 20), if any.
  • These promoIds will be checked against promotional campaigns configured in ShopeePay to determine the valid reward amount the customer can receive for this transaction.
  • metadata
StringOAdditional information for the transaction. Additional information for the transaction.
  • 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

"partnerReferenceNo": "Direct Payment-123",
"merchantId": "Merchant123",
"externalStoreId": "Store123",
"amount": {
"value": "10000.00",
"currency": "IDR"
},
"urlParams": [
{
"url": "https://www.test.com",
"type": "PAY_RETURN",
"isDeepLink": "N"
}
],
"additionalInfo": {
"useCoin": true,
"accountToken": "+Tgd0x95GGgt3kN7m1ItWDGqCTAVYysV",
"promoIds": "Promo1, Promo2",
"metadata": "{\"field1\":\"Data1\",\"field2\":\"Data2\",\"field3\":\"Data3\"}"
}
}
arrow-svg

Copy

Response Parameter

FieldTypeMandatoryDescription
responseCodeStringMError code to specify the error returned
responseMessageStringMDebug message to provide more information
partnerReferenceNoStringOUnique identifier of payment transaction generated by merchant
ReferenceNoStringCTransaction Identifier in ShopeePay System
additionalInfoObjectO
  • value
StringOTransaction amount. 
  • Sample: 10.000,00 will be placed with 10000.00
  • merchantId
StringOUnique identifier of merchant in merchant system
  • externalStoreId
StringOUnique identifier of store in merchant system
  • createTime
StringOCreate time of the individual transaction.
  • updateTime
StringOUpdate time of the individual transaction.
  • latestTransactionStatus
StringO
  • transactionType
uint32O13, referring to subscription transaction type. Refer to Transaction Types for specific transaction types
  • userIdHash
StringOIdentifier for customer that made the payment.
  • promoIdApplied
StringOComma separated eligible promoIds of 100 characters or less (up to 20), if any.
  • paymentChannel
int32OIndicates the source of fund used.

Sample API Response

JS EXAMPLE

{
"responseCode": "2005400",
"responseMessage": "Successful",
"partnerReferenceNo": "Direct Payment-123",
"referenceNo": "Shopee Pay-Direct Payment-123",
"additionalInfo": {
"value": "10000.00",
"merchantId": "Merchant123",
"externalStoreId": "Store123",
"createTime": "2022-07-20T07:00:00+07:00",
"updateTime": "2022-07-20T07:00:01+07:00",
"transactionType": 13,
"userIdHash": "15e455125fba426a4a2bb9145b3af2906813a7f222f6eab93b026ead62dc8d76",
"latestTransactionStatus": "00",
"promoIdApplied": "Promo1, Promo2",
"paymentChannel": 1
}
}
arrow-svg

Copy

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
20054002005400SuccessfulMark Subscription process to Success. Forward customer to Shopeepay page
40054004005400Bad RequestMark Subscription process to Failed. Retry request with proper parameter
40054014005401
  • Invalid field format {fieldName}
  • Invalid field format {timestamp}
  • Invalid Field Format {validUpTo}
  • Invalid Field Format {promoIds}
  • Invalid Field Format {paymentChannelId}
  • Invalid Field Format {paymentChannelName}
  • Invalid Field Format {paymentMethodName}
  • Invalid Field Format {fraudCheckInfo}
  • Invalid field format {currency}
  • Invalid Field Format {metadata}. Exceed Maximum Characters
  • Invalid Field Format {metadata}. Maximum JSON Key Exceeded
  • Invalid Field Format {metadata}. Invalid JSON Key Name
  • Invalid Field Format {metadata}
  • Invalid Field Format
Mark Subscription process to Failed. Retry request with proper parameter
40054024005402
  • Invalid mandatory field {fieldName}
  • Invalid mandatory field {originalPartnerReferenceNo}
  • Invalid mandatory field {merchantId}. Exceed maximum character length
  • Invalid mandatory field {externalStoreId}. Exceed maximum character length
  • Invalid Mandatory Field {currency}
  • Invalid Mandatory Field {merchantId}
  • Invalid Mandatory Field {pointOfInitiation}
  • Invalid Mandatory Field {externalStoreId}
  • Invalid Mandatory Field {pointOfInitiation} or {accountToken}
  • Invalid Mandatory Field {value}. Non Positive Amount Is Not Allowed
  • Invalid Mandatory Field + {error message}
Mark Subscription process to Failed. Retry request with proper parameter
40154004015400
  • Unauthorized. Invalid Client Key
  • Unauthorized.{error message}
Mark Subscription process to Failed. Retry request with proper parameter
40154014015401Invalid TokenMark Subscription process to Failed. Retry request with proper parameter
40354014035401
  • Feature Not Allowed
  • Feature Not Allowed. Selected Payment Channel Is Disabled For Merchant
Mark Subscription process to Failed. Retry request periodically or consult to Shopeepay
40354064035406Feature Not Allowed. Service Is Temporarily Down For Scheduled MaintenanceMark Subscription process to Failed. Retry request periodically or consult to Shopeepay
40454084045408
  • Invalid merchant, status is not active
  • Invalid Field Format
Mark Subscription process to Failed. Retry request with proper parameter or Contact Shopeepay to check merchant/store status
40454134045413Invalid Amount. Currency Does Not Support CentsMark Subscription process to Failed. Retry request with proper parameter
40454184045418Inconsistent RequestMark Subscription process to Failed. Retry request with proper parameter
40954004095400ConflictMark Subscription process to Failed. Retry request periodically or consult to Shopeepay
50054005005400General ErrorMark Subscription process to Failed. Retry request periodically or consult to Shopeepay
50054015005401Internal Server ErrorMark Subscription process to Failed. Retry request periodically or consult to Shopeepay
50454005045400TimeoutMark Subscription process to Failed. Retry request periodically or consult to Shopeepay

Check Transaction Status for Subscription

Note:

  • While a 200xx00 response generally indicates a successful API call, the actual transaction might still be processing in the background. To confirm the latest status of your transaction, we strongly recommend referring to the latestTransctionStatus field in the API response. This will provide the most up-to-date information.

Specification

The following table is the specification of the API:

HTTP MethodPOST
Service Code55
Path.../v1.0/debit/status
Versionv1.0

Request Parameter

FieldTypeMandatoryDescription
originalPartnerReferenceNoStringMUnique identifier of the transaction merchant would like to query, which could be partnerReferenceNo or partnerRefundNo.
merchantIdStringMUnique identifier of merchant in merchant system.
externalStoreIdStringMUnique identifier of store in merchant system.
serviceCodeStringMService code of original transaction, which could be 54 (Subscription) or 58 (refund).
amountObjectM
  • value
StringMTransaction amount
  • Sample: 10.000,00 will be placed with 10000.00
  • currency
StringMCurrency that is associated with the refund amount
  • Accepted values: IDR

Sample API Request

RESPONSE

{
"originalPartnerReferenceNo": "Testing-123",
"merchantId": "Merchant123",
"externalStoreId": "Store123",
"serviceCode": "54",
"amount": {
"value": "10000.00",
"currency": "IDR"
}
}
arrow-svg

Copy

Response Parameter

FieldTypeMandatoryDescription
responseCodeStringMError code to specify the error returned
responseMessageStringMDebug message to provide more information
originalReferenceNoStringCTransaction identifier in ShopeePay system that is shown to the customer.
  • The value will be returned for successful payment.
originalPartnerReferenceNoStringOUnique identifier of the transaction merchant would like to query, which could be partnerReferenceNo or partnerRefundNo.
serviceCodeStringMService code of original transaction, which could be 54 (create subscription transaction) or 58 (refund).
latestTransactionStatusStringM
transAmountObjectO
  • value
CTransaction amount.
  • Sample: 10.000,00 will be placed with 10000.00
  • currency
CRefers to the currency abbreviation for the transaction.
  • IDR
paidTimeStringMUpdate time of the individual transaction.
  • Using ISO-8601 timestamp format.
additionalInfoObjectO
  • createTime
StringOCreate time of the individual transaction.
  • Using ISO-8601 timestamp format.
  • productType
uint32OIndicates the payment method used.
  • transactionType
uint32ORefer to Transaction Types for specific transaction types
  • merchantId
StringOUnique identifier of merchant in merchant system.
  • externalStoreId
StringOUnique identifier of store in merchant system.
  • userIdHash
StringOUnique identifier of the user making the payment.
  • promoIdApplied
StringOComma separated eligible promoIds of 100 characters or less (up to 20), if any.
  • These promoIds will be checked against promotional campaigns configured in ShopeePay to determine the valid reward amount the customer can receive for this transaction.
  • paymentChannel
int32OIndicates the source of fund used.

Sample API Response

RESPONSE

{
"responseCode": "2005500",
"responseMessage": "Successful",
"original ReferenceNo": "Testing-123",
"originalPartnerReferenceNo": "Payment-123",
"serviceCode": "54",
"latestTransactionStatus": "00",
"paidTime": "2022-07-20T07:10:10+07:00",
"transAmount": {
"value": "10000.00",
"currency": "IDR"
},
"additionalInfo": {
"createTime": "2022-07-20T07:05:00+07:00",
"productType": 16,
"transactionType": 13,
"userIdHash": "15e455125fba426a4a2bb9145b3af2906813a7f222f6eab93b026ead62dc8d76",
"merchantId": "Merchant123",
"externalStoreId": "Store123",
"promoIdApplied": "Promo1, Promo2",
"paymentChannel": 1
}
}
arrow-svg

Copy

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
20055002005500SuccessfulMark Subscription payment to corresponding status according to response.additionalInfo.latestTransactionStatus. Retry request periodically if didn't get final status
40055004005500Bad RequestMark Subscription payment to Pending. Retry request with proper parameter
40055014005501
  • Invalid field format {fieldName}
  • Invalid field format {serviceCode}
  • Invalid Field Format {metadata}. Exceed Maximum Characters
  • Invalid Field Format {metadata}. Maximum JSON Key Exceeded
  • Invalid Field Format {metadata}. Invalid JSON Key Name
  • Invalid Field Format {metadata}
  • Invalid mandatory field {value}, Non-Positive Amount
Mark Subscription payment to Pending. Retry request with proper parameter
40055014005501Invalid Field FormatMark Subscription payment to Pending. Retry request with proper parameter
40055024005502
  • Invalid mandatory field {fieldName}
  • Invalid mandatory field {partnerReferenceNo}
  • Invalid mandatory field {merchantId}. Exceed maximum character length
  • Invalid mandatory field {externalStoreId}. Exceed maximum character length
  • Invalid mandatory field {merchantId/externalStoreId}
  • Invalid Amount. Amount cannot contain cents
  • Invalid Mandatory Field + {error message}
Mark Subscription payment to Pending. Retry request with proper parameter
40055084005508Invalid Field format Invalid MerchantMark Subscription payment to Pending. Retry request periodically or consult to Shopeepay
40155004015500Unauthorized invalid client key Unauthorized.{error message}Mark Subscription payment to Pending. Retry request with proper parameter
40155014015501Invalid TokenMark Subscription payment to Pending. Retry request with proper parameter
40355084035508
  • Invalid Merchant, Status Is Not Active
  • Invalid Store, Status Is Not Active
Mark Subscription payment to Pending. Contact Shopeepay to check merchant/store status
40455014045501Transaction not foundMark Subscription payment to Failed
40455084045508Entity not foundMark Subscription payment to Pending. Retry request periodically or consult to Shopeepay
40455134045513
  • Invalid amount. Mismatch with original transaction
  • Invalid Amount. Non Positive Amount Is Not Allowed
Mark Subscription payment to Pending. Retry request with proper parameter
40955004095500ConflictMark Subscription payment to Pending. Retry request periodically or consult to Shopeepay
50055005005500General ErrorMark Subscription payment to Pending. Retry request periodically or consult to Shopeepay
50055015005501Internal Server ErrorMark Subscription payment to Pending. Retry request periodically or consult to Shopeepay
50455005045500TimeoutMark Subscription payment to Pending. Retry request periodically or consult to Shopeepay

Refund Payment

Use this endpoint to request a refund for a successful transaction. Refunds are subject to refund conditions.

HTTP MethodPOST
Service Code58
Path../v1.0/debit/refund
Versionv1.0

Refer to Refund Payment for the detail request and response parameters.

Notify Transaction Status

Note: Merchant needs to confirm that both the payment amount and the originalPartnerReferenceNo correspond to the original /debit/payment-host-to-host request before considering the payment successful.

HTTP MethodPOST
Service Code52
Path.../v1.0/debit/notify
Versionv1.0

Refer to Notify Transaction Status endpoint for the detail request body and response parameters.