Create order¶
POST
*base*/order
This will insert a new order directly into Centra bypassing any needs of a payment. This API could be used to directly import orders from external systems. The API-plugin needs to have “Allow Order Create” set as true
to allow this call to be made.
Warning
Remember that payments for these orders will not be handled at all by Centra. You must make sure the payments are handled and captured elsewhere.
Parameters¶
Here are the parameters allowed to create an order. There are some fields specific for B2B and B2C defined below.
object
optional
|
For B2B the address object is not required as it will then use default address of the B2B-account. If
|
||||||||||||||||||||||||||
int
optional
|
ID of pricelist to use for the order, if not provided, the pricelist for the current country will be used. | ||||||||||||||||||||||||||
string
optional
|
Name of pricelist to use for the order. Will only be used if pricelistId is not provided. If not provided, the pricelist for the current country will be used. |
||||||||||||||||||||||||||
int
optional
|
ID of the market to use for the order. If not provided, the market for the current country will be used. | ||||||||||||||||||||||||||
string
optional
|
Name of the market to use for the order. Will only be used if marketId is not provided. If not provided, the market for the current country will be used. |
||||||||||||||||||||||||||
boolean
optional
b2c
|
Default If |
||||||||||||||||||||||||||
int
optional
b2c
|
If this one is set, the customer ID will be used as the way to attach the order to a customer, independently of the e-mail provided. | ||||||||||||||||||||||||||
boolean
optional
b2c
|
Default false . Will flag the customer so the customer will receive a password reset e-mail when they try to sign in. This can be used when migrating customers over from another system. |
||||||||||||||||||||||||||
object
optional
|
Specifies the origin that the order was created from. If used, it needs to refer to an internal object in Centra.
|
||||||||||||||||||||||||||
int
optional
b2b
|
Account ID for B2B-customer. Required if order is placed for B2B. | ||||||||||||||||||||||||||
int
optional
b2b
|
Buyer ID for B2B-customer. If not provided, the default buyer of the account will be used. | ||||||||||||||||||||||||||
string
optional
b2b
|
Name of the buyer that placed the order. | ||||||||||||||||||||||||||
string
optional
b2b
|
Name of the Delivery Window being used when placing the order. Depending if the products are set to preorder or not, the order might extract stock or not. | ||||||||||||||||||||||||||
object
required
|
Contains the products for the order.
|
||||||||||||||||||||||||||
decimal2 (0.00)
optional
|
Shipping cost, for example: 12.43, without this one, the default shipping cost for the products and country will be used. | ||||||||||||||||||||||||||
decimal2 (0.00)
optional
|
Voucher value, should always be positive value, even though the value ends up reducing the order value. Without this one, the default shipping cost for the products and country will be used. | ||||||||||||||||||||||||||
int
optional
|
Explictly set the order number for the order. Will only work if the order does not already exist in Centra. | ||||||||||||||||||||||||||
boolean
optional
|
Send order confirmation or not, if not provided, the store settings will be used. | ||||||||||||||||||||||||||
boolean
optional
|
Default true . If Centra should calculate the voucher value depending on automatic voucher rules. |
||||||||||||||||||||||||||
boolean
optional
|
Default true . Extract products from stock and fail with error if stock does not exist. If deliveryWindow is set as preorder this setting will not matter. |
||||||||||||||||||||||||||
boolean
optional
|
Default false . Create the order even though products did not exist. These products will be marked as back ordered. |
||||||||||||||||||||||||||
string
optional
|
Text to place inside the “Other Information” field. Might show up on pack-lists and delivery notes depending on store settings. | ||||||||||||||||||||||||||
string
optional
|
Text for the “Internal comment”-field. Will only be shown internally in Centra. | ||||||||||||||||||||||||||
string
optional
b2b
|
PO number used when placing the order. Will be visible on delivery notes and invoices. | ||||||||||||||||||||||||||
date/datetime
optional
|
The time when the order was placed. Timezone is based on the location of the organization’s Centra settings. | ||||||||||||||||||||||||||
date/datetime
optional
|
Expected time of delivery. | ||||||||||||||||||||||||||
date/datetime
optional
|
Date when order should be cancelled if not confirmed. | ||||||||||||||||||||||||||
string
optional
|
Used to define which allocation rule (previously known as “warehouse group”) it should use. Default will use the one set for the market. | ||||||||||||||||||||||||||
boolean
optional
|
Default false . Only prepare the order with all data, can be finalized later using completeOrder. |
||||||||||||||||||||||||||
boolean
optional
|
Default false . Mark the order as internal, will show up in reports as an internal order. |
||||||||||||||||||||||||||
object
optional
|
Will contain information that should be inserted in regards to how the payment was handled outside of Centra.
|
Request example¶
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 | POST <base>/order HTTP/1.1
Content-type: application/json
{
"invoiceAddress": {
"country": "SE",
"firstName": "John",
"lastName": "Smith",
"address": "12 Alto Road",
"coaddress": "c/o Peter",
"zipcode": "90212",
"city": "San Francisco",
"email": "x@example.com"
},
"deliveryAddress": {
"country": "US",
"firstName": "John",
"lastName": "Smith",
"address": "1500 California St",
"coaddress": "c/o Peter",
"zipcode": "90210",
"city": "San Francisco",
"state": "CA"
},
"products": [
{
"qty": 2,
"ean": "ABCDEFGHIJKL",
"unitPrice": 14.11,
"originalPrice": 100.11,
"itemText" : {
"sku": "SPECIAL-SKU-FOR-THIS-ONE",
"product": "A special product",
"variant": ""
}
},
{
"qty": 1,
"sku": "SKUASKUBSKUC",
"unitPrice": 12.11,
"originalPrice": 50.22
}
],
"payment": {
"id": 49,
"auth": {
"status": 1,
"response": "[PSP response]",
"transaction": "[Auth transation ID]",
"method": "cc",
"amount": 100.00
},
"capture": {
"status": 1,
"response": "[PSP response]",
"transaction": "[Capture transation ID]",
"method": "cc",
"amount": 100.00
}
}
}
|
The response will return an array of orders when the call was successful (unless you used createOnly
set as true
). This is because the order might have been split into different orders depending on rules inside Centra.
Response¶
200
Content-type: application/json
string
required
|
ok if success, else no . |
int
optional
|
Will return if createOnly was set as true . |
array of int
optional
|
List of order numbers created. An order might split up in multiple orders after completing it, this is why you might get multiple orders back. |
string
optional
|
If status returns no , this value should send back a message why it failed. |
Response examples¶
1 2 3 4 5 6 7 8 9 | HTTP/1.1 200 OK
Content-type: application/json
{
"status": "ok",
"orders": [
1234
]
}
|
If createOnly
is set to true
, the response looks like this:
1 2 3 4 | {
"status": "ok",
"order": 1234
}
|
Error example¶
1 2 3 4 | {
"status": "no",
"msg": "Message about why the order failed to be created."
}
|