0

I am overriding Worldpay Model class that create xml request file.

<?xml version="1.0" encoding="UTF-8"?>
    <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
        <preference for="Sapient\Worldpay\Model\XmlBuilder\RedirectOrder" type="Company\Worldpay\Model\XmlBuilder\RedirectOrder" />
    </config>

Model code:

    <?php
    /**
     * @copyright 2017 Sapient
     */
    namespace Company\Worldpay\Model\XmlBuilder;

    use Sapient\Worldpay\Model\XmlBuilder\Config\ThreeDSecureConfig;

    /**
     * Build xml for RedirectOrder request
     */
    class RedirectOrder extends \Sapient\Worldpay\Model\XmlBuilder\RedirectOrder
    {
//code here
    }

I am unable to override this piece of code. As I do the same thing for another file its override successfully but this RedirectOrder is not. Please refer complete file that I want to override.

updated constructor code:

public function __construct(array $args = array())
    {
         $this->threeDSecureConfig = new \Sapient\Worldpay\Model\XmlBuilder\Config\ThreeDSecure();

        $this->tokenRequestConfig = new \Sapient\Worldpay\Model\XmlBuilder\Config\TokenConfiguration($args['tokenRequestConfig']);
        $this->shopperId = $args['shopperId'];

    }
  • what do you mean by "unable to override"? please explain what your error is – Philipp Sander Apr 3 at 11:44
  • My new class code is not executing, di.xml <preference is not working – Charlie Apr 3 at 11:46
  • there are no errors main "\Sapient\Worldpay\Model\XmlBuilder\RedirectOrder" is executing everytime – Charlie Apr 3 at 11:49
  • is the module enabled? did you clean your DI-cache? – Philipp Sander Apr 3 at 11:51
  • 1
    @Charlie what you have changed in constructor. Actually i have not found any change. – Rutvee Sojitra Apr 3 at 12:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.