<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Verify webhook in python in Integration and Testing</title>
    <link>https://community.developer.cybersource.com/t5/Integration-and-Testing/Verify-webhook-in-python/m-p/82052#M51726</link>
    <description>&lt;P&gt;This code actually works and I hope it's helpful for anyone using python and verifying the webhook notification since I didn't see any examples in the documentation. The issue was that in my env variable I accidentally had whitespace which was messing with it being encoded properly. So, if you're running into the same issue, make sure the signature key is correct and you're encoding the signature key and body from the webhook event properly.&lt;/P&gt;</description>
    <pubDate>Wed, 06 Apr 2022 18:55:58 GMT</pubDate>
    <dc:creator>Jmont261</dc:creator>
    <dc:date>2022-04-06T18:55:58Z</dc:date>
    <item>
      <title>Verify webhook in python</title>
      <link>https://community.developer.cybersource.com/t5/Integration-and-Testing/Verify-webhook-in-python/m-p/81921#M51639</link>
      <description>&lt;P&gt;Hi all,&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm trying to verify the webhook when I receive the notification in a lambda function in python. This is currently how I'm doing it, but it doesn't match the X-ANET-SIGNATURE, wondering if anyone can help me out here. Thanks!&lt;/P&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;SIGNATURE_KEY= os.environ.get("key")

def lambda_handler(event, context):
    body = json.loads(event["body"])
    verify_webook(body, event["headers"]["X-ANET-Signature"])

def verify_webook(body, hmac_header, secret=SIGNATURE_KEY):
    body = json.dumps(body)
    digest = hmac.new(
    secret.encode("utf-8"), body.encode("utf-8"), hashlib.sha512
    ).hexdigest()
    return hmac_header == f"sha512={digest.upper()}"&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 31 Mar 2022 14:07:25 GMT</pubDate>
      <guid>https://community.developer.cybersource.com/t5/Integration-and-Testing/Verify-webhook-in-python/m-p/81921#M51639</guid>
      <dc:creator>Jmont261</dc:creator>
      <dc:date>2022-03-31T14:07:25Z</dc:date>
    </item>
    <item>
      <title>Re: Verify webhook in python</title>
      <link>https://community.developer.cybersource.com/t5/Integration-and-Testing/Verify-webhook-in-python/m-p/82052#M51726</link>
      <description>&lt;P&gt;This code actually works and I hope it's helpful for anyone using python and verifying the webhook notification since I didn't see any examples in the documentation. The issue was that in my env variable I accidentally had whitespace which was messing with it being encoded properly. So, if you're running into the same issue, make sure the signature key is correct and you're encoding the signature key and body from the webhook event properly.&lt;/P&gt;</description>
      <pubDate>Wed, 06 Apr 2022 18:55:58 GMT</pubDate>
      <guid>https://community.developer.cybersource.com/t5/Integration-and-Testing/Verify-webhook-in-python/m-p/82052#M51726</guid>
      <dc:creator>Jmont261</dc:creator>
      <dc:date>2022-04-06T18:55:58Z</dc:date>
    </item>
  </channel>
</rss>

