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.
Response after developer mode enabled
-
can you post your whole code on making put request or a screenshot in postmanfmsthird– fmsthird2019年04月19日 04:26:26 +00:00Commented Apr 19, 2019 at 4:26
-
@magefms i have added postman code. please check it.Jalpesh Patel– Jalpesh Patel2019年04月19日 09:07:01 +00:00Commented Apr 19, 2019 at 9:07
-
I see. how about the headers?fmsthird– fmsthird2019年04月19日 10:12:39 +00:00Commented Apr 19, 2019 at 10:12
-
@magefms now i added headers.Jalpesh Patel– Jalpesh Patel2019年04月19日 17:07:11 +00:00Commented 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 outfmsthird– fmsthird2019年04月20日 00:12:11 +00:00Commented Apr 20, 2019 at 0:12
1 Answer 1
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
-
@JalpeshPatel Have you resolve your query?Muhammad Hasham– Muhammad Hasham2019年04月22日 07:16:48 +00:00Commented Apr 22, 2019 at 7:16