3

I am working on creating a way to make an order via the magento api and wondering if it is possible to access internal payment methods (payment methods that are only enabled for the admin panel) via the api?

So for example I have a plugin that creates a payment method that can only be seen/used via the magento admin panel. however when I use the magento API to list out payment methods I do not see that payment method listed and think its because its set to be viewable/usable only on the admin panel. So what would i change in the api call to gain access to it?

0

Normally all the payment methods made in magento 2 extend vendor/magento/module-payment/Model/Method/AbstractMethod.php class or extend the child class of this class.

The isAvailable() function of this class defines whether the payment method will be rendered or not. So, I suggest looking into the Model directory of the payment method and looking into isAvailable() payment model of the method.

Also note that the view files needed to render payment form (if any) maybe made according to backend only. You may have to create them for frontend (or maybe not if they are using cc-form from default magento 2).

  • Are internal payment methods accessable when using Magento2 API to programmatically create an order? – Jayreis Apr 23 at 19:22
0

try set your function with areacode adminhtml:

$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$area = $objectManager->get('Magento\Framework\App\State');
$area->setAreaCode(\Magento\Framework\App\Area::AREA_ADMINHTML);
 /// do your code here

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.