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" } } '