我正在使用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
我总是在实时端点上收到无效响应。知道为什么吗?
我用以下代码完成了它:
query_string = self.request.body.decode('ascii')
response = urlopen(url, b("cmd=_notify-validate&%s" % query_string)).read()