Demoing the Stop Condition
Demoing the Stop Condition
We will try purchasing an item. Notice that we will make a request to an order form that contains a need info link.
- Using a REST client, log into the demo store by following the instructions here: http://api-cortex-developers.docs.elasticpath.com/drupal/content/Authenticate_a_customer using Username: oliver.harris@elasticpath.com and password: password.
- Enter the following fields in your REST client to GET the item:
You should get back the following response:
{ "self": { "type": "application/vnd.elasticpath.item", "uri": "/commerce-legacy/items/mobee/gnsdezrymuzdgnzvmjrginbvgbtdkzrugq2tmmbugm4dmztdgiydmzrymjqwmytf", "href": "https://localhost:8443/cortex/items/mobee/gnsdezrymuzdgnzvmjrginbvgbtdkzrugq2tmmbugm4dmztdgiydmzrymjqwmytf", "max-age": 600 }, "links": [ { "type": "application/vnd.elasticpath.cart.lineitem", "rel": "addtocartform", "href": "https://localhost:8443/cortex/carts/items/mobee/gnsdezrymuzdgnzvmjrginbvgbtdkzrugq2tmmbugm4dmztdgiydmzrymjqwmytf/form", "uri": "/commerce-legacy/carts/items/mobee/gnsdezrymuzdgnzvmjrginbvgbtdkzrugq2tmmbugm4dmztdgiydmzrymjqwmytf/form" }, { "type": "application/vnd.elasticpath.itemdefinition", "rel": "definition", "rev": "item", "href": "https://localhost:8443/cortex/itemdefinitions/mobee/gnsdezrymuzdgnzvmjrginbvgbtdkzrugq2tmmbugm4dmztdgiydmzrymjqwmytf", "uri": "/commerce-legacy/itemdefinitions/mobee/gnsdezrymuzdgnzvmjrginbvgbtdkzrugq2tmmbugm4dmztdgiydmzrymjqwmytf" }, { "type": "application/vnd.elasticpath.price", "rel": "price", "rev": "item", "href": "https://localhost:8443/cortex/prices/items/mobee/gnsdezrymuzdgnzvmjrginbvgbtdkzrugq2tmmbugm4dmztdgiydmzrymjqwmytf", "uri": "/commerce-legacy/prices/items/mobee/gnsdezrymuzdgnzvmjrginbvgbtdkzrugq2tmmbugm4dmztdgiydmzrymjqwmytf" }, { "type": "application/vnd.elasticpath.availability", "rel": "availability", "rev": "item", "href": "https://localhost:8443/cortex/availabilities/items/mobee/gnsdezrymuzdgnzvmjrginbvgbtdkzrugq2tmmbugm4dmztdgiydmzrymjqwmytf", "uri": "/commerce-legacy/availabilities/items/mobee/gnsdezrymuzdgnzvmjrginbvgbtdkzrugq2tmmbugm4dmztdgiydmzrymjqwmytf" } ] }
- Make a GET request to the "addtocartform". It should return the following:
{ "self": { "type": "application/vnd.elasticpath.cart.lineitem", "uri": "/commerce-legacy/carts/items/mobee/gnsdezrymuzdgnzvmjrginbvgbtdkzrugq2tmmbugm4dmztdgiydmzrymjqwmytf/form", "href": "https://localhost:8443/cortex/carts/items/mobee/gnsdezrymuzdgnzvmjrginbvgbtdkzrugq2tmmbugm4dmztdgiydmzrymjqwmytf/form", "max-age": 0 }, "links": [ { "rel": "addtodefaultcartaction", "href": "https://localhost:8443/cortex/carts/mobee/default/lineitems/items/mobee/gnsdezrymuzdgnzvmjrginbvgbtdkzrugq2tmmbugm4dmztdgiydmzrymjqwmytf", "uri": "/commerce-legacy/carts/mobee/default/lineitems/items/mobee/gnsdezrymuzdgnzvmjrginbvgbtdkzrugq2tmmbugm4dmztdgiydmzrymjqwmytf" } ], "quantity": 0 }
- Make the following request to "addtodefaultcartaction" to add one "Casablanca" to the cart.
- Make a call to the shopping cart with the following request:
The response you get back should look similar to the following:
Table 3. HTTP Request Parameters HTTP Request Method GET URL https://localhost:8443/cortex/carts/mobee/default Header Content-type: Application/json { "self": { "type": "application/vnd.elasticpath.cart", "uri": "/commerce-legacy/carts/mobee/gqytemrsiu4tslkgifbueljuge2ueljvgizdkljvimyeirkfgjddmmzwgy", "href": "https://localhost:8443/cortex/carts/mobee/gqytemrsiu4tslkgifbueljuge2ueljvgizdkljvimyeirkfgjddmmzwgy", "max-age": 0 }, "total-quantity": 1 "links": [ { "type": "application/vnd.elasticpath.links", "rel": "lineitems", "rev": "cart", "href": "https://localhost:8443/cortex/carts/mobee/gqytemrsiu4tslkgifbueljuge2ueljvgizdkljvimyeirkfgjddmmzwgy/lineitems", "uri": "/commerce-legacy/carts/mobee/gqytemrsiu4tslkgifbueljuge2ueljvgizdkljvimyeirkfgjddmmzwgy/lineitems" }, { "type": "application/vnd.elasticpath.order", "rel": "order", "rev": "cart", "href": "https://localhost:8443/cortex/orders/mobee/gy4tkojvgbctoljygyzdqljuhbcdmlkeiy4dgljsgq3dsmsfgm2tkmzrgm", "uri": "/commerce-legacy/orders/mobee/gy4tkojvgbctoljygyzdqljuhbcdmlkeiy4dgljsgq3dsmsfgm2tkmzrgm" }, { "type": "application/vnd.elasticpath.total", "rel": "total", "rev": "cart", "href": "https://localhost:8443/cortex/totals/carts/mobee/gqytemrsiu4tslkgifbueljuge2ueljvgizdkljvimyeirkfgjddmmzwgy", "uri": "/commerce-legacy/totals/carts/mobee/gqytemrsiu4tslkgifbueljuge2ueljvgizdkljvimyeirkfgjddmmzwgy" } ] }
- Make a GET request to the order resource.
The response you get back should look similar to the following:
{ "self": { "type": "application/vnd.elasticpath.order", "uri": "/commerce-legacy/orders/mobee/gy4tkojvgbctoljygyzdqljuhbcdmlkeiy4dgljsgq3dsmsfgm2tkmzrgm", "href": "https://localhost:8443/cortex/orders/mobee/gy4tkojvgbctoljygyzdqljuhbcdmlkeiy4dgljsgq3dsmsfgm2tkmzrgm", "max-age": 0 }, "links": [ { "type": "application/vnd.elasticpath.cart", "rel": "cart", "rev": "order", "href": "https://localhost:8443/cortex/carts/mobee/gqytemrsiu4tslkgifbueljuge2ueljvgizdkljvimyeirkfgjddmmzwgy", "uri": "/commerce-legacy/carts/mobee/gqytemrsiu4tslkgifbueljuge2ueljvgizdkljvimyeirkfgjddmmzwgy" }, { "type": "application/vnd.elasticpath.links", "rel": "deliveries", "rev": "order", "href": "https://localhost:8443/cortex/orders/mobee/gy4tkojvgbctoljygyzdqljuhbcdmlkeiy4dgljsgq3dsmsfgm2tkmzrgm/deliveries", "uri": "/commerce-legacy/orders/mobee/gy4tkojvgbctoljygyzdqljuhbcdmlkeiy4dgljsgq3dsmsfgm2tkmzrgm/deliveries" }, { "type": "application/vnd.elasticpath.info", "rel": "billingaddressinfo", "rev": "order", "href": "https://localhost:8443/cortex/orders/mobee/gy4tkojvgbctoljygyzdqljuhbcdmlkeiy4dgljsgq3dsmsfgm2tkmzrgm/billingaddressinfo", "uri": "/commerce-legacy/orders/mobee/gy4tkojvgbctoljygyzdqljuhbcdmlkeiy4dgljsgq3dsmsfgm2tkmzrgm/billingaddressinfo" }, { "type": "application/vnd.mycompany.termsandconditions", "rel": "termsandconditions", "href": "https://localhost:8443/cortex/termsandconditions/orders/mobee/gy4tkojvgbctoljygyzdqljuhbcdmlkeiy4dgljsgq3dsmsfgm2tkmzrgm/form", "uri": "/commerce-legacy/termsandconditions/orders/mobee/gy4tkojvgbctoljygyzdqljuhbcdmlkeiy4dgljsgq3dsmsfgm2tkmzrgm/form" }, { "type": "application/vnd.elasticpath.info", "rel": "paymentmethodinfo", "rev": "order", "href": "https://localhost:8443/cortex/paymentmethods/orders/mobee/gy4tkojvgbctoljygyzdqljuhbcdmlkeiy4dgljsgq3dsmsfgm2tkmzrgm", "uri": "/commerce-legacy/paymentmethods/orders/mobee/gy4tkojvgbctoljygyzdqljuhbcdmlkeiy4dgljsgq3dsmsfgm2tkmzrgm" }, { "type": "application/vnd.elasticpath.purchase", "rel": "purchaseform", "href": "https://localhost:8443/cortex/purchases/orders/mobee/gy4tkojvgbctoljygyzdqljuhbcdmlkeiy4dgljsgq3dsmsfgm2tkmzrgm/form", "uri": "/commerce-legacy/purchases/orders/mobee/gy4tkojvgbctoljygyzdqljuhbcdmlkeiy4dgljsgq3dsmsfgm2tkmzrgm/form" }, { "type": "application/vnd.elasticpath.tax", "rel": "tax", "rev": "order", "href": "https://localhost:8443/cortex/taxes/orders/mobee/gy4tkojvgbctoljygyzdqljuhbcdmlkeiy4dgljsgq3dsmsfgm2tkmzrgm", "uri": "/commerce-legacy/taxes/orders/mobee/gy4tkojvgbctoljygyzdqljuhbcdmlkeiy4dgljsgq3dsmsfgm2tkmzrgm" }, { "type": "application/vnd.elasticpath.total", "rel": "total", "rev": "order", "href": "https://localhost:8443/cortex/totals/orders/mobee/gy4tkojvgbctoljygyzdqljuhbcdmlkeiy4dgljsgq3dsmsfgm2tkmzrgm", "uri": "/commerce-legacy/totals/orders/mobee/gy4tkojvgbctoljygyzdqljuhbcdmlkeiy4dgljsgq3dsmsfgm2tkmzrgm" }, { "type": "application/vnd.mycompany.termsandconditions", "rel": "needinfo", "href": "https://localhost:8443/cortex/termsandconditions/orders/mobee/gy4tkojvgbctoljygyzdqljuhbcdmlkeiy4dgljsgq3dsmsfgm2tkmzrgm/form", "uri": "/commerce-legacy/termsandconditions/orders/mobee/gy4tkojvgbctoljygyzdqljuhbcdmlkeiy4dgljsgq3dsmsfgm2tkmzrgm/form" } ] }
- Make a GET request to "purchaseform" to go to the purchase form.
It should return a "needinfo" link, shown below, as we have yet to agree to the order's terms and conditions.
{ "self": { "type": "application/vnd.elasticpath.purchase","href": "https://localhost:8443/cortex/purchases/orders/mobee/iqydirbzgu3eiljzgvcdmljxiu4diljwgezdoljtguzdcmztinbeencfha/form","uri": "/commerce-legacy/purchases/orders/mobee/iqydirbzgu3eiljzgvcdmljxiu4diljwgezdoljtguzdcmztinbeencfha/form", "max-age": 0 }, { "type": "application/vnd.mycompany.termsandconditions","rel": "needinfo","href": "https://localhost:8443/cortex/termsandconditions/orders/mobee/gy4tkojvgbctoljygyzdqljuhbcdmlkeiy4dgljsgq3dsmsfgm2tkmzrgm/form","uri": "/commerce-legacy/termsandconditions/orders/mobee/gy4tkojvgbctoljygyzdqljuhbcdmlkeiy4dgljsgq3dsmsfgm2tkmzrgm/form" } ], }
- Make a GET request to "termsandconditions". This will navigate you to the terms and conditions form.
{ "self": { "type": "application/vnd.mycompany.termsandconditions", "uri": "/commerce-legacy/termsandconditions/orders/mobee/gy4tkojvgbctoljygyzdqljuhbcdmlkeiy4dgljsgq3dsmsfgm2tkmzrgm", "href": "https://localhost:8443/cortex/termsandconditions/orders/mobee/gy4tkojvgbctoljygyzdqljuhbcdmlkeiy4dgljsgq3dsmsfgm2tkmzrgm", "max-age": 0 }, "message": "NEW WORLD ORDER. To approve order: gy4tkojvgbctoljygyzdqljuhbcdmlkeiy4dgljsgq3dsmsfgm2tkmzrgm please sign your life away" "links": [ { "type": "application/vnd.mycompany.termsandconditions", "rel": "agree", "href": "https://localhost:8443/cortex/termsandconditions/orders/mobee/gy4tkojvgbctoljygyzdqljuhbcdmlkeiy4dgljsgq3dsmsfgm2tkmzrgm", "uri": "/commerce-legacy/termsandconditions/orders/mobee/gy4tkojvgbctoljygyzdqljuhbcdmlkeiy4dgljsgq3dsmsfgm2tkmzrgm" } ] }
- Make a POST request to "agree" to the terms and conditons. It will return a link to the orders resource.
- Make a GET request to the orders resource to go back.
- Make a GET request to the "purchaseform". This time, the "needinfo" link for the termsandconditions should not appear as we have already agreed to the terms and conditions.
The purchase form should now look like the following:
{ "self": { "type": "application/vnd.elasticpath.purchase","href": "https://localhost:8443/cortex/purchases/orders/mobee/iqydirbzgu3eiljzgvcdmljxiu4diljwgezdoljtguzdcmztinbeencfha/form","uri": "/commerce-legacy/purchases/orders/mobee/iqydirbzgu3eiljzgvcdmljxiu4diljwgezdoljtguzdcmztinbeencfha/form", "max-age": 0 }, "links": [ { "rel": "submitorderaction","href": "https://localhost:8443/cortex/purchases/orders/mobee/iqydirbzgu3eiljzgvcdmljxiu4diljwgezdoljtguzdcmztinbeencfha","uri": "/commerce-legacy/purchases/orders/mobee/iqydirbzgu3eiljzgvcdmljxiu4diljwgezdoljtguzdcmztinbeencfha" } ] }
- Make a POST request to "submitorderaction" to complete the purchase. It will return a link to the purchases resource.
- Make a GET request to the purchases resource to view the purchase's receipt.
{ "self": { "type": "application/vnd.elasticpath.purchase", "uri": "/commerce-legacy/purchases/mobee/giydambu=", "href": "https://localhost:8443/cortex/purchases/mobee/giydambu=", "max-age": 600 }, "links": [ { "type": "application/vnd.elasticpath.links", "rel": "list", "href": "https://localhost:8443/cortex/purchases/mobee", "uri": "/commerce-legacy/purchases/mobee" }, { "type": "application/vnd.elasticpath.links", "rel": "lineitems", "rev": "purchase", "href": "https://localhost:8443/cortex/purchases/mobee/giydambu=/lineitems", "uri": "/commerce-legacy/purchases/mobee/giydambu=/lineitems" }, { "type": "application/vnd.elasticpath.links", "rel": "paymentmeans", "rev": "purchase", "href": "https://localhost:8443/cortex/purchases/mobee/giydambu=/paymentmeans", "uri": "/commerce-legacy/purchases/mobee/giydambu=/paymentmeans" } ], "monetary-total": [ { "amount": 0, "currency": "CAD", "display": "$0.00" } ], "purchase-date": { "display-value": "December 11, 2012 5:03:37 PM", "value": 1355274217000 }, "purchase-number": "20004", "status": "COMPLETED", "tax-total": { "amount": 0, "currency": "CAD", "display": "$0.00" } }