public function dopayment($data, $form)
    {
        if (self::config()->allow_paying
            && $this->order
            && $this->order->canPay()
        ) {
            // Save payment data from form and process payment
            $data = $form->getData();
            $gateway = (!empty($data['PaymentMethod'])) ? $data['PaymentMethod'] : null;

            if (!GatewayInfo::isManual($gateway)) {
                $processor = OrderProcessor::create($this->order);
                $fieldFactory = new GatewayFieldsFactory(null);
                $response = $processor->makePayment(
                    $gateway,
                    $fieldFactory->normalizeFormData($data),
                    $processor->getReturnUrl()
                );
                if ($response && !$response->isError()) {
                    return $response->redirectOrRespond();
                } else {
                    $form->sessionMessage($processor->getError(), 'bad');
                }
            } else {
                $form->sessionMessage(_t(__CLASS__ . '.ManualNotAllowed', 'Manual payment not allowed'), 'bad');
            }

            return $this->controller->redirectBack();
        }
        $form->sessionMessage(
            _t(__CLASS__ . '.CouldNotProcessPayment', 'Payment could not be processed.'),
            'bad'
        );
        return $this->controller->redirectBack();
    }