Python interface to PayPal - urllib.urlencode non-ASCII characters failing

前端 未结 3 2126
粉色の甜心
粉色の甜心 2021-01-31 19:10

I am trying to implement PayPal IPN functionality. The basic protocol is as such:

  1. The client is redirected from my site to PayPal\'s site to complete payment. He l
3条回答
  •  深忆病人
    2021-01-31 19:55

    Instead of encoding to utf-8, one should encode to what ever the paypal is using for the post. It is available under key 'charset' in the form paypal sends.

    So the following code worked for me:

    data = dict([(k, v.encode(data['charset'])) for k, v in data.items()])

提交回复
热议问题