Unfortunately, there's no way to directly access the parameters via API (we tried to do that but failed). However, we've found an alternative method to get them.
As you probably know, an API request is also classifed as 'Request', and the parameters are anyway sent to it and stored in the
processApiRequest method. If you have a closer look at it, you'll see that the
\Magento\Webapi\Controller\Rest\InputParamsResolver deals with the request parameters. Hence, we can use it to extract the needed parameters from the API request.
Add the class
\Magento\Webapi\Controller\Rest\InputParamsResolver to the di (dependency injection) of your payment class in the
You'll get the parameters in the following way:
$inputParams = $inputParamsResolver->resolve();
The result of your request will look somewhat like this (in my example, it was implemented on the Check Money Order method):
additional_data can be found in the instance
These parameters are exactly the same, as those that are sent to a method called via API:
Just note that this approach has some pitfalls. The parameters come raw, in the array, so you'll have to sort them to find the needed ones.
P.S. If to take the quote payment directly from the quote available via payment info method,
$paymentInfo = $this->getInfoInstance();
$additionalData = $paymentInfo->getQuote()->getPayment()->getData('additional_data');
it's possible to see that the parameter from the request is not there.