1

We are seeing a few orders in our sales list that are 'Cancelled' and when we look at them, the reason for authorization failed is: "You have to enter the card holder name."

I thought this was a bit odd because Magento does not let you progress to the payment page without first entering a first and last name (which passes through automatically to the payment page)

We are using a Sagepay extension to process payments so I asked those developers why the autorization failed on those orders.

They say that Magento creates orders before the payment is executed. This means that if the customer enters wrong data or doesn't even enter any info, Magento sets a corresponding status and cancels the order after 2 hours.

This behaviour is most probably caused by the users themselves, by leaving the payment page without explicitly cancelling the transaction.

Is this true that Magento cancels the order after 2 hours? (I cant seem to find any information regarding this) If so can this timeout be increased?

Thanks

2

Yes, there is a cron task responsible of that

<job name="sales_clean_orders" instance="Magento\Sales\Model\CronJob\CleanExpiredOrders" method="execute">
    <schedule>0 * * * *</schedule>
</job>

You can check what it does, looking in vendor/magento/module-sales/Model/CronJob/CleanExpiredOrders.php file

public function execute()
{
    $lifetimes = $this->storesConfig->getStoresConfigByPath('sales/orders/delete_pending_after');
    foreach ($lifetimes as $storeId => $lifetime) {
        /** @var $orders \Magento\Sales\Model\ResourceModel\Order\Collection */
        $orders = $this->orderCollectionFactory->create();
        $orders->addFieldToFilter('store_id', $storeId);
        $orders->addFieldToFilter('status', Order::STATE_PENDING_PAYMENT);
        $orders->getSelect()->where(
            new \Zend_Db_Expr('TIME_TO_SEC(TIMEDIFF(CURRENT_TIMESTAMP, `updated_at`)) >= ' . $lifetime * 60)
        );

        try {
            $orders->walk('cancel');
            $orders->walk('save');
        } catch (\Exception $e) {
            $this->logger->error('Error cancelling deprecated orders: ' . $e->getMessage());
        }
    }
}

As you can see, you can edit default cancel time in backoffice parameter Stores > Configuration > Sales > Sales > Orders Cron Settings

  • Thanks Raul great info - I couldnt seem to find a setting in back office though? Is it Stores > Configuration > Sales > Sales > Orders Cron Settings? – Richard Laws Dec 20 '17 at 10:14
  • Yes, it is... feel free to flag answer as valid if it helped ;) – Raul Sanchez Dec 20 '17 at 10:26

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.