Page 1 of 2
PayPal Verification Error: Strange Characters
Posted: Sat Nov 20, 2010 4:42 am
by metal450
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!

Re: PayPal Verification Error: Strange Characters
Posted: Wed Jan 05, 2011 12:27 pm
by johnzhang
Me Two
IPN/PDT Auto-Verification Failed
1.4.93
Re: PayPal Verification Error: Strange Characters
Posted: Wed Jan 05, 2011 1:56 pm
by Qphoria
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
Re: PayPal Verification Error: Strange Characters
Posted: Wed Jan 05, 2011 6:20 pm
by metal450
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...?
Re: PayPal Verification Error: Strange Characters
Posted: Wed Jan 05, 2011 9:10 pm
by Qphoria
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
Re: PayPal Verification Error: Strange Characters
Posted: Fri Jan 07, 2011 5:57 pm
by metal450
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

Re: PayPal Verification Error: Strange Characters
Posted: Fri Jan 07, 2011 9:20 pm
by Xsecrets
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.
Re: PayPal Verification Error: Strange Characters
Posted: Wed Jan 12, 2011 1:20 am
by Qphoria
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.
Re: PayPal Verification Error: Strange Characters
Posted: Tue Jan 25, 2011 4:31 am
by BbWebConsult
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!

Re: PayPal Verification Error: Strange Characters
Posted: Tue Jan 25, 2011 5:13 am
by Qphoria
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)
Re: PayPal Verification Error: Strange Characters
Posted: Tue Jan 25, 2011 5:51 am
by BbWebConsult
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!!
Re: PayPal Verification Error: Strange Characters
Posted: Wed Jan 26, 2011 12:50 am
by metal450
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...)

Re: PayPal Verification Error: Strange Characters
Posted: Wed Jan 26, 2011 4:58 am
by Qphoria
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
Re: PayPal Verification Error: Strange Characters
Posted: Wed Jan 26, 2011 5:02 am
by BbWebConsult
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.
Re: PayPal Verification Error: Strange Characters
Posted: Wed Jan 26, 2011 6:13 am
by Qphoria
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)
Re: PayPal Verification Error: Strange Characters
Posted: Wed Jan 26, 2011 11:21 am
by metal450
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.
Re: PayPal Verification Error: Strange Characters
Posted: Wed Jan 26, 2011 4:55 pm
by BbWebConsult
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?
Re: PayPal Verification Error: Strange Characters
Posted: Wed Jan 26, 2011 5:00 pm
by metal450
It's listed as & in that email, which is what I would expect. Strange that it would still fail...

Re: PayPal Verification Error: Strange Characters
Posted: Wed Jan 26, 2011 5:02 pm
by Daniel
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.
Re: PayPal Verification Error: Strange Characters
Posted: Wed Jan 26, 2011 11:36 pm
by Qphoria
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 ?