Author Topic: <Proceed to Payment Page> Where is it?  (Read 23421 times)

artguy101

  • Beginner
  • *
  • Posts: 40
<Proceed to Payment Page> Where is it?
« on: May 15, 2008, 17:04:05 pm »
I'm trying to streamline my checkout by auto-submitting the payment form to WorldPay using this javascript code:

<script type="text/javascript">
function myfunc () {
var frm = document.getElementById("foo");
frm.submit();
}
window.onload = myfunc;
</script>

Problem is:  The form doesn't have a name=""

So, does anyone know which file generates this form???  Then I can add a name and get it to auto submit - thereby saving my clients a useless step.


Unless someone can tell me how to have that form appear on the previous page where you agree to terms or service.

Thansk.

artguy101

  • Beginner
  • *
  • Posts: 40
Re: <Proceed to Payment Page> Where is it?
« Reply #1 on: May 15, 2008, 17:41:50 pm »
I answered my own question:
The form is found in the Admin Panel of Virtuemart (no need to go digging through code).
Look in the Payment Method List --> WorldPay --> configuration
I changed the code to this:
Code: [Select]
<form action="https://select.worldpay.com/wcc/purchase" method="post" name="worldpayform">
  <input type=hidden name="testMode" value="0">
  <input type="hidden" name="instId" value="<?php echo WORLDPAY_INST_ID ?>" />
  <input type="hidden" name="cartId" value="<?php echo $db->f("order_id"?>" />
  <input type="hidden" name="amount" value="<?php echo $db->f("order_total"?>" />
  <input type="hidden" name="currency" value="<?php echo $_SESSION['vendor_currency'?>" />
  <input type="hidden" name="desc" value="Products" />
  <input type="hidden" name="email" value="<?php echo $user->email?>" />
  <input type="hidden" name="address" value="<?php echo $user->address_1?>&#10<?php echo $user->address_2?>&#10<?php echo
&
#160; $user->city?>
&#10<?php echo $user->state?>" />
  <input type="hidden" name="name" value="<?php echo $user->title?><?php echo $user->first_name?>. <?php echo $user->middle_name?><?php echo $user->last_name?>" />
  <input type="hidden" name="country" value="<?php echo $user->country?>"/>
  <input type="hidden" name="postcode" value="<?php echo $user->zip?>" />
  <input type="hidden" name="tel"  value="<?php echo $user->phone_1?>">
  <input type="hidden" name="withDelivery"  value="true">
  <br />
  </form>
<script type="text/javascript">
function myfunc () {
var frm = document.getElementById("worldpayform");
frm.submit();
}
window.onload = myfunc;
</script>
Make sure to name the form!
Then, in /administrator/components/com_virtuemart/html/checkout.thankyou.php
I winnowed the code down to this:
Code: [Select]
<?php
defined
'_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' );
/**
* This file is called after the order has been placed by the customer
*
* @version $Id: checkout.thankyou.php 862 2007-06-19 01:21:13Z gregdev $
* @package VirtueMart
* @subpackage html
* @copyright Copyright (C) 2004-2005 Soeren Eberhardt. All rights reserved.
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php
* VirtueMart is free software. This version may have been modified pursuant
* to the GNU General Public License, and as distributed it includes or
* is derivative of works licensed under the GNU General Public License or
* other free or open source software licenses.
* See /administrator/components/com_virtuemart/COPYRIGHT.php for copyright notices and details.
*
* http://virtuemart.net
*/
mm_showMyFileName__FILE__ );
require_once(
CLASSPATH.'ps_product.php');
$ps_product= new ps_product;
global 
$vendor_currency;
// Order_id is returned by checkoutComplete function
$order_id $GLOBALS['vmInputFilter']->process$vars["order_id"] );
$print mosgetparam$_REQUEST'print'0);
/** Retrieve User Email **/
$q&#160; = "SELECT * FROM #__{vm}_order_user_info WHERE order_id='$order_id' AND address_type='BT'";
$db->query$q );
$db->next_record();
$user $db->record[0];
$dbbt $db->_clone$db );
$user->email $db->f("user_email");
/** Retrieve Order & Payment Info **/
$db = new ps_DB;
$q&#160; = "SELECT * FROM (#__{vm}_order_payment LEFT JOIN #__{vm}_payment_method ";
$q .= "ON #__{vm}_payment_method.payment_method_id&#160; = #__{vm}_order_payment.payment_method_id), #__{vm}_orders ";
$q .= "WHERE #__{vm}_order_payment.order_id='$order_id' ";
$q .= "AND #__{vm}_orders.user_id='" $auth["user_id"] . "' ";
$q .= "AND #__{vm}_orders.order_id='$order_id' ";
$db->query($q);
if (
$db->next_record()) {
?>

<h3><?php echo $VM_LANG->_PHPSHOP_THANKYOU ?></h3>
 
<!-- Begin Payment Information -->
<?php
if ($db->f("order_status") == "P" ) {
// Copy the db object to prevent it gets altered
$db_temp ps_DB::_clone$db );
/** Start printing out HTML Form code (Payment Extra Info) **/ ?>

<br />
<table width="100%">
  <tr>
    <td width="100%" align="center">
    <?php 
&#160; &#160; /* Try to get PayPal/PayMate/Worldpay/whatever Configuration File */
&#160; &#160; @include( CLASSPATH."payment/".$db->f("payment_class").".cfg.php" );
&#160; &#160; 
echo DEBUG vmCommonHTML::getInfoField('Beginning to parse the payment extra info code...' ) : '';
&
#160; &#160; // Here's the place where the Payment Extra Form Code is included
&#160; &#160; // Thanks to Steve for this solution (why make it complicated...?)
&#160; &#160; if( eval('?>
' . $db->f("payment_extrainfo") . '<?php ') === false ) {
&#160; &#160;  echo vmCommonHTML::getErrorField( "Error: The code of the payment method ".$db->f( '
payment_method_name').' ('.$db->f('payment_method_code').''
&#160; &#160;  .'
contains a Parse Error!<br />Please correct that first' );
&#160; &#160; }
&#160; &#160; else {
&#160; &#160;  echo DEBUG ? vmCommonHTML::getInfoField('
Successfully parsed the payment extra info code.' ) : '';
&#160; &#160; }
&#160; &#160; /** END printing out HTML Form code (Payment Extra Info) **/
&#160; &#160; &#160; ?>

    </td>
  </tr>
</table>
<br />
<?php
$db 
$db_temp;
}
?>

<?php
/* End of security check */
?>

Now, when clients click "Proceed with Order", they see a blank screen and are then taken autmoatically to World Pay.
It saves a very confusing step!