0

I'm develop a custom payment method module.When I click place order buttom,page always is loading,can't go to next step. enter image description here When I use other paymen method,I can get error message "Some addresses can't be used due to the configurations for specific countries" like picture. enter image description here

I know the error message is from domain.com/rest/default/V1/carts/mine/payment-information.How to display this kind error message in my payment method?

0

The messageManager object is responsible for messaging in Magento 2. It means that you need to get its instance to write messages. The preferred way is the following: you have to inject this class into your class by adding the following snippet to your __construct method:

protected messageManager;

public function __construct(
    ...
    \Magento\Framework\Message\ManagerInterface $messageManager,
    ...
){
    $this->messageManager = $messageManager;
    ...
}

Now, you can call one of these messages:

$this->messageManager->addError(__("Error"));
$this->messageManager->addWarning(__("Warning"));
$this->messageManager->addNotice(__("Notice"));
$this->messageManager->addSuccess(__("Success"));
| improve this answer | |

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.