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.
Using PHP, you will receive $_POST request to the URL you've set in your OpenCart account.
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.
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
You can use $_SERVER{'HTPP_REFERER'] but this can be forged by the sender if they know what they are doing
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
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
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
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
uksitebuilder wrote:The POST data you receive will contain the following....
Code: Select all
var_dump($_POST);
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
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'){
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.uksitebuilder wrote:Each time there is a sale of one of my extensions,
Anyway, great thanks, code example was useful.
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.
Possibly, also when an order is updated from say 'Pending', but I only test for Complete.
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}
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}
Attn: I no longer provide OpenCart extensions, nor future support - this includes forum posts.
Reason: OpenCart version 3+
Thanks!
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!
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!
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.
HI
i made email notification by api you can use this code
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
?>
Opencart Quick checkout
View All modules
Any opencart issue contact me at support@opencartextensions.in
Thank you
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....uksitebuilder wrote: ↑Sun Dec 18, 2016 4:11 pmYou 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.
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 ?
Will each item be in a separate indexed array containing all order info as a single item purchase, or some other format ?
People's Code - Order Fee / Discount
Who is online
Users browsing this forum: No registered users and 273 guests