Paypal in iframe at Thank You Page (Virtuemart)

Paypal in iframe at Thank You Page (Virtuemart)

Postby admin » Thu Dec 01, 2011 6:28 pm

We just found a way how to load your Website Payments Pro Hosted Solution in an iframe of your site. Please find your PayPal legacy payment method at your Components -> Virtuemart -> Store -> List payment methods -> Choose Paypal Legacy

Located here
/administrator/index.php?pshop_mode=admin&page=store.payment_method_list&option=com_virtuemart

Make sure that Payment class name is "ps_paypal", nothing else and at the extra information you can use this code:

Code: Select all
<?php
$db1 = new ps_DB();
$q = "SELECT country_2_code FROM #__vm_country WHERE country_3_code='".$user->country."' ORDER BY country_2_code ASC";
$db1->query($q);
?>
<iframe name="hss_iframe" width="570px" height="540px"></iframe> 
<form style="display:none" target="hss_iframe" name="form_iframe"
method="post" action="https://securepayments.paypal.com/cgi-bin/acquiringweb">
<input type="hidden" name="cmd" value="_hosted-payment">
<input type="hidden" name="notify_url" value="<?php echo SECUREURL ."administrator/components/com_virtuemart/notify.php"; ?>" >
<?php
$tax_total = $db->f("order_tax");
$discount_total = $db->f("coupon_discount") + $db->f("order_discount");
if (empty($discount_total)) $discount_total = 0;
if (empty($tax_total)) $tax_total = 0;
$total = $db->f("order_subtotal")+$tax_total-$discount_total;
?>
<input type="hidden" name="subtotal" value="<?php echo $total; ?>">
<input type="hidden" name="invoice" value="<?php echo $db->f("order_number"); ?>">
<input type="hidden" name="business" value="<?php echo PAYPAL_EMAIL; ?>">
<input type="hidden" name="paymentaction" value="sale">
<input type="hidden" name="template" value="templateD">
<?php
$post_variables = Array(
"address_override" => "1",
"billing_first_name" => $dbbt->f('first_name'),
"billing_last_name" => $dbbt->f('last_name'),
"billing_address1" => $dbbt->f('address_1'),
"billing_address2" => $dbbt->f('address_2'),
"billing_zip" => $dbbt->f('zip'),
"billing_city" => $dbbt->f('city'),
"billing_state" => $dbbt->f('state'),
"billing_country" => $db1->f('country_2_code'),
"email" => $dbbt->f('user_email'), );
foreach( $post_variables as $name => $value ) {
echo '<input type="hidden" name="'.$name.'" value="'.htmlspecialchars($value).'" />';
}
?>
<input type name="return" value="<?php echo SECUREURL ."index.php?option=com_virtuemart&page=checkout.result&order_id=".$db->f("order_id"); ?>">
</form>
<script type="text/javascript">
     document.form_iframe.submit();
</script>


Important
Please configre your Paypal Mechant ID as your paypal email in the config above. Also make sure to select "confirmed" status for paid orders. You can also configure One Page Checkout to send order status emails after the sucessfull payment.

Best Regards,
Stan
admin
Site Admin
 
Posts: 2708
Joined: Wed Jan 06, 2010 11:43 pm

Return to One Page Checkout for Virtuemart 1.1.x