3

We are using REST API for mobile app from magento 2. We are try to place order using paypal express checkout method. But we get error. Check detail bellow.

API call.

Call Type : PUT

API URL : https://example.com/index.php/rest/V1/carts/302/order

Request Body

{
    "paymentMethod": {
          "method": "paypal_express",
          "additional_data": {
                 "paypal_express_payment_payload": {
                       "create_time":"2019-04-15T23:13:52Z",
                       "id":"PAY-6RV70583SB702805EKEYSZ6Y",
                       "intent":"sale",
                       "state":"approved"
                 }
          }
    }
}

Response of API call :

{ "message": "Internal Error. Details are available in Magento log file. Report ID: webapi-5cb8df18c6197" }

Magento Error log

    [2019-04-18 20:33:28] main.CRITICAL: Report ID: webapi-5cb8df18c6197; Message: Notice: Array to string conversion in /vendor/magento/framework/Reflection/TypeProcessor.php on line 473 
{"exception":"[object] (Exception(code: 0): Report ID: webapi-5cb8df18c6197; Message: Notice: Array to string conversion in /vendor/magento/framework/Reflection/TypeProcessor.php on line 473 
at /vendor/magento/framework/Webapi/ErrorProcessor.php:206, Exception(code: 0): Notice: Array to string conversion in /vendor/magento/framework/Reflection/TypeProcessor.php on line 473 at /vendor/magento/framework/App/ErrorHandler.php:61)"} []

Here is my postman screenshot.

enter image description here

enter image description here

Response after developer mode enabled

enter image description here

5
  • can you post your whole code on making put request or a screenshot in postman
    – fmsthird
    Commented Apr 19, 2019 at 4:26
  • @magefms i have added postman code. please check it. Commented Apr 19, 2019 at 9:07
  • I see. how about the headers?
    – fmsthird
    Commented Apr 19, 2019 at 10:12
  • @magefms now i added headers. Commented Apr 19, 2019 at 17:07
  • everything is good. The error is weird can you please enable developer mode and check if the exact error will come out
    – fmsthird
    Commented Apr 20, 2019 at 0:12

1 Answer 1

0

As far I understood, It is a known issue of Magento 2. You need to wrote a module with a preference for Magento\Quote\Observer\Frontend\Quote\Address\VatValidator in your module di.xml and copied the validate method

Added these lines of code in the method

if (is_array($quoteAddress->getRegion()))
{
                $regionData = $quoteAddress->getRegion();
                if (array_key_exists('region_code', $regionData))
                {
                    $quoteAddress->setRegionCode($regionData['region_code']);
                }
                if (array_key_exists('region_id', $regionData))
                {
                    $quoteAddress->setRegionId($regionData['region_id']);
                }
                $quoteAddress->setRegion(null);
}

before Store validation

// Store validation results in corresponding quote address
  $quoteAddress->setVatIsValid((int)$validationResult->getIsValid());
  $quoteAddress->setVatRequestId($validationResult->getRequestIdentifier());

Reference: https://github.com/magento/magento2/issues/12612

I hope this will help

1
  • @JalpeshPatel Have you resolve your query? Commented Apr 22, 2019 at 7:16

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.