0

Internal Error. Details are available in Magento log file. Report ID: webapi-5a291a13d9760

I am using Magento 2.1

I am hitting the url to place order:-

Method:- PUT
https://www.xxxxxx.com/index.php/rest/V1/guest-carts/ddaae427f0a12acf52a73b056b78++++/order

My Payment Method is COD!

I am sending in Body

{
 "paymentMethod": {
 "code": "cashondelivery",
 "title": "Cash On Delivery"
 }
}

Expected result: Order_ID

Actual result it is returning:

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

Log.FILE: Next Exception: Report ID: webapi-5a291a13d9760; Message: Property "Code" does not have corresponding setter in class "Magento\Quote\Api\Data\PaymentInterface". in /var/www/vhosts/myserverexample.com/httpdocs/vendor/magento/‌​framework/Webapi/Err‌​orProcessor.php:195

asked Dec 8, 2017 at 7:09
2
  • Could you also add the content of a log file? Commented Dec 8, 2017 at 7:12
  • Next Exception: Report ID: webapi-5a291a13d9760; Message: Property "Code" does not have corresponding setter in class "Magento\Quote\Api\Data\PaymentInterface". in /var/www/vhosts/myserverexample.com/httpdocs/vendor/magento/framework/Webapi/ErrorProcessor.php:195 Commented Dec 8, 2017 at 8:28

2 Answers 2

1

The Magento-2, the place order is done by the function savePaymentInformationAndPlaceOrder() and it is defined in two model files. For guest user , it is invoked from the model \Magento\Checkout\Model\GuestPaymentInformationManagement and it takes 4 arguments.

1) Quote Id

2) email

3) Instance of the \Magento\Quote\Api\Data\PaymentInterface in to which the Payment Method parameters should be set.

The parameters that should be set for the payment method interface should be the following,

a) method

b) po_number

c) additional_data

If you are custom setting these parameters, you can set this parameters by using the setData() method of the \Magento\Quote\Api\Data\PaymentInterface interface instance.

In your case, since the payment method is Cash On Delivery, you should send the payment method parameters in the following way,

{
 "paymentMethod": {
 "method": "cashondelivery",
 "po_number": null,
 "additional_data": null
 } 
}

4) The fourth and last parameter for the savePaymentInformationAndPlaceOrder() function for guest place order, is the billing address which should be set with the \Magento\Quote\Api\Data\AddressInterface interface instance.

For Logged-In customer, the place order is happening through the savePaymentInformationAndPlaceOrder() function from the model \Magento\Checkout\Model\PaymentInformationManagement and it takes 3 parameters.

1) Quote Id

2) Payment method parameters set to the instance of the \Magento\Quote\Api\Data\PaymentInterface

3) Billing address parameters set to the instance of \Magento\Quote\Api\Data\AddressInterface interface

As per my view, your stated error may be fixed if you send the payment method details in the following format,

{
 "paymentMethod": {
 "method": "cashondelivery",
 "po_number": null,
 "additional_data": null
 } 
}
answered Dec 8, 2017 at 11:08
9
  • Thanks But it is responding now { "message": "No such entity with %fieldName = %fieldValue", "parameters": { "fieldName": "customerId", "fieldValue": null } } Commented Dec 8, 2017 at 11:19
  • Are you placing order for a logged in customer ? Commented Dec 8, 2017 at 11:31
  • Can you please post the billing address parameters which you are sending Commented Dec 8, 2017 at 11:37
  • yes i am passing token also for log in Commented Dec 8, 2017 at 11:48
  • can you post the format of your entire input data here? Commented Dec 8, 2017 at 11:52
0

You can't send such a data through webapi. As you can see:

/**
 * Get purchase order number
 *
 * @return string|null
 */
public function getPoNumber();
/**
 * Set purchase order number
 *
 * @param string $poNumber
 * @return $this
 */
public function setPoNumber($poNumber);
/**
 * Get payment method code
 *
 * @return string
 */
public function getMethod();
/**
 * Set payment method code
 *
 * @param string $method
 * @return $this
 */
public function setMethod($method);
/**
 * Get payment additional details
 *
 * @return string[]|null
 */
public function getAdditionalData();
/**
 * Set payment additional details
 *
 * @param string $additionalData
 * @return $this
 */
public function setAdditionalData($additionalData);

There is no code or title setter/getter in payment method interface. To set code you should use "method" instead and set title in additional data array.

In short, all data that can be passed through webapi must have related setter/getter configured in appropriate interface. This is exactly what your error in log saying: Message: Property "Code" does not have corresponding setter in class "Magento\Quote\Api\Data\PaymentInterface"

You might ask, which properties can I use then? Read the interface again, you will see that method, poNumber, additionaldata got relevant setter/getters and these are attributes you can set through api call.

Update:

Actually you can't set title of payment method. There is no such a field in payment's table. All you can do is to set data as interface allow. Title will be eventually derived from object because it is defined in a particular payment class and not stored in database.

answered Dec 8, 2017 at 8:37
6

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.