Orders API
You can use this "orders" API method to tell Quixly when an order has been placed on your system. You can send Quixly all the necessary info about the transaction, and Quixly will take it from there. Quixly will then create an order record for the transaction and email your customer a link to download the appropriate file.
"orders" Method
- URL: https://YOUR_ACCOUNT_NAME.quixly.com/orders/?api_key=YOUR_API_KEY¶m=value¶m=value...
- Request Method: POST
- Return Format: JSON
- Parameters:
- sku: Required - SKU/ID of the file to be downloaded. This is a value assigned to each file you upload into Quixly, and can be found inside the Quixly application. Numbers and Letters only. Example: 52
- customer_email: Required - Email address of the customer who made the purchase. This is the email that will be used to deliver the files.
- total_price: Required - Total price of the transaction. Numbers only. Example: 89.99
- origin: Optional - This is a description of where the order came from. For example, if your web store was named "Cool Store", you might want the origin to be "cool store". If you have multiple web stores ("Cool Store" and "Dog Store") tied to a single Quixly account, you can differentiate which orders came from where by using this origin parameter.
- transaction_id: Optional - If you have your own internal transaction ID system you can send that ID over to Quixly as well to make it easier to find orders from within the Quixly application.
- customer_name: Optional - Name of the customer who made the purchase. This can be used to personalize the emails sent with Quixly.
When you make a request to the API, it will return a status of 200 is everything completes successfully. If there are any errors, it will return a status of 400. Below are examples of the JSON returned to you along with the status code.
- 200:
{ count: TOTAL_COUNT_HERE } - The "count" is the total number of items we processed (ex: 3). - 400:
{ error: "ERROR_MESSAGE_HERE" }
PHP cURL Example:
Here is an example of using the cURL library in PHP to send
Order information to Quixly server to server in the background. You
would want to run this cURL request in your system whenever a new
Order or Transaction is made (ie. someone buys something).
Be sure to replace fictitious values with your actual
Order/Transaction values, and your Quixly account information.
$params = array('api_key' => 'YOUR_API_KEY', 'sku' => '52', 'email' => 'customer@email.com', 'total_price' => '89.99', 'origin' => 'My Store', 'transaction_id' => '12345', 'fullname' => 'Customer Name');
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://YOUR_ACCOUNT_NAME.quixly.com/api/orders/');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $params);
//If you get "error communicating with Quixly server", add this option.
//curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
$response = curl_exec($ch);
curl_close($ch);
$json = json_decode($response);
if (@$json->count > 0){ // check to see if any records were affected
echo "success";
} else {
if ($json){
echo @$json->error;
} else {
echo "error communicating with Quixly server";
}
}