I am using Website Payments Pro Payflow
Edition for my store and wanted to know if there is a way to automatically change the order status from Processing
to Ready to ship
if the transaction it successful as currently our admin is having to do this manually.
I was thinking to use an Observer
to change the status but so far I can only find the event to invoice:
<?php
class MyCompany_OrdersObserver_Model_Observer {
public $order;//the order...
function afterSalesOrderSaveCommitAfter(&$event) {
return $this->__process($event);
}
protected function __process($event) {
$this->order = $event->getEvent()->getOrder();
if (!$this->order->getId()) {
//order is not saved in the database
return $this;
}
else {
$this->createInvoice();
}
}
protected function createInvoice() {
$orderState = $this->order->getState();
if ($orderState === Mage_Sales_Model_Order::STATE_NEW) { // Check for state new.
if ($this->order->canInvoice()) {
$this->order->getPayment()->setSkipTransactionCreation(false);
$invoice = $this->order->prepareInvoice();
$invoice->setRequestedCaptureCase(Mage_Sales_Model_Order_Invoice::CAPTURE_ONLINE);
$invoice->register();
Mage::getModel('core/resource_transaction')
->addObject($invoice)
->addObject($this->order)
->save();
}
else {
//we can not invoice it so the process is normal.
}
}
}
}
Is there another event I could use to achieve this? Or is it a configuration issue?
Any advice would be greatly appreciated