3

One of my customer purchased a physical product via Paypal Express Checkout. His shipping address is oversea.

However Paypal refuses the payment, because Paypal doubts the account/credit card is stolen (because of oversea shipping address).

Paypal suggests us NOT sending the shipping address to them.

How we could achieve this in Magento?

  • Customer required to fill-in the shipping address in order form
  • but not sending to Paypal.
  • Customer should be able to review the shipping address in My Order afterward.

Thanks a lot !

2
  • 1
    By following magento.stackexchange.com/questions/45282/…. Please first try in file magento\vendor\magento\module-paypal\Model\Api\Nvp.php set $request['NOSHIPPING'] = 1; // add this line. If it works fine then Override that File
    – Jackson
    Dec 12, 2016 at 4:02
  • @Jackson where we need to add this line? it is on public function call($methodName, array $request) Oct 3, 2023 at 14:52

1 Answer 1

2

You can create a Plugin for it.

Declare module - /app/code/Namespace/Module/registration.php :

<?php
\Magento\Framework\Component\ComponentRegistrar::register(
    \Magento\Framework\Component\ComponentRegistrar::MODULE,
    'Namespace_Module',
    __DIR__
);

Declare Plugin - /app/code/Namespace/Module/etc/di.xml :

<?xml version="1.0" ?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
    <type name="Magento\Paypal\Model\Api\Nvp">
        <plugin sortOrder="1" name="namespaceModuleNvp" type="Namespace\Module\Plugin\Model\Api\NvpPlugin"/>
    </type>
</config>

Plugin file - /app/code/Namespace/Module/Plugin/Model/Api/NvpPlugin.php :

<?php

namespace Webart\Base\Plugin\Model\Api;

/**
 * Class NvpPlugin
 * @package Webart\Base\Plugin\Model\Api
 */
class NvpPlugin
{
    /**
     * @param \Magento\Paypal\Model\Api\Nvp $subject
     * @param callable $proceed
     * @param $methodName
     * @param array $request
     * @return mixed
     */
    public function aroundCall(\Magento\Paypal\Model\Api\Nvp $subject, callable $proceed, $methodName, array $request)
    {
        $request['NOSHIPPING'] = 1; // All this stuff for that ;-)
        return $proceed($methodName, $request);
    }
}
2
  • Can We pass "NOSHIPPING" if free shipping selected? Apr 8, 2019 at 8:48
  • No need for an around plugin. Using beforeCall() is enough. Feb 23, 2021 at 14:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.