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

  • can you post your whole code on making put request or a screenshot in postman – magefms Apr 19 at 4:26
  • @magefms i have added postman code. please check it. – Jalpesh Patel Apr 19 at 9:07
  • I see. how about the headers? – magefms Apr 19 at 10:12
  • @magefms now i added headers. – Jalpesh Patel Apr 19 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 – magefms Apr 20 at 0:12
0

As far I understood, It is known issue of Magento 2. You need to wrote a module with 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 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

  • @JalpeshPatel Have you resolve your query? – Muhammad Hasham Apr 22 at 7:16

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.