Jump to content

shipping/delivery address for paypal direct payment


Guest krypton1

Recommended Posts

Guest krypton1

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

Link to comment
Share on other sites

  • 1 month later...

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.

Link to comment
Share on other sites

  • 1 month later...

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

Link to comment
Share on other sites

  • 2 months later...
Guest jimrobo

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

Link to comment
Share on other sites

  • 1 year later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...