سؤال

First of all i will explain you about the actuall functionality:

  1. Customer buys in shop via PayPal
  2. Shop operators call the order from an external software (WaWi; don't know in en) and the software sets the order state to complete
  3. Shop operators collect the money at paypal, based on their seller account, from customer
  4. After that, Paypal sends after some time an automatic Ipn request back to magento and set the order back to pending

The thing is to prevent paypal (or Ipn Model) from setting the order from state finished back to pending.

We allready did some modifications to the class: Mage_Paypal_Model_Ipn in Mage/Paypal/Model/Ipn.php. In my opinion is there the responsible code in _registerPaymentCapture(). Here are our edits (marked with Edit):

 if ($this->getRequestData('transaction_entity') == 'auth') {
        return;
    }
    $this->_importPaymentInformation();
    $payment = $this->_order->getPayment();

    /* Edit: check if order state is complete */
    $orderStateComplete = (Mage_Sales_Model_Order::STATE_COMPLETE == $this->_order->getState());

    $orderStatusBefore = $this->_order->getStatus();
    $payment->setTransactionId($this->getRequestData('txn_id'))
        ->setPreparedMessage($this->_createIpnComment(''))
        ->setParentTransactionId($this->getRequestData('parent_txn_id'))
        ->setShouldCloseParentTransaction('Completed' === $this->getRequestData('auth_status'))
        ->setIsTransactionClosed(0)
        ->registerCaptureNotification($this->getRequestData('mc_gross'));

    /* Edit: reset state and status, if order was already complete before */
    if ($orderStateComplete) {
        $this->_order->setState(Mage_Sales_Model_Order::STATE_COMPLETE)
            ->setStatus($orderStatusBefore);
    }
    $this->_order->save();

    // notify customer
    $invoice = $payment->getCreatedInvoice();
    if ($invoice && !$this->_order->getEmailSent()) {
        $this->_order->sendNewOrderEmail()->addStatusHistoryComment(
            Mage::helper('paypal')->__('Notified customer about invoice #%s.', $invoice->getIncrementId())
        )
        ->setIsCustomerNotified(true)
        ->save();
    }

The problem is still there and i don't know where to edit the file to prevent order state changes.

greetz & thanks in advance

هل كانت مفيدة؟

المحلول

We managed it. The problem was that the ERP Software the order state didn't set, just the status, so the condition didn't woked.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى magento.stackexchange
scroll top