0

We are exporting orders to a dispatch warehouse using the Xtento Order Export module. It is set up to happen automatically on order confirmation. The warehouse sends back a response of "received" and a transaction code. On receipt of this response we change the order status to a custom status of "Received".

This works when we manually export an order after the fact. However when an order gets placed and the export happens on the fly, the status gets changed but then Opayo/Sagepay changes it back to "Processing". So in the comments you can see the status getting changed to Received and then, in the same second, Opayo changing it back to Processing. I can't see anything in the Opayo set up to stop the status change.

Code is as follows, in vendor\xtento\orderexport\model\destination\Http.php:

$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
        $order = $objectManager->create('\Magento\Sales\Model\Order') ->loadByIncrementId($orderId);
       // $order->setState($statuschange);
        $order->setStatus($statuschange);
        $order->addStatusToHistory($statuschange, "Sent to XX {$txref}", false); 
        $order->setData('export_log', "Received by XX");
        $order->save($order);

Not sure this is a coding question though so much as a "how to get around this" question. My first thought was to put a slight delay on the save, a second or 2 to let Opayo do its thing, and then sneak in there afterwards, but I don't like time delays. Maybe keep checking if there is a message from Opayo and don't save until there is? We will probably also have Paypal set up there too so I'm assuming that's going to do similar. Any other suggestions or pitfalls to watch out for? Thanks

0

Kindly Check Success Controller of Opayo/Sagepay.

Every payment method handle the response return by the gateway request like failure or success of the transaction.

So check the success event which change the Order Status.

2
  • Thank you - yes since I posted this I have been looking in the Success.php files but not 100% sure what to change. A bit wary of unwittingly making a change to a payment gateway that would affect things in future. Aug 25 at 12:43
  • You can create the staging site and check there. If above answer help then upvote and accept as solution so it will help other in community. Aug 25 at 12:50
0

I think I may have fixed my problem. It was a matter of setting the "export event" to After order modification rather than After order creation. Need to run a few more tests but think I'm on the right track.

1
  • Actually for the sake of completeness and in case anyone has a problem with Xtento Exports in future, it turned out that I still had issues with Paypal not wanting to send orders through when order status was being changed, whether with the built in Xtento version or my own code. Xtento advise not using Event exports as things trigger too fast and get confused. So have switched to a cron export every 5 mins and it seems much smoother. Aug 27 at 13:01

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.