Paypal Error - AWO + Virtuemart


  • Default avatar
    david456    
     13 years ago
    0

    My customers are reporting a Paypal error when using AWO Coupon Pro 1.36 in Joomla 1.5.23 with Virtuemart 1.1.18 .

    I have tried to checkout too and get the same error: "The link you have used to enter the PayPal system contains an incorrectly formatted item amount"

    One example is on a sale of a $100 item + $10 item minus 25% discount = $82.50

    I did repair the zero payment gift cert issue using your fix, otherwise a plain, clean install.

    Any ideas where to start?

    Many Thanks

    David
    The Cribbage Guy
    www.cribbageguy.com
  • Default avatar
    david456    
     13 years ago
    0

    Updated to Awo Coupon Pro 1.4

    Same error
  • Your avatar
    seyi    
     13 years ago
    0

    You should take a look at admin->components->virtuemart->store->payment method list->paypal->configuration tab

    In the Payment Extra Info tab should be a bunch of code. This is the code that creates what is sent to paypal. Take a look at the amount, mine looks like this

    <?php
    "amount" => round$db->f("order_total")-$db->f("order_shipping"), 2),
    ?>
  • Default avatar
    david456    
     13 years ago
    0

    I sure have a bunch of code there. I got it (perhaps foolishly) from a virtuemart forum search and it has worked perfectly until now. It is added below for reference.

    Here's the amount section:

    "amount" => round( $db->f("order_subtotal")+$tax_total-$discount_total, 2),

    Obviously it is different.

    Should I try to return the code to standard and then make sure the "amount" is like yours?

    I assume that upgrading VM/Joomla/AWO has maybe made the code outdated.

    Thanks for the prompt response!




    The code in full:


    <?php
     
    $url 
    "https://www.paypal.com/cgi-bin/webscr";
     
    $order_id $db->f("order_id");
     
    $tax_total $db->f("order_tax") + $db->f("order_shipping_tax");
     
    $discount_total $db->f("coupon_discount") + $db->f("order_discount");  
     
     
     
    // Query for Order Items
     
    $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);
     
     
     
    $row_num $dboi->num_rows();
     
     
     
    //Getting Cart Items
     
    $auth $_SESSION['auth'];
     
    $cart $_SESSION['cart'];
     
    $t_quantity 0;
     
    $disc_perItem 0;
     
    $i=1;
     
     
     
    // Query to get User Info
     
    $dbb = new ps_DB;
     
    $q "SELECT * FROM #__vm_user_info ";
     
    $q .= "WHERE user_id ='".$my->id."' ";
     
    $dbb->setQuery($q);
     
    $dbb->query();
     
     
     
    //logic for applying discounts to multiple items
     
    $discount_totalCP $db->f("coupon_discount") + $db->f("order_discount");
     
     
     
    while(
    $dboi->next_record()) {
     
      
    $t_quantity $t_quantity intval($dboi->f("product_quantity"));
     
    }
     
     
     
    $dboi null;
     
    $dboi = new ps_DB;
     
    $dboi->query($q_oi);
     
     
     
    if(
    $t_quantity 0)
     
    {
     
      if(
    $discount_totalCP 0) {
     
        
    $disc_perItem round($discount_totalCP $t_quantity2);
     
      }
     
      else {
     
        
    $disc_perItem 0;
     
      }
     
    }
     
    else {
     
      
    $disc_perItem 0;
     
    }
     
    //query to optain product attributes
     
    while($dboi->next_record()) {
     
     
     
      
    $prod_attrib $dboi->f("product_attribute");
     
      
    $supp_var['item_name_' $i] = strip_tags($VM_LANG->_('PHPSHOP_ORDER_LIST_ID') . " " $db->f("order_id").": "$dboi->f("order_item_name"));
     
     
     
      if(
    $prod_attrib ''){
     
        
    $attributes_array explode('
    '
    ,$prod_attrib);
     
        
    $v 0;
     
        
    $z 1;
     
        foreach ( 
    $attributes_array as $attributes_value){
     
          
    $attrib_name trim(substr($attributes_value0strpos($attributes_value':')), " ");
     
          
    $supp_var['on' $z '_' $i] = $attrib_name;
     
          
    $attrib_sel trim(substr_replace(substr_replace($attributes_value""0strrpos($attributes_value':')), ""02));
     
          
    $supp_var['os' $z '_' $i] = $attrib_sel;
     
          
    $v++;
     
          
    $z++;
     
          unset(
    $attributes_value);
     
        }
     
      }
     
     
     
      
    $supp_var['item_number_' $i] = $dboi->f("order_item_sku");
     
      
    $supp_var['quantity_' $i] = $dboi->f("product_quantity");
     
      
    $supp_var['amount_' $i] = round(($dboi->f("product_item_price") - $disc_perItem),2);
     
      
    $i++;
     
    }
     
     
     
     
     
    //Query used to find whether to use Bill Address or Ship to address
     
    $dboui = new ps_DB;
     
    $q_oui "SELECT * FROM #__vm_order_user_info ";
     
    $q_oui .= "WHERE #__vm_order_user_info.order_id='$order_id' ORDER BY #__vm_order_user_info.order_info_id DESC";
     
    $dboui->query($q_oui);
     
     
     
     
     
      
    $first_name $dboui->f("first_name");
     
      
    $last_name $dboui->f("last_name");
     
      
    $address1 $dboui->f("address_1");
     
      
    $address2 $dboui->f("address_2");
     
      
    $city $dboui->f("city");
     
      
    $state $dboui->f("state");
     
      
    $address_country $dboui->f("country_2_code");
     
      
    $zip $dboui->f("zip");
     
      
    $H_PhoneNumber $dboui->f("phone_1");
     
     
     
     
     
    // Builds array for the form
     
    $post_variables = Array(
     
    "charset" => "utf8",
     
    "cmd" => "_cart",
     
    "upload" => "1",
     
    "page_style" => "paypal",
     
    "business" => PAYPAL_EMAIL,
     
    "currency_code" => $_SESSION['vendor_currency'],
     
    "amount" => round$db->f("order_subtotal")+$tax_total-$discount_total2),
     
    "handling_cart" => sprintf("%.2f"$db->f("order_shipping")),
     
    "tax" => $tax_total,
     
    "tax_cart" => $tax_total,
     
    "invoice" => $db->f("order_number"),
     
    "image_url" => $vendor_image_url,
     
    "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",
     
    "no_shipping" => "1",
     
    "no_note" => "1",
     
    "email" => $dbb->f("user_email"),
     
    "address_override" => "1",//change this to 0 if you have - Paypal does not allow your country of residence to ship to the country you wish to - errors
     
    "first_name" => $first_name,
     
    "last_name" => $last_name,
     
    "address1" => $address1,
     
    "address2" => $address2,
     
    "city" => $city,
     
    "state" => $state,
     
    "country" => $address_country,
     
    "zip" => $zip,
     
    "night_phone_b" => $H_PhoneNumber
     
    );
     
    //add and send the new variables
     
    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) ."&";
     
        }
     
      }
     
     
     
      
    vmRedirect$url $query_string );
     

     
    else {
     
      echo 
    '<form action="'.$url.'" method="post" target="_blank">';
     
     
     
      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 
    '<input type="image" name="submit" src="https://www.paypal.com/en_US/i/btn/x-click-but6.gif" border="0" alt="Make payments with PayPal, it is fast, free, and secure!">';
     
    //Change the above image url for different languages and countries
     
      
    echo '</form>';
     
    }
     
    ?>
  • Your avatar
    seyi    
     13 years ago
    0

    that is alot of code. Not sure what it is all doing so I would not revert it back just yet. I think its worth a try to just change the amount and see if that fixes it. So from this

    <?php
    "amount" => round$db->f("order_subtotal")+$tax_total-$discount_total2),
    ?>


    to this
    <?php
    //"amount" => round( $db->f("order_subtotal")+$tax_total-$discount_total, 2),
    "amount" => round$db->f("order_total")-$db->f("order_shipping")-$db->f("order_shipping_tax"), 2),
    ?>


    Notice I added a new variable order_shipping_tax. Maybe there is a problem in the calculation of $discount_total when there is a coupon. The variable holds the amount the customer should pay. So it includes product price, product tax, shipping, coupon discount, payment discount, everything. So I come about my amount by subtracting the shipping from the total and saying the rest has to be the product amount.
  • Default avatar
    david456    
     13 years ago
    0

    I followed the instruction, but I still get the same error of

    "The link you have used to enter the PayPal system contains an incorrectly formatted item amount."

    Without using a coupon, it goes through to Paypal just fine with the correct pricing.

    Time to put in the standard code?

    Here's what I have for the standard code:

    <?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);
    $url "https://www.paypal.com/cgi-bin/webscr";
    $tax_total $db->f("order_tax") + $db->f("order_shipping_tax");
    $discount_total $db->f("coupon_discount") + $db->f("order_discount");
    $post_variables = Array(
    "cmd" => "_ext-enter",
    "redirect_cmd" => "_xclick",
    "upload" => "1",
    "business" => PAYPAL_EMAIL,
    "receiver_email" => PAYPAL_EMAIL,
    "item_name" => $VM_LANG->_('PHPSHOP_ORDER_PRINT_PO_NUMBER').": "$db->f("order_id"),
    "order_id" => $db->f("order_id"),
    "invoice" => $db->f("order_number"),
    "amount" => round$db->f("order_subtotal")+$tax_total-$discount_total2),
    "shipping" => sprintf("%.2f"$db->f("order_shipping")),
    "currency_code" => $_SESSION['vendor_currency'],
    "address_override" => "1",
    "first_name" => $dbbt->f('first_name'),
    "last_name" => $dbbt->f('last_name'),
    "address1" => $dbbt->f('address_1'),
    "address2" => $dbbt->f('address_2'),
    "zip" => $dbbt->f('zip'),
    "city" => $dbbt->f('city'),
    "state" => $dbbt->f('state'),
    "country" => $db1->f('country_2_code'),
    "email" => $dbbt->f('user_email'),
    "night_phone_b" => $dbbt->f('phone_1'),
    "cpp_header_image" => $vendor_image_url,
    "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" => "NRUBJXESJTY24",
    "no_shipping" => "1",
    "no_note" => "1"
    );
    if( 
    $page == "checkout.thankyou" ) {
    $query_string "?";foreach( $post_variables as $name => $value ) {
    $query_string .= $name"=" urlencode($value) ."&";
    }
    vmRedirect$url $query_string );
    } else {
    echo 
    '<form action="'.$url.'" method="post" target="_blank">';
    echo 
    '<input type="image" name="submit" src="https://www.paypal.com/en_US/i/btn/x-click-but6.gif" alt="Click to pay with PayPal - it is fast, free and secure!" />';
    foreach( 
    $post_variables as $name => $value ) {
    echo 
    '<input type="hidden" name="'.$name.'" value="'.htmlspecialchars($value).'" />';
    }
    echo 
    '</form>';
    }
    ?>
  • Your avatar
    seyi    
     13 years ago
    0

    yes, try the standard
  • Default avatar
    david456    
     13 years ago
    0

    The standard code has fixed the error issue.

    Thank you Seyi for your help - clearly now, the issue is outside of your wonderful product.

    What I have lost are the item descriptions and attributes being handed off to Paypal, which used to help customers confirm what they were purchasing. Now Paypal just refers to the order number and the total. I guess that is what the code was achieving up until the last day or two.

    I am willing to forgo that extra functionality for a functioning system although I think the whole process benefits from that information being available to the customer throughout the Paypal payment.

    Many thanks,

    David
    The Cribbage Guy
  • Default avatar
    SMART TRADING DIFFUSION    
     13 years ago
    0

    "The standard code has fixed the error issue."

    With or without the modified code ?
    <?php
    //"amount" => round( $db->f("order_subtotal")+$tax_total-$discount_total, 2),
    "amount" => round$db->f("order_total")-$db->f("order_shipping")-$db->f("order_shipping_tax"), 2),
    ?>


    I just move from version 1.3.6 to 1.40

    Best regards

    Christophe
  • Your avatar
    seyi    
     13 years ago
    0

    Either should work. One puts the subtotal of the product as the amount while the second one subtracts the coupon discount.
  • Default avatar
    david456    
     13 years ago
    0

    I modified the standard code with the modification shown.
  • Default avatar
    manuxx    
     12 years ago
    0

    Can you please post the entire correct code for this David?

    We want to use awocoupon and we have a lot of orders by paypal and want to prevent this from happening:

    This is the code we have for Paypal if someone could check it up a minute, thanks:

    <?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);

    $url "https://www.paypal.com/cgi-bin/webscr";
    $tax_total $db->f("order_tax") + $db->f("order_shipping_tax");
    $discount_total $db->f("coupon_discount") + $db->f("order_discount");
    $post_variables = Array(
    "cmd" => "_ext-enter",
    "redirect_cmd" => "_xclick",
    "upload" => "1",
    "business" => PAYPAL_EMAIL,
    "receiver_email" => PAYPAL_EMAIL,
    "item_name" => $VM_LANG->_('PHPSHOP_ORDER_PRINT_PO_NUMBER').": "$db->f("order_id"),
    "order_id" => $db->f("order_id"),
    "invoice" => $db->f("order_number"),
    "amount" => round$db->f("order_total")-$db->f("order_shipping"), 2),
    "shipping" => sprintf("%.2f"$db->f("order_shipping")),
    "currency_code" => $_SESSION['vendor_currency'],

    "address_override" => "1",
    "first_name" => $dbbt->f('first_name'),
    "last_name" => $dbbt->f('last_name'),
    "address1" => $dbbt->f('address_1'),
    "address2" => $dbbt->f('address_2'),
    "zip" => $dbbt->f('zip'),
    "city" => $dbbt->f('city'),
    "state" => $dbbt->f('state'),
    "country" => $db1->f('country_2_code'),
    "email" => $dbbt->f('user_email'),
    "night_phone_b" => $dbbt->f('phone_1'),
    "cpp_header_image" => $vendor_image_url,

    "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" => "NRUBJXESJTY24",
    "no_shipping" => "1",
    "no_note" => "1"
    );
    if( 
    $page == "checkout.thankyou" ) {
    $query_string "?";
    foreach( 
    $post_variables as $name => $value ) {
    $query_string .= $name"=" urlencode($value) ."&";
    }
    vmRedirect$url $query_string );
    } else {
    echo 
    '<form action="'.$url.'" method="post" target="_blank">';
    echo 
    '<input type="image" name="submit" src="https://www.paypal.com/en_US/i/btn/x-click-but6.gif" alt="Click to pay with PayPal - it is fast, free and secure!" />';

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

    }
    ?>
  • Default avatar
    csaba6    
     12 years ago
    0

    Hi Seyi,

    I'm having the same issue with this Paypal stuff.

    I do not really want to loose the extra PayPal information. With my code, when the user is on the PayPall checkout site, there are detailed info about the ordered products, like: color, product's details etc.

    So I do not want to switch back to the standard PayPal code.

    Should you please investigating, what is the problem?

    My code is (WITH the extra PayPal infos)

    <?php
    $url 
    "https://www.paypal.com/cgi-bin/webscr";
    $order_id $db->f("order_id");
    $tax_total $db->f("order_tax") + $db->f("order_shipping_tax");
    $discount_total $db->f("coupon_discount") + $db->f("order_discount");  
     
    // Query for Order Items
    $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);
     
    $row_num $dboi->num_rows();
     
    //Getting Cart Items
    $auth $_SESSION['auth'];
    $cart $_SESSION['cart'];
    $t_quantity 0;
    $disc_perItem 0;
    $i=1;
     
    // Query to get User Info
    $dbb = new ps_DB;
    $q "SELECT * FROM #__vm_user_info ";
    $q .= "WHERE user_id ='".$my->id."' ";
    $dbb->setQuery($q);
    $dbb->query();
     
    //logic for applying discounts to multiple items
    $discount_totalCP $db->f("coupon_discount") + $db->f("order_discount");
     
    while(
    $dboi->next_record()) {
      
    $t_quantity $t_quantity intval($dboi->f("product_quantity"));
    }
     
    $dboi null;
    $dboi = new ps_DB;
    $dboi->query($q_oi);
     
    if(
    $t_quantity 0)
    {
      if(
    $discount_totalCP 0) {
        
    $disc_perItem round($discount_totalCP $t_quantity2);
      }
      else {
        
    $disc_perItem 0;
      }
    }
    else {
      
    $disc_perItem 0;
    }
    //query to optain product attributes
    while($dboi->next_record()) {
     
      
    $prod_attrib $dboi->f("product_attribute");
      
    $supp_var['item_name_' $i] = strip_tags("Order #"$db->f("order_id").": "$dboi->f("order_item_name"));
     
      if(
    $prod_attrib ''){
        
    $attributes_array explode('<br/>',$prod_attrib);
        
    $v 0;
        
    $z 1;
        foreach ( 
    $attributes_array as $attributes_value){
          
    $attrib_name trim(substr($attributes_value0strpos($attributes_value':')), " ");
          
    $supp_var['on' $z '_' $i] = $attrib_name;
          
    $attrib_sel trim(substr_replace(substr_replace($attributes_value""0strrpos($attributes_value':')), ""02));
          
    $supp_var['os' $z '_' $i] = $attrib_sel;
          
    $v++;
          
    $z++;
          unset(
    $attributes_value);
        }
      }
     
      
    $supp_var['item_number_' $i] = $dboi->f("order_item_sku");
      
    $supp_var['quantity_' $i] = $dboi->f("product_quantity");
      
    $supp_var['amount_' $i] = round(($dboi->f("product_item_price") - $disc_perItem),0);
      
    $i++;
    }
     
     
    //Query used to find whether to use Bill Address or Ship to address
    $dboui = new ps_DB;
    $q_oui "SELECT * FROM #__vm_order_user_info ";
    $q_oui .= "WHERE #__vm_order_user_info.order_id='$order_id' ORDER BY #__vm_order_user_info.order_info_id DESC";
    $dboui->query($q_oui);
     
    /*$oui_id = $dboui->f("order_info_id");
     
    if($oui_id == $order_id){
      $first_name = $dbb->f("first_name");
      $last_name = $dbb->f("last_name");
      $address1 = $dbb->f("address_1");
      $address2 = $dbb->f("address_2");
      $city = $dbb->f("city");
      $state = $dbb->f("state");
      $address_country = $dbbt->f("country");
      $zip = $dbb->f("zip");
      $H_PhoneNumber = $dbb->f("phone_1");
    }
    else {*/
      
    $first_name $dboui->f("first_name");
      
    $last_name $dboui->f("last_name");
      
    $address1 $dboui->f("address_1");
      
    $address2 $dboui->f("address_2");
      
    $city $dboui->f("city");
      
    $state $dboui->f("state");
      
    $address_country $dboui->f("country");
      
    $zip $dboui->f("zip");
      
    $H_PhoneNumber $dboui->f("phone_1");
    //}
     
    // Builds array for the form
    $post_variables = Array(
    "cmd" => "_cart",
    "upload" => "1",
    "page_style" => "paypal",
    "business" => PAYPAL_EMAIL,
    "currency_code" => $_SESSION['vendor_currency'],
    //"amount" => round( $db->f("order_subtotal")+$tax_total-$discount_total, 0),
    "amount" => round$db->f("order_total")-$db->f("order_shipping")-$db->f("order_shipping_tax"), 2),
    "handling_cart" => sprintf("%.2f"$db->f("order_shipping")),
    "tax" => round($tax_total0),
    "tax_cart" => round($tax_total0),
    "invoice" => $db->f("order_number"),
    "image_url" => $vendor_image_url,
    "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",
    "no_shipping" => "1",
    "no_note" => "1",
    "email" => $dbb->f("user_email"),
    "address_override" => "1",//change this to 0 if you have - Paypal does not allow your country of residence to ship to the country you wish to - errors
    "first_name" => $first_name,
    "last_name" => $last_name,
    "address1" => $address1,
    "address2" => $address2,
    "city" => $city,
    "state" => $state,
    "country" => $address_country,
    "zip" => $zip,
    "night_phone_b" => $H_PhoneNumber,
    'charset' => 'utf-8',
    );
    //add and send the new variables
    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) ."&";
        }
      }
     
      
    vmRedirect$url $query_string );

    else {
      echo 
    '<form action="'.$url.'" method="post" target="_blank">';
     
      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 
    '<input type="image" name="submit" src="https://www.paypal.com/en_US/i/btn/x-click-but6.gif" border="0" alt="Fizess PayPal-al, gyors, ingyenes, Ã©s biztonságos!">';
    //Change the above image url for different languages and countries
      
    echo '</form>';
    }
    ?>


  • Default avatar
    csaba6    
     12 years ago
    0

    Hi,

    After I have been playing 5-6 hours, with this stupid PayPal issue, I found if I do this trick, detailed here: https://awodev.com/blog/virtuemart-coupon-error-discount-before-tax, the PayPal does its thing!!!! So, there is no "The link you have used to enter the PayPal system contains an incorrectly formatted item amount." error.

    But even if I changed the basket.php and ps_checkout.php as you mentioned, the virtuemart and Paypal amount is just not good, exactly the same issue happened like your detailed in the above link.....I'm getting confused! Really!.

    But anyway I keep investigating the problem. I want a fully working and well configured system. :P


    csaba
  • Your avatar
    seyi    
     12 years ago
    0

    Hello,

    I am a little confused what the problem is. It seems you are having trouble with the paypal amount. Can you give an example? I would be interested in the Total, shipping excluding tax, shipping tax, coupon discount and the actual total sent to paypal.

    For the link you mentioned, that is a fix to use only if you have 'discount before tax' checked.
  • Default avatar
    csaba6    
     12 years ago
    0

    Well, I'm already confused!!!!! :)

    Ok, I try.

    Virtuemart setting: Subtract payment discount before tax/shipping? clicked (basket.php, and ps_checkout.php changed)
    Paypal settings: "amount" => round( $db->f("order_total")-$db->f("order_shipping"), 2),

    This is the virtuemart basket: http://homesys.tv/download/4.jpg which is right! (including the 27% TAX as well)

    Coupon setting: http://homesys.tv/download/6.jpg


    Shipping excluding tax: 1200 HUF
    Shipping tax: 27%
    Normal tax: 27% as well
    Coupon discount: 36400 HUF brutto value
    The right total sent would be: 51424 HUF

    But check what Paypal thinks: http://homesys.tv/download/5.jpg

    So this is the problem, which I could not figure out... :(

    thanks for helping.

    cs.
  • Your avatar
    seyi    
     12 years ago
    0

    I think your paypal total is closer to being correct than your basket, since you are using discount before tax/shipping. I am assuming 86.3 is the product total including tax. If that is the case then:
    Product total no tax: 86.3/1.27 = 67.953
    Product total no tax after discount: 67.953-36.4 = 31.553
    Product tax: 31.553 * 0.27 = 8.52
    Shipping no tax: 1.2
    Shipping tax: 1.2 * 0.27 = 0.324
    =====================
    Total Tax: 0.324 + 8.52 = 8.844
    Total: 8.844 + 1.2 + 31.553 = 41.597

    So where paypal is going wrong is in the tax calculated, which is just taken from your shop. But your basket is just off.
  • Default avatar
    csaba6    
     12 years ago
    0

    Ah.

    Thanks for this Seyi. Even I understood your calculation, this is still so complicated for me.

    What I understand that I have to use netto discount (no tax) in the coupons settings. The reason that I want to use a fix discount is, that I want to set the end user price to a fix amount.

    Please note that the Paypall intergation seems okay, if there is no discount in the basket...

    The problem only appears if there IS coupon discount.....

    Can you suggest a solution? What do I have to modify and where.......

    Thanks in advance.

    csaba
  • Your avatar
    seyi    
     12 years ago
    0

    If I understand, you still want to use discount before tax/shipping?

    If the only modifications you have made to ps_checkout.php, basket.php, and ro_basket.php have to do with the discount before tax/shipping modifications in the blog, revert them back to the original. Then in admin->components->awocoupon->configuration, set 'Calculate the discount before tax' to yes and test.
  • Default avatar
    csaba6    
     12 years ago
    0

    yes, I want to use discount before tax/shipping.

    but actually now, I do not care, if the disocunt will be calculated after tsx/shipping...

    I just need that the virtuemart basket amount will be sent to the paypall...

    i have modified what you said, but the same issue happened. :( :(
  • Your avatar
    seyi    
     12 years ago
    0

    if the discount mechanism does not matter, then change disable discount before tax within awocoupon and virtuemart since its easier after tax. That should work ok.
  • Default avatar
    Alceste    
     12 years ago
    0

    Hello,
    Escuse my English. I think that we have the same error using VirtueMart 1.9.9 and Joomla 1.5.26. When I use a coupon, the final invoice of Paypal not charge the taxes in a shipping price. For example, the cost of shipping must be 8 Euros, (that is 6.78 Euros + 18% Spanish taxes), but on Paypal, the customer pay only 6.78 Euros (without taxes) In a order of Virtuemart all is correct, the total amount is right, but the money we really received are allways with this nagative difference.

    If we don't use the coupon, the proces is right.

    Thanks for your help.
  • Your avatar
    seyi    
     12 years ago
    0

    You should take a look at admin->components->virtuemart->store->payment method list->paypal->configuration tab

    In the Payment Extra Info tab should be a bunch of code. This is the code that creates what is sent to paypal. Take a look at the shipping variable, it should look like this

    <?php
    "shipping" => sprintf("%.2f"$db->f("order_shipping")+$db->f("order_shipping_tax")),
    ?>
  • Default avatar
    Alceste    
     12 years ago
    0

    Thanks Seyi,

    I writte you all my code because I think something else is wrong. I try to change the original code as you say but I make something error.

    This is all my original code (without changes) at admin->components->virtuemart->store->payment method list->paypal->configuration tab. Thanks for your help

    <?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);

    $url "https://www.paypal.com/cgi-bin/webscr";
    $tax_total $db->f("order_tax") + $db->f("order_shipping_tax");
    $discount_total $db->f("coupon_discount") + $db->f("order_discount");
    $post_variables = Array(
    "cmd" => "_ext-enter",
    "redirect_cmd" => "_xclick",
    "upload" => "1",
    "business" => PAYPAL_EMAIL,
    "receiver_email" => PAYPAL_EMAIL,
    "item_name" => $VM_LANG->_('PHPSHOP_ORDER_PRINT_PO_NUMBER').": "$db->f("order_id"),
    "order_id" => $db->f("order_id"),
    "invoice" => $db->f("order_number"),
    "amount" => round$db->f("order_subtotal")+$tax_total-$discount_total2),
    "shipping" => sprintf("%.2f"$db->f("order_shipping")),
    "currency_code" => $_SESSION['vendor_currency'],
    "address_override" => "1",
    "first_name" => $dbbt->f('first_name'),
    "last_name" => $dbbt->f('last_name'),
    "address1" => $dbbt->f('address_1'),
    "address2" => $dbbt->f('address_2'),
    "zip" => $dbbt->f('zip'),
    "city" => $dbbt->f('city'),
    "state" => $dbbt->f('state'),
    "country" => $db1->f('country_2_code'),
    "email" => $dbbt->f('user_email'),
    "night_phone_b" => $dbbt->f('phone_1'),
    "cpp_header_image" => $vendor_image_url,

    "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" => "NRUBJXESJTY24",
    "no_shipping" => "1",
    "no_note" => "1"
    );
    if( 
    $page == "checkout.thankyou" ) {
    $query_string "?";
    foreach( 
    $post_variables as $name => $value ) {
    $query_string .= $name"=" urlencode($value) ."&";
    }
    vmRedirect$url $query_string );
    } else {
    echo 
    '<form action="'.$url.'" method="post" target="_blank">';
    echo 
    '<input type="image" name="submit" src="https://www.paypal.com/en_US/i/btn/x-click-but6.gif" border="0" alt="Click to pay with PayPal - it is fast, free and secure!" />';

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

    }
    ?>
  • Your avatar
    seyi    
     12 years ago
    0

    Here is your code with the change

    <?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);
    $url "https://www.paypal.com/cgi-bin/webscr";
    $tax_total $db->f("order_tax") + $db->f("order_shipping_tax");
    $discount_total $db->f("coupon_discount") + $db->f("order_discount");
    $post_variables = Array(
    "cmd" => "_ext-enter",
    "redirect_cmd" => "_xclick",
    "upload" => "1",
    "business" => PAYPAL_EMAIL,
    "receiver_email" => PAYPAL_EMAIL,
    "item_name" => $VM_LANG->_('PHPSHOP_ORDER_PRINT_PO_NUMBER').": "$db->f("order_id"),
    "order_id" => $db->f("order_id"),
    "invoice" => $db->f("order_number"),
    "amount" => round$db->f("order_subtotal")+$tax_total-$discount_total2),
    //"shipping" => sprintf("%.2f", $db->f("order_shipping")),
    "shipping" => sprintf("%.2f"$db->f("order_shipping")+$db->f("order_shipping_tax")),
    "currency_code" => $_SESSION['vendor_currency'],
    "address_override" => "1",
    "first_name" => $dbbt->f('first_name'),
    "last_name" => $dbbt->f('last_name'),
    "address1" => $dbbt->f('address_1'),
    "address2" => $dbbt->f('address_2'),
    "zip" => $dbbt->f('zip'),
    "city" => $dbbt->f('city'),
    "state" => $dbbt->f('state'),
    "country" => $db1->f('country_2_code'),
    "email" => $dbbt->f('user_email'),
    "night_phone_b" => $dbbt->f('phone_1'),
    "cpp_header_image" => $vendor_image_url,
    "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" => "NRUBJXESJTY24",
    "no_shipping" => "1",
    "no_note" => "1"
    );
    if( 
    $page == "checkout.thankyou" ) {
    $query_string "?";
    foreach( 
    $post_variables as $name => $value ) {
    $query_string .= $name"=" urlencode($value) ."&";
    }
    vmRedirect$url $query_string );
    } else {
    echo 
    '<form action="'.$url.'" method="post" target="_blank">';
    echo 
    '<input type="image" name="submit" src="https://www.paypal.com/en_US/i/btn/x-click-but6.gif" border="0" alt="Click to pay with PayPal - it is fast, free and secure!" />';
    foreach(

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

This thread is locked.