Page 1 of 1

opencart 1.5.6.4 - 2checkout not redirect after payment

Posted: Sat Dec 28, 2019 7:36 am
by Cloudeze
Hi everyone!

Hi, please can you help me, the 2checkout does not work with my opencart, everything is set correct but always once I paid, it redirect me to call back url http://mysite.com/index.php?route=payme ... t/callback with parameters and display message :

The response from 2checkout.com can't be parsed. Contact site administrator, please!

Code: Select all

https://mystore.com/payment/twocheckout/callback?middle_initial=&sid=326584598547&fixed=Y&cart_weight=0&key=AE3275C1E2154AD512049D7986DAEE82&state=Hauts+de+Seine&last_name=Doe&email=johndoe%40yahoo.com&city=Le+Plessis&street_address=9+Avenue+Denis&cart_order_id=263&order_number=250266293682&ip_country=France&country=FRA&merchant_order_id=&cart_id=263&currency_code=USD&lang=en&demo=Y&invoice_id=250266293681&pay_method=CC&cart_tangible=N&total=0.40&phone=%2B33752365425+&credit_card_processed=Y&zip=92350&street_address2=&x_receipt_link_url=https%3A%2F%2Fmystore.com%2Fpayment%2Ftwocheckout%2Fcallback&first_name=John&card_holder_name=John+Doe
also in my opencart log, i have :

Code: Select all

2019-12-27 17:18:14 - PHP Notice: Undefined variable: street_address2 in /public_html/catalog/view/theme/custom/template/payment/twocheckout.tpl on line 7
2019-12-27 17:18:14 - PHP Notice: Undefined variable: ship_name in /public_html/catalog/view/theme/custom/template/payment/twocheckout.tpl on line 14 
2019-12-27 17:18:14 - PHP Notice: Undefined variable: ship_street_address2 in /public_html/catalog/view/theme/custom/template/payment/twocheckout.tpl on line 16 
2019-12-27 17:18:14 - PHP Notice: Undefined variable: currency_code in /public_html/catalog/view/theme/custom/template/payment/twocheckout.tpl on line 35 
2019-12-27 17:18:14 - PHP Notice: Undefined variable: display in /public_html/catalog/view/theme/custom/template/payment/twocheckout.tpl on line 42 
2019-12-27 18:55:27 - PHP Notice: Undefined index: cart_order_id in /public_html/catalog/controller/payment/twocheckout.php on line 80 
2019-12-27 18:55:27 - PHP Notice: Undefined index: total in /public_html/catalog/controller/payment/twocheckout.php on line 88 
2019-12-27 18:55:27 - PHP Notice: Undefined index: key in /public_html/catalog/controller/payment/twocheckout.php on line 88

please if anyone can help me to fix it a soon as possible.. ?? ???

Thanks.

Re: opencart 1.5.6.4 - 2checkout not redirect after payment

Posted: Sat Dec 28, 2019 9:28 am
by IP_CAM
Well, below are all the Variables, as they exist in a default OC .1.5.6.4 twocheckout.tpl File,
but most (failed one's) of those shown in your Posting do not exist. You seem to use another Extension
(or Module) for this in your Custom Theme, as it looks.
Ernie

Code: Select all

<input type="hidden" name="sid" value="<?php echo $sid; ?>">
<input type="hidden" name="total" value="<?php echo $total; ?>">
<input type="hidden" name="cart_order_id" value="<?php echo $cart_order_id; ?>">
<input type="hidden" name="card_holder_name" value="<?php echo $card_holder_name; ?>">
<input type="hidden" name="street_address" value="<?php echo $street_address; ?>">
<input type="hidden" name="city" value="<?php echo $city; ?>">
<input type="hidden" name="state" value="<?php echo $state; ?>">
<input type="hidden" name="zip" value="<?php echo $zip; ?>">
<input type="hidden" name="country" value="<?php echo $country; ?>">
<input type="hidden" name="email" value="<?php echo $email; ?>">
<input type="hidden" name="phone" value="<?php echo $phone; ?>">
<input type="hidden" name="ship_street_address" value="<?php echo $ship_street_address; ?>">
<input type="hidden" name="ship_city" value="<?php echo $ship_city; ?>">
<input type="hidden" name="ship_state" value="<?php echo $ship_state; ?>">
<input type="hidden" name="ship_zip" value="<?php echo $ship_zip; ?>">
<input type="hidden" name="ship_country" value="<?php echo $ship_country; ?>">
<?php $i = 0; ?>
<?php foreach ($products as $product) { ?>
<input type="hidden" name="c_prod_<?php echo $i; ?>" value="<?php echo $product['product_id']; ?>,<?php echo $product['quantity']; ?>">
<input type="hidden" name="c_name_<?php echo $i; ?>" value="<?php echo $product['name']; ?>">
<input type="hidden" name="c_description_<?php echo $i; ?>" value="<?php echo $product['description']; ?>">
<input type="hidden" name="c_price_<?php echo $i; ?>" value="<?php echo $product['price']; ?>">
<?php $i++; ?>
Controller file:

Code: Select all

$this->data['sid'] = $this->config->get('twocheckout_account');
$this->data['total'] = $this->currency->format($order_info['total'], $order_info['currency_code'], $order_info['currency_value'], false);
$this->data['cart_order_id'] = $this->session->data['order_id'];
$this->data['card_holder_name'] = $order_info['payment_firstname'] . ' ' . $order_info['payment_lastname'];
$this->data['street_address'] = $order_info['payment_address_1'];
$this->data['city'] = $order_info['payment_city'];

if ($order_info['payment_iso_code_2'] == 'US' || $order_info['payment_iso_code_2'] == 'CA') {
$this->data['state'] = $order_info['payment_zone'];
} else {
$this->data['state'] = 'XX';
}

$this->data['zip'] = $order_info['payment_postcode'];
$this->data['country'] = $order_info['payment_country'];
$this->data['email'] = $order_info['email'];
$this->data['phone'] = $order_info['telephone'];
if ($this->cart->hasShipping()) {
$this->data['ship_street_address'] = $order_info['shipping_address_1'];
$this->data['ship_city'] = $order_info['shipping_city'];
$this->data['ship_state'] = $order_info['shipping_zone'];
$this->data['ship_zip'] = $order_info['shipping_postcode'];
$this->data['ship_country'] = $order_info['shipping_country'];
} else {
$this->data['ship_street_address'] = $order_info['payment_address_1'];
$this->data['ship_city'] = $order_info['payment_city'];
$this->data['ship_state'] = $order_info['payment_zone'];
$this->data['ship_zip'] = $order_info['payment_postcode'];
$this->data['ship_country'] = $order_info['payment_country'];			
}

Re: opencart 1.5.6.4 - 2checkout not redirect after payment

Posted: Sat Dec 28, 2019 8:07 pm
by Cloudeze
IP_CAM wrote:
Sat Dec 28, 2019 9:28 am
Well, below are all the Variables, as they exist in a default OC .1.5.6.4 twocheckout.tpl File,
but most (failed one's) of those shown in your Posting do not exist. You seem to use another Extension
(or Module) for this in your Custom Theme, as it looks.
Ernie

Code: Select all

<input type="hidden" name="sid" value="<?php echo $sid; ?>">
<input type="hidden" name="total" value="<?php echo $total; ?>">
<input type="hidden" name="cart_order_id" value="<?php echo $cart_order_id; ?>">
<input type="hidden" name="card_holder_name" value="<?php echo $card_holder_name; ?>">
<input type="hidden" name="street_address" value="<?php echo $street_address; ?>">
<input type="hidden" name="city" value="<?php echo $city; ?>">
<input type="hidden" name="state" value="<?php echo $state; ?>">
<input type="hidden" name="zip" value="<?php echo $zip; ?>">
<input type="hidden" name="country" value="<?php echo $country; ?>">
<input type="hidden" name="email" value="<?php echo $email; ?>">
<input type="hidden" name="phone" value="<?php echo $phone; ?>">
<input type="hidden" name="ship_street_address" value="<?php echo $ship_street_address; ?>">
<input type="hidden" name="ship_city" value="<?php echo $ship_city; ?>">
<input type="hidden" name="ship_state" value="<?php echo $ship_state; ?>">
<input type="hidden" name="ship_zip" value="<?php echo $ship_zip; ?>">
<input type="hidden" name="ship_country" value="<?php echo $ship_country; ?>">
<?php $i = 0; ?>
<?php foreach ($products as $product) { ?>
<input type="hidden" name="c_prod_<?php echo $i; ?>" value="<?php echo $product['product_id']; ?>,<?php echo $product['quantity']; ?>">
<input type="hidden" name="c_name_<?php echo $i; ?>" value="<?php echo $product['name']; ?>">
<input type="hidden" name="c_description_<?php echo $i; ?>" value="<?php echo $product['description']; ?>">
<input type="hidden" name="c_price_<?php echo $i; ?>" value="<?php echo $product['price']; ?>">
<?php $i++; ?>
Controller file:

Code: Select all

$this->data['sid'] = $this->config->get('twocheckout_account');
$this->data['total'] = $this->currency->format($order_info['total'], $order_info['currency_code'], $order_info['currency_value'], false);
$this->data['cart_order_id'] = $this->session->data['order_id'];
$this->data['card_holder_name'] = $order_info['payment_firstname'] . ' ' . $order_info['payment_lastname'];
$this->data['street_address'] = $order_info['payment_address_1'];
$this->data['city'] = $order_info['payment_city'];

if ($order_info['payment_iso_code_2'] == 'US' || $order_info['payment_iso_code_2'] == 'CA') {
$this->data['state'] = $order_info['payment_zone'];
} else {
$this->data['state'] = 'XX';
}

$this->data['zip'] = $order_info['payment_postcode'];
$this->data['country'] = $order_info['payment_country'];
$this->data['email'] = $order_info['email'];
$this->data['phone'] = $order_info['telephone'];
if ($this->cart->hasShipping()) {
$this->data['ship_street_address'] = $order_info['shipping_address_1'];
$this->data['ship_city'] = $order_info['shipping_city'];
$this->data['ship_state'] = $order_info['shipping_zone'];
$this->data['ship_zip'] = $order_info['shipping_postcode'];
$this->data['ship_country'] = $order_info['shipping_country'];
} else {
$this->data['ship_street_address'] = $order_info['payment_address_1'];
$this->data['ship_city'] = $order_info['payment_city'];
$this->data['ship_state'] = $order_info['payment_zone'];
$this->data['ship_zip'] = $order_info['payment_postcode'];
$this->data['ship_country'] = $order_info['payment_country'];			
}
Thanks IP_CAM for your reply, appreciated.

Actually, I tried with opencart default module payment come with 1.5.6.4, so it does not work for me, after I tried with this module on github :

https://github.com/craigchristenson/opencart-2checkout

But all of them, after I pay, instead of redirect me to success page, it redirect me to blank page with message :

The response from 2checkout.com can't be parsed. Contact site administrator, please!


URL:

Code: Select all

https://mystore.com/payment/twocheckout/callback?middle_initial=&sid=326584598547&fixed=Y&cart_weight=0&key=AE3275C1E2154AD512049D7986DAEE82&state=Hauts+de+Seine&last_name=Doe&email=johndoe%40yahoo.com&city=Le+Plessis&street_address=9+Avenue+Denis&cart_order_id=263&order_number=250266293682&ip_country=France&country=FRA&merchant_order_id=&cart_id=263&currency_code=USD&lang=en&demo=Y&invoice_id=250266293681&pay_method=CC&cart_tangible=N&total=0.40&phone=%2B33752365425+&credit_card_processed=Y&zip=92350&street_address2=&x_receipt_link_url=https%3A%2F%2Fmystore.com%2Fpayment%2Ftwocheckout%2Fcallback&first_name=John&card_holder_name=John+Doe
Please advice, it look like the md5 can not be verified, because when I tried to remove this part on my /catalog/controller/payment/twocheckout.php

Code: Select all

 if (strtoupper(md5($this->config->get('twocheckout_secret') . $this->config->get('twocheckout_account') . $order_number . $this->request->request['total'])) == $this->request->request['key']) {
Successfully redirected me back my shop, so I think the problem is that 2checkout script can't bypass the md5 hash .. I double check my secret word and account id and it's correct.

Please help me to fix the issue ??

Thanks so much!!

Re: opencart 1.5.6.4 - 2checkout not redirect after payment

Posted: Sat Dec 28, 2019 10:27 pm
by xxvirusxx
Try to downgrade 3.x version from here to 1.5.6.4

https://github.com/craigchristenson/ope ... ndor2-v3.0

Possible code from first repo doesn't work anymore.

Or pay a developer to fix for you.

LE. 3.x version use "same" code and work. Confirmed by this guy.
https://github.com/craigchristenson/ope ... /issues/18

Code: Select all

if (strtoupper(md5($this->config->get('payment_twocheckout_pp_secret') . $this->config->get('payment_twocheckout_pp_account') . $order_number . $this->request->request['total'])) == $this->request->request['key']) {
So better check again account credentials or contact opencart2chckout support.

Also you can remove these lines from .tpl

Code: Select all

 <input type="hidden" name="ship_street_address2" value="<?php echo $ship_street_address2; ?>" />

Code: Select all

 <input type="hidden" name="ship_name" value="<?php echo $ship_name; ?>" />
And from controller...

Re: opencart 1.5.6.4 - 2checkout not redirect after payment

Posted: Sun Dec 29, 2019 12:15 am
by Cloudeze
xxvirusxx wrote:
Sat Dec 28, 2019 10:27 pm
Try to downgrade 3.x version from here to 1.5.6.4

https://github.com/craigchristenson/ope ... ndor2-v3.0

Possible code from first repo doesn't work anymore.

Or pay a developer to fix for you.

LE. 3.x version use "same" code and work. Confirmed by this guy.
https://github.com/craigchristenson/ope ... /issues/18

Code: Select all

if (strtoupper(md5($this->config->get('payment_twocheckout_pp_secret') . $this->config->get('payment_twocheckout_pp_account') . $order_number . $this->request->request['total'])) == $this->request->request['key']) {
So better check again account credentials or contact opencart2chckout support.

Also you can remove these lines from .tpl

Code: Select all

 <input type="hidden" name="ship_street_address2" value="<?php echo $ship_street_address2; ?>" />

Code: Select all

 <input type="hidden" name="ship_name" value="<?php echo $ship_name; ?>" />
And from controller...
Thanks for your reply.

Well, I have downloaded the latest version of opencart which is 3.0.3.2 and almost I can confirm 100% the same code are used for twocheckout.php. Just some field name in database was changed because of the new structure of the opencart was changed on v2+. The question is why 1.5.6.4 does not work and v2 or even v3 works ?

Please if someone can investigate on this and help me fix it.

Thanks so much!!

Re: opencart 1.5.6.4 - 2checkout not redirect after payment

Posted: Sun Dec 29, 2019 12:47 am
by xxvirusxx
Maybe has something to do with encryption....

Try to replace encryption.php from 1.5.6.4 (system/library) with encryption from 3.0.3.2, then test with default 2checkout from 1.5.6.4

Re: opencart 1.5.6.4 - 2checkout not redirect after payment

Posted: Sun Dec 29, 2019 7:06 am
by Cloudeze
xxvirusxx wrote:
Sun Dec 29, 2019 12:47 am
Maybe has something to do with encryption....

Try to replace encryption.php from 1.5.6.4 (system/library) with encryption from 3.0.3.2, then test with default 2checkout from 1.5.6.4
Ok I will try, but can you tell if is there any relation with 2checkout api file and encryption.php file ?? Because I don't see any encryption in the catalog/controller/payment/twocheckout.php file. Please advice if I'm wrong.

Thanks in advance!

Re: opencart 1.5.6.4 - 2checkout not redirect after payment

Posted: Sun Dec 29, 2019 8:41 am
by xxvirusxx
xxvirusxx wrote:
Sun Dec 29, 2019 12:47 am
system/library)

Re: opencart 1.5.6.4 - 2checkout not redirect after payment

Posted: Sun Dec 29, 2019 9:25 am
by Cloudeze
xxvirusxx wrote:
Sun Dec 29, 2019 8:41 am
xxvirusxx wrote:
Sun Dec 29, 2019 12:47 am
system/library)
Not clear, please explain bit more ??

Re: opencart 1.5.6.4 - 2checkout not redirect after payment

Posted: Sun Dec 29, 2019 9:46 am
by IP_CAM
It means, that the encryption.php exists in the shop/SYSTEM/LIBRARY/... Subdirectory ... ::)
Easy enough ? :laugh:

Re: opencart 1.5.6.4 - 2checkout not redirect after payment

Posted: Sun Dec 29, 2019 9:58 am
by Cloudeze
IP_CAM wrote:
Sun Dec 29, 2019 9:46 am
It means, that the encryption.php exists in shop/SYSTEM/LIBRARY/... Subdirectory ... ::)
Yeah, so easy! :)

But the 2checkout has nothing to do with the encryption since the api of 2checkout use md5 to check the $_REQUEST["key"]. Btw, a few minutes ago, I tried to debug the /catalog/controller/payment/twocheckout.php during the payment and here is what I found :

On this condition :

Code: Select all

if (strtoupper(md5($this->config->get('twocheckout_secret') . $this->config->get('twocheckout_account') . $order_number . $this->request->post['total'])) == $this->request->post['key']) {
I print the the following codes :
$this->request->post['key']
and
$this->config->get('twocheckout_secret') . $this->config->get('twocheckout_account') . $order_number . $this->request->post['total']

and both display the same values, which is true and should be redirect to my site, however, even if the values is equal, always skip the if(..) and going to else condition to display message of : "The response from 2checkout.com can't be parsed. Contact site administrator, please!"

Please let me know!!

Thanks.

Re: opencart 1.5.6.4 - 2checkout not redirect after payment

Posted: Sun Dec 29, 2019 4:09 pm
by xxvirusxx
You can post on Commercial.

Re: opencart 1.5.6.4 - 2checkout not redirect after payment

Posted: Mon Dec 30, 2019 12:04 am
by Cloudeze
xxvirusxx wrote:
Sun Dec 29, 2019 4:09 pm
You can post on Commercial.
I already contacted 2checkout support and they are investigate on this. But I think the issue is on v1.5.6.4 not 2checkout since it works with the same codes on latest version ???

Could someone please help me or do some debugging and find out what's going on v1.5.6.4 ?? My website is offline for about 20 days just because of this. Please guys!!

Thanks so much!!

Re: opencart 1.5.6.4 - 2checkout not redirect after payment

Posted: Mon Dec 30, 2019 1:05 am
by xxvirusxx
Cloudeze wrote:
Mon Dec 30, 2019 12:04 am
My website is offline for about 20 days just because of this.
Worked before?
As I said, better post Commercial and pay a developer to take a look, because I don't think someone will spend 1-2-3 hours to debug for free.

Also you can upgrade you store to 2.3.0.2 or 3.0.3.2

Re: opencart 1.5.6.4 - 2checkout not redirect after payment

Posted: Mon Dec 30, 2019 5:06 am
by Cloudeze
xxvirusxx wrote:
Mon Dec 30, 2019 1:05 am
Cloudeze wrote:
Mon Dec 30, 2019 12:04 am
My website is offline for about 20 days just because of this.
Worked before?
As I said, better post Commercial and pay a developer to take a look, because I don't think someone will spend 1-2-3 hours to debug for free.

Also you can upgrade you store to 2.3.0.2 or 3.0.3.2
No, this is the first I tried the 2checkout on opencart 1.5.6.4.

anyone who just can give some help on this community ?? the key returned is the same but why always run inside else){..} instead of if(){..} please if you can give some suggestions idea of what you think and what should I do please ??

Re: opencart 1.5.6.4 - 2checkout not redirect after payment

Posted: Mon Dec 30, 2019 5:40 am
by straightlight
Despite the upgrade suggestion, in this case, followed are the remaining supported payment extensions list in the Github version from now on: https://github.com/opencart/opencart/tr ... on/payment

Re: opencart 1.5.6.4 - 2checkout not redirect after payment

Posted: Tue Dec 31, 2019 7:49 pm
by ADD Creative
Are the values the same after the MD5 hash? Any spaces, linefeeds, cragage returns, ect. added to the values, that you might not see on the displayed values?

Have you check the file against the original in case something has been changed, such as brackets being removed or added.
https://github.com/opencart/opencart/bl ... eckout.php

Re: opencart 1.5.6.4 - 2checkout not redirect after payment

Posted: Tue Dec 31, 2019 10:31 pm
by straightlight
See this solution: viewtopic.php?t=209761#p759524 for Authorize.net (SIM).