You may pay someone to create your store, or you visit our seminar and become a professional yourself with the silver certification

Main Menu

My updated worldpay_notify.php

Started by drpop, August 28, 2007, 12:38:00 PM

Previous topic - Next topic


Worldpay and download_id mails just weren't playing nice on my VM. I couldn't find anyone else with the same problems, in fact, I couldn't find anyone using worldpay and downloads. Payment would process, order would update to confirmed via callback, but no download_id mail would be sent. Manually switching the order back to pending, then to confirmed again would get the mal out ok, but it just wouldnt work automatically via the worldpay_notify.

To this end I tweaked the stock worldpay_notify.php with chunks from notify.php and now all is fine.

Theres probably a pile of stuff in here I dont need and I am sure someone could tidy it up but for what its worth, and in the hope of helping someone else in this situation here is my updated worldpay_notify.php,

* @version $Id: worldpay_notify.php 617 2007-01-04 19:43:08Z soeren_nb $
* @package VirtueMart
* @subpackage Payment
* @copyright (C) 2004 Soeren Eberhardt
* @license GNU/GPL
* VirtueMart is Free Software.
* VirtueMart comes with absolute no warranty.

$messages = Array();
debug_msg$msg ) {
PAYPAL_DEBUG == "1" ) {
        if( !
defined"_DEBUG_HEADER")  ) {
"<h2>PayPal Notify.php Debug OUTPUT</h2>";
define"_DEBUG_HEADER""1" );
$messages[] = "<pre>$msg</pre>";
end$messages );

if (
$_POST) {
header("Status: 200 OK");
/*** access Joomla's configuration file ***/
$my_path dirname(__FILE__);
file_exists($my_path."/../../../configuration.php")) {
$my_path."/configuration.php" );
"Joomla Configuration File not found!" );
$my_path.'/compat.joomla1.5.php' );
class_exists'jconfig')) {
define('JPATH_BASE'$mosConfig_absolute_path );

require_once ( JPATH_BASE .'/includes/defines.php' );
require_once ( JPATH_BASE .'/includes/application.php' );
require_once ( JPATH_BASE'/includes/database.php');
// create the mainframe object
$mainframe = new JSite();

// set the configuration
$mainframe->setConfiguration(JPATH_CONFIGURATION DS 'configuration.php');

// load system plugin group
JPluginHelper::importPlugin'system' );

// trigger the onStart events
$mainframe->triggerEvent'onBeforeStart' );

// create the session
$mainframe->setSession$mainframe->getCfg('live_site').$mainframe->getClientId() );
$database =& JFactory::getDBO();
        else {

$database = new database$mosConfig_host$mosConfig_user$mosConfig_password$mosConfig_db$mosConfig_dbprefix );
// load Joomla Language File
if (file_exists$mosConfig_absolute_path'/language/'.$mosConfig_lang.'.php' )) {
$mosConfig_absolute_path'/language/'.$mosConfig_lang.'.php' );
        elseif (
file_exists$mosConfig_absolute_path'/language/english.php' )) {
$mosConfig_absolute_path'/language/english.php' );
/*** END of Joomla config ***/
    /*** VirtueMart part ***/        
require_once( CLASSPATH"language.class.php" );
$vmLoggerConf = array(
'buffering' => true
 * This Log Object will help us log messages and errors
 * See
 * @global Log vmLogger
$vmLogger = &vmLog::singleton('display'''''$vmLoggerConfPEAR_LOG_TIP);
$GLOBALS['vmLogger'] =& $vmLogger;

CLASSPATH 'phpmailer/class.phpmailer.php');
$mail = new vmPHPMailer();
$mail->PluginDir CLASSPATH 'phpmailer/';
$mail->SetLanguage("en"CLASSPATH 'phpmailer/language/');
/* load the VirtueMart Language File */
if (file_existsADMINPATH'languages/'.$mosConfig_lang.'.php' ))
ADMINPATH'languages/'.$mosConfig_lang.'.php' );
ADMINPATH'languages/english.php' );
/* Load the Worldpay Configuration File */ 
require_once( CLASSPATH'payment/ps_worldpay.cfg.php' );
/* Load the VirtueMart database class */
require_once( CLASSPATH'ps_database.php' );
    // restart session

    // Constructor initializes the session!
    $sess = new ps_session();                        
    // Include globals; for this, $db is needed, as is htmlTools.class.php
    $db = new ps_DB;
    require_once( CLASSPATH'htmlTools.class.php' );
    require_once( ADMINPATH'global.php' );
/*** END VirtueMart part ***/

    Read in the post from worldpay.
    Email was used in PayPal version

$workstring 'cmd=_notify-validate'// Notify validate
$i 1;
    foreach (
$_POST as $ipnkey => $ipnval) {
        if (
// Fix issue with magic quotes
$ipnval stripslashes ($ipnval);
       if (!
eregi("^[_0-9a-z-]{1,30}$",$ipnkey)  || !strcasecmp ($ipnkey'cmd'))  { 
// ^ Antidote to potential variable injection and poisoning
unset ($ipnkey); 
            unset (
// Eliminate the above
        // Remove empty keys (not values)
if (@$ipnkey != '') { 
//unset ($_POST); // Destroy the original ipn post array, sniff...
"key ".$i++.": $ipnkey, value: $ipnval<br />";
// Notify string

$payment_status  trim(stripslashes($_POST['transStatus'])); //if $payment_status == 'Y'?
$order_id =  trim(stripslashes($_POST['cartId']));
$d['order_id'] = $order_id;    //this identifies the order record

if( $payment_status == 'Y' ){
$d['order_status'] = 'C';  //this is the new value for the database field I think X for cancelled, C for confirmed
    else if( 
$payment_status == 'C' ){
$d['order_status'] = 'X';  //this is the new value for the database field I think X for cancelled, C for confirmed

    require_once ( 
CLASSPATH 'ps_order.php' );

$ps_order= new ps_order;




Doesn't work for me.  All I get is a Restricted Access error.  I've double checked the callback url, uploaded the worldpay_notify.php again, tested again.  Just a blank page with 'Restricted Access'.

Any ideas?  This is the last part of the setup for me and I just want it over with...
Geek to the extreme...


Now I will use worldpay because Paypal sucks, but still I use it.

Since I don't need to send downloads id, only the change of the status the original notify worked fine for me.


Geek to the extreme...


I replyied your PM.

Have you configured your installation ID in the virtuemart payment module editor. If you have enabled and configured your WP admin panel with your callback url now that should work.


Geek to the extreme...


I have updated the callback url to and set it to full read/write access (to be on the safe side).  Even waited a few hours because I know some changes on Worldpay's servers can take some time to update. 

I tried a sale, and no luck.  I'm beginning to wonder if the worldpay_notify is using deprecated functions in Joomla?

FWIW - Joomla 1.5 RC3, Virtuemart 1.1 Beta2.
Geek to the extreme...


I'm getting the same. Was this ever solved?

J! 1.5.22
VM 1.1.8

Sales are processed but customer just sees a blank page with 'Restricted access' after payment.

Quick Reply

Warning: this topic has not been posted in for at least 120 days.
Unless you're sure you want to reply, please consider starting a new topic.

Please leave this box empty:
Type the letters shown in the picture
Listen to the letters / Request another image

Type the letters shown in the picture:
Shortcuts: ALT+S post or ALT+P preview