Magento – Paypal Express Checkout without shipping address

magento2orderspaypal

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 !

Best Answer

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);
    }
}
Related Topic