test with apple official package

main
Laurent 2 years ago
parent 427e9e6860
commit b585beb942
  1. 40
      subscriptions/views.py

@ -4,6 +4,9 @@ from django.views.decorators.csrf import csrf_exempt
from .models import ASSNotification from .models import ASSNotification
from django.conf import settings from django.conf import settings
from appstoreserverlibrary.models.Environment import Environment
from appstoreserverlibrary.signed_data_verifier import VerificationException, SignedDataVerifier
import json, jwt import json, jwt
import base64 import base64
# import os # import os
@ -26,20 +29,43 @@ def app_store_webhook(request):
decoded = request.body.decode('utf-8') decoded = request.body.decode('utf-8')
# Parse the JSON payload # Parse the JSON payload
#fulljson = json.loads(data) fulljson = json.loads(data)
# signedPayload = fulljson['signedPayload'] signedPayload = fulljson['signedPayload']
root_certificates = load_root_certificates()
enable_online_checks = True
bundle_id = "stax.SlashPoker.nosebleed"
environment = Environment.SANDBOX
signed_data_verifier = SignedDataVerifier(root_certificates, enable_online_checks, environment, bundle_id)
try: try:
data = asn2.parse(decoded) signed_notification = "ey.."
type = data['notificationType'] payload = signed_data_verifier.verify_and_decode_notification(signedPayload)
print(payload)
notification = ASSNotification( notification = ASSNotification(
content=type, content=payload,
) )
notification.save() notification.save()
except InvalidTokenError:
pass except VerificationException as e:
print(e)
# try:
# data = asn2.parse(decoded)
# type = data['notificationType']
#
# notification = ASSNotification(
# content=type,
# )
# notification.save()
#
# except InvalidTokenError:
# pass
# KEY_FILE = settings.ASS_KEY_FILE # KEY_FILE = settings.ASS_KEY_FILE
# #

Loading…
Cancel
Save