API Documentation
Understand The PrinterCo API In 6 Steps
Let’s walk through step-by-step PrinterCo API documentation. Our API makes it easy to integrate our could printing platform with almost any website or application.
To use a PrinterCo terminal you need to have a valid subscription. Check out which subscription plan is best suited for your needs.
We also provide some tools to operate the printer remotely. This becomes very handy for having to make adjustments to the printer settings for your clients who are already in the live field.
Some other tools include user management, reports, watchdog and more.
We’ve worked relentlessly to deliver a system for maximum user flexibility, and at the same time keep things easy to use – even for the less tech-savvy. See below how we’ve broken down our powerful but simple-to-understand API in just 6 simple steps.
1. Send Order To API
The first step is to send your order to our API. How? It depends on whether you’re using one of our WordPress plugin extensions or you’re doing the API integration yourself. You don’t need to do much for the former method as we’ve taken care of the code for you. All you need to do is just install the plugin, punch in your API and Printer ID details, and you’re ready to go! For a more in-depth tutorial (with screenshots), be sure to check out WooCommerce Extension or WP-Pizza Extension.
For the latter method, where you’re not using an open-source platform (such as WordPress), you’ll need to first format your order content so that it can be read as an HTTP POST. For more details on how to do this, along with a list of available order parameters that you can use (i.e. order ID, order type, currency etc), see our sample PHP file. Enter your email to get your copy. And yes…don’t worry…it’s free!
Once you’ve formatted your order correctly, you’ll need to send it to our API through our API URL
2. Probe the Server Every 30 Sec
If your order was sent successfully, it’ll be sitting in the Transaction List with a pending status. Orders with pending status are picked up by the printers and are printed. If you don’t see your order in the Transaction List, then chances are it’s in the WatchDog. All orders that fail to follow protocol are dumped here, with details on how you can possibly fix the issue. More information on our WatchDog can be found on our forum.
Once you’ve subscribed to our print server and connected your first printer, it’s programmed to probe our servers every 30 seconds to search for any new orders (or orders with a pending status).
Although in most cases you won’t need to, you have the option to reduce this frequency to a longer gap (i.e. 60 seconds). A feature if you’re on a tight budget with data costs. To change this setting, you’ll need to navigate through the printer menus – Tutorials for this and other settings can be found here.
3. New Order
When an order with a pending status is picked up, the printer will stop probing the server. The contents of the order are then pulled for a quick print job, which usually takes a couple of seconds. Orders with pending status are highlighted in yellow, accepted orders are in green and rejected orders are in red.
Once the order is printed, the printer will resume probing the servers after another 30-second break.
4. Print Order
We understand that businesses operate differently, so we’ve adapted our system to give them more flexibility for our users when printing their orders. You can set up how you want your orders to print beforehand. This means, that you can set the printer to initially ring to grab your attention. And then, after a short user interaction have the order printed. Or you set it to print the order immediately, and then ring while waiting for you to accept or reject the order. You can even set up the printer to view your order on the screen before deciding to print it. So play around with the different combinations to so see what works for your business.
5. Update Order Status
If enabled, after the order is printed, you’ll be required to accept or reject the order. What follows, is the option to enter an estimated time for completion, or a reason for the rejection. This information is then sent to our print servers and saved for further processing.
Coming soon are more advanced features that involve an SMS notification of the updated order status and live order tracking.
6. Customer Acknowledgement
After the order status is changed from the printer (i.e. when the order has been accepted or rejected), the information is passed to a page referred to as the Notify URL. You’ll need to create this page for your website and include the URL in your code when submitting the order to our API. From this page, you can extract the new order status and then take the next appropriate actions to notify the customer.
Here’s another reason that makes us one of the best cloud printing service providers.
To avoid any disappointments, we encourage you to use our demo account to do your integration. There, you’ll find a virtual printer. It won’t print anything out for you, but you can use it as a guide to testing if your setup works correctly. Once you’re able to send orders to the virtual test printer and see them in the transaction list, you can then commit to subscribing and buying your own printer.
API Documentation (Fixed Style)
Order Submit URL (Fixed style)
URL | https://mypanel.printerco.net/submitorder.php |
Note | Submit your order details according to API guidelines to this URL using the post method including API key, API password, Printer ID etc. from your website to our API. For more details please check our API documentation. Also please note that you should do URL encoding before sending it to API. |
Fields Reference (Fixed Style)
Field | Importance | Format | Details |
---|---|---|---|
api_key | Mandatory | String | API key of client account |
api_password | Mandatory | String | API password of client account |
notify_url | Mandatory | String | URL to where you want to be notified about order accept/reject from the printer |
receipt_header | Mandatory | String | The header for print receipt |
receipt_footer | Mandatory | String | The footer for print receipt |
printer_id | Mandatory | Integer | Printer ID to where you want to send the order |
order_id | Mandatory | Integer | Order ID to track order (must be unique, must not contain any space ) |
currency | Mandatory | String | Your currency |
order_type | Mandatory | Integer | Order type: 1 – Delivery 2 – Collection 3 – Reservation |
payment_status | Mandatory | Integer | Status of the payment: 6 – paid 7 – not paid |
payment_method | Mandatory | String | Payment method name. Ex. Cash, paypal etc. |
order_time | Optional | Date and Time | Time and date when order placed. e.g- 18:30 17-09-10 (h:m dd-mm-yy) |
delivery_time | Mandatory | Date and Time | Time and date of delivery. e.g- 18:30 17-09-10 (h:m dd-mm-yy) |
auth_code | Optional | String | Authentication code of payment method |
Field | Importance | Format | Details |
line_items[] -> array( category(string) | category – it is the item category name | ||
item(string) | item – it is item name | ||
item_description(string) | item_description – it is item description (ex. Selection or toppings) | ||
item_qty(integer) | item_qty – it is item quantity | ||
item_price(number) | item_price – quantity X unit priceAll post variables for the item must be passed to API even if any field needs to be kept | ||
item_addon[] -> array ( title(string) | Mandatory at least one | Array | item_addon – it is additional item positions item_addon -> title – it is header of additional positions in order item |
name(string) | item_addon -> name – it is name of additional item position | ||
price(number) ) ) | item_addon -> price – it is price of additional item position |
Field | Importance | Format | Details |
deliverycost | Mandatory | Number | Zero or greater |
card_fee | Mandatory | Number | Zero or greater |
extra_fee | Optional | Number | Zero or greater |
total_discount | Optional | Number | Zero or greater |
total_amount | Mandatory | Number | Zero or greater (must be calculated total including item price and other fees and discount) |
cust_name | Mandatory | String | Customer name |
cust_address | Mandatory | String | Customer address |
cust_phone | Mandatory | String | Customer phone number |
cust_instruction | Optional | String | Customer instruction about order |
isVarified | Mandatory | Integer | Customer verification status 4 – verified 5 – not verified |
num_prev_order | Optional | Integer | Total number of orders of this customer |
POST Example (Fixed Style)
<form method="post" action="https://mypanel.printerco.net/submitorderext.php">
<input name="api_key" value="Your API Key" />
<input name="api_password" value="Your API Password" />
<input name="notify_url" value="Notify URL" /> <!-Notify url is your websites url where you would like to get notification from isynctel api -->
<input name="receipt_header" value="Header Line1@@123 Street Address, City, Zip Code" />
<input name="receipt_footer" value="Thanks for your custom..." />
<input name="printer_id" value="Your printer ID" />
<input name="order_id" value="OrderID" />
<input name="currency" value="Currency" /><!--ex. USD/GBP -->
<input name="order_type" value="1" /><!--Delivery=1, Pick up=2, Reservation=3-->
<input name="payment_status" value="6" /><!--Paid=6, Not Paid=7-->
<input name="payment_method" value="Payment Method" />
<input name="delivery_time" value="18:30 17-09-10 " /><!--Format=HH:MM DD-MM-YY-->
<input name="auth_code" value="Payment authorization code" />
<input name="line_items[0][category]" value="Category 1" />
<input name="line_items[0][item]" value="Item Name 1" />
<input name="line_items[0][item_description]" value="Item description 1" />
<input name="line_items[0][item_qty]" value="1" />
<input name="line_items[0][item_price]" value="10.50" />
<input name="line_items[0][item_addon][0][title]" value="Additional item title 1" />
<input name="line_items[0][item_addon][0][name]" value="Additional item name 1" />
<input name="line_items[0][item_addon][0][price]" value="5.50" />
<input name="line_items[0][category]" value="Category 2" />
<input name="line_items[0][item]" value="Item Name 2" />
<input name="line_items[0][item_description]" value="Item description 2" />
<input name="line_items[0][item_qty]" value="1" />
<input name="line_items[0][item_price]" value="10.50" />
<input name="line_items[0][category]" value="Category 3" />
<input name="line_items[0][item]" value="Item Name 3" />
<input name="line_items[0][item_description]" value="Item description 3" />
<input name="line_items[0][item_qty]" value="1" />
<input name="line_items[0][item_price]" value="10.50" />
<input name="line_items[0][item_addon][0][title]" value="Additional item title 3" />
<input name="line_items[0][item_addon][0][name]" value="Additional item name 3" />
<input name="line_items[0][item_addon][0][price]" value="5.50" />
---------
You can place more items here using above format.
Please note that you don't need to send category name for the items after first item if the category name is same and if you put all same category items consecutively.
---------
<input name="deliverycost" value="3.50" />
<input name="card_fee" value="0.50" />
<input name="extra_fee" value="1.50" />
<input name="total_discount" value="4.50" />
<input name="total_amount" value="56.50" /><!--Grand Total -->
<input name="cust_name" value="Customer Name" />
<input name="cust_address" value="Customer address" />
<input name="cust_phone" value="Phone number" />
<input name="cust_instruction" value="Special instruction" />
<input name="isVarified" value="4" /><!-Verified=4, Not verified=5 -->
<input name="num_prev_order" value="Number of previous order" />
<input type="submit" value="Submit" />
</form>
Error Response (Fixed Style)
<response>
<status>FAILED</status>
<details>
<error> Authentication failed </error>
<error> Other errors...</error>
</details>
</response>
Success Response (Fixed Style)
<response>
<status>OK</status>
<details>
<msg>Order has been stored successfully</msg>
</details>
</response>
Order Updates Notification (Fixed style)
When the printer sends a callback response to API the API sends a notification to the Provided Notify URL with the order status. In your notification URL, you will get a notification regarding the status of the order, all the information will be submitted via post method which will allow you to grab information easily.
Post variables:
“printer_id” | = | Printer ID |
“order_id” | = | Order ID |
“status” | = | 1 -> accepted | 2 -> rejected |
“msg” | = | message from the printer (this variable will not be present for manual order update from MyPanel) |
“delivery_time” | = | confirmed delivery time from the printer (this variable will not be present for manual order update from MyPanel) |
“manual_update” | = | 1 -> manual update identifier |
“booking” | = | 1 -> manage booking identifier |
Please note that you will not get the notification while sending the order to API even if the notify URL is the same as where you are sending the order to API. API will send the response later automatically when the order is accepted/rejected from the printer to that Notify URL you provided with the order. So we recommend you use a separate URL/file to send the order to API and receive notification from API to avoid confusion.
Example in PHP:
Let’s say you are sending the order to the URL of your site www.example.com/sendorder.php to API,
So you need to write the necessary code on sendorder.php to send order information from your site to API. I am not telling you the details here on how to send the order to API. Please check our example HTML form above to send order information to API.
Let’s say you have used the value of the notification URL field
www.example.com/receivenotification.php
in the orders sending form
<input name=”notify_url” value=”www.example.com/receivenotification.php” />
then MyPanel API will send a notification to
www.example.com/receivenotification.php
as soon as API get a response from the printer when an order will be accepted/rejected after printing. Here is the example code to grab the information from the API notification that needs to be placed on the receivenotification.php file.
<?php
$printer_id = $_REQUEST['printer_id'];
$order_id = $_REQUEST['order_id'];
$order_status = $_REQUEST['status'];
$message = $_REQUEST['msg'];
$delivery_time = $_REQUEST['delivery_time'];
if($order_status==1)
{
//order has been accepted from the printer
//do your necessary task for accepted order like update database, send email to the customer to inform him that his order has been accepted and will be delivered on the returned delivery time (variable $delivery_time).
}
else
{
//order has been rejected from printer
//do your necessary task for rejected order like update databse, send email to customer to inform him that his order has been rejected for the returned reason (variable $message).
}
?>
Get Printer Status (fixed style)
You can get printer status programmatically through API.
API URL –
https://mypanel.printerco.net/get_status.php
Field | Importance | Format | Details |
---|---|---|---|
api_key | Mandatory | String | API key of client account |
api_password | Mandatory | String | API password of client account |
printer_id | Mandatory | Integer | Printer ID for which you want to get the status |
Success response:
<response>
<status>OK</status>
<details>
<printer_id>Printer ID</printer_id>
<printer_status>active or inactive</printer_status>
<shop_status>open or closed</shop_status>
<last_connected>last connection time(YYYY-MM-DD HH:MM:SS) or NA</last_connected>
<connection_status>connected or not connected</connection_status>
</details>
</response>
Please note that you can use the connection status that is calculated by the offline time settings of your MyPanel account or you need to decide whether the printer is connected or not by the last connection time. Because it’s up to you how long you want to allow to calculate the connection status. Just to inform you that only if the printer is Idle, the printer connects to MyPanel in each 30 seconds period to check for new orders. It (30 seconds) sometimes may vary due to a network issue. And also if the printer user is busy navigating other sections like the menu or other features then the printer only connects to the MyPanel after the user is back to Idle mode. So please keep it in mind when you calculate the connection status.
Failed response:
<response>
<status>FAILED</status>
<details>
<error> Authentication failed </error>
<error> Other errors...</error>
</details>
</response>
Get Order Status
You can get order status programmatically through API.
API URL –
https://mypanel.printerco.net/get_order_status.php
Field | Importance | Format | Details |
---|---|---|---|
api_key | Mandatory | String | API key of client account |
api_password | Mandatory | String | API password of client account |
printer_id | Mandatory | Integer | Associated Printer ID |
order_id | Mandatory | Integer | Order ID for which you want to get the status |
Success response:
<response>
<status>OK</status>
<details>
<printer_id>Printer ID</printer_id>
<order_id>Order ID</order_id>
<order_status>pending or accepted or rejected</order_status>
<accepted_for>agreed delivery/pickup time if the order is accepted</accepted_for>
<rejected_for>rejected reason if order is rejected</rejected_for>
</details>
</response>
Please note that if the order status is accepted then the rejected_for field will contain an NA value and if the order status is rejected then the accepted_for field will contain an NA value.
Failed response:
<response>
<status>FAILED</status>
<details>
<error> Authentication failed </error>
<error> Other errors...</error>
</details>
</response>
API Documentation (Freestyle)
Order Submit URL (Fixed style)
URL | https://mypanel.printerco.net/submitorderfreestyle.php |
Note | Submit your order details according to API guidelines to this URL using the post method including API key, API password, Printer ID etc. from your website to our API. For more details please check our API documentation. Also please note that you should do URL encoding before sending it to API. |
Fields Reference (Freestyle)
Field | Importance | Format | Details |
---|---|---|---|
api_key | Mandatory | String | API key of client account |
api_password | Mandatory | String | API password of client account |
notify_url | Mandatory | String | URL to where you want to be notified about order accept/reject from printer |
printer_id | Mandatory | Integer | Printer ID to where you want to send the order |
order_id | Mandatory | Integer | Order ID to track order (must be unique, must not contain any space ) |
currency | Mandatory | String | Your currency |
receipt_header | Mandatory | String | Header for print receipt |
receipt_footer | Mandatory | String | Footer for print receipt |
print_data | Mandatory | String | Receipt body(please see Receipt Formatting Markup) |
order_time | Optional | Date and Time | Time and date when order placed. e.g- 18:30 17-09-10 (h:m dd-mm-yy) |
delivery_time | Mandatory | Date and Time | Time and date of delivery. e.g- 18:30 17-09-10 (h:m dd-mm-yy) |
total_amount | Mandatory | Number | Zero or greater (must be calculated total including item price and other fees and discount) |
FIELD “order_type” WILL ADD SAME LIKE FIXED STYLE API
Fields Reference (Freestyle)
order_type
Mandatory
Integer
Order type:
1 – Delivery
2 – Collection
3 – Reservation
Post example (Freestyle)
Post example (Freestyle)
<form method="post" action="https://mypanel.printerco.net/submitorderfreestyle.php">
<input name="api_key" value="Your API Key" />
<input name="api_password" value="Your API Password" />
<input name="notify_url" value="Notify URL" /> <!-Notify url is your websites url where you would like to get notification from isynctel api -->
<input name="receipt_header" value="Header Line1@@123 Street Address, City, Zip Code" />
<input name="receipt_footer" value="Thanks for your custom..." />
<input name="printer_id" value="Your printer ID" />
<input name="order_id" value="OrderID" />
<input name="currency" value="Currency" /><!--ex. USD/GBP -->
<input name="delivery_time" value="18:30 17-09-10 " /><!--Format=HH:MM DD-MM-YY-->
<input name="print_data" value="Line 1/rLine 2@@Line 3/-" />
<input name="total_amount" value="56.50" /><!--Grand Total -->
<input type="submit" value="Submit" />
</form>
Success response
<response>
<status>OK</status>
<details>
<msg>Order has been stored successfully</msg>
</details>
</response>
Error response
<response>
<status>FAILED</status>
<details>
<error> Authentication failed </error>
<error> Other errors...</error>
</details>
</response>
Order Updates Notification
When the printer sends a callback response to API the API sends a notification to the Provided Notify URL with the order.
In your notification URL, you will get a notification regarding the status of the order, all the information will be submitted via post method which will allow you to grab information easily.
Post variables:
"printer_id" = Printer ID
"order_id" = Order ID
"status" = (1=accepted,2=rejected)
"msg" = message from printer (this varibale will not be present for manual order update from MyPanel)
"delivery_time" = confirmed delivery time from printer (this varibale will not be present for manual order update from MyPanel)
"manual_update" = (1=manual update identifier)
"booking" = (1=manage booking identifier)
Please note that you will not get the notification while you are sending the order to API even if the notify URL is the same as where you are sending the order to API. API will send a response later automatically when the order will be accepted/rejected by the printer to that Notify URL you provided with the order. So we recommend you use a separate URL/file to send orders to API and receive notification from API to avoid confusion.
Example in PHP
Let’s say you are sending an order to the URL of your site www.example.com/sendorder.php to API
So you need to write the necessary code on sendorder.php to send order information from your site to API. I am not telling you the details here of how to send the order to API. Please check our example html form above to send order information to API.
Let’s say you have used the value of the notification URL field
www.example.com/receivenotification.php
in the orders sending form
<input name="notify_url" value="www.example.com/receivenotification.php" />
then MyPanel API will send a notification to
www.example.com/receivenotification.php
as soon as API get a response from the printer when an order will be accepted/rejected after printing. Here is the example code to grab the information from the API notification that needs to be placed on receivenotification.php file.
<?php
$printer_id = $_REQUEST['printer_id'];
$order_id = $_REQUEST['order_id'];
$order_status = $_REQUEST['status'];
$message = $_REQUEST['msg'];
$delivery_time = $_REQUEST['delivery_time'];
if($order_status==1){
//order has been accepted from printer
//do your necessary task for accepted order like update databse, send email to customer to inform him that his order has been accepted and will be delivered on returned delivery time (variable $delivery_time).
}
else{
//order has been rejected from printer
//do your necessary task for rejected order like update databse, send email to customer to inform him that his order has been rejected for the returned reason (variable $message).
}
?>
Receipt Formatting Markup
You will be able to use some markup language to format your items and any other text that you use on the order. These are mainly,
@@ = New line
/q = Bold (text that starts from previous @@ device)
/r = Big font (text that are start from previous @@ or /- or /q and ends to /r)
/- = Dotted line
Please see below some examples of how to use them.
Examples:
@@ = New Line
You can use a new line to give a line break, for example on the header,
My Company@@QeensStreen London
On the receipt, it will print
My Company
Queens Street London
Also, you can use it when you have some items with toppings or selections, you can use the new line identifier to give the toppings details below the item, for example,
Where you would put your item name, you can put,
Vegetable Pizza @@ + Onion @@ + Green Pepper @@ + Sweet corn
This will be printed on the receipt as,
Vegetable Pizza
+ Onion
+ Green Pepper
+ Sweet Corn
/q = Bold
You can bold a block of text to make it highlighted. The way to do it is that you need to place /q at the end of the text and need to give another markup where it starts. For example,
If you put
“text1@@text2/qtext3”
Then only text2 will be bold
/r = Big font
You can bold a block of text to make it highlighted. The way to do it is that you need to place /r at the end of the text and need to give another markup where it starts. For example,
If you put
“text1@@text2/rtext3”
Then only text2 will be in big font
/- = Dotted line
You can place a dotted line to separate some text or make an end of a section. This is used to design the receipt to look better.
For example,
If you place /- end of the comment. It will print a dotted line at the end, such as
Please knock on the window, doorbell
is not working.
———————————————
Please note that these markups are developed for specially free-style formatted orders. but you can use them for fixed formatted order in some specific sections(ex. Header, Customer Info, Address, Comment, Footer etc. but you can’t use these markups for price and labels).
Get printer status
You can get printer status programmatically through API.
API URL: https://mypanel.printerco.net/get_status.php
Field | Importance | Format | Details |
---|---|---|---|
api_key | Mandatory | String | API key of client account |
api_password | Mandatory | String | API password of client account |
printer_id | Mandatory | Integer | Printer ID for which you want to get the status |
Success response:
<response>
<status>OK</status>
<details>
<printer_id>Printer ID</printer_id>
<printer_status>active or inactive</printer_status>
<shop_status>open or closed</shop_status>
<last_connected>last connection time(YYYY-MM-DD HH:MM:SS) or NA</last_connected>
<connection_status>connected or not connected</connection_status>
</details>
</response>
Please note that you can use the connection status that is calculated by the offline time settings of your MyPanel account or you need to decide whether the printer is connected or not by the last connection time. Because it’s up to you how long you want to allow to calculate the connection status. Just to inform you that only if the printer is Idle the printer connects to MyPanel in each 30 seconds period to check for new orders. It (30 seconds) sometimes may vary due to network issues. And also if the printer user is busy navigating other sections like the menu or other features then the printer only connects to the MyPanel after the user is back to Idle mode. So please keep it in mind when you calculate the connection status.
Failed response:
<response>
<status>FAILED</status>
<details>
<error> Authentication failed </error>
<error> Other errors...</error>
</details>
</response>
Get order status
You can get order status programmatically through API.
API URL: https://mypanel.printerco.net/get_order_status.php
Field | Importance | Format | Details |
---|---|---|---|
api_key | Mandatory | String | API key of client account |
api_password | Mandatory | String | API password of client account |
printer_id | Mandatory | Integer | Associated Printer ID |
order_id | Mandatory | Integer | Order ID for which you want to get the status |
Success response:
<response>
<status>OK</status>
<details>
<printer_id>Printer ID</printer_id>
<order_id>Order ID</order_id>
<order_status>pending or accepted or rejected</order_status>
<accepted_for>agreed delivery/pickup time if the order is accepted</accepted_for>
<rejected_for>rejected reason if order is rejected</rejected_for>
</details>
</response>
Please note that if the order status is accepted then the rejected_for field will contain the NA value and if the order status is rejected then the accepted_for field will contain the NA value.
Failed response:
<response>
<status>FAILED</status>
<details>
<error> Authentication failed </error>
<error> Other errors...</error>
</details>
</response>
Get Shop Status (iconnect printers only)
Once the shop status is changed via the printer, a notification is sent to our server to update our records. And once this is updated, the website in question is notified of the new shop status through the notify URL. You can check the ‘status’ or ‘update_shop_status’ variables to see if your eCommerce store should be opened or closed for business.
Field | Importance | Format | Details |
---|---|---|---|
printer_ID | Mandatory | String | Associated Printer ID |
status | Mandatory | Integer | 0 for shop is closed; 1 for shop is open |
update_shop_status | Mandatory | Integer | 1 for a change is needed; 0 not needed |
Below is a template PHP script that you can use to send orders from your website to the PrinterCo API. To alter the font settings and printer behaviour, you can use either your printer or your MyPanel dashboard.
To change the fonts, you can refer to the article Optimize receipt fonts for the best layout
To change the printer behaviour, you can refer to the section Printer Functions
After integrating with our API, if you find that your orders are still not printing out from your printer, head over to the Watchdog to see if any errors were found with your order submission. Check out the article Troubleshooting with Watchdog for more help.
<?php
// ======================================================
// PART 1. Set-up required variables from a typical order - You can find more details for the post fields in your MyPanel dashboard. Visit mypanel.printerco.net
// ======================================================
$order_id = '32001';
$currency = 'USD';
$order_type = 'delivery';
$payment_status = 'paid';
$payment_method = 'creditcard';
$auth_code = '443AD453454'; //identification code of payment
$order_time = '18:30 14-08-14'; //h:m dd-mm-yy
$delivery_time = '18:45 14-08-14'; //h:m dd-mm-yy
$deliverycost = 3.50;
$card_fee = 2.50;
$extra_fee = 0.00;
$total_discount = 1.50;
$total_amount = 15.00;
$cust_name = 'Jhon Smith';
$cust_address = 'Address line1%%address line2%%...';
$cust_phone = '44034343434';
$isVarified = 'verified';
$cust_instruction = 'Make it spicy';
$num_prev_order = 10;
// ===================================================
// Part 2. Additional options for the printer settings - These can also be changed from your MyPanel dashboard
// ===================================================
$apply_settings = 0; //0=settings NOT applied, 1=settings applied
$auto_print = 0;
$auto_accept = 0;
$enter_delivery_time = 1;
$time_input_method = 1;
$time_list = '0-5-10-15-20-25-30-35-40-45-50-55-60';
$extra_line_feed = 3;
// =============================================
// Part 3. Save the items ordered into an array
// =============================================
$menu_item = array(
array(
'category'=>'item category 1',
'item'=>'item name 1',
'item_description'=>'item description 1',
'item_qty'=>'1',
'item_price'=>'3.50',
'item_addon' => array(
array(
'title'=>'additional item title 1',
'name'=>'additional item name 1',
'price'=>'5.50'
),
array(
'title'=>'additional item title 2',
'name'=>'additional item name 2',
'price'=> '5.50'
)
)
),
array(
'category'=>'item category 2',
'item'=>'item name 2',
'item_description'=>'item description 2',
'item_qty'=>'3',
'item_price'=>'6.00'
)
);
// =============================
// PART 4. API access credential - Find this in your MyPanel dashboard under My account > Edit Information.
// =============================
$api_key = 'apikey';
$api_password = 'secretapipassword'
// ============================
// PART 5. PrinterCo printer ID - visit your MyPanel dashboard and then the Printer List page to find the printer ID.
// ============================
$printer_id = 2501;
// =====================================
// PART 6. Set receipt header and footer
// =====================================
$receipt_header = "PrinterCo Restaurant%%Kemp House, 160 City Road%%London, EC1V 2NX%%0800 689 5326";
$receipt_footer = "Thank you";
// ==========================
// PART 7. Notification URL - When an order is either accepted or rejected on the printer, this info will be sent to this URL.
// ==========================
$notify_url = 'http://yourwebsite.com/notify.php';
// Even if this will not be used, this is a mandatory field needed to send orders to the API
// =========================================
// PART 8. Preparing post fields as an array
// before sending to the PrinterCo API
// =========================================
$post_array = array();
$post_array['api_key'] = $api_key;
$post_array['api_password'] = $api_password;
$post_array['receipt_header'] = $receipt_header;
$post_array['receipt_footer'] = $receipt_footer;
$post_array['notify_url'] = $notify_url;
$post_array['printer_id'] = $printer_id;
$post_array['order_id'] = $order_id;
$post_array['currency'] = $currency;
//1=Delivery, 2=Collection/Pickup, 3=Reservation
if($order_type=='delivery'){
$post_array['order_type'] = 1;
}
else if($order_type=='collection' || $order_type=='pickup'){
$post_array['order_type'] = 2;
}
else if($order_type=='reservation'){
$post_array['order_type'] = 3;
}
//6=paid, 7=not paid
if($payment_status=='paid'){
$post_array['payment_status'] = 6;
}
else{
$post_array['payment_status'] = 7;
}
$post_array['payment_method'] = $payment_method;
$post_array['auth_code'] = $auth_code;
$post_array['order_time'] = $order_time;
$post_array['delivery_time'] = $delivery_time;
$post_array['deliverycost'] = $deliverycost;
$post_array['card_fee'] = $card_fee;
$post_array['extra_fee'] = $extra_fee;
$post_array['total_discount'] = $total_discount;
$post_array['total_amount'] = $total_amount;
$post_array['cust_name'] = $cust_name;
$post_array['cust_address'] = $cust_address;
$post_array['cust_phone'] = $cust_phone;
//4=verified, 5=not verified
if($isVarified=='verified'){
$post_array['isVarified'] = 4;
}
else{
$post_array['isVarified'] = 5;
}
$post_array['cust_instruction'] = $cust_instruction;
$post_array['num_prev_order'] = $num_prev_order;
$post_array['apply_settings'] = $apply_settings;
$post_array['auto_print'] = $auto_print;
$post_array['auto_accept'] = $auto_accept;
$post_array['enter_delivery_time'] = $enter_delivery_time;
$post_array['time_input_method'] = $time_input_method;
$post_array['time_list'] = $time_list;
$post_array['extra_line_feed'] = $extra_line_feed;
$post_array['line_items'] = $menu_item;
// ========================================
// Part 8. Post order data to PrinterCo API
// ========================================
$printerco_api_url = 'https://mypanel.printerco.net/submitorderext.php';
$response = post_to_api($printerco_api_url,$post_array);
//do your necessary things here based on the response status
if($response['status']=='OK'){
//order submitted successfully
}
else{
//order submission failed because of the following reason
}
// ===================================
// Part 9. Post data to API using CURL
// ===================================
function post_to_api($url, $post_data) {
set_time_limit(60);
$output = array();
$fields = http_build_query($post_data);
$curlSession = curl_init();
curl_setopt($curlSession, CURLOPT_URL, $url);
curl_setopt($curlSession, CURLOPT_HEADER, 0);
curl_setopt($curlSession, CURLOPT_POST, 1);
curl_setopt($curlSession, CURLOPT_POSTFIELDS, $fields);
curl_setopt($curlSession, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curlSession, CURLOPT_TIMEOUT, 30);
curl_setopt($curlSession, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($curlSession, CURLOPT_SSL_VERIFYHOST, 1);
$rawresponse = curl_exec($curlSession);
$response_array = simplexml_load_string($rawresponse);
if($response_array->status == 'OK'){
$output['status'] = 'OK';
$output['details'] = (string)$response_array->details->msg;
}
else{
$output['status'] = 'FAILED';
$output['error'] = array();
foreach($response_array->details->error as $val){
$output['error'][] = (string)$val;
}
}
curl_close($curlSession);
return $output;
}
?>