GET /orders
Requires authentication with server access token.
Deprecated since version 2.84
List and search all orders.
Examples
Fetch all orders that changed within the past 7 days:
curl http://identity-pre.schibsted.com/api/2/users?oauth_token=TOKEN&\
since=last week&\
filters=updated
Fetch all orders created between yesterday and today:
curl http://identity-pre.schibsted.com/api/2/users?oauth_token=TOKEN&\
since=yesterday&\
until=today
Fetch 10 orders created today (since midnight):
curl http://identity-pre.schibsted.com/api/2/users?oauth_token=TOKEN&\
since=today&\
limit=10&\
offset=20
Fetch 10 orders created since february 22nd 2013:
curl http://identity-pre.schibsted.com/api/2/users?oauth_token=TOKEN&\
since=2013-02-22&\
limit=10&\
offset=20
See also
Help us improve
Did you spot an error? Or maybe you just have a suggestion for how we can improve? Leave us a comment.
Request
GET /api/2/orders
sort | optional |
---|---|
userId | optionalThe user's |
status | optionalOne or more statuses to filter results by |
ocr | optionalFilter results by OCR/KID number |
orderId | optionalShow this specific order |
clientReference | optionalFilter by custom client reference |
filters | optional
|
The pagination parameters limit, offset, since, and until are also supported.
Example request
cURL
Minimal example
curl https://login.schibsted.com/api/2/orders -G \
-d "oauth_token=[access token]"
With all parameters
curl https://login.schibsted.com/api/2/orders -G \
-d "oauth_token=[access token]" \
-d "sort=userId" \
-d "userId=42" \
-d "status=0" \
-d "ocr=1234567" \
-d "orderId=42" \
-d "clientReference=ref"
Java
Minimal example
SpidOAuthToken token = spidClient.getServerToken();
String responseJSON = spidClient.
GET(token, "/orders").
getResponseBody();
With all parameters
Map<String, String> params = new HashMap<>() {{
put("sort", "userId");,
put("userId", "42");,
put("status", "0");,
put("ocr", "1234567");,
put("orderId", "42");,
put("clientReference", "ref");
}};
SpidOAuthToken token = spidClient.getServerToken();
String responseJSON = spidClient.
GET(token, "/orders", params).
getResponseBody();
This example is an excerpt, see a full example
PHP
Minimal example
<?php
$client->auth();
echo var_dump($client->api("/orders"));
With all parameters
<?php
$params = array(
"sort" => "userId",
"userId" => "42",
"status" => "0",
"ocr" => "1234567",
"orderId" => "42",
"clientReference" => "ref"
);
$client->auth();
echo var_dump($client->api("/orders", $params));
This example is an excerpt, see a full example
Clojure
Minimal example
(ns example
(:require [spid-client-clojure.core :as spid]))
(let [client (spid/create-client "[client-id]" "[secret]")
token (spid/create-server-token client)]
(spid/GET client token "/orders"))
With all parameters
(ns example
(:require [spid-client-clojure.core :as spid]))
(let [client (spid/create-client "[client-id]" "[secret]")
token (spid/create-server-token client)]
(spid/GET client token "/orders" {"sort" "userId"
"userId" "42"
"status" "0"
"ocr" "1234567"
"orderId" "42"
"clientReference" "ref"}))
Response
This endpoint supports the JSON and JSON-P response formats.
Success: 200 OK
Returns a list of order objects
Order
Orders contain one or more order items. Orders with status other than failed
and pending
will have transactions attached to them.
Crediting an order can be done by a full credit or a partial credit. Partial credits must be done by specifying which order item you want to credit. If you specify an amount (optional), the corresponding order item will be partially credited. In a full credit there is no need to specify any other fields than description, which is required in both full and partial credits.
Crediting an order will trigger a user notification, which will inform the user about the order change. This can be optionally turned off by setting the field notifyUser
to false.
Capturing an order can be done by a full or a partial capture. Partial captures must be done by specifying which order item you want to capture. If you specify an amount (optional), the corresponding order item will be partially captured. In a full capture there is no need to specify any other fields.
All captured and credited VAT amounts will match the corresponding VAT percentage set in the order item.
orderId ✓ | integerUnique order ID |
---|---|
clientId ✓ | stringID of the client this order belongs to |
merchantId ✓ | integerMerchant ID |
clientReference ✓ | stringCustom client reference (inherited from Paylinks) |
extOrderRef ✓ | stringExternal order reference |
extTransRef ✓ | stringExternal transaction reference |
identifierId ✓ | integerPayment method identifier ID |
identifierType ✓ | Payment optionsPayment type for the payment method identifier used |
userFlow ✓ | User flowThe user involvement level during creation of this order |
purchaseFlow ✓ | Purchase flowWhat type of purchase flow this order was processed with |
userId ✓ | integerID of the user this order belongs to |
sellerUserId ✓ | integerID of the user who will receive money from this order. Used in P2P. |
paylinkId ✓ | integerID used to create this order |
ocr ✓ | stringOCR/KID number |
type ✓ | Order typeOrder type |
totalPrice ✓ | integerTotal price (including VAT amount) for the complete order |
vat ✓ | integerVAT, fraction × 10000. For instance, 25% would be 2500 |
calculatedVat ✓ | integerTotal amount of VAT for this order |
creditedAmount ✓ | integerAmount of the order credited. Defaults to 0. |
capturedAmount ✓ | integerAmount of the order captured. Defaults to full amount or 0, depending on paymentFlow. |
creditedVatAmount ✓ | integerCredited VAT amount |
capturedVatAmount ✓ | integerCaptured VAT amount |
currency ✓ | stringOrder currency; SEK, NOK, USD |
campaignId ✓ | integerID of the campaign that triggered this order |
voucherId ✓ | integerID of the voucher used for this order |
tag ✓ | stringCan be used for custom order tracking |
status ✓ | Order status |
transactionSynced ✓ | Transaction synced status |
transactionStatus ✓ | integerThird party payment provider transaction status |
errorCode ✓ | stringError Code |
errorDescription ✓ | stringError Description |
errorThirdparty ✓ | stringThird-Party Error Description (e.g. VISA error) |
updated ✓ | datetimeThe time the order was last updated |
created ✓ | datetimeThe time the order was created |
statusChecked ✓ | datetimeThe last time the order status was checked by a client via the /status endpoint |
identifier | Payment identifierPayment method used for this order |
items | list of Order items |
transactions | list of Transactions |
The check mark ✓ indicates that the field always contains a valid non-empty value.
Order item
orderItemId ✓ | integerUnique order item ID |
---|---|
orderId ✓ | integerUnique Order ID |
clientId ✓ | stringClient ID |
clientItemReference ✓ | stringA client provided reference to this order item. (Inherited from Paylink items) |
productId ✓ | integerProduct ID. Defaults to 0 |
discountId ✓ | integerDiscount ID (if available) |
type ✓ | Order item type |
status ✓ | integerOrder item status |
code ✓ | stringProduct code |
name ✓ | stringProduct Name |
description ✓ | stringOrder item description |
description_2 ✓ | stringOrder item description, line 2 |
description_3 ✓ | stringOrder item description, line 3 |
description_4 ✓ | stringOrder item description, line 4 |
price ✓ | priceSingle item price (including VAT amount) |
vat ✓ | integerVAT, fraction × 10000. For instance, 25% would be 2500 |
capturedAmount ✓ | integerThe amount captured on this item |
creditedAmount ✓ | integerThe amount credited on this item |
quantity ✓ | integerThe number of occurrences of this productId/type |
updated ✓ | datetimeWhen the order was last updated |
created ✓ | datetimeWhen the order was created |
The check mark ✓ indicates that the field always contains a valid non-empty value.
Order status
Order status changes happen according to the following state-machine:
See callbacks to learn how to subscribe to these changes.
An enum, with the following possible values:
| Expired |
---|---|
| Cancelled |
| Failed |
| Created |
| Pending |
| Complete |
| Credited |
| Authorized |
Order type
An enum, with the following possible values:
| Purchase |
---|---|
| Renew |
| Transfer |
| Re-purchase |
| Direct |
Payment options
Payment options can be provided as a bit mask.
Bitmask format is the default format. If payment options are not provided, the default value is 2 (bank card with PayEx).
Examples: 2
means credit card, 4
means SMS, while 6
means both credit card and SMS.
An enum, with the following possible values:
| Masterpass |
---|---|
| Credit card |
| SMS |
| PayEx Invoice |
| Voucher |
| Klarna Invoice |
| Klarna Mobile |
| Wallet |
Purchase flow
An enum, with the following possible values:
| Direct purchase flow |
---|---|
| Authorize/Capture purchase flow |
Payment identifier
A payment identifier is a means of payment, e.g. credit card, SMS and others.
identifierId ✓ | integer (as string)Unique payment identifier ID |
---|---|
identifier ✓ | stringThe actual identifier, like a credit card number or cell phone number |
type ✓ | Payment identifier type |
mediaDistribution ✓ | stringInvoice distribution; |
method ✓ | stringPayment method (VISA, MC, SMS) |
description ✓ | string |
expirationDate ✓ | datetimeWhen this payment identifier expires |
userId ✓ | string
|
maxAmount ✓ | stringThe maximum amount that can be charged |
status ✓ | Payment identifier status |
updated ✓ | stringWhen the payment identifier was last updated |
created ✓ | stringWhen the payment identifier was created |
The check mark ✓ indicates that the field always contains a valid non-empty value.
Transaction
transactionId ✓ | integer (as string)Unique ID of the transaction |
---|---|
masterId ✓ | integer (as string)ID of master transaction |
clientId ✓ | string |
userId ✓ | integer (as string)ID of the user the transaction is for |
type ✓ | Transaction type |
reference ✓ | stringThird-party reference |
orderId ✓ | integer (as string) |
amount ✓ | price |
currency ✓ | string |
description ✓ | string |
ip ✓ | stringThe IP address from which the transaction was made |
createdBy ✓ | integer (as string)ID of the user who created the transaction |
created ✓ | datetime |
The check mark ✓ indicates that the field always contains a valid non-empty value.
Failure cases
Some HTTP response codes are used for multiple error situations. There is no consistent way to tell these apart, but the error object will contain a textual explanation of the reason for the error. For explanation on OAuth related failures and errors see OAuth authentication failures.
- 401 Unauthorized You don't have administration rights for this client.
- 401 Unauthorized Your client doesn't have administration rights for this client.
- 403 Forbidden Client is not authorized to access this API endpoint. Contact SPiD to request access.
- 403 Forbidden Requesting IP is not whitelisted
- 403 Forbidden Access token rejected
- 404 Not Found Unknown client ID
- 404 Not Found Client ID mismatch. The client making the request is no the owner of this resource, and does not have administrative privileges for it.
- 404 Not Found No order found
- 420 Request Ratelimit exceeded
Sample response
JSON
{
"4466": {
"sellerUserId": null,
"status": "2",
"clientReference": "Order number 1403529697359",
"vat": "2400",
"errorCode": "OK",
"clientId": "[Your client ID]",
"userId": "102968",
"currency": "NOK",
"paylinkId": "4319",
"transactionSynced": "1",
"calculatedVat": "5748",
"extTransRef": "4337518",
"orderId": "4466",
"totalPrice": "29700",
"capturedAmount": "29700",
"errorDescription": "OK",
"merchantId": "[Your merchant ID]",
"creditedVatAmount": "0",
"identifierType": "2",
"voucherId": null,
"statusChecked": "2014-06-23 15:25:17",
"created": "2014-06-23 15:21:40",
"updated": "2014-06-23 15:25:17",
"type": "0",
"creditedAmount": "0",
"errorThirdparty": null,
"ocr": "47000000000044660",
"campaignId": null,
"capturedVatAmount": "5748",
"purchaseFlow": "1",
"extOrderRef": "EFF7F358E6B64635885C85EFA7C131D6",
"tag": null,
"transactionStatus": null,
"userFlow": "2",
"identifierId": "1934"
}
}
JSON-P
callback({
"4466": {
"sellerUserId": null,
"status": "2",
"clientReference": "Order number 1403529697359",
"vat": "2400",
"errorCode": "OK",
"clientId": "[Your client ID]",
"userId": "102968",
"currency": "NOK",
"paylinkId": "4319",
"transactionSynced": "1",
"calculatedVat": "5748",
"extTransRef": "4337518",
"orderId": "4466",
"totalPrice": "29700",
"capturedAmount": "29700",
"errorDescription": "OK",
"merchantId": "[Your merchant ID]",
"creditedVatAmount": "0",
"identifierType": "2",
"voucherId": null,
"statusChecked": "2014-06-23 15:25:17",
"created": "2014-06-23 15:21:40",
"updated": "2014-06-23 15:25:17",
"type": "0",
"creditedAmount": "0",
"errorThirdparty": null,
"ocr": "47000000000044660",
"campaignId": null,
"capturedVatAmount": "5748",
"purchaseFlow": "1",
"extOrderRef": "EFF7F358E6B64635885C85EFA7C131D6",
"tag": null,
"transactionStatus": null,
"userFlow": "2",
"identifierId": "1934"
}
});
Comments/feedback
Do you have questions, or just want to contribute some newly gained insight? Want to share an example? Please leave a comment. SPiD reads and responds to every question. Additionally, your experience can help others using SPiD, and it can help us continuously improve our documentation.