diff --git a/src/test_server.py b/src/test_server.py index 3835901..beb4292 100644 --- a/src/test_server.py +++ b/src/test_server.py @@ -23,7 +23,7 @@ time = int(time()) import asquare as sq # Square SDK webhook validation -from square.utilities.webhooks_helper import is_valid_webhook_event_signature +from square.utils.webhooks_helper import verify_signature # from asquareclass import AsyncSquareClient # type: ignore from abricksetapi import AsyncBricksetAPI @@ -121,11 +121,11 @@ async def hook_handler(request: web.Request) -> web.Response: return web.Response(status=401, text="Unauthorized: Missing signature") # Use Square SDK's official validation function - is_valid = is_valid_webhook_event_signature( - body_str, - signature_header, - SQUARE_WEBHOOK_SIGNATURE_KEY, - SQUARE_WEBHOOK_URL, + is_valid = verify_signature( + request_body=body_str, + signature_header=signature_header, + signature_key=SQUARE_WEBHOOK_SIGNATURE_KEY, + notification_url=SQUARE_WEBHOOK_URL, ) if not is_valid: diff --git a/test_square_webhook.py b/test_square_webhook.py index 575ef11..900ce40 100644 --- a/test_square_webhook.py +++ b/test_square_webhook.py @@ -9,7 +9,7 @@ import sys sys.path.insert(0, "src") -from square.utilities.webhooks_helper import is_valid_webhook_event_signature +from square.utils.webhooks_helper import verify_signature # Test data from Square's documentation TEST_BODY = '{"hello":"world"}' @@ -29,8 +29,11 @@ def test_signature_validation(): print() # This should return True with Square's test data - is_valid = is_valid_webhook_event_signature( - TEST_BODY, TEST_SIGNATURE, TEST_SIGNATURE_KEY, TEST_NOTIFICATION_URL + is_valid = verify_signature( + request_body=TEST_BODY, + signature_header=TEST_SIGNATURE, + signature_key=TEST_SIGNATURE_KEY, + notification_url=TEST_NOTIFICATION_URL, ) if is_valid: