我正在使用django,python和request。当我尝试使用以下代码验证IPN消息时:
data = self.request.POST.copy()
data['cmd'] = "_notify-validate"
url = ""
if settings.DEBUG:
url = settings.PAYMENT['paypal']['sandbox_ipn_endpoint']
else:
url = settings.PAYMENT['paypal']['live_ipn_endpoint']
self.logger.debug("Let us try to validate IPN message.")
response = requests.post(url, data=data)
print response.text
我总是在实时端点上获得INVALID响应。有什么想法吗?
答案 0 :(得分:0)
我用以下代码完成了它:
query_string = self.request.body.decode('ascii')
response = urlopen(url, b("cmd=_notify-validate&%s" % query_string)).read()