public function authorize(Varien_Object $payment, $amount)
    {
        parent::authorize($payment, $amount);
        $payment->setLastTransId($this->getTransactionId())->setIsTransactionPending(true);

        /** @var Mage_Sales_Model_Order $order */
        $order = $payment->getOrder();
        $amount = $order->getGrandTotal();

        // check if a zero auth should be done for this order
        $useZeroAuth = (bool)Mage::helper('adyen')->getConfigData('use_zero_auth', null, $order->getStoreId());
        $zeroAuthDateField = Mage::helper('adyen')->getConfigData(
            'base_zero_auth_on_date', null,
            $order->getStoreId()
        );

        if ($useZeroAuth) { // zero auth should be used
            // only orders that are scheduled to be captured later than
            // the auth valid period use zero auth
            // the period is 7 days since this works for most payment methods
            $scheduledDate = strtotime($order->getData($zeroAuthDateField));
            if ($scheduledDate > strtotime("+7 days")) { // scheduled date is higher than now + 7 days
                $amount = 0; // set amount to 0 for zero auth
            }
        }

        /*
         * ReserveOrderId for this quote so payment failed notification
         * does not interfere with new successful orders
         */
        $incrementId = $order->getIncrementId();
        $quoteId = $order->getQuoteId();
        $quote = Mage::getModel('sales/quote')
            ->load($quoteId)
            ->setReservedOrderId($incrementId)
            ->save();

        // by zero authentication payment is authorised when api responds is succesfull
        if ($order->getGrandTotal() == 0) {
            $payment->setIsTransactionPending(false);
        }

        /*
         * Do not send a email notification when order is created.
         * Only do this on the AUHTORISATION notification.
         * For Boleto and Multibanco send it on order creation
         */
        if (!in_array($this->getCode(), array('adyen_boleto', 'adyen_multibanco'))) {
            $order->setCanSendNewEmailFlag(false);
        }

        if ($this->getCode() == 'adyen_boleto' || $this->getCode() == 'adyen_cc' || substr(
            $this->getCode(), 0,
            14
        ) == 'adyen_oneclick' || $this->getCode() == 'adyen_sepa' || $this->getCode() == 'adyen_apple_pay' || $this->getCode() == 'adyen_multibanco') {
            if (substr($this->getCode(), 0, 14) == 'adyen_oneclick') {
                // set payment method to adyen_oneclick otherwise backend can not view the order
                $payment->setMethod("adyen_oneclick");

                $recurringDetailReference = $payment->getAdditionalInformation("recurring_detail_reference");

                // load agreement based on reference_id (option to add an index on reference_id in database)
                $agreement = Mage::getModel('sales/billing_agreement')->load($recurringDetailReference, 'reference_id');

                // agreement could be a empty object
                if ($agreement && $agreement->getAgreementId() > 0 && $agreement->isValid()) {
                    $agreement->addOrderRelation($order);
                    $agreement->setIsObjectChanged(true);
                    $order->addRelatedObject($agreement);
                    $message = Mage::helper('adyen')->__(
                        'Used existing billing agreement #%s.',
                        $agreement->getReferenceId()
                    );

                    $comment = $order->addStatusHistoryComment($message);
                    $order->addRelatedObject($comment);
                }
            }

            $_authorizeResponse = $this->_processRequest($payment, $amount, "authorise");
        }

        return $this;
    }