News:

Looking for documentation? Take a look on our wiki

Main Menu

Help geting 2checkout process to do the same as PayPal

Started by grant, April 03, 2007, 03:45:52 AM

Previous topic - Next topic

grant

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

grant

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

grant

If someone could point me to where the post to 2checkout is
IE  https://www.2checkout.com/2co/etc.
Thanks
Grant

grant

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.

gregdev

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

[tr][td]
[/td][td]
www.plainlycode.com[/td][/tr]
[/table]

grant

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

gregdev

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?

[tr][td]
[/td][td]
www.plainlycode.com[/td][/tr]
[/table]

grant

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

Ruppert


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

Ruppert.

Ruppert.

________________________
VM 1.1.3
Joomla 1.5.9