|
|
|
|
@ -26,6 +26,30 @@ g6_cert_bytes: bytes = requests.get(G6_CER_URL).content |
|
|
|
|
def index(request): |
|
|
|
|
return HttpResponse("Hello, world. You're at the subs index.") |
|
|
|
|
|
|
|
|
|
@csrf_exempt |
|
|
|
|
def test(request): |
|
|
|
|
try: |
|
|
|
|
# Construct the path to payload.txt at the root of the Django project |
|
|
|
|
payload_file_path = os.path.join(settings.BASE_DIR, 'payload.txt') |
|
|
|
|
|
|
|
|
|
# Read the content of the file |
|
|
|
|
with open(payload_file_path, 'r') as file: |
|
|
|
|
payload_content = file.read() |
|
|
|
|
|
|
|
|
|
# Call save_payload_file with the content |
|
|
|
|
save_payload_file(payload_content) |
|
|
|
|
|
|
|
|
|
# Return success response |
|
|
|
|
return JsonResponse({'status': 'success', 'message': 'Payload processed successfully'}) |
|
|
|
|
|
|
|
|
|
except FileNotFoundError: |
|
|
|
|
return JsonResponse({'status': 'error', 'message': 'payload.txt file not found'}, status=404) |
|
|
|
|
|
|
|
|
|
except Exception as e: |
|
|
|
|
# Log the exception |
|
|
|
|
logging.error(f"Error in test endpoint: {str(e)}") |
|
|
|
|
return JsonResponse({'status': 'error', 'message': str(e)}, status=500) |
|
|
|
|
|
|
|
|
|
# @csrf_exempt |
|
|
|
|
# def app_store_webhook_prod(request): |
|
|
|
|
|
|
|
|
|
@ -92,12 +116,12 @@ def decodePayload(signedPayload): |
|
|
|
|
revocationDateTime = datetime.datetime.fromtimestamp(transaction_info.revocationDate / 1000) |
|
|
|
|
|
|
|
|
|
offer_type = None |
|
|
|
|
if payload.offerType is not None: |
|
|
|
|
offer_type = int(payload.offerType) |
|
|
|
|
if transaction_info.offerType is not None: |
|
|
|
|
offer_type = int(transaction_info.offerType) |
|
|
|
|
|
|
|
|
|
offer_discount_type = None |
|
|
|
|
if payload.offerDiscountType is not None: |
|
|
|
|
offer_discount_type = payload.offerDiscountType.value |
|
|
|
|
if transaction_info.offerDiscountType is not None: |
|
|
|
|
offer_discount_type = transaction_info.offerDiscountType.value |
|
|
|
|
|
|
|
|
|
notification = ASSNotification( |
|
|
|
|
notificationType=payload.notificationType, |
|
|
|
|
@ -118,7 +142,7 @@ def decodePayload(signedPayload): |
|
|
|
|
transactionId=transaction_info.transactionId, |
|
|
|
|
transactionReason=transaction_info.rawTransactionReason, |
|
|
|
|
offerDiscountType=offer_discount_type, |
|
|
|
|
offerIdentifier=payload.offerIdentifier, |
|
|
|
|
offerIdentifier=transaction_info.offerIdentifier, |
|
|
|
|
offerType=offer_type, |
|
|
|
|
) |
|
|
|
|
notification.save() |
|
|
|
|
|