|
|
|
@ -9,21 +9,14 @@ from appstoreserverlibrary.api_client import AppStoreServerAPIClient, APIExcepti |
|
|
|
from appstoreserverlibrary.models.Environment import Environment |
|
|
|
from appstoreserverlibrary.models.Environment import Environment |
|
|
|
import requests |
|
|
|
import requests |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
from pokeranalytics_backend.settings import APNS_ENVIRONMENT_SANDBOX |
|
|
|
|
|
|
|
|
|
|
|
import json, jwt |
|
|
|
import json, jwt |
|
|
|
import base64 |
|
|
|
import base64 |
|
|
|
import os |
|
|
|
import os |
|
|
|
|
|
|
|
|
|
|
|
import datetime |
|
|
|
import datetime |
|
|
|
|
|
|
|
|
|
|
|
# from OpenSSL.crypto import ( |
|
|
|
|
|
|
|
# X509Store, |
|
|
|
|
|
|
|
# X509StoreContext, |
|
|
|
|
|
|
|
# X509StoreContextError, |
|
|
|
|
|
|
|
# load_certificate, |
|
|
|
|
|
|
|
# FILETYPE_ASN1, |
|
|
|
|
|
|
|
# FILETYPE_PEM |
|
|
|
|
|
|
|
# ) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ROOT_CER_URL = "https://www.apple.com/certificateauthority/AppleRootCA-G3.cer" |
|
|
|
ROOT_CER_URL = "https://www.apple.com/certificateauthority/AppleRootCA-G3.cer" |
|
|
|
G6_CER_URL = "https://www.apple.com/certificateauthority/AppleWWDRCAG6.cer" |
|
|
|
G6_CER_URL = "https://www.apple.com/certificateauthority/AppleWWDRCAG6.cer" |
|
|
|
root_cert_bytes: bytes = requests.get(ROOT_CER_URL).content |
|
|
|
root_cert_bytes: bytes = requests.get(ROOT_CER_URL).content |
|
|
|
@ -32,16 +25,16 @@ g6_cert_bytes: bytes = requests.get(G6_CER_URL).content |
|
|
|
def index(request): |
|
|
|
def index(request): |
|
|
|
return HttpResponse("Hello, world. You're at the subs index.") |
|
|
|
return HttpResponse("Hello, world. You're at the subs index.") |
|
|
|
|
|
|
|
|
|
|
|
@csrf_exempt |
|
|
|
# @csrf_exempt |
|
|
|
def app_store_webhook_prod(request): |
|
|
|
# def app_store_webhook_prod(request): |
|
|
|
|
|
|
|
|
|
|
|
decoded = request.body.decode('utf-8') |
|
|
|
# decoded = request.body.decode('utf-8') |
|
|
|
fulljson = json.loads(decoded) |
|
|
|
# fulljson = json.loads(decoded) |
|
|
|
signedPayload = fulljson['signedPayload'] |
|
|
|
# signedPayload = fulljson['signedPayload'] |
|
|
|
|
|
|
|
|
|
|
|
decodePayload(signedPayload) |
|
|
|
# decodePayload(signedPayload) |
|
|
|
|
|
|
|
|
|
|
|
return JsonResponse({'status': 'success'}) |
|
|
|
# return JsonResponse({'status': 'success'}) |
|
|
|
|
|
|
|
|
|
|
|
@csrf_exempt |
|
|
|
@csrf_exempt |
|
|
|
def app_store_webhook(request): |
|
|
|
def app_store_webhook(request): |
|
|
|
@ -56,11 +49,11 @@ def app_store_webhook(request): |
|
|
|
|
|
|
|
|
|
|
|
def decodePayload(signedPayload): |
|
|
|
def decodePayload(signedPayload): |
|
|
|
|
|
|
|
|
|
|
|
# with open('payload.txt') as f: |
|
|
|
|
|
|
|
# signedPayload = f.read() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
enable_online_checks = True |
|
|
|
enable_online_checks = True |
|
|
|
environment = Environment.PRODUCTION |
|
|
|
environment = Environment.PRODUCTION |
|
|
|
|
|
|
|
if APNS_ENVIRONMENT_SANDBOX == True: |
|
|
|
|
|
|
|
environment = Environment.SANDBOX |
|
|
|
|
|
|
|
|
|
|
|
bundle_id = "stax.SlashPoker.nosebleed" |
|
|
|
bundle_id = "stax.SlashPoker.nosebleed" |
|
|
|
app_apple_id = 1073540690 |
|
|
|
app_apple_id = 1073540690 |
|
|
|
verifier = SignedDataVerifier([root_cert_bytes, g6_cert_bytes], enable_online_checks, environment, bundle_id, app_apple_id) |
|
|
|
verifier = SignedDataVerifier([root_cert_bytes, g6_cert_bytes], enable_online_checks, environment, bundle_id, app_apple_id) |
|
|
|
@ -100,6 +93,9 @@ def decodePayload(signedPayload): |
|
|
|
storefront=transaction_info.storefront, |
|
|
|
storefront=transaction_info.storefront, |
|
|
|
transactionId=transaction_info.transactionId, |
|
|
|
transactionId=transaction_info.transactionId, |
|
|
|
transactionReason=transaction_info.rawTransactionReason, |
|
|
|
transactionReason=transaction_info.rawTransactionReason, |
|
|
|
|
|
|
|
offerDiscountType=payload.offerDiscountType, |
|
|
|
|
|
|
|
offerIdentifier=payload.offerIdentifier, |
|
|
|
|
|
|
|
offerType=payload.offerType, |
|
|
|
) |
|
|
|
) |
|
|
|
notification.save() |
|
|
|
notification.save() |
|
|
|
elif payload.summary: |
|
|
|
elif payload.summary: |
|
|
|
|