News:

Support the VirtueMart project and become a member

Main Menu

Send Product Name and Attributes to Paypal

Started by kontrolfreek, December 20, 2008, 08:12:49 AM

Previous topic - Next topic

scothern99

This doesn't pass the Shipping zip code.  Plus it does actually add the tax to the product amount.

scothern99

#61
Sorry, I was really tired.  The tax thing is a different issue with VM altogether and may be a config issue on my part.  But what I'm seeing, is after adding this most recent code to the paypal extensions in the VM admin, it works on the store side and goes to PayPal alright, but paypal is asking me to enter the zip code to verify the total.  The customer would then have to enter it again.  Is this not right because I do not remember ever having to do this before.

Seiko

Hi scothern99,

Are you using the code I posted?
If so, is your paypal address and VM ship_to address match exactly?
Have you tested the code with PayPal sandbox?

- Seiko
Do you have questions and need some help for your Virtuemart project?
I'm ready to help you. Hire Me on oDesk

scothern99

Yes sir I am.  I'm using my wifes paypal login to test and the address is the same exactly.  I'm not using the sandbox due to the variences in the sandbox and live.  I've tested sandbox before that doesn't work when live so I'm just testing live and canceling the order before processing it at paypal.

Seiko

Hi scothern99,

I totally agree with there are variances in the sandbox and the live paypal server (and also their documents).
So that it's too difficult to find the causes.
But if you try with the sandbox first, we can still catch some issues.
I'm sorry that I can't give you much help since I can't ask detailed information about real paypal seller/buyer accounts.
I wish you good luck!

- Seiko
Do you have questions and need some help for your Virtuemart project?
I'm ready to help you. Hire Me on oDesk

scothern99

I'm not sure what you mean about asking information about seller accounts.  I'm not sure any of that information would matter.  Its info being passed to paypal thats not right.  That shouldn't have anything to do with a seller account.  Before I found your PHP script, I tried a couple of the earlier ones.  Yours so far is the only one that is doing this.  This is happening before I even attempt to login to paypal, on the order info screen that is first displayed, above the sign-in form..

Seiko

See 'Using Your PayPal Account Profile' (https://www.x.com/docs/DOC-1358)
and read 'Displaying the Shipping Charges that PayPal Calculates During Checkout'.
Is this happening to you?
PayPal account profile does matter for the PayPal behaviors.
Hope this helps you.
Do you have questions and need some help for your Virtuemart project?
I'm ready to help you. Hire Me on oDesk

scothern99

I guess that would make sense, if we weren't passing this info to paypal from VM.  That info all appeared to relate to "payapl" shopping carts.  We don't have anythign set-up in paypal to handle shipping or anything because its all being passed to paypal via the API.

I know this has nothing to do with my account for certain.  See we have a store already up and running that uses paypal standard this same way.  Only difference is I didn't have to paste this stuff into a setting like in VM.  It doesn't prompt for again for the zip code so I know this has to do with the code that is in your PHP script.  I do not know PHP but I know someone who does, perhaps he will address this for me.

Seiko

I'd very much welcome somebody can address/fix the issues in my code.
That is the one reason, I posted it here.

As I learned from previous contributer's posts and paypal developer site, '_cart' PayPal HTML variable is required to pass additional information to the PayPal.
Original virtuemart PayPal extra payment info code is using '_xclick' instead, and it works fine without problems.
So your problem must be related with using '_cart' and/or other variables in the code though...
I don't have any more clue since I'm not having same problem. ???

Do you have questions and need some help for your Virtuemart project?
I'm ready to help you. Hire Me on oDesk

scothern99

I don't know either and it really isn't that big of a deal.  All the math appears right so if they have to verify their zip again, oh well.  Keep out the Fake spammers.

nirajlama

I am using Paypal code submitted by ajredding earlier.
My problem is that the shipping and handling variable do not show up on the Payment Notification that I receive from Paypal. It is however included in the total. (See attachment)Curiously, I get to "insurance" shows up on the notification, which I can live without.
The shipping and handling variable but do show up on checkout on the Paypal page (see attachment#2).

The code I use:
*******************************************************************
<?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);

$row_num = $dboi->num_rows();

//New code Getting Cart Items
$auth = $_SESSION['auth'];
$cart = $_SESSION['cart'];
$t_quantity = 0;
$disc_perItem = 0;
$i=1;

$dbb = new ps_DB;
$q = "SELECT * FROM jos_vm_user_info ";
$q .= "WHERE user_id ='".$my->id."' ";
$dbb->setQuery($q);
$dbb->query();

$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");  //New Code
$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_quantity, 2);
        }
        else
        {
                $disc_perItem = 0;
        }
}
else
{
        $disc_perItem = 0;
}

while($dboi->next_record()) {

    $prod_attrib = $dboi->f("product_attribute");
             
    $supp_var['item_name_' . $i] = strip_tags($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_value, 0, strpos($attributes_value, ':')), " ");
        $supp_var['on' . $z . '_' . $i] = $attrib_name;
        $attrib_sel = trim(substr_replace(substr_replace($attributes_value, "", 0, strrpos($attributes_value, ': ')), "", 0, 2));
        $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++;
}
//End New Code

//Start New Code - Ship to Address Versus Bill 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");
}
//End New Code

$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, 2),
"handling_cart" => sprintf("%.2f", $db->f("order_shipping")),
"tax" => $tax_total,
"tax_cart" => $tax_total,
"invoice" => $db->f("order_id"),
"image_url" => "https://www.darjeelingteaexclusive.com/images/mw_dte_logo.png",
"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" => "0",
"first_name" => $first_name,
"last_name" => $last_name,
"address1" => $address1,
"address2" => $address2,
"city" => $city,
"state" => $state,
"address_country" => $address_country,
"zip" => $zip
);

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!">';
echo '</form>';
}
?>
***********************************

Further with each order I also get a mail on my Paypal registered email regarding Paypal IPN transaction. This comes from my own store's email. Many times even when there are no problems in receiving payments, the Paypal IPN transaction notifies errors. A recent example:

Subject: PayPal IPN Transaction on your site: Possible fraud‏
Error code 506. Possible fraud. Error with REMOTE IP ADDRESS = 216.113.188.202.
                        The remote address of the script posting to this notify script does not match a valid PayPal ip address

            These are the valid IP Addresses: 66.211.169.2,
66.211.169.65,
64.4.241.33,
64.4.241.49,
66.211.170.66,

           
            The Order ID received was: 141
******************************************
There was actually no problem with order ID 141.

Can someone please help me?
Why does the shipping and handling variable do not show in the payment notification?
How can I remove the variable insurance?
Why are some of the order generating IPN errors?

Thank you for your time.

[attachment cleanup by admin]

stinga

G'day

[cpde]
Further with each order I also get a mail on my Paypal registered email regarding Paypal IPN transaction. This comes from my own store's email. Many times even when there are no problems in receiving payments, the Paypal IPN transaction notifies errors. A recent example:

Subject: PayPal IPN Transaction on your site: Possible fraud‏
Error code 506. Possible fraud. Error with REMOTE IP ADDRESS = 216.113.188.202.
                        The remote address of the script posting to this notify script does not match a valid PayPal ip address

            These are the valid IP Addresses: 66.211.169.2,
66.211.169.65,
64.4.241.33,
64.4.241.49,
66.211.170.66,


Either all the ip address to the list of valid one, making sure it is a paypal ip :-) or fix the thing forever by comparing against the paypal domain name and not the ip address's.

I don't understand you problem, those two screen shots don't match at all, should they?

I don't see where you re setting your shipping info to send to PP.

Have a look at
http://forum.virtuemart.net/index.php?topic=59668.msg199060#msg199060
That might help a bit.
I have posted my extra info on th site somewhere and I get options + all the relevant data to make it look nice.
Stinga.
614869 products in 747 categories with 15749 products in 1 category.
                                             Document Complete   Fully Loaded
                Load Time First Byte Start Render   Time      Requests      Time      Requests
First View     2.470s     0.635s     1.276s          2.470s       31            2.470s      31
Repeat View  1.064s     0.561s     1.100s          1.064s       4             1.221s       4

nirajlama

Thank you Stinga for your response.
I tried your extra info but it did not post the shipping and handling charges on checkout.
I am not able to follow your instructions: "Either all the ip address to the list of valid one, making sure it is a paypal ip :-) or fix the thing forever by comparing against the paypal domain name and not the ip address's."
Where can I make this fix?
About the snapshots I had posted: no they were not supposed to match. I was just showing that while Shipping and Handling charges do get posted on Paypal while checking out, it is missing in the Payment Notification. However, the total sum does include the Shipping Handling charges.

stinga

G'day I have not read the whole thread, is this PayPal Pro or PayPal?
I am surprised it did not work, but maybe I have added some other bits.

If you want, you can point your paypal url to www.recovery-cd-disk.com/cgi-bin/data_dump.pl and it will dump out to your screen what you are sending to PayPal, you could then post that back here, that might show us what is going on.

Also this was for VM 1.1.2 maybe there is a difference for 1.1.4
Stinga.
614869 products in 747 categories with 15749 products in 1 category.
                                             Document Complete   Fully Loaded
                Load Time First Byte Start Render   Time      Requests      Time      Requests
First View     2.470s     0.635s     1.276s          2.470s       31            2.470s      31
Repeat View  1.064s     0.561s     1.100s          1.064s       4             1.221s       4

nirajlama

Sorry for delay in reverting back to you Stinga.
I am using the normal PayPal account and VM 1.1.3
I tried to use the url that you had sent to verify the data transfer. But I cannot open the page. Could it be because I am testing on localhost?