inquireMemberAssets
POST /v2/pds/memberships/inquireMemberAssets
With this API call, Mini Program Platform can request the merchant to query the membership assets of a user.
The message structure of this API is defined by us. Follow the specifications below when the merchant develops this API.
Structure
A message consists of a header and body. The following sections are focused on the body structure. For the header structure, see:
Request parameters
Field | Data type | Required | Description | Example |
cardNo | String | Yes | Indicates the unique card number generated by Mini Program Platform to identify a card, which is returned in the issueCard API.
| "011164508621375700010170***" |
assetTypes | Array<String> | Yes | Indicates the types of the assets.
Valid values are:
| [ "BENEFIT", "POINT", "BALANCE" ] |
queryConditions | String | No | Indicates the conditions for making an asset query. This parameter can be specified based on the following:
Note:
| - |
extendInfo | String | No | Indicates the extended information about this API.
| - |
Response parameters
Field | Data type | Required | Description |
result | Yes | Indicates the request result, such as status and error codes. | |
assetDetails | Array<AssetDetail> | Yes | Indicates the details of the membership assets. Maximum size: 3 elements |
extendInfo | String | No | Indicates the extended information about the response.
|
Result Process Logic
In the response, the result.resultStatus
field indicates the result of processing a request. The following table describes each result status:
resultStatus | Description |
S | The request to query membership assets is successful. The corresponding |
U | The status of the request to query membership assets is unknown. The corresponding |
F | The request to query membership assets failed. The corresponding |
More information
The scenarios for querying assets are listed below:
- When the value of assetTypes is
BENEFIT
, specify the benefitStatus and benefitPage parameters to query all the benefits specified.
- When the value of assetTypes is
POINT
andBALANCE
, specify the useThreholdsByOrderItems and useThresholdByOrderType parameters to query the available points and balance.
- When the value of assetTypes is
BENEFIT
,POINT
, andBALANCE
, specify the benefitStatus, benefitPage, useThreholdsByOrderItems, and useThresholdByOrderType parameters to query the available benefits, points, and balance. Note: In this scenario, assetDetails.assetValue.amount must be returned in the response.
Error codes
Error codes are usually classified into the following categories:
- Common error codes are common for all Mini Program OpenAPIs in V2. Â
- API-specific error codes:
Error code | Result status | Error message |
EXPIRED_CRM_BIND_TOKEN | F | The CRM authentication token of the user is expired. |
Sample
The data flow of sending a request to query membership assets is illustrated as follows:
The above diagram consists of the following steps:
- Mini Program Platform calls this API to send a request to the merchant to query the benefit details of a member.
- The merchant processes the request and queries the benefit details.
- The merchant returns the result of the query to Mini Program Platform.
Request
Query benefits based on benefitStatus
The following provides the sample request for querying benefits based on the benefit statuses:
{
"cardNo": "CARD_2102010113769***",
"assetTypes": [
"BENEFIT"
],
"queryConditions": {
"benefitStatus": [
"ACTIVATED",
"USED",
"EXPIRED"
],
"benefitPage": {
"offset": 0,
"limit": 10
}
}
}
Query available points and balance
The following provides the sample request for querying the available points and balance based on the order items and the order type:
{
"cardNo": "CARD_2102010113769***",
"assetTypes": [
"POINT",
"BALANCE"
],
"queryConditions": {
"useThresholdByOrderItems": [
{
"categoryId": "100",
"itemId": "11010",
"requestSubOrderId": "2022050400311864775",
"notAvailableOption": "Remove it from my order",
"priceInfo": {
"currency": "SGD",
"saleAmount": 869
},
"quantity": 1,
"skuId": "76251",
"storeId": "121",
"modifierGroupDetails": "[{\"groupId\":\"14524\",\"itemDetail\":[{\"categoryId\":\"100\",\"itemId\":\"11011\",\"requestSubOrderId\":\"2022050400311864775\",\"notAvailableOption\":\"Remove it from my order\",\"priceInfo\":{\"currency\":\"SGD\",\"saleAmount\":10},\"quantity\":2,\"storeId\":\"121\"}]}]"
},
{
"categoryId": "100",
"itemId": "11012",
"requestSubOrderId": "2022050400311864775",
"notAvailableOption": "Remove it from my order",
"priceInfo": {
"currency": "SGD",
"saleAmount": 300
},
"quantity": 2,
"storeId": "121"
}
],
"useThresholdByOrderType": "PICKUP"
}
}
Query available benefits, points, and balance
The following provides the sample request for querying the available benefits, points, and balance based on the benefit statuses, order items, and order type:
{
"cardNo": "CARD_2102010113769***",
"assetTypes": [
"BENEFIT",
"POINT",
"BALANCE"
],
"queryConditions": {
"useThresholdByOrderItems": [
{
"categoryId": "100",
"itemId": "11010",
"requestSubOrderId": "2022050400311864775",
"notAvailableOption": "Remove it from my order",
"priceInfo": {
"currency": "SGD",
"saleAmount": 869
},
"quantity": 1,
"skuId": "76251",
"storeId": "121",
"modifierGroupDetails": "[{\"groupId\":\"14524\",\"itemDetail\":[{\"categoryId\":\"100\",\"itemId\":\"11011\",\"requestSubOrderId\":\"2022050400311864775\",\"notAvailableOption\":\"Remove it from my order\",\"priceInfo\":{\"currency\":\"SGD\",\"saleAmount\":10},\"quantity\":2,\"storeId\":\"121\"}]}]"
},
{
"categoryId": "100",
"itemId": "11012",
"requestSubOrderId": "2022050400311864775",
"notAvailableOption": "Remove it from my order",
"priceInfo": {
"currency": "SGD",
"saleAmount": 300
},
"quantity": 2,
"storeId": "121"
}
],
"useThresholdByOrderType": "PICKUP",
"benefitStatus": [
"ACTIVATED",
"USED",
"EXPIRED"
],
"benefitPage": {
"offset": 0,
"limit": 10
}
}
}
Response
Query benefits based on benefitStatus
The following provides the sample response for querying benefits:
{
"assetDetails": [
{
"assetType": "BENEFIT",
"assetValue": [
{
"benefitInstanceId": "011164508621375700010170***",
"status": "ACTIVATED",
"benefitTitle": {
"defaultLanguage": "en-US",
"languageValues": {
"en-US": "xxx",
"zh-CN": "xxx"
}
},
"useRules": {
"defaultLanguage": "en-US",
"languageValues": {
"en-US": "xxx",
"zh-CN": "xxx"
}
},
"useScenarios": {
"defaultLanguage": "en-US",
"languageValues": {
"en-US": "xxx",
"zh-CN": "xxx"
}
},
"iconUrl": "https://cdn.example.com/icon/xxx.icon",
"createdTime": "2022-02-14T00:00:00+08:00",
"expireTime": "2023-01-26T00:00:00+08:00"
}
]
}
],
"result": {
"resultCode": "SUCCESS",
"resultMessage": "Success",
"resultStatus": "S"
}
}
Query available points and balance
The following provides the sample response for querying the available points and balance:
{
"assetDetails": [
{
"assetType": "POINT",
"assetValue": {
"pointMaxAmount": {
"currency": "SGD",
"value": 100
},
"pointUnitAmount": {
"currency": "SGD",
"value": 1
}
}
},
{
"assetType": "BALANCE",
"assetValue": {
"currency": "SGD",
"value": 100
}
}
],
"result": {
"resultCode": "SUCCESS",
"resultMessage": "Success",
"resultStatus": "S"
}
}
Query available benefits, points, and balance
The following provides the sample response for querying the available benefits, points, and balance:
{
"assetDetails": [
{
"assetType": "BENEFIT",
"assetValue": [
{
"benefitInstanceId": "011164508621375700010170***",
"status": "ACTIVATED",
"amount": {
"currency": "SGD",
"value": 100
},
"benefitTitle": {
"defaultLanguage": "en-US",
"languageValues": {
"en-US": "xxx",
"zh-CN": "xxx"
}
},
"useRules": {
"defaultLanguage": "en-US",
"languageValues": {
"en-US": "xxx",
"zh-CN": "xxx"
}
},
"useScenarios": {
"defaultLanguage": "en-US",
"languageValues": {
"en-US": "xxx",
"zh-CN": "xxx"
}
},
"iconUrl": "https://cdn.example.com/icon/xxx.icon",
"createdTime": "2022-02-14T00:00:00+08:00",
"expireTime": "2023-01-26T00:00:00+08:00"
}
]
},
{
"assetType": "POINT",
"assetValue": {
"pointMaxAmount": {
"currency": "SGD",
"value": 100
},
"pointUnitAmount": {
"currency": "SGD",
"value": 1
}
}
},
{
"assetType": "BALANCE",
"assetValue": {
"currency": "SGD",
"value": 100
}
}
],
"result": {
"resultCode": "SUCCESS",
"resultMessage": "Success",
"resultStatus": "S"
}
}