2co not waiting for PASS email to activate account fix

Discussion in 'Payments processing' started by youjoomla, Nov 7, 2010.

  1. youjoomla

    youjoomla Member

    Joined:
    May 15, 2007
    Messages:
    61
    By default the 2co plugin does not wait for Order passed email to activate the user account. If you run a website with downloadable goods this can be a big issue since 2co fraud check process can take up to 6h and in meantime the user can download from your website and after 6h you get email stating Order failed.

    I looked trough the plugin code and find out that there is no action on FRAUD_STATUS_CHANGED email which are the ones that we need.

    So to fix this issue and have amember wait for the email FIRST BACKUP!!!!!!
    amember/plugins/payment/twocheckout_r/inc.php


    than open


    amember/plugins/payment/twocheckout_r/inc.php

    around line 188 - 193 find

    Code:
                    $err = $db->finish_waiting_payment($payment_id,
                        'twocheckout_r', 
                        $vars['order_number']?$vars['order_number']:$vars['x_trans_id'],
                         '', $vars);
                    if ($err)
                        return "finish_waiting_payment error: $err";
    Change it to


    Code:
                   $err = "YOUR MESSAGE TO CUSTOMER ADVISING THAT 2CO FRAUD CHECK IS IN PROCESS .";
                    if ($err)
                        return "Your order is pending: $err";




    next step is to kill the account activation on signup

    around line 238 -244 find



    Code:
    	    case 'ORDER_CREATED' : //Order creation is a new order placed online by a customer
                if (!$p['completed']){
    
                    $db->finish_waiting_payment($p['payment_id'], $this->get_plugin_name(), $vars['invoice_id'], '', $vars);
                    
                }
                break;
    change to

    Code:
    	    case 'ORDER_CREATED' : //Order creation is a new order placed online by a customer
      			 //nothing need to do there
                break;
    now let us wait for that email ,

    line 247
    Code:
            case 'FRAUD_STATUS_CHANGED' :
                //nothing need to do there
                break;
    change to

    Code:
            case 'FRAUD_STATUS_CHANGED' :
    			// CHANGED BY YOUJOOMLA
    			if ($vars['fraud_status'] =='pass'){
    						  
    				$db->finish_waiting_payment($p['payment_id'], $this->get_plugin_name(), $vars['sale_id'], '', $vars);
    			}
    			// END BY YOUJOOMLA
                break;
    
    finally you can relax , no order will be activated until Order Passed email comes along , just make sure that you have setup all 2co notifications email to go to you

    http://www.YOUR_SITE_NAME.com/amember/plugins/payment/twocheckout_r/ipn.php


    you might also notice that before this change , you were never able to find the order in amember by the 2co Order ID ,

    for example you get the order passed email with something like
    Vendor ID Order ID Comments
    XXXXXX 43XXXXXX


    If you entered order ID in amember search , you were not able to find your order , reason for this is the plugin was actually putting in your customer invoice # in Receipt # which we don't need at all. We need our order Sale ID # ,

    this is also changed in above addon from

    $vars['invoice_id'] to $vars['sale_id']

    now when you get that email and input the order ID within amamber admin search box you will find that order.

Share This Page