public function pay(OrderPaymentEvent $event)
    {
        $order = $event->getOrder();

        /* call pay method */
        if (null === $paymentModule = ModuleQuery::create()->findPk($order->getPaymentModuleId())) {
            throw new \RuntimeException(
                Translator::getInstance()->trans(
                    "Failed to find a payment Module with ID=%mid for order ID=%oid",
                    [
                        "%mid" => $order->getPaymentModuleId(),
                        "%oid" => $order->getId()
                    ]
                )
            );
        }

        $paymentModuleInstance = $paymentModule->getPaymentModuleInstance($this->container);

        $response = $paymentModuleInstance->pay($order);

        if (null !== $response && $response instanceof Response) {
            $event->setResponse($response);
        }
    }
public function pay(OrderPaymentEvent $event)
    {
        $order = $event->getOrder();

        /* call pay method */
        if (null === $paymentModule = ModuleQuery::create()->findPk($order->getPaymentModuleId())) {
            throw new \RuntimeException(
                Translator::getInstance()->trans(
                    "Failed to find a payment Module with ID=%mid for order ID=%oid",
                    [
                        "%mid" => $order->getPaymentModuleId(),
                        "%oid" => $order->getId()
                    ]
                )
            );
        }

        $paymentModuleInstance = $paymentModule->getPaymentModuleInstance($this->container);

        $response = $paymentModuleInstance->pay($order);

        if (null !== $response && $response instanceof Response) {
            $event->setResponse($response);
        }
    }
public function pay ( OrderPaymentEvent $ event ) { $ order = $ event -> getOrder ( ) ; /* call pay method */ if ( null === $ paymentModule = ModuleQuery :: create ( ) -> findPk ( $ order -> getPaymentModuleId ( ) ) ) { throw new \ RuntimeException ( Translator :: getInstance ( ) -> trans ( "Failed to find a payment Module with ID=%mid for order ID=%oid" , [ "%mid" => $ order -> getPaymentModuleId ( ) , "%oid" => $ order -> getId ( ) ] ) ) ; } $ paymentModuleInstance = $ paymentModule -> getPaymentModuleInstance ( $ this -> container ) ; $ response = $ paymentModuleInstance -> pay ( $ order ) ; if ( null !== $ response && $ response instanceof Response ) { $ event -> setResponse ( $ response ) ; } }
Call the payment method of the payment module of the given order

@param OrderPaymentEvent $event

@throws \RuntimeException if no payment module can be found.
Call the payment method of the payment module of the given order