Post by oceklenti » Sun Aug 14, 2016 8:08 am

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.

Newbie

Posts

Joined
Sun Aug 14, 2016 8:01 am

Post by MarketInSG » Tue Aug 16, 2016 10:58 pm

Using PHP, you will receive $_POST request to the URL you've set in your OpenCart account.


User avatar
Guru Member

Posts

Joined
Wed Nov 16, 2011 11:53 am
Location - Singapore

Post by oceklenti » Mon Sep 05, 2016 11:40 pm

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

Newbie

Posts

Joined
Sun Aug 14, 2016 8:01 am

Post by MarketInSG » Tue Sep 06, 2016 8:55 am

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.


User avatar
Guru Member

Posts

Joined
Wed Nov 16, 2011 11:53 am
Location - Singapore

Post by uksitebuilder » Tue Sep 06, 2016 2:40 pm

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

ImageImageImageImageImage

For Friendly Professional Support - Click Here


User avatar
Guru Member

Posts

Joined
Thu Jun 09, 2011 11:37 pm
Location - United Kindgom

Post by oceklenti » Tue Sep 13, 2016 6:46 am

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

Newbie

Posts

Joined
Sun Aug 14, 2016 8:01 am

Post by Devman Extensions » Fri Dec 09, 2016 3:25 pm

Hi all!

Could anyone use it? I'm trying but is not working. An example use?

Thanks!

User avatar

Posts

Joined
Fri Dec 09, 2016 3:20 pm


Post by uksitebuilder » Mon Dec 12, 2016 11:01 pm

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

ImageImageImageImageImage

For Friendly Professional Support - Click Here


User avatar
Guru Member

Posts

Joined
Thu Jun 09, 2011 11:37 pm
Location - United Kindgom

Post by zengrafic » Sat Dec 17, 2016 1:53 am

uksitebuilder wrote:The POST data you receive will contain the following....

Code: Select all

var_dump($_POST);
is an empty array.

Newbie

Posts

Joined
Mon Nov 14, 2016 11:17 pm
Location - Earth

Post by uksitebuilder » Sat Dec 17, 2016 5:05 pm

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'){

ImageImageImageImageImage

For Friendly Professional Support - Click Here


User avatar
Guru Member

Posts

Joined
Thu Jun 09, 2011 11:37 pm
Location - United Kindgom

Post by zengrafic » Sun Dec 18, 2016 12:25 am

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.

Newbie

Posts

Joined
Mon Nov 14, 2016 11:17 pm
Location - Earth

Post by uksitebuilder » 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.

ImageImageImageImageImage

For Friendly Professional Support - Click Here


User avatar
Guru Member

Posts

Joined
Thu Jun 09, 2011 11:37 pm
Location - United Kindgom

Post by artcore » Sun Dec 18, 2016 5:29 pm

I can confirm it works. Just learned about this feature from this thread a few days ago, thanks :D
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+ ;D

Thanks!


User avatar
Active Member

Posts

Joined
Tue Jul 09, 2013 4:13 am
Location - The Netherlands

Post by Devman Extensions » Tue Dec 20, 2016 3:26 am

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!

User avatar

Posts

Joined
Fri Dec 09, 2016 3:20 pm


Post by zengrafic » Tue Dec 20, 2016 8:57 pm

Devman Extensions wrote:What happen when Opencart team refund extension and change order status
You can try it out and let us know. ;)

Newbie

Posts

Joined
Mon Nov 14, 2016 11:17 pm
Location - Earth

Post by MarketInSG » Tue Dec 20, 2016 9:08 pm

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.


User avatar
Guru Member

Posts

Joined
Wed Nov 16, 2011 11:53 am
Location - Singapore

Post by Tomit » Tue Dec 27, 2016 4:38 pm

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.

Image


New member

Posts

Joined
Sat Sep 14, 2013 9:54 pm
Location - Netherlands

Post by ashwani_multi » Tue Jan 03, 2017 4:11 pm

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
?>

Opencart Quick checkout
View All modules
Any opencart issue contact me at support@opencartextensions.in

Thank you


User avatar
New member

Posts

Joined
Tue Dec 09, 2014 2:40 pm
Location - Ludhiana,Punjab,India

Post by zengrafic » Fri May 26, 2017 9:09 am

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....

Newbie

Posts

Joined
Mon Nov 14, 2016 11:17 pm
Location - Earth

Post by PeoplesCode » Sun Sep 06, 2020 4:50 pm

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 ?

People's Code - Order Fee / Discount


Newbie

Posts

Joined
Wed Jun 05, 2013 2:43 pm
Who is online

Users browsing this forum: No registered users and 10 guests