Reputation: 165
I need to verify the the signature of the PayPal webhooks I receive. (The PayPal-Python-SDK is not an option since it is deprecated)
Here is what I'm trying:
access_token = "Bearer " + r['access_token']
data = {"auth_algo": auth_algo,
"transmission_id": transmission_id,
"transmission_sig": transmission_sig,
"transmission_time": transmission_time,
"webhook_id": webhookID,
"webhook_event": res,
"cert_url":cert_url }
headers = {"Authorization":access_token, "Content-Type": "application/json"}
response = requests.post("https://api-m.paypal.com/v1/notifications/verify-webhook-signature", data=data, headers=headers)
Getting a 400 response:
{'name': 'VALIDATION_ERROR', 'message': 'Invalid request - see details', 'debug_id': '4d3f231bb0c69', 'details': [{'location': 'body', 'issue': 'MALFORMED_REQUEST_JSON'}], 'links': []}
I'm trying to follow this guide: https://developer.paypal.com/docs/api/webhooks/v1/#verify-webhook-signature_post
Upvotes: 0
Views: 1341
Reputation: 30467
data=data
data takes a string, not a python dict
You need to use json=
, https://docs.python-requests.org/en/master/user/quickstart/#more-complicated-post-requests
Upvotes: 1