Post by panagos » Sun Nov 27, 2016 10:14 pm

Version: Opencart 2.0.1.1
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");
}
So what I did was to modify it as follows:

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");
}

--
Soteri Panagou
Freelance Developer and Opencart Zealot

http://www.opencart.com/index.php?route ... @gmail.com


New member

Posts

Joined
Sun Oct 25, 2015 3:01 am


Post by panagos » Tue Mar 07, 2017 3:31 am

I created a little VQMOD which does two things:

Apply patch as described in the other post, to sort out the missing order issue
Paypal Express very nicely adds an "action" tab to orders when viewing the order, which allows you to see what happened with the paypal payment for the order. Unfortunately when the paypal express payment module is disabled, then the "action" tab is removed. The vQmod now also fixes this so that the "action" tab is visible irrespective of the pp_express status.

Attachments


--
Soteri Panagou
Freelance Developer and Opencart Zealot

http://www.opencart.com/index.php?route ... @gmail.com


New member

Posts

Joined
Sun Oct 25, 2015 3:01 am


Post by jasonc310771 » Wed Mar 08, 2017 4:54 pm

Hi,

Would this work for PayPal Payments Standard Extension ? I am using version 2.3.0.2 of OC

Active Member

Posts

Joined
Fri Mar 01, 2013 6:46 pm

Post by panagos » Wed Mar 08, 2017 10:06 pm

Hi Jason,

Would not assume that it would out of the box. Will need to be tested to verify whether the standard opencart payment module has the same issue. Have you experienced similar behaviour with paypal standard?

Rgds
Soteri

--
Soteri Panagou
Freelance Developer and Opencart Zealot

http://www.opencart.com/index.php?route ... @gmail.com


New member

Posts

Joined
Sun Oct 25, 2015 3:01 am


Post by jasonc310771 » Thu Mar 09, 2017 2:33 am

panagos wrote:
Wed Mar 08, 2017 10:06 pm
Hi Jason,

Would not assume that it would out of the box. Will need to be tested to verify whether the standard opencart payment module has the same issue. Have you experienced similar behaviour with paypal standard?

Rgds
Soteri
Yes with paypal standard. I can not believe that none of this was tested before it was set free for us to use. Being an important part of the software.

Active Member

Posts

Joined
Fri Mar 01, 2013 6:46 pm

Post by panagos » Thu Mar 09, 2017 3:42 am

I just checked the pp_standard.php which is part of oc_2302 and my little mod definitely will not work for that. Can you advise if you have been experiencing the same symptoms with standard as what I outlined above for express?

Also, what may sometimes happen is that payment providers change the way their functionality works which may explain the regression.

--
Soteri Panagou
Freelance Developer and Opencart Zealot

http://www.opencart.com/index.php?route ... @gmail.com


New member

Posts

Joined
Sun Oct 25, 2015 3:01 am


Post by jasonc310771 » Fri Mar 10, 2017 4:48 pm

Yes I am also facing the same issue with pp_standard

Active Member

Posts

Joined
Fri Mar 01, 2013 6:46 pm

Post by yowchuan » Wed Aug 15, 2018 7:56 pm

OC: Version 2.0.2.0

I did not experience any such issue until 6 months ago.

Orders paid using PayPal just don't update correctly anymore. I suspected that something on PayPal's side changed and PayPal is not returning the correct confirmation token to OpenCart and thus causing OpenCart to set the order to Missing Order, even though the payment successfully went through.

So, I would really like to know if anyone with version 2.0.2.0 tried this patch and how was the outcome?

Best,
YC

New member

Posts

Joined
Wed Feb 06, 2013 2:39 am

Post by ivan2121 » Tue Aug 28, 2018 9:02 pm

OC: version 2.3.0.2

I started having the same issue. All new orders are marked as Missing Orders and I see them only when I go to Orders and filter by Missing orders. Happen after 25Aug 2018. before that all was okay. Did anybody have the same issue? How to resolve this? thanks

Newbie

Posts

Joined
Tue Aug 28, 2018 8:51 pm
Who is online

Users browsing this forum: No registered users and 50 guests