Gift cart is not sent after payment system sets the orders status to Confirmed


  • Your avatar
    seyi    
     4 years ago
    0

    We have successfully integrated you component and it works like charm, except one problem.

    We are using webtopay payment system for on-line payments. Then the customer purchase goods on the checkout he is redirected to payment system web page and after completing the on-line payment he is redirected back to our store.

    Webtopay system after the payment processed sets the order status to "confirmed" in Virtuemart.

    However webtopay server catches an error afterwords instead of "OK" confirmation.

    '

    Fatal error: Call to a member function setQuery() on a non-object in /administrator/components/com_awocoupon/assets/virtuemart/ps_awo_giftcert.php on line 625
    '

    Then purchased Giftcard is not sent automatically via mail. If I update the order status from backend Confirmed=>pending=>Confirmed, giftcard get to the client immediately. that gives a lots of headache to the backend manager.


    Giftcard should be sent automatically after payment system sets the order status to "Confirmed".

    Every time payment server catches the alarm it sends me email and that started to irritate me a lot...

    Can you help us with this situation?





  • Your avatar
    seyi    
     4 years ago
    0

    Hello,

    What version of AwoCoupon is this? There is nothing on line 625 of the current version of AwoCoupon Pro.
  • Default avatar
    automatikas    
     4 years ago
    0

    Hi,

    Awocoupon pro 1.4.4
    Virtuemart 1.1.9
    Joomla 1.5.23

  • Your avatar
    seyi    
     4 years ago
    0

    That is strange.

    The last line of 1.4.4 is 511. Can you open your ps_awo_giftcert.php file and see how many lines you have? Do you have any custom code within it?
  • Default avatar
    automatikas    
     4 years ago
    0

    It getting more weird....

    I just tied to reinstall the component com_awocoupon-PRO-1.4.4.zip all good no errors.

    Then if you open the file from server ps_awo_giftcert.php it contains around 1000 lines.

    If you manually overwrite then the file contains around 600 lines :))

    after manual injection of ps_awo_giftcert.php payment server catches the following:

    '

    Fatal error: Call to a member function setQuery() on a non-object in administrator/components/com_awocoupon/assets/virtuemart/ps_awo_giftcert.php on line 313
    '

    It happens if I try to buy a gift-card, if cart doesn't contain any coupon or gift card all goes fine.

    I see two problems:

    1. Gift card is not sent after order is set Confirmed by payment server.
    2. Awocoupon interupting the payment system to get an answer "OK" for payment server.


    ps_awo_giftcert.php file after installation
    *** REMOVED CODE ***
  • Your avatar
    seyi    
     4 years ago
    0

    this seems to be more of a problem with the payment server not setting some variables.

    In ps_awo_giftcert.php, around line 313, change

    <?php
        
    function use_code($product_id,&$used_codes) {
            global 
    $database;
    ?>


    to

    <?php
        
    function use_code($product_id,&$used_codes) {
            
    $database  = & JFactory::getDBO();
    ?>


    Hopefully that fixes the issue.
  • Default avatar
    automatikas    
     4 years ago
    0

    Hi Seyi Thanks for the tips, but this didn't helped.

    I would say the main problem is not that payment server get error, but the giftcard is not sent.

    There is tips from payment server received by email with error:

    Server sends data to: administrator/components/com_virtuemart/webtopay_notify.php, after data been processed it didn't had required answer "OK" text or you website was not reachable. So the payment server will ask your website for "OK" another two times.
    To avoid such a massages we ask that your website would return "OK" when our server asks for it and right after that perform the rest of the tasks. payment system waits for 10 s to receive an answer.



    webtopay_notify.php around the end there is a function to update the order status to Confirmed.

    <?php

        $messages 
    = Array();
        function 
    debug_msg$msg ) {
            global 
    $messages;
            if( @
    WEBTOPAY_DEBUG == "1" ) {
                if( !
    defined"_DEBUG_HEADER")  ) {
                    echo 
    " Webtopay Notify.php Debug OUTPUT";
                    
    define"_DEBUG_HEADER""1" );
                }
                
    $messages[] = "$msg";
                echo 
    end$messages );
            }
        }

        global 
    $mosConfig_absolute_path$mosConfig_live_site$mosConfig_lang$database,
        
    $mosConfig_mailfrom$mosConfig_fromname;

            
    $my_path dirname(__FILE__);

            if( 
    file_exists($my_path."/../../../configuration.php")) {
                
    $absolute_path dirname$my_path."/../../../configuration.php" );
                require_once(
    $my_path."/../../../configuration.php");
            }
            elseif( 
    file_exists($my_path."/../../configuration.php")){
                
    $absolute_path dirname$my_path."/../../configuration.php" );
                require_once(
    $my_path."/../../configuration.php");
            }
            elseif( 
    file_exists($my_path."/configuration.php")){
                
    $absolute_path dirname$my_path."/configuration.php" );
                require_once( 
    $my_path."/configuration.php" );
            }
            else {
                die( 
    "Joomla Configuration File not found!" );
            }

            
    $absolute_path realpath$absolute_path );

            
    // Set up the appropriate CMS framework
            
    if( class_exists'jconfig' ) ) {
                
    define'_JEXEC');
                
    define'JPATH_BASE'$absolute_path );
                
    define'DS'DIRECTORY_SEPARATOR );

                
    // Load the framework
                
    require_once ( JPATH_BASE DS 'includes' DS 'defines.php' );
                require_once ( 
    JPATH_BASE DS 'includes' DS 'framework.php' );

                
    // create the mainframe object
                
    $mainframe = & JFactory::getApplication'site' );

                
    // Initialize the framework
                
    $mainframe->initialise();

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

                
    // trigger the onBeforeStart events
                
    $mainframe->triggerEvent'onBeforeStart' );
                
    $lang =& JFactory::getLanguage();
                
    $mosConfig_lang $GLOBALS['mosConfig_lang'] = strtolower$lang->getBackwardLang() );
                
    // Adjust the live site path
                
    $mosConfig_live_site str_replace('/administrator/components/com_virtuemart'''JURI::base());
                
    $mosConfig_absolute_path JPATH_BASE;
            } else {
                
    define('_VALID_MOS''1');
                require_once(
    $mosConfig_absolute_path'/includes/joomla.php');
                require_once(
    $mosConfig_absolute_path'/includes/database.php');
                
    $database = new database$mosConfig_host$mosConfig_user$mosConfig_password$mosConfig_db$mosConfig_dbprefix );
                
    $mainframe = new mosMainFrame($database'com_virtuemart'$mosConfig_absolute_path );
            }

            
    // load Joomla Language File
            
    if (file_exists$mosConfig_absolute_path'/language/'.$mosConfig_lang.'.php' )) {
                require_once( 
    $mosConfig_absolute_path'/language/'.$mosConfig_lang.'.php' );
            }
            elseif (
    file_exists$mosConfig_absolute_path'/language/english.php' )) {
                require_once( 
    $mosConfig_absolute_path'/language/english.php' );
            }
        
    /*** END of Joomla config ***/

        
    debug_msg"1. Finished Initialization of the worldpay_notify.php script" );

        
    /*** VirtueMart part ***/

        
    define('PHPSHOPPATH'$mosConfig_absolute_path.'/administrator/components/com_virtuemart/');

        require_once( 
    PHPSHOPPATH."virtuemart.cfg.php");

        require_once( 
    CLASSPATH"language.class.php" );

        
    debug_msg"1a. Included language class" );


        
    //Set up the mailer to infor Warehouse of validated order
        //require_once( $mosConfig_absolute_path . '/includes/phpmailer/class.phpmailer.php');
        //$mail = new mosPHPMailer();
        //$mail->PluginDir = $mosConfig_absolute_path . '/includes/phpmailer/';
        //$mail->SetLanguage("en", $mosConfig_absolute_path . '/includes/phpmailer/language/');


        /* load the VirtueMart Language File */
       /* if (file_exists( ADMINPATH. 'languages/admin/'.$mosConfig_lang.'.php' )) {
          require_once( ADMINPATH. 'languages/admin/'.$mosConfig_lang.'.php' );
        } else {
          require_once( ADMINPATH. 'languages/admin/english.php' );
        }
        */
        
    debug_msg"2. Included admin language files" );  // this is a lie. but as the language isn't used it doesn't really matter.

        
    require_once( CLASSPATH'payment/ps_webtopay.cfg.php' );

        
    /* Load the VirtueMart database class */
        
    require_once( CLASSPATH'ps_database.php' );
        
    /*** END VirtueMart part ***/


        
    require_once( CLASSPATH'libwebtopay/WebToPay.php' );

        try {
            
    $orderid $_GET[WebToPay::PREFIX.'orderid'];
            
    $response WebToPay::checkResponse($_GET, array(
                    
    'projectid'     => WEBTOPAY_PROJECTID,
                    
    'sign_password' => WEBTOPAY_PROJECT_PASSWORD,
                    
    'orderid'       => $orderid,
                    
    'amount'        => $_GET[WebToPay::PREFIX.'amount'],
                    
    'currency'      => $_GET[WebToPay::PREFIX.'currency'],
                ));

            
    $d['order_id'] = $orderid;
            
    $d['order_status'] = WEBTOPAY_VERIFIED_STATUS;

            require_once ( 
    CLASSPATH 'ps_order.php' );
            
    $ps_order= new ps_order();
            
    $ps_order->order_status_update($d);

            echo 
    'OK';
        }
        catch (
    Exception $e) {
            echo 
    get_class($e).': '.$e->getMessage();
        }

        exit();
  • Your avatar
    seyi    
     4 years ago
    0

    from the code you posted, this is what is called to update the gift certificate:
    <?php
    require_once ( CLASSPATH 'ps_order.php' );
    $ps_order= new ps_order();
    $ps_order->order_status_update($d);
    ?>


    This is the exact same code called when you manually update the order from pending to confirmed.

    What is the error you are receiving this time?
  • Default avatar
    automatikas    
     4 years ago
    0

    It is the same error as i posted in my previous post.

    <?php
    require_once ( CLASSPATH 'ps_order.php' );
    $ps_order= new ps_order();
    $ps_order->order_status_update($d);
    echo 
    'OK';
    ?>


    Right after the $ps_order->order_status_update($d); it gives "OK" to the browser what the payment system is missing in this case. I'll test this tonight.

    question: when your component sending the giftcard? why the giftcard is not sent after I update the status with a code above?
  • Default avatar
    automatikas    
     4 years ago
    0

    I've tested some parts of the code:

    <?php

        
    global $mosConfig_absolute_path$mosConfig_live_site$mosConfig_lang$database,
        
    $mosConfig_mailfrom$mosConfig_fromname;

            
    $my_path dirname(__FILE__);

            if( 
    file_exists($my_path."/../../../configuration.php")) {
                
    $absolute_path dirname$my_path."/../../../configuration.php" );
                require_once(
    $my_path."/../../../configuration.php");
            }
            elseif( 
    file_exists($my_path."/../../configuration.php")){
                
    $absolute_path dirname$my_path."/../../configuration.php" );
                require_once(
    $my_path."/../../configuration.php");
            }
            elseif( 
    file_exists($my_path."/configuration.php")){
                
    $absolute_path dirname$my_path."/configuration.php" );
                require_once( 
    $my_path."/configuration.php" );
            }
            else {
                die( 
    "Joomla Configuration File not found!" );
            }

            
    $absolute_path realpath$absolute_path );

            
    // Set up the appropriate CMS framework
            
    if( class_exists'jconfig' ) ) {
                
    define'_JEXEC');
                
    define'JPATH_BASE'$absolute_path );
                
    define'DS'DIRECTORY_SEPARATOR );

                
    // Load the framework
                
    require_once ( JPATH_BASE DS 'includes' DS 'defines.php' );
                require_once ( 
    JPATH_BASE DS 'includes' DS 'framework.php' );

                
    // create the mainframe object
                
    $mainframe = & JFactory::getApplication'site' );

                
    // Initialize the framework
                
    $mainframe->initialise();

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

                
    // trigger the onBeforeStart events
                
    $mainframe->triggerEvent'onBeforeStart' );
                
    $lang =& JFactory::getLanguage();
                
    $mosConfig_lang $GLOBALS['mosConfig_lang'] = strtolower$lang->getBackwardLang() );
                
    // Adjust the live site path
                
    $mosConfig_live_site str_replace('/administrator/components/com_virtuemart'''JURI::base());
                
    $mosConfig_absolute_path JPATH_BASE;
            } else {
                
    define('_VALID_MOS''1');
                require_once(
    $mosConfig_absolute_path'/includes/joomla.php');
                require_once(
    $mosConfig_absolute_path'/includes/database.php');
                
    $database = new database$mosConfig_host$mosConfig_user$mosConfig_password$mosConfig_db$mosConfig_dbprefix );
                
    $mainframe = new mosMainFrame($database'com_virtuemart'$mosConfig_absolute_path );
            }

            
    // load Joomla Language File
            
    if (file_exists$mosConfig_absolute_path'/language/'.$mosConfig_lang.'.php' )) {
                require_once( 
    $mosConfig_absolute_path'/language/'.$mosConfig_lang.'.php' );
            }
            elseif (
    file_exists$mosConfig_absolute_path'/language/english.php' )) {
                require_once( 
    $mosConfig_absolute_path'/language/english.php' );
            }
        
    /*** END of Joomla config ***/

       // debug_msg( "1. Finished Initialization of the worldpay_notify.php script" );

        /*** VirtueMart part ***/

        
    define('PHPSHOPPATH'$mosConfig_absolute_path.'/administrator/components/com_virtuemart/');

        require_once( 
    PHPSHOPPATH."virtuemart.cfg.php");

        require_once( 
    CLASSPATH"language.class.php" );

        
    //debug_msg( "1a. Included language class" );


        //Set up the mailer to infor Warehouse of validated order
        //require_once( $mosConfig_absolute_path . '/includes/phpmailer/class.phpmailer.php');
        //$mail = new mosPHPMailer();
        //$mail->PluginDir = $mosConfig_absolute_path . '/includes/phpmailer/';
        //$mail->SetLanguage("en", $mosConfig_absolute_path . '/includes/phpmailer/language/');


        /* load the VirtueMart Language File */
       /* if (file_exists( ADMINPATH. 'languages/admin/'.$mosConfig_lang.'.php' )) {
          require_once( ADMINPATH. 'languages/admin/'.$mosConfig_lang.'.php' );
        } else {
          require_once( ADMINPATH. 'languages/admin/english.php' );
        }
        */
        //debug_msg( "2. Included admin language files" );  // this is a lie. but as the language isn't used it doesn't really matter.

       // require_once( CLASSPATH. 'payment/ps_webtopay.cfg.php' );

        /* Load the VirtueMart database class */
        
    require_once( CLASSPATH'ps_database.php' );
        
    /*** END VirtueMart part ***/


            
    $d['order_id'] = '290';
            
    $d['order_status'] = 'Q';

            require_once ( 
    CLASSPATH 'ps_order.php' );
            
    $ps_order= new ps_order();
            
    $ps_order->order_status_update($d);

            echo 
    'OK';
        
        exit();


    The results are:
    I can update any order status without problems with this code. When I set an order to 'A' and if order contains giftcard then it give error as it have to send an email and gets stuck there (email is not sent). If I set another status than 'A' Ect.: 'Q','C' the code works perfect and finishes with 'OK'

    Fatal error: Call to a member function setQuery() on a non-object in /administrator/components/com_awocoupon/assets/
    virtuemart/ps_awo_giftcert.php
    on line 313
  • Your avatar
    seyi    
     4 years ago
    0

    ran your code above, and got the same error.
    http://awodev.com/forum/awocoupon/help-section/gift-cart-not-sent-after-payment-system-sets-orders-status-c#comment-2659

    Is still the solution. Just do a search for ALL global $database and replace with the other form. That will fix the problem.
  • Default avatar
    automatikas    
     4 years ago
    0

    Seyi,

    good tip and No error anymore!

    But still there is another problem: Gift card is not sent after order is set as confirmed.

    Any ideas?

  • Your avatar
    seyi    
     4 years ago
    0

    Not sure, verify the below:
    - If you look on the configuration screen is the order status set to confirmed?
    - Is the www/tmp directory writeable?
    - do you have a default profile selected?
    - if you look in awocoupon->history of uses->orders, does your gift certificate show up there? if so, its been sent.
  • Default avatar
    automatikas    
     4 years ago
    0

    Hi Seyi

    All up and running, it was wrong setup in the gift profile.

    Thanks for the grate support!
  • Default avatar
    automatikas    
     4 years ago
    0

    Strange posts numbering :)

    you could clean this thread. 1,2,13,14 is not necessarily.

    Thanks for the support!



  • Default avatar
    murray    
     4 years ago
    0

    This comment has been moved here.