VirtueMart Forum

VirtueMart 1.1.x [ Old version - no longer supported ] => Payment VM 1.1 => PayPal / PayPal Pro VM 1.1 => Topic started by: apex2apex on June 22, 2008, 19:32:50 PM

Title: Passing Cart Details to PayPal for Payment
Post by: apex2apex on June 22, 2008, 19:32:50 PM
I recently set up a new virtuemart cart and am using paypal for all payments.  Currently when users click "confirm order" and are sent to paypal, virtuemart only sends an order number along with the payment total.

How can I make virtuemart pass the cart details and not just a total price and order number?
Title: Re: Passing Cart Details to PayPal for Payment
Post by: john dowling on August 12, 2008, 18:26:48 PM
I too am looking for the same thing?
Title: Re: Passing Cart Details to PayPal for Payment
Post by: apex2apex on August 12, 2008, 18:58:53 PM
I found this posted in another thread and its been working for me

copy everything below into the payment extra info box in the configuration tab for paypal
remember to edit the put-your-domain-here.com part


<?php


$order_id = $db->f("order_id");
$dboi = new ps_DB;
$q_oi = "SELECT * FROM #__vm_order_item ";
$q_oi .= "WHERE #__vm_order_item.order_id='$order_id'";
$dboi->query($q_oi);
$description = "PUT-YOUR-DOMAIN-HERE.COM";
$row_num = $dboi->num_rows();
$i=1;
while($dboi->next_record()) {
   
    $supp_var['item_name_' . $i] = $dboi->f("order_item_name");
    $supp_var['quantity_' . $i] = $dboi->f("product_quantity");
    $supp_var['amount_' . $i] = round($dboi->f("product_final_price"),2);
    $i++;
}

// "item_name" => $VM_LANG->_PHPSHOP_ORDER_PRINT_PO_NUMBER.": ". $db->f("order_id"),

// insert paypal url here
$url = "https://www.paypal.com/cgi-bin/webscr";

$tax_total = $db->f("order_tax") + $db->f("order_shipping_tax");
$post_variables = Array(
    "cmd" => "_cart",
    "upload" => "1",
    "business" => PAYPAL_EMAIL,
    "receiver_email" => PAYPAL_EMAIL,
    // "item_name_1" => "Basket total for your order: ". $db->f("order_id"),
    "order_id" => $db->f("order_id"),
    "invoice" => $db->f("order_number"),
    // "amount_1" => round( $db->f("order_subtotal")+$tax_total, 2),
    "shipping_1" => sprintf("%.2f", $db->f("order_shipping")),
    "currency_code" => $_SESSION['vendor_currency'],
    "return" => SECUREURL ."index.php?option=com_virtuemart&page=checkout.result&order_id=".$db->f("order_id"),
    "notify_url" => SECUREURL ."administrator/components/com_virtuemart/notify.php",
    "cancel_return" => SECUREURL ."index.php",
    "undefined_quantity" => "0",
    "test_ipn" => PAYPAL_DEBUG,
    "pal" => "",
    "no_shipping" => "1",
    "no_note" => "1"
);
if( $page == "checkout.thankyou" ) {
    $query_string = "?";
    foreach( $post_variables as $name => $value ) {
        $query_string .= $name. "=" . urlencode($value) ."&";
    }

        if(is_array($supp_var) && count($supp_var)) {
           foreach($supp_var as $name => $value) {
             $query_string .= $name. "=" . urlencode($value) ."&";
      }
        }
    mosRedirect( $url . $query_string );
}
else {

    echo '<form action="'.$url.'" method="post" target="_blank">';
    echo '<input type="image" name="submit" src="http://images.paypal.com/images/x-click-but6.gif" border="0" alt="Make payments with PayPal, it is fast, free, and secure!">';

    foreach( $post_variables as $name => $value ) {
        echo '<input type="hidden" name="'.$name.'" value="'.$value.'" />';
    }



if(is_array($supp_var) && count($supp_var)) {
   foreach($supp_var as $name => $value) {
      echo '<input type="hidden" name="'.$name.'" value="'.$value.'" />';
      }
}


    echo '</form>';

}

?>
Title: Re: Passing Cart Details to PayPal for Payment
Post by: john dowling on August 12, 2008, 19:13:43 PM
Works great, thanks.
Title: Re: Passing Cart Details to PayPal for Payment
Post by: john dowling on August 13, 2008, 17:07:33 PM
I just noticed that this does work but I am now not getting any sales tax charges sent to paypal?
Title: Re: Passing Cart Details to PayPal for Payment
Post by: apex2apex on August 13, 2008, 17:14:45 PM
there's a line that shows
// "amount_1" => round( $db->f("order_subtotal")+$tax_total, 2),

try removing everything before the "amount in that line and see if that works.
Title: Re: Passing Cart Details to PayPal for Payment
Post by: stevevm on August 24, 2008, 21:53:29 PM
Same for me no tax

I change
// "amount_1" => round( $db->f("order_subtotal")+$tax_total, 2),
to
"amount_1" => round( $db->f("order_subtotal")+$tax_total, 2),


Have you any idea what parameter I should  changed to make possible taxes on paypal.

Thx

Title: Re: Passing Cart Details to PayPal for Payment
Post by: MrBoza on September 03, 2008, 12:35:12 PM
Guys are you tell me that this code displays the product name?
How can it be if the line  $db->f("order_id"), actually calles for the order number...
Iwas hoping to dislay a list of product names and the shipping cost...

any idea?

Thanks