I am getting below error on rest api call on this method

public function handleDecline($order)
        $result = $this->forterConfig->getDeclinePost();
        if ($result == '1') {
            if ($order->canHold()) {
                $this->setMessageToQueue($order, 'decline');
        } elseif ($result == '2') {

        throw new PaymentException($this->forterConfig->getPostThanksMsg());

TypeError: Argument 1 passed to Magento\Framework\Exception\LocalizedException::__construct() must be an instance of Magento\Framework\Phrase, string given, called in

Any thoughts how this can be solved ?

I think this is related to type of "$this->forterConfig->getPostThanksMsg()"

1 Answer 1


Use that:

throw new PaymentException(__($this->forterConfig->getPostThanksMsg()));

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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