I've set up a new payment method in Magento 2 with a custom payment method field (like "po_number" from magento/offline-payment-methods). And front end is working perfectly fine (field showing up, validation, etc.).
However, if I want to place the order Magento the WebAPI request throws the following error:
"Property \"CustomField\" does not have corresponding setter in class \"Magento\Quote\Api\Data\PaymentInterface\".
It seems that Magento validates the custom field against the core payment interface where methods like getPoNumber and setPoNumber are defined.
I already tried to add the custom field via extension attributes:
<extension_attributes for="Magento\Quote\Api\Data\PaymentInterface">
<attribute code="custom_field" type="Vendor\Module\Api\Data\MethodInterface[]" />
</extension_attributes>
and created the interface with the specific methods:
<?php
namespace Vendor\Module\Api\Data;
use Magento\Framework\Api\ExtensibleDataInterface;
interface MethodInterface extends ExtensibleDataInterface
{
public function setCustomField($customField);
public function getCustomField();
}
But this doesn't work. Magento still validates against the core payment interface.
The question now is, how to get Magento to accept the custom payment method field? Any pointers are much appreciated :)