2

We get The requested Payment Method is not available error when we try to create order using REST api.payment method works fine with all online orders and i am using given api.

Request- (Put)

http://MyHost.com/rest/V1/carts/67/order 
json-{ "paymentMethod": { "method": "free"}}

Response-

{
  "message": "The requested Payment Method is not available.",
  "trace": "#0 /chroot/home/folder/html/vendor/magento/module-quote/Model/QuoteManagement.php(337): Magento\\Quote\\Model\\Quote\\Payment->importData(Object(Magento\\Framework\\DataObject))\n#1 [internal function]: Magento\\Quote\\Model\\QuoteManagement->placeOrder(67, Object(Magento\\Quote\\Model\\Quote\\Payment))\n#2 /chroot/home/folder/html/vendor/magento/module-webapi/Controller/Rest.php(307): call_user_func_array(Array, Array)\n#3 /chroot/home/folder/html/vendor/magento/module-webapi/Controller/Rest.php(216): Magento\\Webapi\\Controller\\Rest->processApiRequest()\n#4 /chroot/home/folder/html/var/generation/Magento/Webapi/Controller/Rest/Interceptor.php(37): Magento\\Webapi\\Controller\\Rest->dispatch(Object(Magento\\Framework\\App\\Request\\Http))\n#5 /chroot/home/folder/html/vendor/magento/framework/App/Http.php(135): Magento\\Webapi\\Controller\\Rest\\Interceptor->dispatch(Object(Magento\\Framework\\App\\Request\\Http))\n#6 /chroot/home/folder/html/vendor/magento/framework/App/Bootstrap.php(258): Magento\\Framework\\App\\Http->launch()\n#7 /chroot/home/folder/html/index.php(39): Magento\\Framework\\App\\Bootstrap->run(Object(Magento\\Framework\\App\\Http))\n#8 {main}"
}

Did I miss something About setting ?

and i am using following steps to create an order.

Create customer-

curl -g -X POST "$base_url/index.php/rest/V1/customer" \ -H "Authorization: Bearer $token" \ -H "Content-Type:application/json" \ -d '{"customer":{"email":"[email protected]","firstname":"sunny","lastname":"kumar","store_id":1,"website_id":1,"addresses":[{"region":{"region_code":"WA","region":"Washington","region_id":62},"region_id":62,"country_id":"US","street":["1401 Pennsylvania Ave NW, Washington"],"telephone":"1 202-628-9100","postcode":"DC 20004","city":"Washington","firstname":"sunny","lastname":"kumar","prefix":"Mr."},{"region":{"region_code":"WA","region":"Washington","region_id":62},"region_id":62,"country_id":"US","street":["1401 Pennsylvania Ave NW, Washington"],"telephone":"1 202-628-9100","postcode":"DC 20004","city":"Washington","firstname":"sunny","lastname":"kumar","prefix":"Mr.","default_shipping":true,"default_billing":true}],"disable_auto_group_change":0}}'

Create cart-

Creates an empty cart and quote for a specified customer.

curl -g -X POST "$base_url/index.php/rest/V1/customer/{customerId}/carts/" \ -H "Authorization: Bearer $token"

Add Product To Cart

curl -g -X POST "$base_url/index.php/rest/V1/carts/67/items" \ -H "Authorization: Bearer $token" \ -H "Content-Type:application/json" \ -d '{ "cartItem": { "quote_id": "67", "sku": "Test-Sku", "qty": 2 } }'

Get Payment Method

curl -g -X GET "$base_url/index.php/rest/V1/carts/67/payment-information" \ -H "Authorization: Bearer $token"

response- [ { "code": "free", "title": "No Payment Information Required" } ]

Place Order

curl -g -X PUT "$base_url/index.php/rest/V1/carts/67/order" \ -H "Authorization: Bearer $token" \ -H "Content-Type:application/json" \ -d ' { "method": { "method": "free" } } '

2
  • please provide the more data what parameters you are passing to create order what you are passing in body
    – Brad Hodge
    Commented Sep 27, 2016 at 11:20
  • @AnkitJaiswal please see my update question. Commented Sep 27, 2016 at 11:45

2 Answers 2

1

try this for payment method :

GET "$base_url/index.php/rest/V1/carts/67/payment-methods

response : [ { "code": "checkmo", "title": "Check / Money order" } ]

2
  • still facing same issue requested-body '{ "paymentMethod": { "method": "checkmo"}} ' Commented Sep 27, 2016 at 12:25
  • @vikas : did you enabled payment method From admin please check once because code provided by me its working fine
    – Brad Hodge
    Commented Sep 28, 2016 at 4:11
0

I faced the same issue recently. The issue was with the country id. I was using US as country id for testing purpose, however my magento is set to work for another country. Make sure that you are using the same country code set in magento backend.

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.