Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

Version 1 Next »

In addition to the workflow described in E-Commerce 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
// Login to the site and request the access token
$curl = curl_init('http://your-domain.com/restws/session/token');
curl_setopt($curl, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
curl_setopt($curl, CURLOPT_USERPWD, "restws_webservice:webservice_password"); // Your web service user credentials goes here.
curl_setopt($curl, CURLOPT_RETURNTRANSFER, TRUE);
$token = curl_exec($curl);
// The token looks like "q71OBx05wtECfjA0KmXf6wiktewrywNhkMZv-OcfyOA%"

// 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("X-CSRF-Token: $token", "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
// Login to the site and request the access token
$curl = curl_init('http://your-domain.com/restws/session/token');
curl_setopt($curl, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
curl_setopt($curl, CURLOPT_USERPWD, "restws_webservice:webservice_password"); // Your web service user credentials goes here.
curl_setopt($curl, CURLOPT_RETURNTRANSFER, TRUE);
$token = curl_exec($curl);
// The token looks like "q71OBx05wtECfjA0KmXf6wiktewrywNhkMZv-OcfyOA%"

// 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("X-CSRF-Token: $token", "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
{
  "self": "http://your-domain.com/uc_coupons_orders?oid=200",
  "first": "http://your-domain.com/uc_coupons_orders?oid=200&page=0",
  "last": "http://your-domain.com/uc_coupons_orders?oid=200&page=0",
  "list": [
    {
      "cuid": "1",
      "cid": "2",
      "oid": "200",
      "value": "10.00",
      "code": "FREE4U",
    }
  ]
}

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

  • No labels