Post by andxres » Thu Sep 02, 2021 3:40 pm

Hi,

How to reproduce the issue:
- add some products to the cart
- continue on the Checkout page
- select PayPal as the payment method
- leave the Checkout page opened and open the Cart in a new tab/page
- remove a product (or more) from the Cart
- come back to the already opened Checkout page
- press the Continue button to pay

What happens:
- the amount sent to PayPal is the correct and it's the one corresponding to the updated cart. Also, the list of the purchased products sent to PayPal is correct.
- the order saved to OpenCart contains the products displayed on the last step of the Checkout process, before paying, when in fact it should've contained the products from the updated cart (even if the cart was updated on a different tab..)

This is a serious problem and it was reported by one customer. We don't know exactly how many times this happened, but we're loosing money because we're using the orders from OpenCart to send the products to our customers, so in fact we sent more products than the customers paid!!

Is there a fix for this?

OpenCart version 2.3.0.2

Thanks!
Last edited by andxres on Fri Sep 10, 2021 2:57 pm, edited 2 times in total.

Newbie

Posts

Joined
Thu Sep 02, 2021 3:23 pm

Post by ADD Creative » Thu Sep 02, 2021 4:46 pm

Which PayPal payment module are you using?

www.add-creative.co.uk


Expert Member

Posts

Joined
Sat Jan 14, 2012 1:02 am
Location - United Kingdom

Post by andxres » Thu Sep 02, 2021 5:08 pm

We're using PayPal Express Checkout, but there's no issue with the amount payed, or with the products sent to PayPal, the issue is that the orders saved in OpenCart don't contain the products from the cart (which is and can be updated in a different tab).

Thanks!

Newbie

Posts

Joined
Thu Sep 02, 2021 3:23 pm

Post by ADD Creative » Tue Sep 07, 2021 11:48 pm

I see what you mean. I was able to recreate your issue.

It's a flaw in the PayPal Express module. After the order has been added to the database it still uses the cart data to calculate the amounts send to PayPal, not the finalised order info. I wonder how many other payment modules work the same way.

The 3.x branch looks exactly the same so there doesn't look like there is any fix. You could look at using another PayPal module.

Or as a really, really rough workaround you could try. In catalog/controller/extension/payment/pp_express.php after the following on line 1341.

Code: Select all

$data = array_merge($data, $this->model_extension_payment_pp_express->paymentRequestInfo());
Add.

Code: Select all

$total = round($this->currency->format($order_info['total'], $this->session->data['currency'], false, false), 1);

if ($total !== round($data['PAYMENTREQUEST_0_AMT'], 1)) {
	$this->response->redirect($this->url->link('checkout/checkout', '', true));
}

www.add-creative.co.uk


Expert Member

Posts

Joined
Sat Jan 14, 2012 1:02 am
Location - United Kingdom

Post by straightlight » Tue Sep 07, 2021 11:57 pm

Code: Select all

$this->response->redirect($this->url->link('checkout/checkout', '', true));
for:

Code: Select all

$this->response->redirect($this->url->link('checkout/failure'));

The most generated errors being found on Opencart forum originates from contributed programming. The increased post counters are caused by redundancies of the same solutions that were already provided prior.


Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by andxres » Fri Sep 10, 2021 4:32 am

ADD Creative wrote:
Tue Sep 07, 2021 11:48 pm
I see what you mean. I was able to recreate your issue.
Thank you so much for checking and offering a solution!!

straightlight wrote:
Tue Sep 07, 2021 11:57 pm

Code: Select all

$this->response->redirect($this->url->link('checkout/checkout', '', true));
for:

Code: Select all

$this->response->redirect($this->url->link('checkout/failure'));
Your fix on ADD Creative's solution worked great! Thank you!!!!

Newbie

Posts

Joined
Thu Sep 02, 2021 3:23 pm

Post by straightlight » Fri Sep 10, 2021 7:40 am

andxres wrote:
Fri Sep 10, 2021 4:32 am
ADD Creative wrote:
Tue Sep 07, 2021 11:48 pm
I see what you mean. I was able to recreate your issue.
Thank you so much for checking and offering a solution!!

straightlight wrote:
Tue Sep 07, 2021 11:57 pm

Code: Select all

$this->response->redirect($this->url->link('checkout/checkout', '', true));
for:

Code: Select all

$this->response->redirect($this->url->link('checkout/failure'));
Your fix on ADD Creative's solution worked great! Thank you!!!!
No problem. Now that the issue has been solved, please add: [SOLVED] at the beginning of the subject line on your first post.

The most generated errors being found on Opencart forum originates from contributed programming. The increased post counters are caused by redundancies of the same solutions that were already provided prior.


Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by Thomas456 » Mon Sep 27, 2021 3:14 pm

ADD Creative wrote:
Tue Sep 07, 2021 11:48 pm
I see what you mean. I was able to recreate your issue.

It's a flaw in the PayPal Express module. After the order has been added to the database it still uses the cart data to calculate the amounts send to PayPal, not the finalised order info. I wonder how many other payment modules work the same way.

The 3.x branch looks exactly the same so there doesn't look like there is any fix. You could look at using another PayPal module.

Or as a really, really rough workaround you could try. In catalog/controller/extension/payment/pp_express.php after the following on line 1341.

Code: Select all

$data = array_merge($data, $this->model_extension_payment_pp_express->paymentRequestInfo());
Add.

Code: Select all

$total = round($this->currency->format($order_info['total'], $this->session->data['currency'], false, false), 1);

if ($total !== round($data['PAYMENTREQUEST_0_AMT'], 1)) {
	$this->response->redirect($this->url->link('checkout/checkout', '', true));
}
This works really well for me, thank you! Facing same issue here. Help is appreciated.

Newbie

Posts

Joined
Wed Jul 28, 2021 5:36 pm

Post by Thomas456 » Tue Sep 28, 2021 8:09 pm

ADD Creative wrote:
Tue Sep 07, 2021 11:48 pm
I see what you mean. I was able to recreate your issue.

It's a flaw in the PayPal Express module. After the order has been added to the database it still uses the cart data to calculate the amounts send to PayPal, not the finalised order info. I wonder how many other payment modules work the same way.

The 3.x branch looks exactly the same so there doesn't look like there is any fix. You could look at using another PayPal module indigocard.

Or as a really, really rough workaround you could try. In catalog/controller/extension/payment/pp_express.php after the following on line 1341.

Code: Select all

$data = array_merge($data, $this->model_extension_payment_pp_express->paymentRequestInfo());
Add.

Code: Select all

$total = round($this->currency->format($order_info['total'], $this->session->data['currency'], false, false), 1);

if ($total !== round($data['PAYMENTREQUEST_0_AMT'], 1)) {
	$this->response->redirect($this->url->link('checkout/checkout', '', true));
}
Thanks for sharing. I found a lot of interesting information here.

Newbie

Posts

Joined
Wed Jul 28, 2021 5:36 pm
Who is online

Users browsing this forum: No registered users and 1 guest