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

asked Apr 18, 2019 at 20:36
5
  • can you post your whole code on making put request or a screenshot in postman 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? 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 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

Msquare
9,4627 gold badges30 silver badges71 bronze badges
answered Apr 19, 2019 at 5:08
1
  • @JalpeshPatel Have you resolve your query? Commented Apr 22, 2019 at 7:16

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.