I'm trying to only allow the "checkmo" payment method to be used when an order is placed through the API, but not available for a customer on the frontend to choose.
Ive tried creating a plugin that essentially does the following -
$area_code = $this->app_state->getAreaCode();
if($area_code != \Magento\Backend\App\Area\FrontNameResolver::AREA_CODE){
if($subject->getCode() == 'checkmo') {
return false;
}
This blocks the payment method from the frontend fine, but won't allow it to be used when the API looks at available payment methods. I'm guessing this is because the API is considered frontend.
Is there any way around this, or can another payment method be created where only API orders can access?