Guest krypton1 Posted February 24, 2006 Share Posted February 24, 2006 Hi Guys, For those of you using paypal payment pro (aka paypal direct payment), you might have noticed that it is annoying that the shipping address info is not passed to paypal. Lots of people like to go to their paypal accounts and there is a link that says "ship" that already has the address info filled in. Then they can quickly print a USPS (or other) shipping label and be on their way. For some reason the standard paypal direct payment module doesn't include the shipping address info when the data is sent to paypal. This mod fixes that. By the way, you have Insurrectus to thank for this mod, since he paid good money for it! The rest of you are getting it for free. Open your modules\gateway\DirectPayment\form.inc.php file Around line 124, after this: if(($itemAmount + $taxAmount + $shippingAmount) == $orderAmount) { $itemTotal =& Services_PayPal::getType('BasicAmountType'); $itemTotal->setval(number_format($itemAmount, 2)); $itemTotal->setattr('currencyID', $currencyID); // USD $pdt->setItemTotal($itemTotal); $taxTotal =& Services_PayPal::getType('BasicAmountType'); $taxTotal->setval(number_format($taxAmount, 2)); $taxTotal->setattr('currencyID', $currencyID); // USD $pdt->setTaxTotal($taxTotal); $shippingTotal =& Services_PayPal::getType('BasicAmountType'); $shippingTotal->setval(number_format($shippingAmount, 2)); $shippingTotal->setattr('currencyID', $currencyID); // USD $pdt->setShippingTotal($shippingTotal); } add this in (make sure it is AFTER the curly brace above) //START - adding info for shipping address $shipAddress =& Services_PayPal::getType('AddressType'); $shipAddress->setName($basket['delInf']['firstName']." ".$basket['delInf']['lastName']); $shipAddress->setStreet1($basket['delInf']['add_1']); $shipAddress->setStreet2($basket['delInf']['add_2']); $shipAddress->setCityName($basket['delInf']['town']); $shipAddress->setStateOrProvince($basket['delInf']['county']); $shipAddress->setCountry(countryIso($basket['delInf']['country'])); $shipAddress->setPostalCode($basket['delInf']['postcode']); $pdt->setShipToAddress($shipAddress); //END - adding info for shipping address It looks simple, but it took a while to get it right. Brian Quote Link to comment Share on other sites More sharing options...
Guest Posted March 26, 2006 Share Posted March 26, 2006 krypton1 nice work! I just installed and tested this mod on my site and it worked perfectly! Actually I think this mod should be included in the next CubeCart update. This is really an important feature of PayPal that has been left out of the PayPal Direct mod. Quote Link to comment Share on other sites More sharing options...
Guest Posted May 10, 2006 Share Posted May 10, 2006 Just an update. I changed the first code from: //START - adding info for shipping address $shipAddress =& Services_PayPal::getType('AddressType'); $shipAddress->setName($basket['delInf']['firstName']." ".$basket['delInf']['lastName']); $shipAddress->setStreet1($basket['delInf']['add_1']); $shipAddress->setStreet2($basket['delInf']['add_2']); $shipAddress->setCityName($basket['delInf']['town']); $shipAddress->setStateOrProvince($basket['delInf']['county']); $shipAddress->setCountry(countryIso($basket['delInf']['country'])); $shipAddress->setPostalCode($basket['delInf']['postcode']); $pdt->setShipToAddress($shipAddress); //END - adding info for shipping address TO // *************** S T A R T ******************* // * This will change the delivery State/County* // * from whatever to either its abbreviation * // * or XX which PayPal will accept. * // ********************************************* $newst = $basket['delInf']['county']; // look up county for shipping address $newLookup = $db->select("SELECT abbrev FROM `".$glob['dbprefix']."CubeCart_iso_counties` WHERE `name` LIKE '".$newst."'"); if(strlen($basket['delInf']['county'])==2){ $newst = strtoupper($basket['delInf']['county']); } elseif($newLookup == TRUE) { $newst = $newLookup[0]['abbrev']; } else { $newst = "XX"; } //START - adding info for shipping address $shipAddress =& Services_PayPal::getType('AddressType'); $shipAddress->setName($basket['delInf']['firstName']." ".$basket['delInf']['lastName']); $shipAddress->setStreet1($basket['delInf']['add_1']); $shipAddress->setStreet2($basket['delInf']['add_2']); $shipAddress->setCityName($basket['delInf']['town']); $shipAddress->setStateOrProvince($newst); $shipAddress->setCountry(countryIso($basket['delInf']['country'])); $shipAddress->setPostalCode($basket['delInf']['postcode']); $pdt->setShipToAddress($shipAddress); //END - adding info for shipping address PayPal Direct was having a problem with non-abbreviated County/State names, and would fail the shipping address during the transaction. To get around this, now if the customers shipping state is 'New Jersey', this will automatically abbreviate to 'NJ' which passes through PayPal fine. If the shipping state is already 'NJ', it will leave it alone. And finally if it's something that is not identifiable on the iso_counties database table, it will change it to 'XX' which also passes PayPal's processing okay. -Tim Quote Link to comment Share on other sites More sharing options...
Guest krypton1 Posted May 10, 2006 Share Posted May 10, 2006 Nice solution Tim! Also, for anyone trying to enforce that their customers use a two letter state code when they register, this solution by funkelectic may be of some value: http://www.cubecart.com/site/forums/index....t=0entry90519 I think using that with Tim's code should solve 99.99% of cases. Quote Link to comment Share on other sites More sharing options...
Guest jimrobo Posted July 13, 2006 Share Posted July 13, 2006 Does anyone know if there is a paypal standard mod to drop the address for paypal. PayPal have told me the code that needs to go next to the button......BUT......I can't find the code for the button anywhere!!!! Can anyone help????? Thanks Jonny Quote Link to comment Share on other sites More sharing options...
difonzo Posted December 11, 2007 Share Posted December 11, 2007 Hi, I use Paypal Standard IPN, and the address info WAS being passed thru with no problem until a few days ago. It seems to be random, but now, 75% or so of my orders do not pass the shipping addresses... Any ideas? TIA, Rick Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.