Skip to content

placing order is not working through REST api call #2517

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
arunkasyakar opened this issue Nov 25, 2015 · 14 comments
Closed

placing order is not working through REST api call #2517

arunkasyakar opened this issue Nov 25, 2015 · 14 comments

Comments

@arunkasyakar
Copy link

when i am trying to place order from the api call:

http://MYHOST/rest/default/V1/carts/1/order

payload:

{
"paymentMethod": {
"poNumber": "string",
"method": "checkmo",
"additionalData": [
"string"
],
"extensionAttributes": {
"agreementIds": [
"string"
]
}
}
}

i am getting internal error that is:
{
"message": "Internal Error. Details are available in Magento log file. Report ID: webapi-5655974c6087b"
}

and the error log is:

[2015-11-25 11:11:08] main.CRITICAL: exception 'LogicException' with message 'Report ID: webapi-5655974c6087b; Message: Property "CartId" does not have corresponding setter in class "Magento\Quote\Api\Data\PaymentInterface".' in /var/www/html/MYPROJECT/lib/internal/Magento/Framework/Webapi/ErrorProcessor.php:194
Stack trace:
#0 /var/www/html/MYPROJECT/lib/internal/Magento/Framework/Webapi/ErrorProcessor.php(139): Magento\Framework\Webapi\ErrorProcessor->_critical(Object(LogicException))
#1 /var/www/html/MYPROJECT/app/code/Magento/Webapi/Controller/Rest.php(163): Magento\Framework\Webapi\ErrorProcessor->maskException(Object(LogicException))
#2 /var/www/html/MYPROJECT/var/generation/Magento/Webapi/Controller/Rest/Interceptor.php(24): Magento\Webapi\Controller\Rest->dispatch(Object(Magento\Framework\App\Request\Http))
#3 /var/www/html/MYPROJECT/lib/internal/Magento/Framework/App/Http.php(115): Magento\Webapi\Controller\Rest\Interceptor->dispatch(Object(Magento\Framework\App\Request\Http))
#4 /var/www/html/MYPROJECT/lib/internal/Magento/Framework/App/Bootstrap.php(258): Magento\Framework\App\Http->launch()
#5 /var/www/html/MYPROJECT/index.php(39): Magento\Framework\App\Bootstrap->run(Object(Magento\Framework\App\Http))
#6 {main} [] []

@ishakhsuvarov
Copy link
Contributor

@arunkasyakar Please try adding cartId to the payload as well.

@ishakhsuvarov ishakhsuvarov self-assigned this Nov 26, 2015
@arunkasyakar
Copy link
Author

after adding the cartId in payload i am not getting the internal error but i got error response that is:

{
"message": "The requested Payment Method is not available."
}

my payload is:

{
"cartId" : "1",
"paymentMethod": {
"poNumber": "string",
"method": "free",
"additionalData": [
"string"
],
"extensionAttributes": {
"agreementIds": [
"string"
]
}
}
}

i tried this with various payment method like: cashondelivery, banktransfer, checkmo and free but in all cases i am getting the same response

@ishakhsuvarov
Copy link
Contributor

@arunkasyakar We have tried to reproduce same behaviour as you described in this ticket and in #2497 but currently with no success. These issues seem to be similar. We used current develop branch for testing and stock Magento settings. Which branch and head commit are you on? Have you tried the same with clean installation on latest commit from develop?

To help us solve the issue in a timely manner please provide detailed information on flow you are going through before reaching Place Order, customizations you have done to your installation (if there are any), settings changed since original installation (especially payment settings). Also, please check if Magento's checkout works fine (it uses pretty much the same api calls to place an order).

Thank you.

@arunkasyakar
Copy link
Author

  1. i created a empty cart by using the api: default/V1/carts/1
    and payload is:
    {
    "customerId": 1
    }
  2. then i added the item to the cart by using api : /default/V1/carts/items
    and payload is:
    {
    "cartItem": {
    "sku": "myProduct",
    "qty": 2,
    "quote_id": "1"
    }
    }
  3. then i added the shipping address by using api: /default/V1/carts/1/shipping-address

with pay load:
{
"cartId": "1",
"address": {
"firstname": "sameer",
"lastname": "roy",
"email": "[email protected]",
"company": "techment technology",
"street": [
"Typical Street",
"Tiny House 18"
],
"city": "Big City",
"region_id": 12,
"region": "California",
"region_code": "CA",
"postcode": "0985432",
"country_id": "US",
"telephone": "88776655",
"fax": "44332255"
}
}
4. after that i added the billing address by using api: /default/V1/carts/1/billing-address
with api: {
"cartId": "1",
"address": {
"firstname": "sameer",
"lastname": "roy",
"email": "[email protected]",
"company": "techment technology",
"street": [
"Typical Street",
"Tiny House 18"
],
"city": "Big City",
"region_id": 12,
"region": "California",
"region_code": "CA",
"postcode": "0985432",
"country_id": "US",
"telephone": "88776655",
"fax": "44332255"
}
}
5. then i added the shipping method by using api: default/V1/carts/1/selected-shipping-method
with payload
{
"cartId": "1",
"carrierCode": "flatrate",
"methodCode": "flatrate"
}
6. after that i am trying to add payment method by using the api: /default/V1/carts/1/selected-payment-method

{
"cartId" : "1",
"paymentMethod": {
"poNumber": "string",
"method": "free",
"additionalData": [
"string"
],
"extensionAttributes": {
"agreementIds": [
"string"
]
}
}
}

now i am getting the error

i made some configuration changes on stores-> sales->payment methods
a) In Merchant Location -: i set it to india.
b) In Zero Subtotal Checkout-: i set enable to yes
c) In Bank Transfer Payment-: i set enable to yes, Payment from Applicable Countries to specific conties and Payment from Specific Countries to india.

d) In Check / Money Order-: i set enable to yes, Payment from Applicable Countries to specific                 conties and Payment from Specific Countries to india.
e)  In Cash On Delivery Payment -:  i set enable to yes, Payment from Applicable Countries to specific  conties and Payment from Specific Countries to india.

@ishakhsuvarov
Copy link
Contributor

@arunkasyakar Thank you for the information provided.

  • Payloads you have provided look like you are using merchant_beta branch, please confirm that.
  • According to the data you have provided your payment methods are configured to be available only for India, however in payloads you use US address. This would make those payments unavailable for US addresses, please check it and try another configuration or address.

@arunkasyakar
Copy link
Author

i tried for india's address also but i am getting the same response

@ishakhsuvarov
Copy link
Contributor

@arunkasyakar Please try setting both billing and shipping addresses to India ("countryId": "IN") and Payment method to checkmo ("method": "checkmo").

@arunkasyakar
Copy link
Author

thanks @ishakhsuvarov now its working fine, but what about banktransfer, and cashondeliver payment methods.
i am not able to create order with banktransfer and cashondelivery method

@ishakhsuvarov
Copy link
Contributor

@arunkasyakar You may get the list of available payment methods (with their codes) for the current cart using GET /V1/carts/:cartId/payment-methods request. Also verify your settings for those payment methods, as they may become unavailable due to misconfiguration.

@arunkasyakar
Copy link
Author

thanks @ishakhsuvarov . i have one more doubt, is there any api available to update the payment transaction information after placing the order. i have checked for this in swagger api document but i did not get anything.

@ishakhsuvarov
Copy link
Contributor

@arunkasyakar Order information may not be updated after it's placed.

@arunkasyakar
Copy link
Author

so how will be the order status change from pending to processing or completed

@ishakhsuvarov
Copy link
Contributor

@arunkasyakar Please refer to the Sales section of List of service names per module document, where you can find endpoints to work with Invoices, Credit Memos, Shipments, etc.
Creating these documents for order should also change it's status.

@arunkasyakar
Copy link
Author

Thanks @ishakhsuvarov

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants