How to handle payment through Paypal without collecting the shipping infromation?
-
12-12-2019 - |
Question
The store that I am working on is a Pick-up store, which means that customers can order the things on-line but collection of orders has to be done from the store itself; the customers have to go to the store to collect order items.
Hence, there is nothing like shipping for this online store. So we donot collect shipping information from the user during registration as instructed by the client.
Now at the same time, the client insists to use Paypal Express Checkout for the payment.
Which means that if the user is registered but his shipping information is not available, and if he tries to checkout, the following error appears :
"PayPal gateway has rejected request. The field Shipping Address1 is required (#10727: Shipping Address1 Empty). The field Shipping Address City is required (#10728: Shipping Address City Empty)."
Is there anyway to handle the situation??
I mean, can I do something so that the above fields for Paypal do not remain compulsory or else pass some random static value for them along with other parameters to Paypal?
Any help would be appreciated.
Thanks in advance
Solution
Have a look at class Mage_Paypal_Model_Api_Nvp
and method callSetExpressCheckout()
. Right above this you will see a link to https://cms.paypal.com/us/cgi-bin/?&cmd=_render-content&content_ID=developer/e_howto_api_nvp_r_SetExpressCheckout
. If you visit this page you will find you can pass the argument NOSHIPPING
with 1 of three values, 0
, 1
or 2
. 1
is described as:
PayPal does not display shipping address fields whatsoever
It also says in the description:
For digital goods, this field is required, and you must set it to 1
You effectively have digital goods as you have no shipping address, so you need to pass NOSHIPPING
with a value of 1
to the SetExpressCheckout
call which you can do in the callSetExpressCheckout()
method. So rewrite this class in your own module and add the extra paramater into the method, something like the following:
public function callSetExpressCheckout()
{
// rest of the method here
$request['NOSHIPPING'] = 1; // add this line
$response = $this->call(self::SET_EXPRESS_CHECKOUT, $request);
$this->_importFromResponse($this->_setExpressCheckoutResponse, $response);
}
OTHER TIPS
This is configurable, just hidden under advanced settings:
See: Require Customer's Billing Address.
Edit:
So after review of comments and other answers, there's no need to modify the core code. Simply use $quote->setIsVirtual() in your checkout template or block.
Observe around line 331 in Mage/Paypal/Model/Checkout/Express.php in a 1.9.0.1 install:
// supress or export shipping address
if ($this->_quote->getIsVirtual()) {
if ($this->_config->requireBillingAddress == Mage_Paypal_Model_Config::REQUIRE_BILLING_ADDRESS_VIRTUAL) {
$this->_api->setRequireBillingAddress(1);
}
$this->_api->setSuppressShipping(true);