Post by metal450 » Sat Nov 20, 2010 4:42 am

Hi all,

Because I sell digital products that are purchased from around the world (via PayPal), I find myself *frequently* receiving the following messages:

Code: Select all

PP_Standard - IPN/PDT Auto-Verification Failed. This is often caused by strange characters in the customer address or name. Verify manually.
In each case, it has been due to a character like ø, ü, é, etc in the address. However, this is *extremely* common in non-English countries, and thus seems like quite a big issue to need to manually confirm nearly half of my orders which I'd have expected to go through automatically. Does anyone know of some way to resolve this? I'm running OpenCart version 1.4.9.1

Thanks in advance! :)
Last edited by i2Paq on Sat Nov 20, 2010 11:29 pm, edited 1 time in total.
Reason: Topic moved

Newbie

Posts

Joined
Mon Nov 01, 2010 2:36 am

Post by johnzhang » Wed Jan 05, 2011 12:27 pm

Me Two

IPN/PDT Auto-Verification Failed


1.4.93

China Buy Dropship Buy From China Ebay Taobao


New member

Posts

Joined
Sun Apr 18, 2010 11:02 am


Post by Qphoria » Wed Jan 05, 2011 1:56 pm

Yea this is an annoyance that none of the examples on the paypal forum seems to fix 100%

You can try this:
1. EDIT: catalog/controller/payment/pp_standard.php

2. FIND 2 OF THESE:

Code: Select all

$request .= '&' . $key . '=' . urlencode($value);
3. CHANGE BOTH TO:

Code: Select all

$request .= '&' . $key . '=' . urlencode(html_entity_encode($value, ENT_QUOTES, 'utf-8');
if you still get the error then try:

Code: Select all

$request .= '&' . $key . '=' . urlencode(html_entity_decode($value, ENT_QUOTES, 'utf-8');
If you still get the error then try:

Code: Select all

$request .= '&' . $key . '=' . urlencode(html_entity_encode($value, ENT_NOQUOTES, 'utf-8');
If you still get the error then try

Code: Select all

$request .= '&' . $key . '=' . urlencode(html_entity_encode($value, ENT_QUOTES, 'iso-8859-1');

To be honest I get confused by all these character encodings so I just try a bunch until it works

Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by metal450 » Wed Jan 05, 2011 6:20 pm

Hmm, good tips - but since this is code that deals directly with exchanging money, it would be nice to hear a bit more certain of a solution rather than a several trial-and-error ones :) Any of the devs out there plan to fix this in a future release, for instance...?

Newbie

Posts

Joined
Mon Nov 01, 2010 2:36 am

Post by Qphoria » Wed Jan 05, 2011 9:10 pm

it has nothing to do with exchanging money at this point... this is simply the validate the process.. if it works, you get complete.... if not you just get the same email again

Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by metal450 » Fri Jan 07, 2011 5:57 pm

Well, wouldn't there be the potential of worsening the problem? i.e. by changing the code to something that causes it to misinterpret information that's currently being interpreted correctly (by coding it via guesswork rather than understanding of the encodings/decodings), wouldn't it be possible that, for instance, *every* order might generate that error rather than just the ones that do at present?

Would be great if someone who clearly understands the root of the problem could chime in :)

Newbie

Posts

Joined
Mon Nov 01, 2010 2:36 am

Post by Xsecrets » Fri Jan 07, 2011 9:20 pm

no it shouldn't worsen because those encode/decode functions only act on "special" characters anyways. Also I don't think you'll find anyone here who understands the paypal module better than Q.

OpenCart commercial mods and development http://spotonsolutions.net
Layered Navigation
Shipment Tracking
Vehicle Year/Make/Model Filter


Guru Member

Posts

Joined
Sun Oct 25, 2009 3:51 am
Location - FL US

Post by Qphoria » Wed Jan 12, 2011 1:20 am

I just wish I understood encoding better.. tho oddly none of the methods I've tried on the paypal forums has worked 100% so maybe others don't get it either.

Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by BbWebConsult » Tue Jan 25, 2011 4:31 am

Here is the solution:

1) Edit /catalog/controller/payment/pp_standart.php

Find:

Code: Select all

$this->data['fields']['custom'] = $encryption->encrypt($this->session->data['order_id']);
After, add:

Code: Select all

$this->data['fields']['charset'] = 'utf-8';
Save and upload to server.

2) Connect to you Paypal account.
Go to "Profile" -> "More options" -> "Language Encoding" -> "More Options".
Select "Utf-8" as encoding for both scroll down list.
Save and try again! ;)

Diseño web Barcelona


User avatar
Newbie

Posts

Joined
Tue Jan 25, 2011 4:18 am


Post by Qphoria » Tue Jan 25, 2011 5:13 am

Ok i'll try it, tho I think if you are passing the charset from the module you won't need to change it manually in the paypal account... (not positive tho)

Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by BbWebConsult » Tue Jan 25, 2011 5:51 am

Well, maybe you are right. I first did step number one and that corrected the displaying problem on paypal's payment page (Adress name did display with funny characters).
But then I still had this validation error because Paypal did return the data encoded in Windows-1252.

By changing the charset in the settings for Incoming and outgoing data, that should do it!!

Diseño web Barcelona


User avatar
Newbie

Posts

Joined
Tue Jan 25, 2011 4:18 am


Post by metal450 » Wed Jan 26, 2011 12:50 am

Excellent - now THAT looks like a solution! Will give it a try and report back if any more of those errors pop up (sometimes I get a few in a day, and sometimes none for weeks...just depends where the orders come from...) :)

Newbie

Posts

Joined
Mon Nov 01, 2010 2:36 am

Post by Qphoria » Wed Jan 26, 2011 4:58 am

Just adding charset="utf-8" did not work for me... I will try to change it in the paypal account too and let you know. But from what I can infer from the guides, the charset SHOULD override the setting in your paypal account

Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by BbWebConsult » Wed Jan 26, 2011 5:02 am

The charset overrides the setting in your paypal account for the outgoing data from your website.
When replying back with the response, Paypal sends you the data coded with the charset specified in your Paypal settings.

Diseño web Barcelona


User avatar
Newbie

Posts

Joined
Tue Jan 25, 2011 4:18 am


Post by Qphoria » Wed Jan 26, 2011 6:13 am

BbWebConsult wrote:The charset overrides the setting in your paypal account for the outgoing data from your website.
When replying back with the response, Paypal sends you the data coded with the charset specified in your Paypal settings.
Yea.. but that either isn't working or this isn't a fix.. I had 2 today using only the charset change in the code. Now I have both places changed so I await another person with a & in their name (tho I could just do it myself)

Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by metal450 » Wed Jan 26, 2011 11:21 am

I both added the code mentioned & changed it to UTF-8 on PayPal, but the bug still occurred (someone with & in their name). Apparently that isn't a fix after all.

Newbie

Posts

Joined
Mon Nov 01, 2010 2:36 am

Post by BbWebConsult » Wed Jan 26, 2011 4:55 pm

For me that worked!
Maybe it's just the "&" .. which the variable separator used in Paypal's response. Maybe that's the problem ?
You should receive an email from opencart when a payment fails. If you look in the error message, you should see all the variables sent back by paypal.
Is the '&' encoded or unchanged?

Diseño web Barcelona


User avatar
Newbie

Posts

Joined
Tue Jan 25, 2011 4:18 am


Post by metal450 » Wed Jan 26, 2011 5:00 pm

It's listed as & in that email, which is what I would expect. Strange that it would still fail... :(

Newbie

Posts

Joined
Mon Nov 01, 2010 2:36 am

Post by Daniel » Wed Jan 26, 2011 5:02 pm

i found by changing the request class to:

Code: Select all

<?php
final class Request {
    public $get = array();
    public $post = array();
    public $cookie = array();
    public $files = array();
    public $server = array();
    
      public function __construct() {
        $_GET = $this->clean($_GET);
        $_POST = $this->clean($_POST);
        $_COOKIE = $this->clean($_COOKIE);
        $_FILES = $this->clean($_FILES);
        $_SERVER = $this->clean($_SERVER);
        
        $this->get = $_GET;
        $this->post = $_POST;
        $this->cookie = $_COOKIE;
        $this->files = $_FILES;
        $this->server = $_SERVER;
    }
    
      public function clean($data) {
        if (is_array($data)) {
              foreach ($data as $key => $value) {
                unset($data[$key]);
                
                $data[$this->clean($key)] = $this->clean($value);
              }
        } else { 
              $data = htmlspecialchars($data, ENT_COMPAT);
        }

        return $data;
    }
}
?>
helps.

OpenCart®
Project Owner & Developer.


User avatar
Administrator

Posts

Joined
Fri Nov 03, 2006 6:57 pm

Post by Qphoria » Wed Jan 26, 2011 11:36 pm

Daniel wrote:i found by changing the request class to:

Code: Select all

<?php
final class Request {
    public $get = array();
    public $post = array();
    public $cookie = array();
    public $files = array();
    public $server = array();
    
      public function __construct() {
        $_GET = $this->clean($_GET);
        $_POST = $this->clean($_POST);
        $_COOKIE = $this->clean($_COOKIE);
        $_FILES = $this->clean($_FILES);
        $_SERVER = $this->clean($_SERVER);
        
        $this->get = $_GET;
        $this->post = $_POST;
        $this->cookie = $_COOKIE;
        $this->files = $_FILES;
        $this->server = $_SERVER;
    }
    
      public function clean($data) {
        if (is_array($data)) {
              foreach ($data as $key => $value) {
                unset($data[$key]);
                
                $data[$this->clean($key)] = $this->clean($value);
              }
        } else { 
              $data = htmlspecialchars($data, ENT_COMPAT);
        }

        return $data;
    }
}
?>
helps.
If I'm not mistaken, this removes the explicit utf-8 char encoding. By default php uses ISO-8859-1 so this would make it all use ISO-8859-1 ?

Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am
Who is online

Users browsing this forum: No registered users and 25 guests