Temu Cancel/Refund Orders
Version | Date | Created / Updated | Notes |
---|---|---|---|
v1.0 | Hristiyan Georgiev | First publish |
At present, Temu only supports customer-initiated refunds and cancellations, and sellers are not permitted to cancel or refund orders. Therefore, our development will focus solely on creating functionality to store refunds in Hemi, without any actions being taken on them.
We will need to perform two calls in order to get to the bottom of what was refunded on an order.
The first call is to get a list of orders that have refunds.
Get Refund orders’ list
API Call : POST https://openapi-b-eu.temu.com/openapi/router
API Name : bg.aftersales.parentaftersales.list.get
Please don’t forget that the call itself is to be used based on the value of Channel > Country
as described here: ‼ Please note that the above is true for all calls. In each call we will give the endpoint with an example host but we need to use the correct domain pointer based on the Channel > Country
value ‼
We need to use specific parameters to define the timeframes for the refunds we wish to retrieve. The parameters we'll use are updateAtStart
and updateAtEnd
, both in Unix timestamp format. We'll reference the last_date_run
table to select the relevant date and overlap it with 1 hour.Therefore, updateAtStart
will be the last_date_run
minus 1 hour, and updateAtEnd
will be the current time. For the first cron run, we should retrieve orders from the past 90 days.
Using this call we want to create a Order Payment
record with Type
= Refund and status
= Completed
Find a request sample with params below :
{
"type": "bg.aftersales.parentaftersales.list.get",
"timestamp": timestamp,
"app_key": app_key,
"data_type": "JSON",
"access_token": access_token,
"updateAtStart": 1737377517,
"updateAtEnd": 1738068733,
"pageSize": 100,
"pageNo": 1,
"afterSalesStatusGroup": 5
}
Request mapping :
Temu field | Field type | Notes/Mapping |
---|---|---|
pageSize |
INTEGER | Default is 10 but I suggest we use 100 |
pageNumber |
INTEGER | Start from 1 and if more pages available we need to get them too |
updateAtStart |
INTEGER | last_date_run - 1hour |
updateAtEnd |
INTEGER | CURRTIME() |
afterSalesStatusGroup |
INTEGER | Hardcoded as “5”. This status represents only refunded orders. |
Example response :
{
"result": {
"total": 14,
"pageNumber": 1,
"data": [
{
"parentAfterSalesSn": "PO-076-03461834287911012-D01",
"afterSalesStatusGroup": 5,
"parentAfterSalesStatus": 5,
"parentOrderSn": "PO-076-03461834287911012",
"updateAt": 1737962678,
"afterSalesType": 2,
"createAt": 1737962341
},
{
"parentAfterSalesSn": "PO-076-12502220639270121-D01",
"afterSalesStatusGroup": 5,
"parentAfterSalesStatus": 5,
"parentOrderSn": "PO-076-12502220639270121",
"updateAt": 1737879224,
"afterSalesType": 2,
"createAt": 1737878379
},
{
"parentAfterSalesSn": "PO-076-12502372897830121-D01",
"afterSalesStatusGroup": 5,
"parentAfterSalesStatus": 5,
"parentOrderSn": "PO-076-12502372897830121",
"updateAt": 1737879206,
"afterSalesType": 2,
"createAt": 1737878334
},
{
"parentAfterSalesSn": "PO-076-07004751844390121-D01",
"afterSalesStatusGroup": 5,
"parentAfterSalesStatus": 5,
"parentOrderSn": "PO-076-07004751844390121",
"updateAt": 1737879210,
"afterSalesType": 2,
"createAt": 1737878295
},
{
"parentAfterSalesSn": "PO-076-06747085810470121-D04",
"afterSalesStatusGroup": 5,
"parentAfterSalesStatus": 5,
"parentOrderSn": "PO-076-06747085810470121",
"updateAt": 1737962769,
"afterSalesType": 1,
"createAt": 1737775876
},
{
"parentAfterSalesSn": "PO-076-01400291382311012-D01",
"afterSalesStatusGroup": 5,
"parentAfterSalesStatus": 5,
"parentOrderSn": "PO-076-01400291382311012",
"updateAt": 1737729976,
"afterSalesType": 2,
"createAt": 1737710310
},
{
"parentAfterSalesSn": "PO-076-01206800202790375-D01",
"afterSalesStatusGroup": 5,
"parentAfterSalesStatus": 5,
"parentOrderSn": "PO-076-01206800202790375",
"updateAt": 1737722098,
"afterSalesType": 1,
"createAt": 1737549168
},
{
"parentAfterSalesSn": "PO-076-01206905060390375-D01",
"afterSalesStatusGroup": 5,
"parentAfterSalesStatus": 5,
"parentOrderSn": "PO-076-01206905060390375",
"updateAt": 1737721974,
"afterSalesType": 1,
"createAt": 1737549034
},
{
"parentAfterSalesSn": "PO-076-01206915546150375-D01",
"afterSalesStatusGroup": 5,
"parentAfterSalesStatus": 5,
"parentOrderSn": "PO-076-01206915546150375",
"updateAt": 1737721970,
"afterSalesType": 1,
"createAt": 1737549029
},
{
"parentAfterSalesSn": "PO-076-06747004545830121-D01",
"afterSalesStatusGroup": 5,
"parentAfterSalesStatus": 5,
"parentOrderSn": "PO-076-06747004545830121",
"updateAt": 1737550273,
"afterSalesType": 2,
"createAt": 1737463689
},
{
"parentAfterSalesSn": "PO-076-11021058880551012-D01",
"afterSalesStatusGroup": 5,
"parentAfterSalesStatus": 5,
"parentOrderSn": "PO-076-11021058880551012",
"updateAt": 1737476225,
"afterSalesType": 2,
"createAt": 1737389496
},
{
"parentAfterSalesSn": "PO-076-15144147336231012-D01",
"afterSalesStatusGroup": 5,
"parentAfterSalesStatus": 5,
"parentOrderSn": "PO-076-15144147336231012",
"updateAt": 1737386595,
"afterSalesType": 2,
"createAt": 1737100504
},
{
"parentAfterSalesSn": "PO-076-15144220736551012-D01",
"afterSalesStatusGroup": 5,
"parentAfterSalesStatus": 5,
"parentOrderSn": "PO-076-15144220736551012",
"updateAt": 1737386599,
"afterSalesType": 2,
"createAt": 1737100457
},
{
"parentAfterSalesSn": "PO-076-15144199765031012-D01",
"afterSalesStatusGroup": 5,
"parentAfterSalesStatus": 5,
"parentOrderSn": "PO-076-15144199765031012",
"updateAt": 1737386671,
"afterSalesType": 2,
"createAt": 1737100414
}
]
},
"success": true,
"requestId": "eu-fa1fa676-e2eb-4e1c-bf34-e187e259258a",
"errorCode": 1000000,
"errorMsg": ""
}
Response Mapping :
Temu Field | Hemi Field | Notes | ||
---|---|---|---|---|
result |
||||
total |
||||
pageNumber |
||||
data |
||||
parentAfterSalesSn |
Order Payment > Transaction ID |
We might receive a couple of IDs for the same transaction. We always want to store the first one (i.e with the oldest date) | ||
afterSalesStatusGroup |
N/A | |||
parentAfterSalesStatus |
N/A | |||
parentOrderSn |
We use this to map with Orders > Marketplace Order ID to find out the order which is being refunded |
|||
updateAt |
N/A | |||
afterSalesType |
Order Payment > Refund Note |
We need a mapping : |
1 -Refund Only
2 -Return and Refund |
| | | createAt
| Order Payment
> Payment Date
| |
| success
| | | N/A | |
| requestId
| | | N/A | |
| errorCode
| | | N/A | |
| errorMsg
| | | N/A | |
Get Refund Details
API Call : POST https://openapi-b-eu.temu.com/openapi/router
API Name : bg.aftersales.aftersales.list.get
Example call with params :
{
"type": "bg.aftersales.aftersales.list.get",
"timestamp": timestamp,
"app_key": app_key,
"data_type": "JSON",
"access_token": access_token,
"pageSize": 100,
"parentAfterSalesSnList": ["PO-076-03461834287911012-D01", "PO-076-12502220639270121-D01"]
}
We need to use the parentAfterSalesSn
which we have stored into Order Payment
> Transaction ID
. Multiple parentAfterSalesSn
values can be used, allowing us to fetch orders in bulk.
Example response :
{
"result": {
"total": 6,
"pageNumber": 1,
"data": [
{
"parentAfterSalesSn": "PO-076-03461834287911012-D01",
"productSkuId": 209602340018,
"applyAfterSalesGoodsNumber": 1,
"afterSalesSn": "076-03461897202471012-D01",
"afterSalesType": 2,
"afterSalesStatus": 5
},
{
"parentAfterSalesSn": "PO-076-12502220639270121-D01",
"productSkuId": 756177837728,
"applyAfterSalesGoodsNumber": 1,
"afterSalesSn": "076-12502371656230121-D01",
"afterSalesType": 2,
"afterSalesStatus": 5
},
{
"parentAfterSalesSn": "PO-076-12502220639270121-D01",
"productSkuId": 756177837728,
"applyAfterSalesGoodsNumber": 1,
"afterSalesSn": "076-12502372682790121-D01",
"afterSalesType": 2,
"afterSalesStatus": 5
},
{
"parentAfterSalesSn": "PO-076-12502220639270121-D01",
"productSkuId": 756177837728,
"applyAfterSalesGoodsNumber": 1,
"afterSalesSn": "076-12502340393510121-D01",
"afterSalesType": 2,
"afterSalesStatus": 5
},
{
"parentAfterSalesSn": "PO-076-12502220639270121-D01",
"productSkuId": 756177837728,
"applyAfterSalesGoodsNumber": 1,
"afterSalesSn": "076-12502250181670121-D01",
"afterSalesType": 2,
"afterSalesStatus": 5
},
{
"parentAfterSalesSn": "PO-076-12502220639270121-D01",
"productSkuId": 756177837728,
"applyAfterSalesGoodsNumber": 1,
"afterSalesSn": "076-12502263286310121-D01",
"afterSalesType": 2,
"afterSalesStatus": 5
}
]
},
"success": true,
"requestId": "eu-c82d2884-4d1f-4a4e-99cc-cf245552fbf2",
"errorCode": 1000000,
"errorMsg": ""
}
Response mapping :
Temu Field | Hemi Field | Notes | ||
---|---|---|---|---|
result |
||||
total |
||||
pageNumber |
||||
data |
||||
parentAfterSalesSn |
We have already stored this in the Order Payment > Transaction ID |
|||
productSkuId |
Using this we can identify which product is being refunded. We map this with Product In Order > Item Order Line ID . Based on this we can calculate how much quantity is being refunded and since Temu doesn’t provide costs, we can calculate how much was refunded. We then need to create a refund row for the SKU and calculated amount. |
|||
applyAfterSalesGoodsNumber |
N/A | |||
afterSalesSn |
Based on this we know exactly which line is refunded. We need to remove everything after the last “-” sign and then map it with Order Item Line > Marketplace Order Item ID . We then need to create a record in Order Refund Row Lines for the specific line id. |
|||
afterSalesType |
N/A | |||
afterSalesStatus |
N/A | |||
success |
N/A | |||
requestId |
N/A | |||
errorCode |
N/A | |||
errorMsg |
N/A |
Temu have confirmed that shipping is always refunded, but for partial refunds there are a set of calculation rules however the API interface currently does not involve these contents. So we need to create a refund row for the full shipping only if the refund results in a full order refund and we then need to mark the order as Orders
> Status
= Cancelled . For partial refunds we do not add shipping at all.