URGENT Possible to 'post' successful order details to a third party for fulfilment?

Permalink
Hi there guys, any help you can provide is SERIOUSLY INVALUABLE at this time... I won't go into details...

I currently use paypal on my clients site but we require the use of this add-on, however we need to keep the third party fulfilment for the products meaning that we need a successful sale to post its variables to the third party's queue system.

IS IT POSSIBLE TO DO THIS through eCommerce?

The code currently in place (via paypal usage) is attached.

Thank you so, so much.

1 Attachment

 
mesuva replied on at Permalink Best Answer Reply
mesuva
Yes, it is possible to have concrete5/eCommerce perform additional actions when orders are successfully put through, through the use of concrete5's 'events' system.

It would be a case of utilising the 'core_commerce_change_order_status' event that gets fired when the status of an order gets changed. Your code would check if the status got changed to STATUS_AUTHORIZED and would then fire off your custom code.

Seehttp://www.concrete5.org/documentation/developers/system/events... for an overview of concrete5's built in events, eCommerce just adds more events.

I've used this two times lately: to send additional notification emails (i.e. an email to a warehouse to let them know an order can be dispatched) as well as in a case where a third-party authentication API needed to be hit, to give a customer access to some digital resources.

This requires custom development (in my two cases I built new packages), but fortunately it doesn't require overriding or hacking eCommerce, just hooking into the events.

Here's a generic/stripped version of one of the package controllers I've developed (it's perhaps lazy that I've put the actual behaviour code inside the package controller, but it works fine):

<?php 
defined('C5_EXECUTE') or die(_("Access Denied."));
class CoreCommerceOrderStatusChangePackage extends Package {
   protected $pkgHandle = 'core_commerce_order_status_change';
   protected $appVersionRequired = '5.6.2.1';
   protected $pkgVersion = '0.9.1';
   public function getPackageDescription() {
      return t("Fire custom code when an order status changes");
   }
   public function getPackageName() {
      return t("Fire custom code when an order status changes");
   }
    public function on_start() {
        // extend the order change event here. (refers to a function in this file)
        Events::extend('core_commerce_change_order_status', 'CoreCommerceOrderStatusChangePackage', 'customCode', __FILE__);


One thing to add is that I think it's better to tie this kind of behaviour to the change of status rather than trying to tie it into the actual Paypal payment process - you may down the track want to provide different methods of payment, but you'd still want to trigger off notifications if the order was manually flicked to authorized via the dashboard.

Hope that helps
jem1516 replied on at Permalink Reply
This is INSANELY helpful, so my initial thanks.

However, I am by no means brilliant with php, let me, if I may include the code I need to execute (taken from it's current working form from my clients site):-

<?php
$req = 'cmd=_notify-validate';
$username = "********";
$password = "********";
$hostname = "********";
$dbhl = mysql_connect($hostname, $username, $password)
   or die("Unable to connect to MySQL");
$dbl = mysql_select_db("logging",$dbhl)
   or die("Could not select logging");
$sql = "SET NAMES 'utf8'";
mysql_query($sql);
foreach ($_POST as $key => $value)
{
   $value = urlencode(stripslashes($value));
   $req .= "&$key=$value";


The above is obviously in place to use paypal, however as you state, I do want this code to be fired at the ecommerce top level and not payment gateway level - it needs to send the required information to the third party fulfilment company's system, 'iQue'.

Any further help you could provide would be invaluable, I have posted in the jobs section but to no avail... obviously I am more than happy to pay for your services if you could assist! I have been let down by 2 developers now.

Thank you so much.