GetUserOrder

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

       function getUserOrder (endPoint, clientID, userName, 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/users/" + userName
                    + "/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"]);
           }

           getUserOrder (SERVICE_URI, CLIENT_ID, USER_NAME, ORDER_ID);
       });
   })(jQuery);
</script>
 
 
 
Response
[
    "id": 2,
    "customer_id": 13,
    "address_id": null,
    "username": "testuser1",
    "title": "",
    "summary": null,
    "order_date": "\/Date(1422050323157-0800)\/",
    "order_number": "151",
    "total": 79.90,
    "subtotal": 51.00,
    "tax_total": 6.15,
    "fee_total": 0.00,
    "shipping_total": 22.75,
    "discount_total": 0.00,
    "ip_address": "127.0.0.1",
    "status": "Shipped",
    "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": 0.00
]