Additional E-Commerce Scenarios

In addition to the workflow described in E-Commerce with external checkout via web services, EthosCE is able to expose order data to a third party system for reporting or review, including related order coupons.

Accessing Orders

Orders placed by a specific user may be accessed via web services. The following call queries EthoCE for all orders by User 10. In this example, User 10 has purchased a course with the node ID of 50, via check. This information was stored and processed in order 200.

GET Request Order Coupons
<?php // Send the query request via GET $curl = curl_init("http://your-domain.com/uc_order.xml?uid=10"); curl_setopt($curl, CURLOPT_CUSTOMREQUEST, 'GET'); curl_setopt($curl, CURLOPT_HTTPHEADER, array("Content-Type: application/json")); curl_setopt($curl, CURLOPT_HTTPAUTH, CURLAUTH_BASIC); curl_setopt($curl, CURLOPT_USERPWD, "restws_webservice:webservice_password"); //Your credentials goes here curl_setopt($curl, CURLOPT_RETURNTRANSFER, TRUE); $json = curl_exec($curl); $response = json_decode($json);

Successful Return

A successful return will provide an array of information related to the order, including the Order ID, purchasing user (Customer), Delivery and Billing addresses, order status, and payment methods.

Successful Return
{ "self": "http://your-domain.com/uc_order?uid=10", "first": "http://your-domain.com/uc_order?uid=10&page=0", "last": "http://your-domain.com/uc_order?uid=10&page=0", "list": [ { "order_id": "200", "uid": "10", "customer": { "uri": "http://your-domain.com/user/10", "id": "10", "resource": "user", "uuid": "ca431175-32cc-403e-bff8-907cad62c0d7" }, "delivery_address": { "first_name": "John", "last_name": "Doe", "company": "EthosCE", "street1": "1520 Locust St.", "street2": "1000", "city": "Phila", "zone": "0", "postal_code": "19102", "country": "840", "phone": "2155551234", "email": "jdoe@example.com" }, "billing_address": { "first_name": "John", "last_name": "Doe", "company": "EthosCE", "street1": "1520 Locust St.", "street2": "1000", "city": "Phila", "zone": "0", "postal_code": "19102", "country": "840", "phone": "2155551234", "email": "jdoe@example.com" }, "order_status": "pending", "order_total": 100, "primary_email": "admin@example.com", "payment_method": "check", "created": "1471442556", "modified": "1477582286", "host": "127.0.0.1", "products": [ { "uri": "http://your-domain.com/uc_order_product/50", "id": 50, "resource": "uc_order_product" } ], "payment_balance": 100, } ] }

Accessing Order Coupons

Coupons a user has applied to their order are available for review via the web service. Due to the underlying structure, the coupon information is not included in the uc_order endpoint call. It may only be accessed by requesting the information in a separate call, by order id. The following example will request all coupons attached to order id 200, which was returned above.

GET Request Order Coupons
<?php // Send the query request via GET $curl = curl_init("http://your-domain.com/uc_coupons_orders?oid=200"); curl_setopt($curl, CURLOPT_CUSTOMREQUEST, 'GET'); curl_setopt($curl, CURLOPT_HTTPHEADER, array("Content-Type: application/json")); curl_setopt($curl, CURLOPT_HTTPAUTH, CURLAUTH_BASIC); curl_setopt($curl, CURLOPT_USERPWD, "restws_webservice:webservice_password"); //Your credentials goes here curl_setopt($curl, CURLOPT_RETURNTRANSFER, TRUE); $json = curl_exec($curl); $response = json_decode($json);

Successful Return

A successful return will provide information about the coupon applied to the order.

Successful Return

The following information is available in the return.

Return Attributes

cuid:    The unique internal database ID

cid:    The internal Coupon ID

oid:     The Order ID

value:   The amount subtracted from the order total

code:   The coupon code entered