web design, England, Britain, UK, belgium
 
Ulti Clocks content

Improved configuration of the VirtueMart 1.1 Paypal payment module

sand How to configure the VirtueMart 1.1. payment module to be much more customer friendly.
order, address, paypal, country, dboi, query, value, supp, var, dboui, dbb, info, quantity, attributes, discount, number, code, payment, product, user, tax, virtuemart, item, total, phone, attrib, zip, cart, array, state, city, module, peritem, foreach, shipping, url, oui, disc, echo, string

Home

Die

28.

Apr

Improved configuration of the VirtueMart 1.1 Paypal payment module


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

  • Order Number
  • SKU Number
  • Product Name
  • Product Attributes
  • Quantity of individual products
  • Unit price of individual products
  • Total number of items
  • Product subtotals
VirtueMart Paypal Module 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)
VirtueMart Paypal Module core
Thanks to the all the contributors at the VirtueMart Forums for sorting all this.


Add this page to your favorite Social Bookmarking websites
Digg! Reddit! Del.icio.us! Mixx! Free and Open Source Software News Google! Live! Facebook! Slashdot! Technorati! StumbleUpon! Spurl! Newsvine! Furl! Fark! Yahoo! Netvouz! Mister-Wong! RawSugar! Ma.gnolia! Squidoo! DZone! Swik!
Zuletzt aktualisiert am Freitag, 01. Januar 2010 um 23:40 Uhr Read : 11319 times
 
Comments (55)
Thank you
55 Donnerstag, 08. Juli 2010 um 06:18 Uhr
Liz
Thanks for something so great. Works perfect on my virtuemart website and I did not have to change a thing. You are genius! Exactly what I was looking for. Keep up the good work.
@Joselillo
54 Mittwoch, 16. Juni 2010 um 07:46 Uhr
Thorpalnut
The Paypal var for this is lc so you would need to get the Joomfish lang and send it as the lc var.
If you need help with this contact me thru the contact page
How to add a multi language option whe using Joomfish
53 Mittwoch, 16. Juni 2010 um 06:42 Uhr
Joselillo
I am using this cript and I found really helpful.

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.
s & h line item is no show with PP customers....
52 Sonntag, 30. Mai 2010 um 00:57 Uhr
William Boehm
joomla 1.5.7; VM 1.1.4; shipvalue module 0.1
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.
@zeusrw
51 Mittwoch, 26. Mai 2010 um 15:27 Uhr
admin GJC
There's not a piece of code anywhere in the above that would set the country.
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?
Close but no cigar... customer country defaults to Norway
50 Mittwoch, 26. Mai 2010 um 14:13 Uhr
zeusrw
Thought this was a great solution until my completed orders started to drop off unexpectedly. When I looked into it, no matter what information was entered into the account section of virtuemart, the Paypal code seemed to be passing "Norway" as the customers country. Consequently customers did not proceed with their payment and bailed during the Paypal process. Can't figure out where in the above code the country code is forcing Norway. I see the bit about the language being Norweigian, i.e. lc="NO" but can't see how this would control the customers country...

I've gone back to the default Paypal code until I can figure this out... anyone able to assist?

Thanks

zeusrw
PayPal errors
49 Freitag, 21. Mai 2010 um 08:28 Uhr
Spotted Sparrow
This was working perfectly for me until recently. When a new customer finishes the checkout process on my site and are directed to PayPal, PayPal displays the following error message:

"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!
@ivan
48 Donnerstag, 13. Mai 2010 um 09:29 Uhr
(GJC Admin)
I have done a hack b4 for a customer where a fixed fee is added to the final sum b4 passing on to Paypal.
See here.. http://www.chargedrc.com.au/
If your interested contact me via the Contact page.

John
paypal final value fee
47 Donnerstag, 13. Mai 2010 um 01:47 Uhr
ivan
this is too confusing for me

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
Fix for coupon discount rounding discrepancies
46 Mittwoch, 05. Mai 2010 um 15:47 Uhr
Chris Walker
To Tony Scott, and anyone else with rounding problems when using coupon discounts.....

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),
Yeehaw!!!
45 Freitag, 23. April 2010 um 19:48 Uhr
zeusrw
This is great and exactly what I was looking for. The only issue was that if your site allows the customer to select its preferred currency, the order is passed to Paypal with the same amount but in the home currency, e.g. £100 becomes $100. However adding the following code passes the product currency to Paypal...


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,
@Arild
44 Freitag, 16. April 2010 um 11:23 Uhr
admin (GJC)
You need to add the lc variable as per the Paypal api docs..

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
Language selection
43 Freitag, 16. April 2010 um 09:04 Uhr
Arild
Nice config, but I have one problem. Before I changed to this setup the user got the paypal-page in norwegian (as the store is located in Norway). Now the users can only chose between English, French, Spanish and Chinese.

Anybody got a suggestion on how to fix this?
Thanks
Language selection
42 Samstag, 27. März 2010 um 13:13 Uhr
pat
This is what I was looking for a longtime. Thank you very much. There Is only one problem: whit the default paypal configuration in VM I could select between English, French, and german langugae on the Paypal site. Now I don't have any longer German. Instead I have English, French, Spanish and Chinese. How can I change this?
fixed shipping!
41 Mittwoch, 03. März 2010 um 11:34 Uhr
The Spotted Sparrow
Don't you hate when you've spent hours, if not days, on something and it turns out to be the simplest thing? I just solved my own problem.

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!
shipping not working
40 Mittwoch, 03. März 2010 um 10:42 Uhr
The Spotted Sparrow
I was hoping this would work, but the shipping charges are all screwed up. The VirtueMart total (including shipping) is being passed on to PayPal and then PayPal is tacking on additional shipping charges.

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?
How can I use these codes with Larsen Patch?
39 Samstag, 27. Februar 2010 um 18:32 Uhr
president
I am using Joomla 1.5.15 and VirtueMart 1.1.4. And Larsen's VirtueMart PayPal Patch v0.4 This is the link http://www.b-planet.com/VirtueMart/paypal-patch.html

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
correct shipping for me
38 Dienstag, 09. Februar 2010 um 15:55 Uhr
torben
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.
shipping
37 Montag, 08. Februar 2010 um 17:28 Uhr
torben
HI I was looking for this a long time, still, something is not yet working as it should.

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!
discounts and taxes
36 Freitag, 22. Januar 2010 um 05:37 Uhr
andrea
Does this fix show prices including tax?
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.
2 issues here
35 Sonntag, 10. Januar 2010 um 21:39 Uhr
akeem
Hi All,

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
Shipping address etc
34 Freitag, 01. Januar 2010 um 20:09 Uhr
GJG (admin)
There's been a couple of comments about no shipping/billing address.

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.
@Robert
33 Freitag, 01. Januar 2010 um 20:03 Uhr
GJC (admin)
Sorry for the delay in answering.
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) will always fail
32 Montag, 21. Dezember 2009 um 21:59 Uhr
thehoffr
Seem like this test:
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.
PayPal transaction with VM
31 Dienstag, 01. Dezember 2009 um 05:58 Uhr
Robert
The code and solution above is great, Thanks!

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
Passing only charge transaction to PayPal to verify
30 Dienstag, 01. Dezember 2009 um 05:35 Uhr
Robert
This code is great! The only thing I want to do is pass the total to paypal with the credit card info entered in VM, verify the amount, make the transaction and return either confirmed or denied to notify.php. Is there anyway to do this simple thing?

Thanks,

Robert
No shipping address to Paypal
29 Dienstag, 17. November 2009 um 08:38 Uhr
Irene
Hi, It's very nice. But the problem is no shipping address be sent to Paypal as your sample above. Can anyone help ?
Thank you so much
28 Mittwoch, 28. Oktober 2009 um 13:15 Uhr
Erfan
Thanks thanks thanks
@GJC
27 Sonntag, 18. Oktober 2009 um 13:37 Uhr
buglyo Balazs
Thx
@buglyo Balazs
26 Sonntag, 18. Oktober 2009 um 07:16 Uhr
GJC (admin)
Nope, .....
Only Credit Card?
25 Sonntag, 18. Oktober 2009 um 02:53 Uhr
buglyo Balazs
Hi Dear!

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.
@Tony Scott
24 Montag, 28. September 2009 um 18:04 Uhr
GJC (admin)
This is the line that's passing the amount-->
"amount" => round( $db->f("order_subtotal")+$tax_total-$discount_total, 2),


try
"amount" => $db->f("order_subtotal")+$tax_total-$discount_total,
paypal payment dont match
23 Montag, 28. September 2009 um 14:32 Uhr
Tony Scott
I wonder if you can help me

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 Very Happy
Regards

Tony
Any input please?
22 Freitag, 28. August 2009 um 16:40 Uhr
Rodrigo G
Please any input as far as my last comment? I am not that very good with coding.

Thanks.
shipping address and charge
21 Montag, 24. August 2009 um 20:03 Uhr
Rodrigo G
Hello admin, i did not need to comment anything, after i allowed paypal to override the shipping charge cost it went just well.

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
@Rodrigo Garcia
20 Freitag, 14. August 2009 um 18:37 Uhr
GJC (admin)
Try commenting out handling_cart
simply
19 Freitag, 14. August 2009 um 16:18 Uhr
Rodrigo G
I want paypal to calculate and use its shipping calculator.

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.
shipping
18 Freitag, 14. August 2009 um 16:02 Uhr
Rodrigo G
what i meant is to let VM calculate the shipping, but not to carry the shipping value to paypal and let paypal calculate it. Since it is the same value.

So i want to comment out (add // to the code) the lines that carry that value to the Paypal checkout.
Paypal postage @ Rodrigo G
17 Donnerstag, 13. August 2009 um 19:03 Uhr
GJC (admin)
Not sure what you mean but the simplest way is to remove all shipping calculations from the Paypal admin (nothing to do with this script) and just let VM handle the shipping
What to remove.
16 Donnerstag, 13. August 2009 um 17:01 Uhr
Rodrigo G
GJC, I am ot going to fight paypal anymore, i am going to let VM calculate the shipping value (same rules as Paypal Shopping cart), then i want to drop the shipping calculation and let paypal add it itself.

Which part of the code should i comment out in order to do this?

Thanks again for all your help.
@Robert
15 Montag, 03. August 2009 um 06:36 Uhr
GJC (admin)
Have u removed all postage and shipping from the Paypal backend?
postage problems!
14 Sonntag, 02. August 2009 um 20:31 Uhr
Hamilton
HI there.
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
One more suggestion
13 Dienstag, 28. Juli 2009 um 19:37 Uhr
Claudiu
After the payment is completed on PayPal, a "Return to Merchant" button shows on PayPal.
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.
@Claudiu
12 Samstag, 25. Juli 2009 um 06:32 Uhr
GJC (admin)
Thanks for that and apologies!
I'd actually found that mistake and thought I'd updated the page, sorry.
It's updated now..
Cheers..
Great work. One suggestion.
11 Samstag, 25. Juli 2009 um 00:24 Uhr
Claudiu
I use this code and the items are now showing in PayPal. Thanks for this.

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!
you are correct
10 Donnerstag, 16. Juli 2009 um 19:36 Uhr
Rodrigo Garcia
i saw wha you meant as far as the shipping, you are the man!.
@Rodrigo Garcia
9 Donnerstag, 16. Juli 2009 um 15:31 Uhr
GJC (admin)
But this means you have shipping set in the Paypal backend.
Disable this and just let VirtueMart pass the shipping, then you won't have to update both.
thanks
8 Donnerstag, 16. Juli 2009 um 13:41 Uhr
Rodrigo Garcia
The code is awesome and thank you for your reply, yes that does tell paypal not to add its shipping, but when i enter my paypal login and pass to pay, it included the shipping of vm+the one for paypal.

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.
@Rodrigo Garcia
7 Donnerstag, 16. Juli 2009 um 05:50 Uhr
GJC (admin)
All I can say is this script I personally have used in multiple VM installations and it works.
This line - "no_shipping" => "1", tells Paypal not to add it's own shipping.
Double check all your configs in VM and Paypal.
Paypal inherits the shipping cost and adds it again.
6 Mittwoch, 15. Juli 2009 um 21:11 Uhr
Rodrigo Garcia
I copied and paste the code and it looks great, however after the user logs in with his/hers paypal login and password paypal adds once more the shipping price, so it charges the shipping once (shows USPS 4.95 and the total shipping is 9.90).

Any help?
billing/shipping address
5 Freitag, 03. Juli 2009 um 11:20 Uhr
GJC (admin)
I'm not sure what problem your referring to, can you give us more info.
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
What about the billing address
4 Donnerstag, 02. Juli 2009 um 20:12 Uhr
mari
Yes that would concern me as well.. has the code been fixed for that? As I would love to use this if so.

Thanks
Almost works for me
3 Dienstag, 30. Juni 2009 um 04:21 Uhr
Ryan
I like what you are trying to do; however it replaces the billing address with the shipping address...so credit cards do not verify. Any suggestion on how to pass both the billing and shipping address to Paypal?
Glad to help!
2 Montag, 04. Mai 2009 um 08:48 Uhr
GJC (admin)
Good that you found it useful.
Please social bookmark to spread the info... Smile
THANKS!
1 Montag, 04. Mai 2009 um 08:31 Uhr
andrew
ahhh, beautiful. also solved my problem with the shipping value not being passed by the default extra_info. did paypal replace the shipping parameter with handling_cart ?

Add your comment

BoldItalicUnderlineStrikethroughSubscriptSuperscriptEmailImageHyperlinkOrdered listUnordered listQuoteCodeHyperlink to the Article by its id
Very HappySmileWinkSadSurprisedShockedConfusedCoolLaughingMadRazzEmbarrassedCrying or Very SadEvil or Very MadTwisted EvilRolling EyesExclamationQuestionIdeaArrowNeutralMr. GreenGeekUber Geek
Your name:
Titel:
Comment:



Improved configuration of the VirtueMart 1.1 Paypal payment module



How to configure the VirtueMart 1.1. payment module to be much more customer friendly.


order, address, paypal, country, dboi, query, value, supp, var, dboui, dbb, info, quantity, attributes, discount, number, code, payment, product, user, tax, virtuemart, item, total, phone, attrib, zip, cart, array, state, city, module, peritem, foreach, shipping, url, oui, disc, echo, string