/   /   /  Track V1 Rest url (how you can explore the path of request)

Note:

For more extensions and themes visit our store

Track V1 Rest url (how you can explore the path of request)


Magento choose to use some interaction client as service (click) , for example when you try to place order you get url like rest//V1/guest-carts/:cartId/payment-information , ok but how you can see where is point this url ? Is a module controller action url ? Wrong is a service .
Go and open the webapi.xml inside folder etc Yeah : you will find all the service related to current module . For example :

  1.  
  2.     <!-- Guest place order with payment information saving -->
  3.     <route url="/V1/guest-carts/:cartId/payment-information" method="POST">
  4.         <service class="Magento\Checkout\Api\GuestPaymentInformationManagementInterface" method="savePaymentInformationAndPlaceOrder"/>
  5.         <resources>
  6.             <resource ref="anonymous" />
  7.         </resources>
  8.     </route>
  9.  

But how you can read :
Easy you will use as post(method) ,  is related to interface  GuestPaymentInformationManagementInterface , inside it you can find all abstraction of service , but the real class to execute is Magento\Checkout\Model\GuestPaymentInformationManagement magento use preference to create relation between service and model :

  1.  
  2.     <preference for="Magento\Checkout\Api\GuestPaymentInformationManagementInterface" type="Magento\Checkout\Model\GuestPaymentInformationManagement" />
  3.  

Now is the time to explore the method  savePaymentInformationAndPlaceOrder inside 
 Magento\Checkout\Model\GuestPaymentInformationManagement .

You can create you're own service by using this references :
https://alankent.me/2015/07/24/creating-a-new-rest-web-service-in-magento-2/ 
http://vinaikopp.com/2017/02/18/magento2_repositories_interfaces_and_webapi/ 
http://inchoo.net/magento/api-magento/magento-2-custom-api/ 

Comments

IBNAB is a company made of a group of professionals whose work is providing secure open source solutions. Our company strives for reaching magnificent results with each experience and provides professional open source solutions that cover every part of the business process.