Forums

Registration

Click here to register. Registration is required if you want to post to the forums.

If you register, we can also contact you with news on new module versions, and upgrades to new modules as we make them available. 

Use of your registration information is subject to our privacy policy.

Inventua Forums

Subject: IPN when accented characters in the client information
Prev Next
You are not authorized to post a reply.

Author Messages
Yann Le Heritte
Posts:6

25 Jan 2010 4:35 PM  

Hello,

Every time a user's information (like the address) has accented characters in it, the IPN fails

Inventua PayPal - IPN Notification Log: MODULE ID: nnnn TXN ID:xxxxx  SUBSCR ID:
POSTing to PayPal: 25/01/2010 04:59:10
Result Received: INVALID
PayPal validation failed: INVALID
Server Name: xyz

I have tried every possible change in the encoding language in the seller's account preferences (like using UTF-8) without any success. When I remove accents from the street name, it works. Any suggestion ? The problem here is that we add the user to roles at the IPN stage, so it is a problem since we have to manually add users to the roles when they have accented characters in their profile.

Any suggestion ?

Thanks,

Yann

Anthony Glenwright
Posts:11292

27 Jan 2010 7:44 PM  
I couldn't think of any reason why our module would have this problem, so I did a google search, it looks like it is a problem at PayPal's side. Do a google search for "paypal ipn accented characters"
Yann Le Heritte
Posts:6

28 Jan 2010 10:12 AM  

Hello,

well, I have forced UTF-8 in the seller's account with no success. Here is something taken from the Paypal troubleshooting tips:

"PayPal's IPN server expects that your script will POST back all variables that were posted to it and more importantly, that they are encoded the same way as they were sent to your script. If your script inadvertently changed the encoding of a character or interprets an encoded character as another character and POSTs back, you will likely see INVALID. This can happen sporadically and tends to occur, for example, when a payment is received and the buyer may have an accented character in their name or the order is for some item with a non-standard character in the item name. These instances are tricky to troubleshoot but it is listed here as it can cause INVALID when you would expect VERIFIED.  Look for this issue when you are seeing that certain IPNs are INVALID and all the rest are VERIFIED."

Actually, when doing a search with Google, we can see that it is common, but that it is actually a client side problem that can be solved.

Here is an IPN test I did with the sandbox:

"mc_gross=0.03&protection_eligibility=Eligible&address_status=confirmed&payer_id=G9N6AKCYKSVXJ&tax=0.00&address_street=101 Abénaquis avec accent&payment_date=07:19:28 Jan 28, 2010 PST&payment_status=Completed&charset=UTF-8&address_zip=J1H 1H1&first_name=Yann&mc_fee=0.03&address_country_code=CA&address_name=Yann Le Heritte&notify_version=2.9&custom=UserId=1&PortalId=2&ModuleId=2428&payer_status=verified&business=yann@123.com&address_country=Canada&address_city=Sherbrooke&quantity=1&verify_sign=AMmRovpWd6tl25FKZ.3hW2EDPvnSAJt8Fr-THRG075eCoWMVVzWaWS8J&payer_email=yann@456.com&txn_id=8NS66017H63567941&payment_type=instant&last_name=Le Heritte&address_state=Quebec&receiver_email=yann@123.com&payment_fee=&receiver_id=AXHUJ49Q7PQFN&txn_type=web_accept&item_name=Annuel / Annual&mc_currency=CAD&item_number=PO-1130- Annuel-2009&residence_country=CA&test_ipn=1&handling_amount=0.00&transaction_subject=UserId=1&PortalId=2&ModuleId=2428&payment_gross=&shipping=0.00"

Do you postback the "charset" variable ?

Yann Le Heritte
Posts:6

28 Jan 2010 12:53 PM  

Well I believe I will have to test it with my own implementation of the IPN to understand the problem

Anthony Glenwright
Posts:11292

28 Jan 2010 4:07 PM  
In the HTTP request that we use to verify IPN information, we post exactly what paypal POSTed us, with cmd="_notify-validate" added. We do not alter the charset value - in fact we do not interpret the data in any way, we just send it on to PayPal for verification, and only parse the result after we get a "verified" result.
Yann Le Heritte
Posts:6

17 Mar 2010 5:13 PM  
Well, actually, when doing "Request.Form.ToString()" in EncodeData in your code, accented characters that where UTF-8 encoded, are decoded as HEX ANSI (i.e. "é" is decoded as 00 E9), although content-encoding is actually UTF-8, but if you do something like:
Dim builder As New StringBuilder
For Each formElement As String In Request.Form
builder.Append(formElement + "=" + Request.Form(formElement) + "&")
Next
Then form data is correctly reposted. Another way is to follow Paypal example to build the repost request:
Dim strRequest As String = Encoding.ASCII.GetString(Param)
strRequest = strRequest + "&cmd=_notify-validate"
req.ContentLength = strRequest.Length

'send PayPal request and get response
Dim streamOut As IO.StreamWriter = New IO.StreamWriter(req.GetRequestStream(), Encoding.ASCII)
streamOut.Write(strRequest)
streamOut.Flush()
streamOut.Close()

This way it works ok. I hope it will help you change the way you process IPN transaction and issue a new release for international customers
Thanks
Anthony Glenwright
Posts:11292

17 Mar 2010 5:38 PM  
Hi Yann,

Your code above uses encoding.ascii - which is basically doing the same thing wrong that I have done (except that I used UTF8 instead of ASCII). I think a solution may be to replace a line of code:

Return System.Text.Encoding.UTF8.GetBytes(strUrlEncoded.ToString())

with this

Return Request.ContentEncoding.GetBytes(strUrlEncoded.ToString())

I can do a test build for you to try, but I need to know whether you are using DNN 4 or 5, please also send your email address to support@inventua.com and I will email the test build to you.
Yann Le Heritte
Posts:6

17 Mar 2010 9:10 PM  
Hello,
actually, I thought exactly the same at first, but paypal example shows ASCII encoding. I gave it a try and it works because all UTF-8 characters are url encoded so there is no need to encode characters in the string. And the problem is more in:
builder.Append(Request.Form.ToString())
that behaves differently than:
For Each formElement As String In Request.Form
builder.Append(formElement + "=" + Request.Form(formElement) + "&")
Next
I actually tested the code I posted earlier, and noticed the difference. I tested the IPN verification with the sandbox, and the way I did it works because of how Request.Form.ToString() encodes accented characters vs the other way in the resulting string
I use DNN 4 (hopefully we will upgrade to DNN 5 in the next few months). I wil send my email address in the next minutes.
I passed the whole day testing different ways using a mix of code taken from your IPN verification and my own implementation, taken from a module I did 2 years ago, that does not have problems with accented characters.
Thanks for the follow up
Yann
You are not authorized to post a reply.
Forums > Inventua Forums > DotNetNuke Modules/Components Support > IPN when accented characters in the client information



ActiveForums 3.7