我正在尝试将Pagseguro(类似于PayPal的巴西付款服务)与此库集成在一起
https://github.com/rochacbruno/python-pagseguro
但是,我不知道如何从服务发送给我的通知中访问数据。这是我的代码:
notification_code = request.POST['notificationCode']
pg = PagSeguro(email="[email protected]", token="token")
notification_data = pg.check_notification(notification_code)
print notification_data['status']
在las行中,我收到此错误:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: 'PagSeguroNotificationResponse' object has no attribute '__getitem__'
自述文件中的文档似乎与代码不匹配。它看起来像不是notication_data
一个字典,而是一个具有与自述文件中的字典键匹配的属性的对象。
因此,如果您更改print notification_data['status']
为以下内容,则应该可以使用:
print notification_data.status
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句