Jump to content


Photo

International characters in IPN -- VB .NET


  • This topic is locked This topic is locked
12 replies to this topic

#1 jamesdunn

jamesdunn

    Newbie

  • Members
  • Pip
  • 9 posts

Posted 07 December 2004 - 07:15 AM

Hi everyone,

I've been hassling PayPal about this problem for months now and had no real response. I can't find anyone talking about it on here... so I hope that with this post, I can get people to notice :)

PayPal's IPN does *not work* with international characters.

For example, we just had an order from "CH-5406 Baden-Rütihof". PayPal sent us the information via IPN. We simply passed it back, but it looks like PayPal *rejected* it because of the umlaut (the u with two dots over it).

PayPal recommended we replace the "strange" characters with certain codes... for the umlaut, it was "%fc". So we did that, but we still have problems.

I use a very generic VB .NET script to postback to the IPN. Here's a clip where I generate the URL to post back to:

Dim strToSend As String = Request.Form.ToString()
'Create the string to post back to PayPal system to validate
strToSend &= "&cmd=_notify-validate"

.... that doesn't work. I replaced it with this, following PayPal's suggest:

Dim strToSend As String = Request.Form.ToString()
'Create the string to post back to PayPal system to validate
strToSend &= "&cmd=_notify-validate"
strToSend = strToSend.Replace("æ", "%00").Replace("Š", "%8a").Replace("Œ", "%8c").Replace("Ž", "%8e").Replace("š", "%9a").Replace("œ", "%9c").Replace("ž", "%9e").Replace("Ÿ", "%9f").Replace("¡", "%a1").Replace("¥", "%a5").Replace("§", "%a7").Replace("¨", "%a8").Replace("ª", "%aa").Replace("µ", "%b5").Replace("¿", "%bf").Replace("À", "%c0").Replace("Á", "%c1").Replace("Â", "%c2").Replace("Ã", "%c3").Replace("Ä", "%c4").Replace("Å", "%c5").Replace("Æ", "%c6").Replace("Ç", "%c7").Replace("È", "%c8").Replace("É", "%c9").Replace("Ê", "%ca").Replace("Ë", "%cb").Replace("Ì", "%cc").Replace("Í", "%cd").Replace("Î", "%ce").Replace("Ï", "%cf").Replace("Ð", "%d0").Replace("Ñ", "%d1").Replace("Ò", "%d2"). _
Replace("Ó", "%d3").Replace("Ô", "%d4").Replace("Õ", "%d5").Replace("Ö", "%d6").Replace("Ø", "%d8").Replace("Ù", "%d9").Replace("Ú", "%da").Replace("Û", "%db").Replace("Ü", "%dc").Replace("Ý", "%dd").Replace("Þ", "%de").Replace("ß", "%df").Replace("à", "%e0").Replace("á", "%e1").Replace("â", "%e2").Replace("ã", "%e3").Replace("ä", "%e4").Replace("å", "%e5").Replace("æ", "%e6").Replace("ç", "%e7").Replace("è", "%e8").Replace("é", "%e9").Replace("ê", "%ea").Replace("ë", "%eb").Replace("ì", "%ec").Replace("í", "%ed").Replace("î", "%ee").Replace("ï", "%ef").Replace("ð", "%f0").Replace("ñ", "%f1").Replace("ò", "%f2").Replace("ó", "%f3").Replace("ô", "%f4").Replace("õ", "%f5").Replace("ö", "%f6").Replace("ø", "%f8"). _
Replace("ù", "%f9").Replace("ú", "%fa").Replace("û", "%fb").Replace("ü", "%fc").Replace("ý", "%fd").Replace("þ", "%fe").Replace("ÿ", "%ff")

... but that doesn't work either.

How can you handle international characters, in IPN, with VB .NET?

Thank you,

James :)

#2 jamesdunn

jamesdunn

    Newbie

  • Members
  • Pip
  • 9 posts

Posted 08 December 2004 - 04:29 PM

Hi everyone,

Am I guessing this is too technical for this forum?

James

#3 PayPalStephen

PayPalStephen

    Advanced Member

  • Members
  • 2,138 posts

Posted 09 December 2004 - 04:00 PM

Hello,

The IPN post is URL encoded, so Ü will come as %FC

' Create the request back
Dim req As HttpWebRequest = CType(WebRequest.Create("https://www.paypal.com/cgi-bin/webscr"), _
HttpWebRequest)

' Set values for the request back
req.Method = "POST"
req.ContentType = "application/x-www-form-urlencoded"
strNewValue = strFormValues + "&cmd=_notify-validate"
req.ContentLength = strNewValue.Length

' Write the request back IPN strings
Dim stOut As StreamWriter = New StreamWriter(req.GetRequestStream(), _
Encoding.ASCII)
stOut.Write(strNewValue)
stOut.Close()

Currently we support ASCII plus 7 German characters: ä, ö, ü, Ä, Ö, Ü, and ß.

My test using
CH-5406 Baden-Rütihof
produced the IPN post of
CH-5406+Baden-R%FCtihof

Stephen Ivaskevicius
PayPal/eBay, Inc.
www.paypal.com/pdn

#4 jamesdunn

jamesdunn

    Newbie

  • Members
  • Pip
  • 9 posts

Posted 24 January 2005 - 01:53 PM

Hi Stephen,

Unfortunately your solution doesn't actually... uhm... work :P

Sorry for the belated reply. I've been waiting making tweaks and more tweaks and trying to catch this occuring again. It just happened, so I can give you FULL details.

We've had a customer in Portugal order. The middle line of his address is "nº7 - 1 E". As you can see, the curious character after "n" and before "7" is a "degree" symbol.

Here's the relevant part of my code... as you can see it's almost exactly the same as yours (only difference is object names):

Dim strToSend As String = Request.Form.ToString()

strToSend &= "&cmd=_notify-validate"

'Initialize the WebRequest.
Dim myRequest As System.Net.HttpWebRequest = System.Net.HttpWebRequest.Create("https://www.paypal.com/cgi-bin/webscr")

myRequest.AllowAutoRedirect = False
myRequest.Method = "POST"
myRequest.ContentLength = strToSend.Length
myRequest.ContentType = "application/x-www-form-urlencoded"

Dim RequestStream As System.IO.StreamWriter = _
New System.IO.StreamWriter(myRequest.GetRequestStream(), System.Text.Encoding.ASCII)
RequestStream.Write(strToSend)
RequestStream.Close()

'Send request and get response
Dim myResponse As System.Net.HttpWebResponse = myRequest.GetResponse()

... you don't need to know the rest, but you see what I'm getting at here.

So any thoughts?

It definitely doesn't work :((

Thanks,

Jim

#5 maratd

maratd

    Member

  • Members
  • PipPip
  • 11 posts

Posted 25 January 2005 - 09:50 AM

My IPN script uses PHP and I have a LOT of customers who are International. I have never had a problem with improper formatting from PayPal. They always pass the correct characters, even with "degree" symbols (which are actually equivalent to # and are mostly found in Portugal, Spain, and Italy). I can also verify just fine.

My guess would be that your script/program is using the wrong character set ... in other words, it is converting what PayPal sends you to its native format and converts it improperly.

I know PHP uses ISO-8859-1 and eBay likes UTF-8. Microsoft is partial to its own format. In other words, everybody uses a different text format and you need to convert properly or problems will occur ...

Text is actually not just text and is one of the most complex issues in Internet programming, since you need to support every language and character under the sun ...

- Marat

#6 jamesdunn

jamesdunn

    Newbie

  • Members
  • Pip
  • 9 posts

Posted 25 January 2005 - 02:26 PM

I take your point...

But we do specify the ASCII character set here... which is exactly what PayPal officially tell us to do (see above two messages).

Are there any VB .NET or C# people here with WORKING scripts?

Thanks

James!

#7 ellios

ellios

    Newbie

  • Members
  • Pip
  • 2 posts

Posted 26 January 2005 - 02:54 PM

bump - have to agree with the above, please can we get this sorted - or someone who does have it sorted please post sample code.

#8 jamesdunn

jamesdunn

    Newbie

  • Members
  • Pip
  • 9 posts

Posted 02 February 2005 - 05:57 PM

Please, please... ANYONE?

#9 PayPalStephen

PayPalStephen

    Advanced Member

  • Members
  • 2,138 posts

Posted 07 February 2005 - 09:41 AM

Hello,

Have you tried the sample code from the PayPal web site?

ASP.Net/C#



/// <summary>
/// Verifies the IPN message from PayPal
/// </summary>
/// <remarks>
/// Add code under Create the IpnTransaction to process your IPN
/// </remarks>
public class IpnHandler : System.Web.UI.Page
{

private void Page_Load(object sender, System.EventArgs e)
{
string strFormValues = Request.Form.ToString();
string strNewValue;
string strResponse;
// Create the request back
HttpWebRequest req = (HttpWebRequest) WebRequest.Create("https://www.paypal.com/cgi-bin/webscr");

// Set values for the request back
req.Method = "POST";
req.ContentType = "application/x-www-form-urlencoded";
strNewValue = strFormValues + "&cmd=_notify-validate";
req.ContentLength = strNewValue.Length;
// Write the request back IPN strings
StreamWriter stOut = new StreamWriter (req.GetRequestStream(), System.Text.Encoding.ASCII);
stOut.Write(strNewValue);
stOut.Close();

// Do the request to PayPal and get the response
StreamReader stIn = new StreamReader(req.GetResponse().GetResponseStream());
strResponse = stIn.ReadToEnd();
stIn.Close();

// Confirm whether the IPN was VERIFIED or INVALID. If INVALID, just ignore the IPN
if (strResponse == "VERIFIED")
{
// Create the IpnTransaction

}
}
}


Stephen Ivaskevicius
PayPal/eBay, Inc.
www.paypal.com/pdn

#10 jamesdunn

jamesdunn

    Newbie

  • Members
  • Pip
  • 9 posts

Posted 07 February 2005 - 10:27 AM

Stephen,

Please check your code against mine... it's EXACTLY the same.

Sure, yours is in C# and mine in VB .NET. But they're the same. And I am still getting the errors.

I'm going to pass this along to my account manager. Unless you can help further??

Thanks,

James

#11 jamesdunn

jamesdunn

    Newbie

  • Members
  • Pip
  • 9 posts

Posted 09 March 2005 - 05:18 PM

Still no reply. And we've just had another customer fail.

PayPal, this sucks.

If anyone here IS accepting international characters with VB .NET, please get in touch.

I've monitored the situation and PayPal IGNORES the international characters... it literally does NOT pass them at all.

James

#12 DrProctor

DrProctor

    Newbie

  • Members
  • Pip
  • 3 posts

Posted 06 June 2007 - 05:45 AM

Does anyone know where I can get VB versions of the following two files:

IpnService and IpnTransaction

many thanks

#13 davejuk

davejuk

    Member

  • Members
  • PipPip
  • 25 posts

Posted 06 June 2007 - 08:34 AM

Petrick - That link you posted is dead. Do you have a copy of the solution?

<blockquote id="quote"><font size="1" face="Verdana, Arial, Helvetica" id="quote">quote:<hr height="1" noshade id="quote">Originally posted by PayPal_PatrickO
[br]I think your string search/replace logic is the best bet. PayPal only allows 7 "special" charcters for front-end form input. The 7 characters are ä, ö, ü, Ä, Ö, Ü, and ß. characters<hr height="1" noshade id="quote"></blockquote id="quote"></font id="quote">

So when a customer is making payment through the PayPal website, these are the only special characters that the various form fields will accept?

And are you saying that this occurrs because .NET is somehow processing the string before it is passed back?

What encoding should we be using for the POST back? I'm currently using System.Text.Encoding.ASCII (in .NET 2.0) and am having this problem.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users