9

We are using Magento EE 1.13.0.2 with the PayPal Website Payments Standard payment method. Unfortunately it's not possible to set an order status for paid PayPal orders in the back-end.

We need to set a custom order status when the order has been paid successfully (and not partial). Tutorials to modify the PayPal order status seem to be outdated, wrong or ugly hacks.

From what I gathered:

  • the payment updates would be handled by PayPal IPN.
  • There is a method Mage_Paypal_Model_Ipn::_registerPaymentCapture() responsible for "Process completed payment (either full or partial)".
  • In Mage_Paypal_Model_Ipn::_registerTransaction() the request from PayPal is analysed and the payment status is compared to Mage_Paypal_Model_Info::PAYMENTSTATUS_COMPLETED.

To be honest I'm not sure what to do with this information. I may rewrite Mage_Paypal_Model_Ipn::_registerTransaction() and just add my code:

// paid
case Mage_Paypal_Model_Info::PAYMENTSTATUS_COMPLETED:
    $this->_registerPaymentCapture(true);
    // my code here
    break;

Of course an event observer (e.g. for one of the order or order state events) would be much nicer but I'm not sure if there is a 100% reliable way to catch that one-time event when the order gets paid completely via PayPal.

Any ideas?

Update

We chose to modify our order status flow and don't need to modify the status anymore. I'll leave the question open for some time in case somebody wants to answer it.

2

The big problem is, there is not even a single event in the whole paypal work flow.

So there are two options:

Rewrite any of these Paypal models

As you said, just rewrite the model, change the behavior and everything works as expected - hopefully or...

Hook into sales_order_save_before

Then you check for the payment type, which should be \Mage_Paypal_Model_Standard::$_code with:

protected $_code  = Mage_Paypal_Model_Config::METHOD_WPS;

\Mage_Paypal_Model_Config
-> const METHOD_WPS         = 'paypal_standard';

And then, when the status is changed to the one you don't want, change it to the one you want.

  • Thanks Fabian, I guess we won't get a better solution in Magento 1.x. :-) – Matthias Zeis Feb 18 '14 at 7:13
0

I ended up with another solution. After struggling with this issue for a few hours, I realized that in my particular case it didn't matter if only PayPal orders got a particular status (it's for an ERP connection, which searches for orders in a particular status).

PayPal doesn't set the status of the order. It just captures the payment. Magento sets the order's state to Processing (see Mage_Sales_Model_Order_Payment::registerCaptureNotification()) and sets the status to the default status within that state.

All I had to do was changing the default status within the state Processing to the status I needed through the admin interface (System » Order Statuses).

Hope this helps someone!

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.