Paypal IPN override charset

前端 未结 2 1990
闹比i
闹比i 2021-02-04 00:47

i have a problem with this paypal IPN. I saw, a lot of people had.

I try to pay as a user: Árvíztűrő Tükörfúrógép In this name, there are all special chars, what are in

2条回答
  •  被撕碎了的回忆
    2021-02-04 01:15

    Lenart's answer is great and very useful, but I thought I'd add a few things that wouldn't fit in a comment.

    • To clarify: setting the charset on your site, in your order form (e.g.: via a hidden input), is NOT enough, you also need to set your default encoding – as explained in Lenart's answer.
      • That's because that option applies only to your own data, while the default setting applies to the data sent by PayPal to your IPN-handling script.
      • e.g.: maybe you have UTF-8 as a hidden input on your order form but PayPal IPNs still are in windows-1252. You can only fix that by changing the default setting in your PayPal account.
    • For testing purposes, you'll want to set that encoding option for your Sandbox merchant account, too! (Just log in to https://sandbox.paypal.com with your Sandbox merchant details.)
    • After setting the default encoding, if you go back to the setting again to check on its value, it will show the default value instead of the value you set. This is a bug (and illustrative of the quality of PayPal's work) and the value you set previously is actually still set.
      • So if you want to make sure what the charset really is, do so inside of your IPN-handling script by checking the value of charset in the POST message.
    • The default charset used by PayPal does not work properly.
      • e.g.: Western European Languages (including English) would cause French accented characters not to work.
      • You're better off using UTF8 everywhere (will show as UTF-8 in the IPNs.)

    §

    EDIT. Last but not least:

    If you'd like to test your IPN-handling script with special or accented characters, you have (theoretically) a few different options but most do not work in practice.

    Here's a recap:

    • Using the IPN Simulator won't work as it cannot validate the request (it produces fake requests, not real ones.)
    • Creating a PayPal Sandbox customer account with special characters inside of the firstname or last name is sadly not possible.
      • The user interface does not support it and will ask you to Only enter letters (sic).
      • The bulk account upload functionality is no better, resulting in Something went wrong. One or more sandbox accounts could not be uploaded. Try again.
    • The one option that works: test your site with the PayPal Sandbox server and choose to pay without a PayPal account.
      • This way, you'll be able to enter accented / special characters for the first and last names.
      • (You'll get the credit card number, type and expiry date from `Developer/Sandbox Accounts › your customer account › Profile › Funding – any number will do for the CVV value.)

    I reported this issue to PayPal months ago but nothing has changed.

    §

    Working with PayPal is no fun and a big waste of time. I hope this will help you save some time. Take your business elsewhere if you can.

提交回复
热议问题