Hi I am fairly new to Magento2 and it's API.

I need to send out a SOAP call to the API of our distributor using PHP after a successful order has been placed (after completing the payment).

Is there anyone who can send me in the right direction?

  • Welcome to community, If i am not wrong you want to send some information of product like sku, qty to its manufacturer. right ? – Pawan Sep 7 '18 at 1:56
  • Hi Pawan, that is indeed correct. I will need to send the SKU and QTY of the product along with the information of the customer for the delivery. – Hendrik M. Sep 8 '18 at 14:57
  • why only SOAP, Is your distributor specified this ? Is there any format for send data ? – Pawan Sep 8 '18 at 17:01
  • Our distributor only accepts SOAP calls indeed, there is no option to use REST unfortunately. – Hendrik M. Sep 9 '18 at 18:18

capture checkout_onepage_controller_success_action event and on that event write your module observer class ( i.e ApiCallAfterPlaceOrder.php ) to achieve what you want , your events.xml will be something like this :


<?xml version="1.0"?>

<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Event/etc/events.xsd">
<event name="checkout_onepage_controller_success_action">
    <observer name="manufacturer_controller_success_action" instance="Vendor\Module\Observer\ApiCallfterPlaceOrder"/>


from here you can start coding and do what you want your ApiCallfterPlaceOrder.php will be something like :

namespace Vendor\Module\Observer; 
use Magento\Framework\Event\ObserverInterface;
use Magento\Framework\App\Request\DataPersistorInterface;

class ApiCallAfterPlaceOrder implements ObserverInterface
protected $_order;

public function __construct(
    \Magento\Sales\Api\Data\OrderInterface $order
) {
    $this->order = $order;

 * @param \Magento\Framework\Event\Observer $observer
 * @return void

  public function execute(\Magento\Framework\Event\Observer $observer)

    $orderids = $observer->getEvent()->getOrderIds();
    // Other code goes here

  • Hi Naveed, thank your for your answer. How would I get the order details into my own module like SKU, QTY, and the customer/delivery details? – Hendrik M. Sep 8 '18 at 15:29
  • get order Id from event observer and order id get Order details. – Naveed Asim Sep 8 '18 at 18:26
  • I have updated code a starting point from where you can get Order detail by order id. – Naveed Asim Sep 8 '18 at 18:33
  • Many thanks for the code example, I shall use it as a starting point. I will be working on the module this week, so I may return with questions if that is okay. – Hendrik M. Sep 9 '18 at 18:22
  • always place your custom module in app/code folder, vendor folder only have magento core modules however 3rd party modules which are installed using composer also placed in vendor. so best practice is place your module in app/code – Naveed Asim Sep 11 '18 at 16:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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