Zend certified PHP/Magento developer

Adding an input to all payment methods in checkout: accessor error

I’m adding a custom input to the checkout place order.

The input appears in the payment so this seems to be fine but it’s not.

When trying to place the order i was having this error :

Message: Property “Numfacture” does not have accessor method “getNumfacture” in class “MagentoQuoteApiDataPaymentInterface”

So I said ok it makes sense, it’s a new field, I need to add it

So i created :

<preference for="MagentoQuoteApiDataPaymentInterface" type="CpyPaymentLcrApiDataPaymentInterface"/>
<preference for="MagentoQuoteModelQuotePayment" type="CpyPaymentLcrModelQuotePayment"/>

And I defined the accessors

namespace CpyPaymentLcrApiData;


interface PaymentInterface extends MagentoQuoteApiDataPaymentInterface
{

    /**#@+
     * Constants defined for keys of array, makes typos less likely
     */
    const KEY_NUM_FACTURE = 'numfacture';

    /**
     * Get invoice number
     *
     * @return string|null
     */
    public function getNumfacture();

    /**
     * Set invoice number
     *
     * @param string $numfacture
     * @return PaymentInterface
     */
    public function setNumfacture($numfacture);

}

So as the model from the preference ; but now I’m getting

main.CRITICAL: Error: Cannot instantiate interface CpyPaymentLcrApiDataPaymentInterface in /var/www/magento/vendor/magento/framework/ObjectManager/Factory/AbstractFactory.php:121

And can’t understand why.

Any idea ?