VirtueMart Forum

VirtueMart Dev/Coding Central: VM1 (old version) => Development Projects, Modifications, Hacks & Tweaks. VM1.1 => Payment Modules => Topic started by: grant on April 03, 2007, 03:45:52 AM

Title: Help geting 2checkout process to do the same as PayPal
Post by: grant on April 03, 2007, 03:45:52 AM
Hi all great job on the cart. I need to make 2checkout payment module do the same process as PayPal. At the end of the paypal checkout process you get redirected to the PayPal website. At the end of the 2 checkout process you have to click on a image to finnish the process.
Question?
How can I modify the 2chekout process to redirect stright to 2checkout and NOT have to click on the 2checkout image.
Thanks for reading or helping me with theis.
Grant
Title: Re: Help geting 2checkout process to do the same a
Post by: grant on April 03, 2007, 03:58:41 AM
I have downloaded the Developer Manual and turned on Debug. I still am trying to find out how to do this.
Thanks for any help.
Grant
Title: Re: Help geting 2checkout process to do the same a
Post by: grant on April 03, 2007, 05:05:52 AM
If someone could point me to where the post to 2checkout is
IE  https://www.2checkout.com/2co/etc.
Thanks
Grant
Title: Re: Help geting 2checkout process to do the same a
Post by: grant on April 05, 2007, 02:22:20 AM
Wow NoOne here to point me in the right direction on this. When all someone had to say was look in the mysql database at jos_vm_payment_method /2checkout/ExtraInfo I am only posting this to help others. Sad though.
Post Script: Great job on the cart good work.
Title: Re: Help geting 2checkout process to do the same as PayPal
Post by: gregdev on April 05, 2007, 03:56:18 AM
Hi Grant,

There are a lot of posts to try to answer on the forum. Some are unfortunately missed.

I'm glad you find a solution. There is a way to change that through the VIrtueMart user interface, though. In the VirtueMart administration area, from the menu, choose Store > List Payment Methods. Then choose 2Checkout, then the Configuration tab.

Greg
Title: Re: Help geting 2checkout process to do the same as PayPal
Post by: grant on April 05, 2007, 04:23:54 AM
Thanks I am new to joomla / virtuemart. So you can edit that info there. Nice to Know. If anyone is inetersted ask and I will post the code i modified to autoredirect to 2checkout.
Thanks Greg
Regards Grant
Title: Re: Help geting 2checkout process to do the same as PayPal
Post by: gregdev on April 05, 2007, 04:31:27 AM
I am interested. Also, you never know when some interested person will come by in the future. Please post the code.

Since I do not use 2Checkout, do you have any ideas why a person wouldn't want to be redirected there automatically?
Title: Re: Help geting 2checkout process to do the same as PayPal
Post by: grant on April 05, 2007, 04:39:48 AM
Hey Greg I think the desighn of the cart uses the same checkout process so people can clik on a link to print invoice. But for the 2checkout it is confusing when you see the conformation message and only a little lin of text telling you to click the image to finnish the 2checkout process. Here is the mod_code.
Just modify the form at the bottom. and a little javascript to do the job.
<<<<<<<<<<<<<<<<<<Begin Code>>>>>>>>>>>>>>>>>>>>>>>>>>
<form id="cho" action="<?php echo $url ?>" method="post" target="_self">
   <?php echo $poststring ?>
   <p>Click on the Image below to pay...</p>
   <input type="image" name="submit" src="https://www.2checkout.com/images/buy_logo.gif" border="0" alt="Make payments with 2Checkout, it's fast and secure!" title="Pay your Order with 2Checkout, it's fast and secure!" />
   </form>S
   <script language="JavaScript" type="text/javascript">
   <!--
   document.getElementById('cho').submit();
   //-->
   </script>
<<<<<<<<<<<<<<<<<<<<EndCodeModify>>>>>>>>>>>>>>>>>>>>
Tip: I use _self so they get shot right to 2checkout. YOu can use _blank to open up in a new browser and still show your thankyou page.
Regards
Grant
Title: Re: Help geting 2checkout process to do the same as PayPal
Post by: Ruppert on September 27, 2008, 17:10:31 PM

I found that the javascript redirect sometimes is blocked by the browser. So inspired by the Paypal code, I'm doing a VM redirect instead.

if( $page == "checkout.thankyou" ) {
    $query_string = "?";
    foreach( $formdata as $name => $value ) {
    $query_string .= $name. "=" . urlencode($value) ."&";
    }
    vmRedirect( $url . $query_string );
}
else {

//build the post string
       $poststring = '';
       
   foreach($formdata AS $key => $val){
          $poststring .= "<input type='hidden' name='$key' value='$val' />
          ";
    }   
?>
    <form id="cho" action="<?php echo $url ?>" method="post" target="_blank">
       <?php echo $poststring ?>
    <p><font size=+4>Click on the Image below to pay...</font></p>
     <input type="image" name="submit" src="https://www.2checkout.com/images/buy_logo.gif" border="0" alt="Make payments with 2Checkout, it's fast and secure!" title="Pay your Order with 2Checkout, it's fast and secure!" />
      </form>

   <!-- Uncomment if you want to try a javascript redirect no matter what -->
   <!-- script language="JavaScript" type="text/javascript">
   document.getElementById('cho').submit();
   </script -->
   
<?php 
}
?>


The whole code is here:

<?php
  
       
// Get ship_to information
    
if( $db->f("user_info_id") != $dbbt->f("user_info_id")) {
         
$q2  "SELECT * FROM #__vm_user_info WHERE user_info_id='".$db->f("user_info_id")."'"
    
$dbst = new ps_DB;
   
$dbst->setQuery($q2);
       
$dbst->query();
      
$dbst->next_record();
      }
     else  {
         
$dbst $dbbt;
    }

              
      
//Authnet vars to send
        
$formdata = array (
   
'x_login' => TWOCO_LOGIN,
   
'x_email_merchant' => ((TWOCO_MERCHANT_EMAIL == 'True') ? 'TRUE' 'FALSE'),
                  
      
// Customer Name and Billing Address
  
'x_first_name' => $dbbt->f("first_name"),
        
'x_last_name' => $dbbt->f("last_name"),
  
'x_company' => $dbbt->f("company"),
      
'x_address' => $dbbt->f("address_1"),
    
'x_city' => $dbbt->f("city"),
    
'x_state' => $dbbt->f("state"),
  
'x_zip' => $dbbt->f("zip"),
      
'x_country' => $dbbt->f("country"),
      
'x_phone' => $dbbt->f("phone_1"),
        
'x_fax' => $dbbt->f("fax"),
      
'x_email' => $dbbt->f("email"),
 
       
// Customer Shipping Address
  
'x_ship_to_first_name' => $dbst->f("first_name"),
        
'x_ship_to_last_name' => $dbst->f("last_name"),
  
'x_ship_to_company' => $dbst->f("company"),
      
'x_ship_to_address' => $dbst->f("address_1"),
    
'x_ship_to_city' => $dbst->f("city"),
    
'x_ship_to_state' => $dbst->f("state"),
  
'x_ship_to_zip' => $dbst->f("zip"),
      
'x_ship_to_country' => $dbst->f("country"),
     
       
'x_invoice_num' => $db->f("order_number"),
       
'x_receipt_link_url' => SECUREURL."2checkout_notify.php",
  );
    
     if( 
TWOCO_TESTMODE == "Y" )
   
$formdata['demo'] = "Y";
       
       
$version "2";
    
$url "https://www2.2checkout.com/2co/buyer/purchase";
    
$formdata['x_amount'] = number_format($db->f("order_total"), 2'.''');
 
      
if( 
$page == "checkout.thankyou" ) {
    
$query_string "?";
    foreach( 
$formdata as $name => $value ) {
    
$query_string .= $name"=" urlencode($value) ."&";
    }
    
vmRedirect$url $query_string );
}
else {

//build the post string
       
$poststring '';
       
   foreach(
$formdata AS $key => $val){
          
$poststring .= "<input type='hidden' name='$key' value='$val' />
          "
;
    }    
?>

    <form id="cho" action="<?php echo $url ?>" method="post" target="_blank">
       <?php echo $poststring ?>
    <p><font size=+4>Click on the Image below to pay...</font></p>
     <input type="image" name="submit" src="https://www.2checkout.com/images/buy_logo.gif" border="0" alt="Make payments with 2Checkout, it's fast and secure!" title="Pay your Order with 2Checkout, it's fast and secure!" />
      </form>
 
   <!-- Uncomment if you want to try a javascript redirect no matter what -->
   <!-- script language="JavaScript" type="text/javascript">
   document.getElementById('cho').submit();
   </script -->
   
<?php 
}
?>


This includes the fix for ignored costumer billing address at http://forum.virtuemart.net/index.php?topic=44314.msg147775#msg147775 (http://forum.virtuemart.net/index.php?topic=44314.msg147775#msg147775)

Ruppert.