Page 1 of 1
Seller account API documentation?
Posted: Sun Aug 14, 2016 8:08 am
by oceklenti
Hello. There is API integration for developers on the account settings page. There is only API POST Reference. Does anybody know if there is more detailed information with examples? I just want to receive the order ID every time some one makes an order and use the order ID for registration/licence purposes.
Re: Seller account API documentation?
Posted: Tue Aug 16, 2016 10:58 pm
by MarketInSG
Using PHP, you will receive $_POST request to the URL you've set in your OpenCart account.
Re: Seller account API documentation?
Posted: Mon Sep 05, 2016 11:40 pm
by oceklenti
Thank you!.
Do you have any idea how can I get the post url? So I can allow $_POST method from this url/domain only
Re: Seller account API documentation?
Posted: Tue Sep 06, 2016 8:55 am
by MarketInSG
You will enter your notification URL in your OpenCart account and you will receive the POST. From there, you can capture and experiment with it.
Re: Seller account API documentation?
Posted: Tue Sep 06, 2016 2:40 pm
by uksitebuilder
There is currently no reliable way of verifying the post has come from OpenCart.com
You can use $_SERVER{'HTPP_REFERER'] but this can be forged by the sender if they know what they are doing
Re: Seller account API documentation?
Posted: Tue Sep 13, 2016 6:46 am
by oceklenti
Thank you for your help.
What is your suggestion?
At he moment I created a php file with a complex name to receive post requests.
ex:
http://example.com/api/f7gsum85dxx87hu8nn62d5ax0xzn.php
Re: Seller account API documentation?
Posted: Fri Dec 09, 2016 3:25 pm
by Devman Extensions
Hi all!
Could anyone use it? I'm trying but is not working. An example use?
Thanks!
Re: Seller account API documentation?
Posted: Mon Dec 12, 2016 11:01 pm
by uksitebuilder
The POST data you receive will contain the following:
order_id // the opencart order id
extension_id // the extension id
member_id // buyer's member id
username // buyer's username
email // buyer's email address
extension // name of the extension
quantity // quantity of extension license purchased
sub_total // sell price of extension * quantity
commission // what percentage rate OpenCart.com take from the sale
total // what you will be paid
order_status // status of the order - complete, pending, etc
date_added // date and time
date_modified // date and time
Do with that information what you will. Populate your own database or licensing system. Store for your accounts records, etc
Re: Seller account API documentation?
Posted: Sat Dec 17, 2016 1:53 am
by zengrafic
uksitebuilder wrote:The POST data you receive will contain the following....
is an empty array.
Re: Seller account API documentation?
Posted: Sat Dec 17, 2016 5:05 pm
by uksitebuilder
Strange, it works for me.
Each time there is a sale of one of my extensions, I receive a post and add the details automatically to my license database
Here's the beginning code in my api file
Code: Select all
if($_SERVER['REQUEST_METHOD']=='POST'){
if(!empty($_POST['order_id']) && !empty($_POST['extension_id']) && !empty($_POST['member_id']) && !empty($_POST['username']) && !empty($_POST['email']) && !empty($_POST['extension']) && !empty($_POST['quantity']) && !empty($_POST['sub_total']) && !empty($_POST['commission']) && !empty($_POST['total']) && !empty($_POST['order_status']) && !empty($_POST['date_added']) && !empty($_POST['date_modified'])){
if($_POST['order_status'] == 'Complete'){
Re: Seller account API documentation?
Posted: Sun Dec 18, 2016 12:25 am
by zengrafic
uksitebuilder wrote:Each time there is a sale of one of my extensions,
That's an important detail. I tought the API would be more complete, e.g. you can take your personal data from the OC seller account (sells already made, ecc.). Didn't get you.
Anyway, great thanks, code example was useful.
Re: Seller account API documentation?
Posted: Sun Dec 18, 2016 4:11 pm
by uksitebuilder
You are right of course, it is only a Sale Notification POST that is sent at the time a Sale is made.
Possibly, also when an order is updated from say 'Pending', but I only test for Complete.
Re: Seller account API documentation?
Posted: Sun Dec 18, 2016 5:29 pm
by artcore
I can confirm it works. Just learned about this feature from this thread a few days ago, thanks

This is very needed as the email notifications have been broken for many weeks now!
In response to previous posts for a bit of security:
I used a query param in the callback for some extra checking.
http://yourdomain.com/oc_order.php?opencart=cool
if(!isset($_GET['opencart']) || $_GET['opencart']!=='cool')exit;
Use any key/value pair, above is just an example.
And knowing the posted array, you can whitelist the variables to process.
if(in_array($key,$array){//process + filtering the values}
Re: Seller account API documentation?
Posted: Tue Dec 20, 2016 3:26 am
by Devman Extensions
Oh! Thanks you all, I'm trying it!.
Then this API call only will be triggered if a customer buy some of our extension, correct? What happen when Opencart team refund extension and change order status?
Thanks!
Re: Seller account API documentation?
Posted: Tue Dec 20, 2016 8:57 pm
by zengrafic
Devman Extensions wrote:What happen when Opencart team refund extension and change order status
You can try it out and let us know.

Re: Seller account API documentation?
Posted: Tue Dec 20, 2016 9:08 pm
by MarketInSG
if a refund is made, you will get the notification as well. All change in order status will notify you through the link you've entered.
Re: Seller account API documentation?
Posted: Tue Dec 27, 2016 4:38 pm
by Tomit
It would be nice if they added a secret key in the seller api options (under api url) and if they would md5 hash or sha1 hash the emailaddress of the buyer with the secret key, and add it as an extra post variable.
this way we can verify the post is coming from opencart pretty easy.
Re: Seller account API documentation?
Posted: Tue Jan 03, 2017 4:11 pm
by ashwani_multi
HI
i made email notification by api you can use this code
Code: Select all
<?php
// Opencart Sale Script
if($_SERVER['REQUEST_METHOD']=='POST'){
if(!empty($_POST['order_id']) && !empty($_POST['extension_id']) && !empty($_POST['member_id']) && !empty($_POST['username']) && !empty($_POST['email']) && !empty($_POST['extension']) && !empty($_POST['quantity']) && !empty($_POST['sub_total']) && !empty($_POST['commission']) && !empty($_POST['total']) && !empty($_POST['order_status']) && !empty($_POST['date_added']) && !empty($_POST['date_modified'])){
$order_id=$_POST['order_id'];
$extension_id=$_POST['extension_id'];
$member_id=$_POST['member_id'];
$username=$_POST['username'];
$email=$_POST['email'];
$extension=$_POST['extension'];
$quantity=$_POST['quantity'];
$commission=$_POST['commission'];
$total=$_POST['total'];
$order_status=$_POST['order_status'];
$date_added=$_POST['date_added'];
// Multiple recipients
$to = 'Your email here'; // note the comma
// Subject
$subject = 'OpenCart Purchased';
// Message
$message = ' New Module Purchased '.$extension.'<br />';
$message .= ' Order ID '.$order_id.'<br />';
$message .= ' Username '.$username.'<br />';
$message .= ' email '.$email.'<br />';
$message .= ' commission '.$commission.'<br />';
$message .= ' Order status'.$order_status.'<br />';
$message .= ' Total '.$total.'<br />';
// To send HTML mail, the Content-type header must be set
$headers[] = 'MIME-Version: 1.0';
$headers[] = 'Content-type: text/html; charset=iso-8859-1';
// Additional headers
$headers[] = 'From: Opencart <your from email here>';
// Mail it
mail($to, $subject, $message, implode("\r\n", $headers));
}
}
// Opencart Sale Script
?>
Re: Seller account API documentation?
Posted: Fri May 26, 2017 9:09 am
by zengrafic
uksitebuilder wrote: ↑Sun Dec 18, 2016 4:11 pm
You are right of course, it is only a Sale Notification POST that is sent at the time a Sale is made.
Possibly, also when an order is updated from say 'Pending', but I only test for Complete.
A message is only sent on order statuses "complete || failed || denied", but when an order has e.g. status "refunded" nothing is sended. Not a good deal....
Re: Seller account API documentation?
Posted: Sun Sep 06, 2020 4:50 pm
by PeoplesCode
Hello, has anyone had any experience of how the API $_POST array is formatted when a customer purchases two different extensions in the same order?
Will each item be in a separate indexed array containing all order info as a single item purchase, or some other format ?