GetOrderByID

SmithCart > Integration > REST Endpoints
Usage
Retrieve an order by its ID
Basic URI
/orders/{oid}.json
Parameters
int oid              The order ID
HTTP Example
https://domain.com/DesktopModules/Smith.BuyNow/Services/v1/Checkout.svc/orders/15.json
AUTH
Bearer JWT
 
C# Code
 
JavaScript Code
<script>
   (function ($) {
       var CLIENT_ID = "4SnPA6lqpY76ODEr",
           SERVICE_URI = "https://domain.com/DesktopModules/Smith.BuyNow/Services/v1/",
           ORDER_ID = "15";

       function getOrder (endPoint, clientID, oID) {
           var jwt = sessionStorage.getItem("jwt");
           if (!jwt) {
               var uri = endPoint + "Authorize.ashx?"
                   + "response_type=token"
                   + "&client_id=" + clientID
                   + "&redirect_uri=" + encodeURIComponent(window.location)
                   + "&scope=" + encodeURIComponent("orders create edit delete");
               window.location = uri;
               return;
           }

           $.ajax({
               type: "GET",
               url: endPoint + "/Checkout.svc/orders/" + oID + ".json",
               headers: { "Authorization": "Bearer " + jwt },
               contentType: "application/json; charset=utf-8",
               dataType: "json"
           }).fail(function (jqXHR, textStatus) {
               console.log("SmithCart API: " + textStatus);
           });
       }

       $(function () {
           var params = {},
               queryString = location.hash.substring(1),
               regex = /([^&=]+)=([^&]*)/g,
               m;

           while (m = regex.exec(queryString)) {
               params[decodeURIComponent(m[1])] = decodeURIComponent(m[2]);
           }
           if (params["access_token"]) {
               sessionStorage.setItem("jwt", params["access_token"]);
           }

           getOrder (SERVICE_URI, CLIENT_ID, ORDER_ID);
       });
   })(jQuery);
</script>
 
 
 
Response
{
    "id": 7,
    "customer_id": 1,
    "address_id": null,
    "username": null,
    "title": "",
    "summary": null,
    "order_date": "\/Date(1422050753657-0800)\/",
    "order_number": "",
    "total": 106.95,
    "subtotal": 62.00,
    "tax_total": 8.15,
    "fee_total": 0.00,
    "shipping_total": 36.80,
    "discount_total": 0.00,
    "ip_address": "127.0.0.1",
    "status": "Open",
    "sort_order": null,
    "created_date": null,
    "created_by": null,
    "modified_date": null,
    "modified_by": null,
    "portal_id": null,
    "ship_firstname": "Test",
    "ship_lastname": "User",
    "ship_address1": "123 Some St",
    "ship_address2": "Apt 10",
    "ship_city": "My City",
    "ship_state": "CA",
    "ship_zipcode": "12345",
    "ship_country": "US",
    "balance": 56.95
}