din 28 apr |
|
Update 01.01.2010:
Seems the Paypal API has changed since this was written. The country variable is changed from "address_country" to "country". Also as thehoffr pointed out below the logic for the shipping/billing address doesn't work and in fact is unnecessary. The shipping address, if used is always added after the billing address in the vm_order_user_info table so if present will be used. Have commented out the superfluous section and tested extensively. If it causes any problems please leave a comment. Have also noticed that Paypal puts the country code in front of the telephone number from the Paypal account holders country (in my case +32 for Belgium) unless the number is formatted correctly i.e. +44 1234 567 for GB etc. The Paypal API states "The three-digit prefix for U.S. phone numbers, or the entire phone number for phone numbers outside the U.S., excluding country code. This will pre-populate the payer’s home phone number." so it should work but doesn't. This won't affect you if your Vendor Paypal account is in the same country as your customers, otherwise if you don't want that info passed comment out that line. Changes made below and tested working 01.01.2010. With these changes we can pass and display the following information to Paypal
Open your Paypal payment module configuration VirtueMart-->Store-->List Payment Methods.Choose the Paypal module and when it opens the "Configuration" Tab. Scroll down to the "Payment Extra Info:" text field. For safety copy/paste the existing code somewhere safe in case any thing goes wrong with your updating. If so you can simply paste the old code straight back in. The code basically gets various parameters from your database, manipulates some of them and then passes them to Paypal where they are displayed in the Paypal payment dialogue. In the updated code we will make a couple of new database queries and pass this information to Paypal. It is possible just to copy and paste all this code directly into the "Payment Extra Info:" text field, the only adjustment needed will be the image at the end of the code, setting this to your own language/country. <?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_quantity, 2); } 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_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++; } //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, 2), "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>'; } ?>The result is a huge improvement on the original VirtueMart core distribution of the Paypal payment module. (see below) ![]() Thanks to the all the contributors at the VirtueMart Forums for sorting all this. |
| Laatste aanpassing op vrijdag 01 januari 2010 23:40 Read : 11320 times |

Open your Paypal payment module configuration VirtueMart-->Store-->List Payment Methods.























If you need help with this contact me thru the contact page
But I have a multilingual and multi currency website, when a customer goes to paypal from my site the landing page is on English.
Do you an advice to set the joomfish language in this form and see at the paypal landing page in that language?
Or take a customer country and sent to paypal to present the language page in that language?
Any help is appreciatted.
all VM cart line items xfer fine when customer does credit card purchase via paypal - s & h as determined in VM is what shows in the PayPal cart - great.
customer using PayPal account to purchase sees product line items sub total, tax line item and then Total (which is correct - it does include the shipping amount) but the shipping line item isn't shown.
thus shipping line item is shown with credit card purchase, not shown with paypal account purchase. both cases the grand total is correct.
The code $address_country = $dboui->f("country");
sends the country to Paypal.
I use the code above for my shop and don't have any problems.
The country is taken from the vm_order_user_info, what is in yours?
I've gone back to the default Paypal code until I can figure this out... anyone able to assist?
Thanks
zeusrw
"Some required information is missing or incomplete. Please correct your entries and try again."
It only seems to happen when a new customer creates an account during the order process. If they are already logged in with an existing account, the order goes through to PayPal correctly.
Does anyone have any idea what needs to be changed or what I need to look at? I would appreciate any and all feedback!
See here.. http://www.chargedrc.com.au/
If your interested contact me via the Contact page.
John
I have an issue very simple infact
all i want is the shooping cart to show the cost of the product £50
add the shipping £8
and have paypal add its 3.4% too the final value £58 + 3.4% = £59.97
then the user can go pay for it via paypal
i hate for the customer to pay and find paypal's xtra costs
Any advise would be great
The problem is this script takes the total discount and splits it evenly across all the order lines, which seems slightly strange to me, because that's not how it appears in the VM cart. This introduces slight rounding differences, and once the individual (discounted) order line totals are added up, the total can then be slightly different to the original total due to the cumulative effect of the rounding differences.
I have fixed this by removing this per-order-item discount logic and just applying the total discount as an overall cart discount (PayPal accepts a variable for this) - which then eliminates these minor discrepancies and makes the PayPal basket match your VM cart exactly, regardless of whether you're using a fixed or percentage discount coupon.
Firstly, we don't want to remove the discount on a per order line basis, so change this line...
$supp_var['amount_' . $i] = round(($dboi->f("product_item_price") - $disc_perItem),2);
... to this...
$supp_var['amount_' . $i] = round(($dboi->f("product_item_price")),2);
... next, we don't want to remove the coupon discount from the subtotal ourselves (as we'll be passing the total discount as a separate variable, so PayPal will deduct it from the total for us), so change this line...
"amount" => round( $db->f("order_subtotal")+$tax_total-$discount_total, 2),
... to this...
"amount" => round( $db->f("order_subtotal")+$tax_total, 2),
... then finally, add this to the $post_variables array (I put it below the 'tax_cart' line)...
"discount_amount_cart" => round( $discount_total, 2),
if(isset($_SESSION['product_currency']) && $_SESSION['product_currency']!=''){
$currency = $_SESSION['product_currency'];
}else{
$currency = $_SESSION['vendor_currency'];
}
at the top after the first line and then change the currency code line to call your new variable
"currency_code" => $currency,
lc
Sets the payer’s language for the billing information/log-in page only. The default is US.
so
"lc" => "NO",
in the variable array
Anybody got a suggestion on how to fix this?
Thanks
For anyone else having shipping rate issues, make sure you check your Shipping Calculations settings in PayPal. The calculations will be shown for your default currency, but you need to also select and change them for any additional currency you accept in your store.
Everything is now working perfectly. Thank you!
Where are these extra charges coming from? I've checked my PayPal shipping calculations and they are all set to €0. The box is also checked to allow transaction-based shipping values to override the profile shipping settings. I've also tried torben's code where he says:
"if i set this line "handling_cart" => sprintf("%.2f", $db->f("order_shipping")), to sprintf("%.2f", 0), the shipping price in paypal gets displayed and processed correctly."
Still not working. Can anyone help?
I am not so good at coding. My question is that How can I use these wonderful codes of yours with the codes provided by Larsen for the extra_info?
PLEASE HELP US GO AHEAD
to
sprintf("%.2f", 0),
the shipping price in paypal gets displayed and processed correctly.
I have the standard shipping module setup up with 3 country zones and not weight dependend (2€ UK, 3€ europe, 4€ world)
i put 2 cds, each €8 in my basket and on checkout, virtuemart shows me €19, 2x8+3 for europe, which is right, the paypal shipping though shows €22, 2x8+2x3.
i checked the code but cant find out why this is.
any help?
thanks!
Does this fix work with coupons, where a discount is given off the total cart amount, and the tax altered accordingly?
I need to show amounts including tax, but a line showing how much tax has been paid.
I found 2 issue that have to look into:
1. vendor_currency is used instead of product_currency. Which after my testing, if the site using multiple currency then the currency sent to paypal would be the default vendor currency (only one currency) instead of currency from "List of accepted currencies". Therefore its better to use product_currency.
2. If theres extra fees or discounts due to the selection of payment methods (in discount box of payment method form), then it will not be included in the data send to paypal. Could anyone point out where to solve this?
thanks
cheers
akeem
All I can say (and I've just tested this on a clean install of VM) is that the shipping/billing address works perfectly depending on what is chosen at the VM checkout stage.
The correct details are filled in at the 2nd stage of the Paypal process (either Credit Card payment or login to your Paypal account) the correct details appear pre-filled in the Paypal dialogue.
Why take the CC details of the payment with all the attendant hassle?
Why not let Paypal handle the payment either by Paypal or their credit card option?
if($oui_id == $order_id)
would always fail because oui_id is and auto_increment key, never matching the order_id (that is also auto_increment.
So I don't understand your logic. Really, since if there is multi-record resultset with order by oui_id DESC then the first record is always ST, but would be assured ST record if you sorted on address type and just pull the first record. If you want to send both to paypal you can test numrows, right? So please explain logic here.
However, all I want to do is pass the amount of the sale (digital downloads) to PayPal using the customers credit card, validate & approve and pass the confirm or deny back to notify.php to trigger the confirmed status to kick off the download email sending.
Amy ideas?
Thanks,
Robert
Thanks,
Robert
I have only a question. Can it be possible that if i choose the payment by paypal the buyers can only use the cardit card part of the system? So if i click to pay not the main page should come in , the second 1 where i have to give the card number and etc.
Im waiting for you answer.
try
The problem i have is if i checkout using the above paypal script i get the following error from paypal:
The amount received was: 40.19 GBP.
It should be: 40.2 GBP.
If i revert back to the original paypal code this is not the case so somewhere in the new paypal script their is a rounding error but i cannot find it - a little stumped and would be great if you could help
Regards
Tony
Thanks.
However, the shipping address is not carrying to the paypal order, and the shipping charges are being reflected on the Handling Charges, am ataching picture for reference, am using Joomla 1.5.9 and VM 1.1.2.
http://i102.photobucket.com/albums/m93/rodrigogar/address_shipping.png
However i still want shipping to show on the VM shipping calculator (which is the ame criteria/amount of payal).
So i dont want that shipping value to carry to Paypal. WHich piece of code can i comment so it doesnt carry.
So i want to comment out (add // to the code) the lines that carry that value to the Paypal checkout.
Which part of the code should i comment out in order to do this?
Thanks again for all your help.
I used the script above for my VM cart and it all works wonderfully! Thank you.
One remaining problem is postage. Paypal is still adding it's own postage costs even after checking the override boxes for £,$ and Euro.
Is there something I'm missing? (probably)
Have checked everywhere with no success. Any help appreciated.
Robert
Clicking this button returns the buyer to the seller's website, based on the "return" url provided in the "extra info" section. Also PayPal returns the transaction information back to the seller in a post or get form.
Now, if the value of "cmd" parameter passed to PayPal is "_ext-enter" (for the default "extra info" configuration), then PayPal returns the buyer to the seller's website using post, and to the successful page specified by the "return" variable.
If the value of "cmd" parameter is "_cart", PayPal returns the buyer to the seller's website using get. It looks like the "return" url provided in "extra info" section is altered with the transation information, thus bringing the buyer to the seller's home page and not the successful page as instructed by the "return" variable.
The solution to this issue is to explicitly instruct PayPal to redirect the buyer to the seller's successful page (return url) using the post method.
To do this, you need to add the following line in your code:
"rm" => "2",
For more information check out this page:
https://cms.paypal.com/us/cgi-bin/?cmd=_render-content&content_ID=developer/e_howto_html_Appx_websitestandard_htmlvariables
All the best.
I'd actually found that mistake and thought I'd updated the page, sorry.
It's updated now..
Cheers..
There is one issue though. In PayPal the transaction ID shows as 0 on the confirmation page. Also notify.php is not called by PayPal, so the order in Virtuemart doesn't get confirmed.
After couple of hours investigating on this, I found that the "invoice" variable should be "order_number" not "order_id".
So, replace:
"invoice" => $db->f("order_id")
with:
"invoice" => $db->f("order_number")
This is for Virtuemart 1.1.3. I don't know about the older versions of Virtuemart.
With this, a valid transaction id is created in PayPal and also notify.php is called by PayPal, and the order gets confirmed. Happy days!
Disable this and just let VirtueMart pass the shipping, then you won't have to update both.
What other options can i check for this? What i did right now is I commented out the portion of the script that carries the shipping value and let paypal add it, still comes to the same total, however at some point in time it might vary in a future.
This line - "no_shipping" => "1", tells Paypal not to add it's own shipping.
Double check all your configs in VM and Paypal.
Any help?
If it's a "Paypal does not allow your country of residence to ship to the country you wish to" message from Paypal then change
"address_override" => "1"
to
"address_override" => "0"
or is it another problem
Thanks
Please social bookmark to spread the info...