Summary of problem: Some pp_express orders are in a "missing" state while payment on paypal reflects as complete.
Detail
Customer has enabled paypal express as a valid payment method. While many of the orders are completed successfully with payment reflecting as complete, there are others where the payment status is complete, but the order status is 0.
I tracked it down to around line 1635,, which updates the paypal_order_transaction with the update, but does not trigger an addOrderHistory event on the opencart order, which means that the order status never updates, leading to the order being in an invalid state, even though the customer has paid for the order.
Has anyone come across this situation?
Code: Select all
//if the transaction is pending but the new status is completed
if ($transaction['payment_status'] != $this->request->post['payment_status']) {
$this->db->query("UPDATE `" . DB_PREFIX . "paypal_order_transaction` SET `payment_status` = '" . $this->request->post['payment_status'] . "' WHERE `transaction_id` = '" . $this->db->escape($transaction['transaction_id']) . "' LIMIT 1");
} elseif ($transaction['payment_status'] == 'Pending' && ($transaction['pending_reason'] != $this->request->post['pending_reason'])) {
//payment is still pending but the pending reason has changed, update it.
$this->db->query("UPDATE `" . DB_PREFIX . "paypal_order_transaction` SET `pending_reason` = '" . $this->request->post['pending_reason'] . "' WHERE `transaction_id` = '" . $this->db->escape($transaction['transaction_id']) . "' LIMIT 1");
}
Code: Select all
//if the transaction is pending but the new status is completed
if ($transaction['payment_status'] != $this->request->post['payment_status']) {
$this->db->query("UPDATE `" . DB_PREFIX . "paypal_order_transaction` SET `payment_status` = '" . $this->request->post['payment_status'] . "' WHERE `transaction_id` = '" . $this->db->escape($transaction['transaction_id']) . "' LIMIT 1");
/*****
** PATCH STARTS HERE
*****/
if ($this->config->get('pp_express_debug') == 1) {
$this->log->write('[2] Applying Patch to update order status for transaction: ' . print_r($transaction,true));
}
//handle order status
switch($this->request->post['payment_status']) {
case 'Canceled_Reversal':
$a_order_status_id = $this->config->get('pp_express_canceled_reversal_status_id');
break;
case 'Completed':
$a_order_status_id = $this->config->get('pp_express_completed_status_id');
break;
case 'Denied':
$a_order_status_id = $this->config->get('pp_express_denied_status_id');
break;
case 'Expired':
$a_order_status_id = $this->config->get('pp_express_expired_status_id');
break;
case 'Failed':
$a_order_status_id = $this->config->get('pp_express_failed_status_id');
break;
case 'Pending':
$a_order_status_id = $this->config->get('pp_express_pending_status_id');
break;
case 'Processed':
$a_order_status_id = $this->config->get('pp_express_processed_status_id');
break;
case 'Refunded':
$a_order_status_id = $this->config->get('pp_express_refunded_status_id');
break;
case 'Reversed':
$a_order_status_id = $this->config->get('pp_express_reversed_status_id');
break;
case 'Voided':
$a_order_status_id = $this->config->get('pp_express_voided_status_id');
break;
}
$a_order_id = $transaction['order_id'];
$this->load->model('checkout/order');
$this->model_checkout_order->addOrderHistory($a_order_id, $a_order_status_id);
/*****
** PATCH ENDS HERE
*****/
} elseif ($transaction['payment_status'] == 'Pending' && ($transaction['pending_reason'] != $this->request->post['pending_reason'])) {
//payment is still pending but the pending reason has changed, update it.
$this->db->query("UPDATE `" . DB_PREFIX . "paypal_order_transaction` SET `pending_reason` = '" . $this->request->post['pending_reason'] . "' WHERE `transaction_id` = '" . $this->db->escape($transaction['transaction_id']) . "' LIMIT 1");
}