8

I am having some issues with PayPal IPN. The documentation uses ASCII encoding. I am using UTF-8. It works fine but as a rarest case I get some random characters. As far as I know the Paypal account can be setup for different encoding. Is there any way to identify that?.

Or is there a standard way of handling all the cases.

tmjam
  • 1,029
  • 2
  • 12
  • 25

2 Answers2

12

You can set the encoding for IPN via Account Settings > Website Payments > PayPal Button Language Encoding > More Options. (direct link)

The IPN message itself contains a 'charset' field as well which you can check against. See also https://cms.paypal.com/us/cgi-bin/?cmd=_render-content&content_ID=developer/e_howto_admin_IPNIntro#id091F0M006Y4

Richard Moss
  • 1,550
  • 3
  • 26
  • 43
Robert
  • 19,326
  • 3
  • 58
  • 59
  • That's true I agree with that, but what if my IPN listener does not know about that encoding? – tmjam Dec 22 '11 at 22:22
  • 2
    The IPN message itself contains a 'charset' field as well which you can check against. See also: https://cms.paypal.com/us/cgi-bin/?cmd=_render-content&content_ID=developer/e_howto_admin_IPNIntro#id091F0M006Y4 – Robert Dec 23 '11 at 00:16
  • Thanks Robert that helps. I just wonder if it will overwrite the setting made on the profile and is it a good practice – tmjam Dec 23 '11 at 00:32
  • That value should show the setting from the Profile, since there is no other way to set/override the IPN charset. – Robert Dec 24 '11 at 16:37
  • @Robert I think you should add your first comment to the answer as it is much more scalable (e.g. if you have many customers that you are implementing IPN for, asking each of them to set encoding via their profiles is not feasible, but checking/converting against an already existing value can be done automatically). Also a great catch. – Halil Özgür Jun 07 '12 at 09:54
  • it seems "charset" is no longer included in the ipn message? – Adam Rabung Jun 07 '13 at 04:06
  • 4
    Why on the world wouldn't PayPal default to UTF-8 encoding. Some engineers just want to watch the world burn. – Mahn Mar 15 '15 at 21:20
  • 2
    @Mahn PayPal's IPN system dates back to the 1990s before knowledge of internationalization was widespread amongst web-developers - they can't risk breaking hundreds of thousands of websites. FWIW, PayPal has a set of new web-APIs (such as their new Webhook API) which look like they'll replace IPN in the long-term. – Dai Apr 23 '17 at 11:34
0

I see this as a part of the solution.

specifying the encoding method used in the form we send to paypal

<INPUT TYPE="hidden" name="charset" value="utf-8">

This link is more helpful

tmjam
  • 1,029
  • 2
  • 12
  • 25