magento2 – Custom Order API Extension Attribute Not Saving

I am trying to create a new extension attribute for the order API but I keep getting “does not have accessor method getRepeatOrder” error when I call the API endpoint.
This is how I currently have things setup.

Vendor/Module/etc/extension_attributes.xml

<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Api/etc/extension_attributes.xsd">
    <extension_attributes for="MagentoSalesApiDataOrderInterface">
        <attribute code="repeat_order" type="VendorModuleApiDataRepeatOrderInterface"/>
    </extension_attributes>
</config>

Vendor/etc.di.xml

<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/ObjectManager/etc/config.xsd">
    <preference for="VendorModuleApiDataRepeatOrderInterface" type="VendorModuleModelDataRepeatOrder"/>
</config>

Vendor/Module/Api/Data/RepeatOrderInterface

<?php

namespace VendorModuleApiData;

use MagentoFrameworkApiExtensibleDataInterface;

interface RepeatOrderInterface extends ExtensibleDataInterface
{
    const REPEAT_ORDER = 'repeat_order';

    /**
     * Get repeat order value
     * 
     * @return string
     */ 
     public function getRepeatOrder();   
     
     /**
     * Set repeat order value
     * 
     * @param string $repeatOrder
     * @return $this
     */ 
     public function setRepeatOrder($repeatOrder);
}

Vendor/Module/Model/Data/RepeatOrder

<?php       
        
namespace VendorModuleModelData;     

use VendorModuleApiDataRepeatOrderInterface;
use MagentoFrameworkModelAbstractExtensibleModel;

class Items extends AbstractExtensibleModel implements RepeatOrderInterface
{       
    /**     
     * {@inheritdoc}        
     */     
    public function getRepeatOrder()        
    {       
        return $this->getData(self::REPEAT_ORDER);  
    }       
        
    /**     
     * {@inheritdoc}        
     */     
    public function setRepeatOrder($repeatOrder)        
    {       
        return $this->setData(self::REPEAT_ORDER, $repeatOrder);    
    }
}   

Vendor/Plugin/OrderRepositoryPlugin

<?php
namespace VendorModulePlugin;
 
use MagentoSalesApiDataOrderExtensionFactory;
use MagentoSalesApiDataOrderExtensionInterface;
use SonsAPIApiDataRepeatOrderInterface;
use MagentoSalesApiDataOrderSearchResultInterface;
use MagentoSalesApiOrderRepositoryInterface;
 

class OrderRepositoryPlugin
{
    const REPEAT_ORDER = 'repeat_order';
 
    protected $extensionFactory;
 
    public function __construct(OrderExtensionFactory $extensionFactory)
    {
        $this->extensionFactory = $extensionFactory;
    }

    public function beforeSave(
        OrderRepositoryInterface $subject,
        RepeatOrderInterface $order
    ) {
        $extensionAttributes = $order->getExtensionAttributes(); 
        $extensionAttributes = $extensionAttributes ? $extensionAttributes : $this->extensionFactory->create();

        $repeatOrderAttribute = $extensionAttributes->getRepeatOrder();

        if (!is_null($repeatOrderAttribute)) {
            $order->setData('repeat_order',$repeatOrderAttribute);
        }

        return $order;
    }
}

But whenever I make a call to {magento_api_url}/V1/orders using the following payload:

{
  "entity":{
    "entity_id":1557418,
    "repeat_order":"true"
  }
}

I get the following error: "message": "Property "RepeatOrder" does not have accessor method "getRepeatOrder" in class "Magento\Sales\Api\Data\OrderInterface".",

I’d really appreciate any help on this one, as it’s been driving me crazy all day 😀

Thanks everyone,

Best wishes