Searching for Orders
The Merchant Hub provides an API over a powerful search engine to let you do fast reliable searches of all your orders and customers.
Searching
To perform a search for orders or attached properties to orders, a GET request is performed against the /orders
endpoint.
Simple search
The default response is a list of orders sorted by created date descending. There is a limit that is defaulted to 10 orders per page.
- Request
- Response
GET /orders HTTP/1.1
Host: api.uat.walleydev.com // (Please note! Different hostname in production)
Content-Type: application/json
Authorization: Bearer bXlVc2VybmFtZTpmN2E1ODA4MGQzZTk0M2VmNWYyMTZlMDE...
{
"data": [
{
"id": "c75f9525-ac1a-484e-8f9e-acd800cd1e3d",
"orderNumber": "MX_210223_132648",
"merchantId": "5DFFF2F1",
"storeId": 9664,
"paymentMethod": "Invoice",
"totalAmount": 2168.88,
"totalVat": 433.78,
"currency": "SEK",
"status": "Activated",
"countryCode": "SE",
"placedAt": "2021-04-29T13:26:48.8534534+02:00",
"expiresAt": null,
"customerDetails": {
"type": "Person",
"name": "Mats Edström",
"firstName": "Mats",
"lastName": "Edström",
"customerId": 8271403,
"registrationNumber": "9806039955",
"countryCode": "SE",
"addressLine1": "Finksvängen 38",
"city": "Malung",
"postalCode": "885 35",
"email": "mats.edstrom@sink.walleydev.com",
"mobilePhoneNumber": "+46731234567",
"homePhoneNumber": "+46731234567"
},
"deliveryAddress": {
"addressLine1": "Finksvängen 38",
"addressLine2": null,
"city": "Malung",
"coAddress": null,
"receiverName": "Mats Edström",
"countryCode": "SE",
"email": "mats.edstrom@sink.walleydev.com",
"mobilePhone": "+46731234567",
"phoneNumber": "+46731234567",
"postalCode": "885 35"
},
"invoiceAddress": {
"addressLine1": "Finksvängen 38",
"addressLine2": null,
"city": "Malung",
"coAddress": null,
"receiverName": "Mats Edström",
"countryCode": "SE",
"email": "mats.edstrom@sink.walleydev.com",
"mobilePhone": "+46731234567",
"phoneNumber": "+46731234567",
"postalCode": "885 35"
},
"tags": [
"all-all-all",
"all-all-orderdetails",
"all-9664-all",
"all-9664-orderdetails",
"5DFFF2F1-all-all",
"5DFFF2F1-all-orderdetails",
"5DFFF2F1-9664-all",
"5DFFF2F1-9664-orderdetails"
]
},
{
"id": "ec3375c9-8a66-46e3-97cb-acd800cd049e",
"orderNumber": "MX_210223_132624",
"merchantId": "5DFFF2F1",
"storeId": 9664,
"paymentMethod": "Invoice",
"totalAmount": 31.18,
"totalVat": 6.24,
"currency": "SEK",
"status": "Activated",
"countryCode": "SE",
"placedAt": "2021-04-29T13:26:27.0930646+02:00",
"expiresAt": null,
"customerDetails": {
"type": "Person",
"name": "Petra Ekblom",
"firstName": "Petra",
"lastName": "Ekblom",
"customerId": 8271402,
"registrationNumber": "9501059589",
"countryCode": "SE",
"addressLine1": "Rönnsvängen 6",
"city": "Öxnevalla",
"postalCode": "348 47",
"email": "petra.ekblom@sink.walleydev.com",
"mobilePhoneNumber": "+46731234567",
"homePhoneNumber": "+46731234567"
},
"deliveryAddress": {
"addressLine1": "Rönnsvängen 6",
"addressLine2": null,
"city": "Öxnevalla",
"coAddress": null,
"receiverName": "Petra Ekblom",
"countryCode": "SE",
"email": "petra.ekblom@sink.walleydev.com",
"mobilePhone": "+46731234567",
"phoneNumber": "+46731234567",
"postalCode": "348 47"
},
"invoiceAddress": {
"addressLine1": "Rönnsvängen 6",
"addressLine2": null,
"city": "Öxnevalla",
"coAddress": null,
"receiverName": "Petra Ekblom",
"countryCode": "SE",
"email": "petra.ekblom@sink.walleydev.com",
"mobilePhone": "+46731234567",
"phoneNumber": "+46731234567",
"postalCode": "348 47"
},
"tags": [
"all-all-all",
"all-all-orderdetails",
"all-9664-all",
"all-9664-orderdetails",
"5DFFF2F1-all-all",
"5DFFF2F1-all-orderdetails",
"5DFFF2F1-9664-all",
"5DFFF2F1-9664-orderdetails"
]
}
],
"links": {
"self": {
"method": "GET",
"href": "/orders?page=1&perPage=10",
"query": "page=1&perPage=10"
},
"next": {
"method": "GET",
"href": "/orders?page=2&perPage=10",
"query": "page=2&perPage=10"
}
},
"metaData": {
"totalNumberOfRecords": 32672,
"numberOfPages": 3268,
"currentPage": 1,
"range": {
"from": 1,
"to": 10
}
}
}
Http status code | Description |
---|---|
200 | OK |
401 | Unauthorized, token verification needed. See: Authentication for more information |
403 | Permissions needed e.g. trying to handle content for a store you don't have permission to |
404 | Search not found |
Using search phrases
To perform a search with a search phrase you include a query
parameter in the request querystring. Almost anything on the order can be searched for, including Order Number
, Purchase Identifier
or a Customers data like Reg no
, name
, email
, phone
, address
The following request performs a search with the phrase ABC123
:
/manage/orders?query=ABC123
Using filters
Use filters for a search if you want to filter for a specific property or maybe a period of time like all orders placed between two dates.
To use filters add one or several filter
parameters to the request querystring.
/manage/orders?query=ABC123&filter=status:["activated"]&filter=storeId:["1158"]&filter=placedAt:["2021-03-01","2021-03-04"]
Filter examples
Example | Description |
---|---|
filter=status:["Activated", "NotActivated"] | Return only orders that are in status Activated or NotActivated |
filter=storeId:["1158", "1433"] | Return only orders for stores 1158 and 1433 |
filter=placedAt:["2021-03-01","2021-03-04"] | Return only orders that are placed between 2021-03-01 and 2021-03-04 |
filter=placedAt:["","2021-03-04"] | Return only orders that are placed before 2021-03-04 |
Pagination
You can control how many orders that are returned by setting the perpage
request property and control which page to return by setting the page
property.
The following request will return page 2 of all pages when there are 30 orders per page:
/manage/orders?query=ABC123&page=2&perpage=30
Paging metadata
The metaData
object of the response provides information about the paging and total values.
"metaData": {
"totalNumberOfRecords": 32672,
"numberOfPages": 3268,
"currentPage": 1,
"range": {
"from": 1,
"to": 10
}
Property | Description |
---|---|
totalNumberOfRecords | The total number of records that matched the current criteria |
numberOfPages | The total number of pages available |
currentPage | The currently displayed page |
range | The from and to positions of search results currently returned |
Following links
{
"links": {
"self": {
"method": "GET",
"href": "/orders?page=2&perPage=30",
"query": "page=2&perPage=30"
},
"next": {
"method": "GET",
"href": "/orders?page=3&perPage=30",
"query": "page=3&perPage=30"
},
"prev": {
"method": "GET",
"href": "/orders?page=1&perPage=30",
"query": "page=1&perPage=30"
}
}
}
Sorting
Sorting for a specific property of the response can be acomplished by adding the sort
querystring property.
Valid values are property name followed by -asc
or -desc
for ascending or descending sort.
/manage/orders?query=ABC123&sort=paymentMethod-desc
Sortable fields
Currently sortable fields are
Field | Description |
---|---|
PlacedAt | Timestamp when the order was placed |
ExpiresAt | Timestamp when the order expires if not activated |
OrderNumber | The order number |
StoreId | The merchant store id |
customerDetails.name | The name of the customer |
Status | The status of the order |
PaymentMethod | The payment method of the order |
TotalAmount | The total amount of the order, excl. financial fees |
Data Model
Request
Request headers
Header | Required | Explanation |
---|---|---|
Authorization | Yes | Instructions on how to generate the Bearer token value can be found here |
Response
This is the main structure of the response object:
{
"data": [],
"links": {},
"metaData": {}
}
response.data
object is an array of the following structure:
Example
{
"id": "853f3f82-ab12-47c3-9d97-af17009852cd",
"reference": "MX_220921_111434",
"paymentMethod": "Invoice",
"totalAmount": 2362.36,
"currency": "SEK",
"status": "Activated",
"salesSegment": "B2C",
"countryCode": "SE",
"productCode": "DI_001",
"placedAt": "2022-09-21T11:14:35.7900411+02:00",
"expiresAt": null,
"customer": {
/*...*/
},
"deliveryAddress": {
/*...*/
},
"invoiceAddress": {
/*...*/
},
"items": [
/*...*/
],
"invoices": [
/*...*/
]
}
Property | Explanation |
---|---|
id | The id of the order |
reference | The order number/reference set by merchant at point of purchase |
paymentMethod | The method used by the end customer to perform the Purchase. Invoice , Account , Installment , Card , BankTransfer , Swish , InterestFreeAccount |
totalAmount | The total amount of the order excluding financial fees |
currency | The currency of the order |
status | The status of the entire order. NotActivated , Activated , PartActivated , Returned , Expired , OnHold , Closed |
salesSegment | The type of endcustomer that made the order, B2C , B2B |
countryCode | The country code of the market where the order was placed |
productCode | The product code used for the payment method |
placedAt | Timestamp in UTC of when the order was placed |
expiresAt | Timestamp in UTC of when the order expires if not activated |
customer | Customer specific details. See Customer |
deliveryAddress | Delivery address. See Address |
invoiceAddress | Invoicing address. See Address |
items | All items of the order See Items |
invoices | List of invoices the end customer has been notified. See Invoice |
links
response.links
See following links section
metaData
response.metaData
See paging metadata