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 :
<!-- Guest place order with payment information saving --> <route url="/V1/guest-carts/:cartId/payment-information" method="POST"> <service class="Magento\Checkout\Api\GuestPaymentInformationManagementInterface" method="savePaymentInformationAndPlaceOrder"/> <resources> <resource ref="anonymous" /> </resources> </route>
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 :
<preference for="Magento\Checkout\Api\GuestPaymentInformationManagementInterface" type="Magento\Checkout\Model\GuestPaymentInformationManagement" />
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