custom integration for php based software

The integration of RatingChamp is possible in almost every software. In this example, we will explain a basics was how to do it.

It is imperative that you sent the orders that your store received to our software interface. This must be done automatically, ideally at the time at which the order is changed to a status "shipped".

This can be realized by implementing following php function in your software and call it with the appropriate parameters:

    function notifiy_ratingchamp($firstname,$lastname,$g='m',$mail,$order_id,$lang,$date){

        $order_data = array();

        // order No.
        $order_data['merchant_orders_id']= $order_id;

        // Customers firstname
        $order_data['customers_firstname']= $firstname;

        // Customers lastname
        $order_data['customers_lastname']= $lastname;

        // Customers gender
        $order_data['customers_gender']= $g;

        // Customers Mail-Adresse
        $order_data['customers_email_address']= $mail;

        // language of the store FE that the customers used to order
        $order_data['orders_language']= $lang;    

        // Date of the order
        $order_data['orders_date']= $date;

        $data_string = json_encode($order_data);

        $ch = curl_init('https://api.ratingchamp.com/api/public/order');
        curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
        curl_setopt($ch, CURLOPT_USERPWD, RATINGCHAMP_API_ACCOUNT_KEY . ":" . RATINGCHAMP_API_PW);
        curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($ch, CURLOPT_HTTPHEADER, array(
                'Content-Type: application/json',
                'Content-Length: ' . strlen($data_string))
        );
        $result = curl_exec($ch);

        $result = json_decode($result);

        if ($result->code=='200') {       	
			// everything ok, order submitted        	
        } else {
        	// show error
        	echo $result->message;
        }

    }

Make sure to define RATINGCHAMP_API_ACCOUNT_KEY & RATINGCHAMP_API_PW with your API-Data of your RatingChamp account.

This function should be called ideally when the order status of an order marks the shipping of goods.

Alternatively, there is also the possibility to run daily a script (for example cronjob), which transmits the orders of this day with the function above.

In this case, you should ensure that the orders that have been transmitted to our service are marked, to avoid to sent them twice.

API resonses for errors:

Wrong credentials:

{
    "code": "500",
    "status": "error",
    "message": "Authentication failed"
}

Max order amound exceeded. (depends on your plan)

{
    "code": 501,
    "message": "max quota exceeded",
    "max_quota": null
}

Invalid data (missing values etc.):

{
  "code": 502,
  "message": "Invalid data",
  "errors": {
    "order": [
      {
        "field": "merchant_orders_id",
        "message": "merchant_orders_id already exists"
      }
    ]
  }
}

 

Custom Widget-Integration:

The widget can be very flexible integrated in your shop, you only need to add the following line before the closing body tag (</ body>):

<script type="text/javascript" src="http://widget.ratingchamp.com/xxxxxx.js"></script>

Replace the  xxxxxx with the API-Key of your account.

To display the widget add following code in the position, where the widget should be displayed:

<!-- RatingChampWidget START -->
<div class="RatingChampWidget sidebar-box">
<a href="https://RatingChamp.com" rel="nofollow" target="_blank">RatingChamp verified Shop</a>
</div>
<!-- RatingChampWidget END -->

Was this answer helpful?

 Print this Article

Also Read

Modified Shop (Version 1.06 and older)

Please follow the instructions below in order to integrate RatingChamp in your...

WooCommerce / Wordpress

System requirements: WordPress (min. version 3.0.0) WooCommerce (min. version 2.1.6)...

xt:Commerce 4

1. Plugin download Download the RatingChamp plugin for xt:Commerce 4 and extract the files....

xt:Commerce v3.0.4 SP2.1

Follow the following instructions below to integrate RatingChamp with your xt:Commerce v3.0.4...

Modified Shop (V. 2.x)

Please follow the instructions below in order to integrate RatingChamp in your...