Post by darth_danny » Mon Aug 01, 2016 4:58 pm

Hi,

I am trying to create a module that posts new order information when a new order is made (or payment is confirmed). I had gone as far as this script but needed some help. I intend to post the order information using curl once payment is confirmed but having some trouble finding a way of pulling new order information on payment confirmation (using Paypal standard)

Code: Select all

class ControllerModuleDelivery extends Controller {
    
    public function install() {
        $this->load->model('extension/event');
        $this->model_extension_event->addEvent('delivery', 'post.order.history.add', 'module/delivery/on_new_order');
    }
    
    public function uninstall() {
        $this->load->model('extension/event');
        $this->model_extension_event->deleteEvent('delivery');
    }
    
    public function on_new_order($order_id) {
        
    }
    
}
How would I proceed from here to send new order information once payment is confirmed?

Thanks

New member

Posts

Joined
Wed Jul 27, 2016 5:41 pm

Post by straightlight » Mon Aug 01, 2016 7:06 pm

darth_danny wrote:Hi,

I am trying to create a module that posts new order information when a new order is made (or payment is confirmed). I had gone as far as this script but needed some help. I intend to post the order information using curl once payment is confirmed but having some trouble finding a way of pulling new order information on payment confirmation (using Paypal standard)

Code: Select all

class ControllerModuleDelivery extends Controller {
    
    public function install() {
        $this->load->model('extension/event');
        $this->model_extension_event->addEvent('delivery', 'post.order.history.add', 'module/delivery/on_new_order');
    }
    
    public function uninstall() {
        $this->load->model('extension/event');
        $this->model_extension_event->deleteEvent('delivery');
    }
    
    public function on_new_order($order_id) {
        
    }
    
}
How would I proceed from here to send new order information once payment is confirmed?

Thanks
Which OC version are you using?

Do you have an API documentation you can provide on what actually needs to be sent to your provider in order to integrate the requirements?

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by darth_danny » Mon Aug 01, 2016 7:34 pm

Hi

I am using version 2.2.0.0. I basically needed: Products purchased information, address information and buyer information. The store I am setting up will be handling delivery so needed that information for my delivery API which accepts CURL posts.

New member

Posts

Joined
Wed Jul 27, 2016 5:41 pm

Post by straightlight » Mon Aug 01, 2016 7:40 pm

darth_danny wrote:Hi

I am using version 2.2.0.0. I basically needed: Products purchased information, address information and buyer information. The store I am setting up will be handling delivery so needed that information for my delivery API which accepts CURL posts.
Each providers typically have their own ways to send and receive data information throughout their API. With a provided API documentation from their website, it might be possible to integrate your request into Opencart.

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by darth_danny » Mon Aug 01, 2016 7:46 pm

hi,


So using the module script I had started on, it would be possible to get that order information and POST it to a custom URL?

Thanks

New member

Posts

Joined
Wed Jul 27, 2016 5:41 pm

Post by straightlight » Mon Aug 01, 2016 7:51 pm

darth_danny wrote:hi,


So using the module script I had started on, it would be possible to get that order information and POST it to a custom URL?

Thanks
As mentioned above; yes - by following their API documentation. If you require assistance, the minimum requirement would be the API documentation.

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by darth_danny » Mon Aug 01, 2016 8:26 pm

hi

The documentation isnt quite done yet but here is some sample code of the delivery API page that receives the POST on payment/new order confirmation

Code: Select all

<?php

include_once("delivery_request_include.php");


// Get POST XML From Vendor
$postdata = trim(file_get_contents('php://input'));

//check if any raw data is received
if($postdata)
{
    $transaction = simplexml_load_string($postdata);
    
    //check if xml object successfully created from raw input
    if($transaction)
    {
        $input_array = array();
        $input_array['clientEmail']     = trim($transaction->clientEmail);
        $input_array['firstName']       = trim($transaction->firstName);
        $input_array['lastName']        = trim($transaction->lastName);
        $input_array['receiverPhone']   = trim($transaction->receiverPhone);
        $input_array['dateWeSoldIt']    = trim($transaction->dateWeSoldIt);

        //check whether any essential delivery details are missing
        if (!empty(!empty($input_array['clientEmail']) && !empty($input_array['firstName']) && 
            !empty($input_array['lastName']) && !empty($input_array['receiverPhone']))
        {
            $insertIntoDB = insertIntoDB($input_array);
        }
    }
}
?>

New member

Posts

Joined
Wed Jul 27, 2016 5:41 pm

Post by straightlight » Mon Aug 01, 2016 8:32 pm

What does this file content includes?
include_once("delivery_request_include.php");
In addition, based on your first post, you wish to accomplish the request method with cURL which the post you indicated right above rather calls: file_get_contents().

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by darth_danny » Tue Aug 02, 2016 1:36 pm

Hi

Code: Select all


include_once("delivery_request_include.php");

contains the function that inserts the posted data into a database. Yes, the intention was to use curl to post the order information.

New member

Posts

Joined
Wed Jul 27, 2016 5:41 pm
Who is online

Users browsing this forum: No registered users and 21 guests