Difference between revisions of "API Order"
From Spiffy Stores Knowledge Base
Line 672: | Line 672: | ||
==== Example Request and Response ==== | ==== Example Request and Response ==== | ||
+ | |||
+ | <pre> | ||
+ | GET /api/orders/16789.json | ||
+ | |||
+ | HTTP/1.1 200 OK | ||
+ | |||
+ | { | ||
+ | "order": | ||
+ | { | ||
+ | "id": 16789, | ||
+ | "order_number": 23543, | ||
+ | "name": "#023543", | ||
+ | "browser_ip": "127.0.0.1", | ||
+ | "buyer_accepts_marketing": false, | ||
+ | "cart_token": null, | ||
+ | "created_at": "2015-02-27T18:08:33Z", | ||
+ | "updated_at": "2015-02-27T18:08:33Z", | ||
+ | ... | ||
+ | } | ||
+ | } | ||
+ | |||
+ | </pre> |
Revision as of 14:48, 27 February 2015
The Spiffy Stores API Order object represents a request from a customer to purchase one or more products from your store. The process of creating an order during the checkout process collects together sets of information about the customer's requested, including customer details and billing and shipping addresses, a list of the items being purchased, information about the payment, and shipping and fulfilment details.
Contents
Order Properties
id | { "id" : 123456789 } A unique numeric identifier for the order. This ID is only used with the API interface. This ID is not the same as the Order Number, which is also a unique numeric identifier for the order, but is used by the store owner and customer. |
order_number | { "order_number" : 1045 } A unique numeric identifier for the order that is used as a reference number for the store owner and customers. This is not the same as the |
name | { "name" : "#001045" } This is the |
browser_ip | { "browser_ip" : "202.60.66.249" } This is the IP address used by the customer when the order was placed. |
buyer_accepts_marketing | { "buyer_accepts_marketing" : true } If the customer indicates during the checkout process that they are happy to receive marketing and other promotional emails, then their response is recorded here. |
cart_token | { "cart_token" : "65853ecbd10916e70999e7056b01a5e7" } This is a unique token that identifies the cart that is associated with a particular order. |
created_at | { "created_at" : "2007-10-24T18:26:31Z" } The date and time when the order was created. The timestamp is in ISO 8601 format. |
updated_at | { "updated_at" : "2014-01-16T05:50:56Z" } The date and time when the order was last updated. The timestamp is in ISO 8601 format. |
currency | { "currency" : "AUD" } The three letter currency code (ISO 4217) used for the order. |
{ "email" : "customer@any_domain.com" } The customer's email address. | |
credit | { "credit" : "0.0" } An order can have credit applied to it from a customer's account. If this is the case, then the amount of credit that has been applied to the order is returned here. |
taxes_included | { "taxes_included" : true } For certain tax systems such as GST and VAT, the amount of tax is included in the price of an item and in this case, this field will return |
tax_price | { "tax_price" : "3.04" } The total amount of all taxes applied to the order. |
included_tax_price | { "included_tax_price" : "3.04" } The total amount of all taxes applied to the order that are included as part of the item prices. |
tax_label | { "tax_label" : "GST" } The description of the tax item applied to the entire order. |
discount_price | { "discount_price" : "0.0" } The total amount of all discounts that have been applied to the order via coupon codes. Note that this does not include the amount of any discount that has been calculated as a result of a shopping cart discount. This amount is available through |
cart_discount_price | { "cart_discount_price" : "3.8" } The total amount of all discounts that have been applied to the order via shopping cart discounts. |
shipping_price | { "shipping_price" : "17.2" } The total amount of shipping costs for the order. |
shipping_lines | { "shipping_lines" : [ An array of
|
subtotal_price | { "subtotal_price" : "16.19" } The total amount of the order less coupon code discounts, but before shipping and additional taxes. |
total_line_items_price | { "total_line_items_price" : "16.19" } The total amount of the order, before shipping and additional taxes and before any coupon code discounts have been applied. |
total_price | { "total_price" : "33.39" } The total amount of all items in the order, including shipping, taxes and discounts. |
test | { "test" : false } Return true if this is a test order. |
gateway | { "gateway" : "Bank Deposit" } The name of the payment gateway that was used to process the payment for this order. |
note | { "note" : "This order has top priority." } The text of an optional note that can be attach to the order by the store owner. |
total_weight | { "total_weight" : 200.0 } The total weight of all items in the order, expressed in grams. |
financial_status | { "financial_status" : "paid" } Returns the current financial status of the order. The following statuses are used:
|
fulfilment_status | { "fulfilment_status" : null } Returns the current fulfilment status of the order. The following statuses are used:
|
tax_lines | { "tax_lines" : [ An array of
|
cancel_reason | { "cancel_reason" : "Fraudulent order" } If an order has been cancelled, the reason for the cancellation is returned. The following reasons may be returned:
|
cancelled_at | { "cancelled_at" : "2015-02-23T03:02:51Z" } The date and time when the order was cancelled. The timestamp is in ISO 8601 format. |
closed_at | { "closed_at" : "2015-02-23T03:02:51Z" } The date and time when the order was closed. The timestamp is in ISO 8601 format. |
discount_codes | { "discount_codes" : [ An array of
The following discount types are supported:
|
billing_address | { "billing_address" : { Returns the billing address associated with the order. The address has the following properties:
|
shipping_address | { "shipping_address" : { Returns the shipping address associated with the order. The address has the following properties:
|
customer | { "customer" : { Returns an object containing information about the customer. This information is only available if the customer has registered for an account, so this information will not be available for guest checkout orders. Customer objects contain the following fields:
|
line_items | { "line_items" : [ An array of
Items that are marked as gift cards are not taxed or included in any shipping charge calculations. |
fulfilments | { "fulfilments" : [ An array of
|
transactions | { "transactions" : [ An array of
|
Endpoints
GET /api/orders.json
Return a list of open orders. Use the optional status
to return other orders.
Optional Parameters
limit | Number of results returned. The default is 30, with a maximum of 50 in a single request. |
page | The number of the page to return. The number of results per page is set by the limit parameter. If more results are required, then submit the request again, increasing the page number each time.
|
ids | A comma-separated list of order ids. |
since_id | Limit the results to only include objects which have an id greater than the given value. |
created_at_min | Return only the orders created after the given date and time. Use the format "2014-12-31 12:00". |
created_at_max | Return only the orders created before the given date and time. Use the format "2014-12-31 12:00". |
updated_at_min | Return only the orders updated after the given date and time. Use the format "2014-12-31 12:00". |
updated_at_max | Return only the orders updated before the given date and time. Use the format "2014-12-31 12:00". |
paid_at_min | Return only the orders paid after the given date and time. Use the format "2014-12-31 12:00". |
paid_at_max | Return only the orders paid before the given date and time. Use the format "2014-12-31 12:00". |
closed_at_min | Return only the orders closed after the given date and time. Use the format "2014-12-31 12:00". |
closed_at_max | Return only the orders closed before the given date and time. Use the format "2014-12-31 12:00". |
status | Return only orders with the given status.
|
financial_status | Return only orders with the given financial status.
|
fulfilment_status | Return only orders with the given fulfilment status.
|
customer_id | Return all the orders belonging to the specified customer. |
Return all orders that have been placed with the specified email address. | |
fields | A comma-separated list of fields to return in the response. |
Example Request and Response
GET /api/orders.json HTTP/1.1 200 OK { "orders": [ { "id": 378, "order_number": 1169, "name": "#01169", "browser_ip": "127.0.0.1", "buyer_accepts_marketing": false, "cart_token": null, "created_at": "2015-02-27T18:08:33Z", "updated_at": "2015-02-27T18:08:33Z", "currency": "AUD", "email": "customer@customer.domain.com", "credit": "0.0", "taxes_included": true, "tax_price": "0.91", "included_tax_price": "0.91", "tax_label": "GST", "discount_price": "0.0", "cart_discount_price": "0.0", "shipping_price": "0.0", "subtotal_price": "10.0", "total_line_items_price": "10.0", "total_price": "10.0", "test": false, "gateway": "Friendly Bank", "note": "Very important customer", "total_weight": 100.0, "financial_status": "authorized", "fulfilment_status": null, "billing_address": { "id": 687, "title": "Mr", "first_name": "Important", "last_name": "Customer", "name":"Mr Important Customer", "company": "", "address1": "1 Main St", "address2": "", "city": "Sydney", "province": "New South Wales", "province_code": "NSW", "country": "Australia", "country_code": "AU", "zip": "1234", "phone": "0291234567" }, "shipping_address": { "id": 688, "title": "Mr", "first_name": "Important", "last_name": "Customer", "name": "Mr Important Customer", "company": "", "address1": "1 Main St", "address2": "", "city": "Sydney", "province": "New South Wales", "province_code": "NSW", "country": "Australia", "country_code": "AU", "zip": "1234", "phone": "0291234567" }, "customer": { "id": 6, "title": "Mr", "first_name": "Important", "last_name": "Customer", "name": "Mr Important Customer", "email": "customer@customer.domain.com", "accepts_marketing": true, "created_at": "2010-06-15T13:15:50Z", "note": "Here is some sample text.", "orders_count": 512, "state": "enabled", "total_spent": "11230.63", "updated_at": "2015-02-23T03:02:51Z", "sign_in_count": 261, "current_sign_in_at": "2015-02-23T03:02:51Z", "current_sign_in_ip": "192.168.10.164", "last_sign_in_at": "2015-02-19T05:58:54Z", "last_sign_in_ip": "192.168.10.164", "wholesale": true, "credit": "0.0", "tags":"friend,wholesaler" }, "fulfilments": [], "line_items": [ { "id": 410, "product_id": 1506, "variation_id": 1691, "product_exists": true, "quantity": 1, "sku": "SHIRT002", "name": "T-Shirt - S - Teal-Blue", "title": "T-Shirt", "variation_title": "S/Teal-Blue", "discount_description": "", "vendor": "Spiffy Stores", "weight": 0.1, "grams": 100.0, "length": 0.0, "width": 0.0, "height": 0.0, "price": "10.0", "wholesale_price": "0.0", "taxable": true, "discount_price": "0.0", "total_price": "10.0", "ship_separately": false, "free_shipping": false, "requires_shipping": true, "fulfilment_service": "manual", "fulfillable_quantity": 1, "shipping_method": "", "instalments": 1, "gift_card": false, "fulfilment_status": null } ], "transactions": [ { "id": 253, "order_id": 378, "amount": "10.0", "authorization": "1156177", "created_at": "2009-02-27T18:08:34Z", "gateway": "Friendly Bank", "kind": "Authorization", "status": "Success", "transaction_id": "", "description": "TRANSACTION APPROVED" } ], "tax_lines": [ { "title": "Including GST", "rate": "0.1", "price": "0.91" } ], "shipping_lines": [], "discount_codes": [] }, ... ] } Examples using filters GET /api/orders.json?status=closed GET /api/orders.json?customer_id=2322
GET /api/orders/count.json
Return a count of open orders. Use the optional status
to return the count of other orders.
Optional Parameters
since_id | Limit the results to only include objects which have an id greater than the given value. |
created_at_min | Return only the orders created after the given date and time. Use the format "2014-12-31 12:00". |
created_at_max | Return only the orders created before the given date and time. Use the format "2014-12-31 12:00". |
updated_at_min | Return only the orders updated after the given date and time. Use the format "2014-12-31 12:00". |
updated_at_max | Return only the orders updated before the given date and time. Use the format "2014-12-31 12:00". |
paid_at_min | Return only the orders paid after the given date and time. Use the format "2014-12-31 12:00". |
paid_at_max | Return only the orders paid before the given date and time. Use the format "2014-12-31 12:00". |
closed_at_min | Return only the orders closed after the given date and time. Use the format "2014-12-31 12:00". |
closed_at_max | Return only the orders closed before the given date and time. Use the format "2014-12-31 12:00". |
status | Return only orders with the given status.
|
financial_status | Return only orders with the given financial status.
|
fulfilment_status | Return only orders with the given fulfilment status.
|
customer_id | Return all the orders belonging to the specified customer. |
Return all orders that have been placed with the specified email address. |
Example Request and Response
GET /api/orders/count.json HTTP/1.1 200 OK { "count": 123 } Examples using filters GET /api/orders/count.json?status=closed
GET /api/orders/ORDER_ID.json
Return a single order.
Optional Parameters
fields | A comma-separated list of fields to return in the response. |
Example Request and Response
GET /api/orders/16789.json HTTP/1.1 200 OK { "order": { "id": 16789, "order_number": 23543, "name": "#023543", "browser_ip": "127.0.0.1", "buyer_accepts_marketing": false, "cart_token": null, "created_at": "2015-02-27T18:08:33Z", "updated_at": "2015-02-27T18:08:33Z", ... } }