From 9c187e64cac34cf6abf6346da747989875d128bc Mon Sep 17 00:00:00 2001 From: Laurent Date: Sat, 17 Feb 2024 17:11:53 +0100 Subject: [PATCH] Fixes issues --- subscriptions/views.py | 42 ++++++++++++++++-------------------------- 1 file changed, 16 insertions(+), 26 deletions(-) diff --git a/subscriptions/views.py b/subscriptions/views.py index ac19ffe..10781fb 100644 --- a/subscriptions/views.py +++ b/subscriptions/views.py @@ -40,11 +40,10 @@ def index(request): def app_store_webhook_prod(request): decoded = request.body.decode('utf-8') + fulljson = json.loads(decoded) + signedPayload = fulljson['signedPayload'] - notification = ASSNotification( - content=decoded, - ) - notification.save() + decodePayload(signedPayload) return JsonResponse({'status': 'success'}) @@ -57,29 +56,8 @@ def app_store_webhook(request): decodePayload(signedPayload) - # client = AppStoreServerAPIClient(private_key_bytes, key_id, issuer_id, bundle_id, environment) - - # environment = Environment.SANDBOX - # bundle_id = 'stax.SlashPoker.nosebleed' - # verifier = SignedDataVerifier([root_cert_bytes, g6_cert_bytes], False, environment, bundle_id) - # try: - # # response = client.get_transaction_info() - # decoded_txn = verifier.verify_and_decode_signed_transaction(signedPayload) - # print(decoded_txn) - - # type = data['notificationType'] - - # notification = ASSNotification( - # content=type, - # ) - # notification.save() - - # except APIException as e: - # print(e) - return JsonResponse({'status': 'success'}) - def decodePayload(signedPayload): # with open('payload.txt') as f: @@ -139,12 +117,24 @@ def decodePayload(signedPayload): notificationType=payload.notificationType, subtype=payload.subtype, notificationUUID=payload.notificationUUID, - signedDate=signedDateTime.date, + signedDate=signedDateTime, + productId=summary.productId, requestIdentifier=summary.requestIdentifier, succeededCount=summary.succeededCount, failedCount=summary.failedCount, ) + + # notification = ASSNotification( + # notificationType=payload.notificationType, + # subtype=payload.subtype, + # notificationUUID=payload.notificationUUID, + # signedDate=signedDateTime, + # productId=summary.productId, + # requestIdentifier=summary.requestIdentifier, + # succeededCount=summary.succeededCount, + # failedCount=summary.failedCount, + # ) notification.save() except APIException as e: