diff --git a/.env.example b/.env.example index 4d3fcac..dba3fa6 100644 --- a/.env.example +++ b/.env.example @@ -14,6 +14,8 @@ DB_PASS=lol123 DB_USE_SSL=false INITIALLY_AVAILABLE_DB=postgres +DISCORD_WEBHOOK_URL= + PAYPAL_BUSINESS_EMAIL=support@akatsuki.gg SHOULD_ENFORCE_UNIQUE_PAYMENTS=true SHOULD_REQUIRE_IPN_VERIFICATION=true diff --git a/app/api/webhooks/paypal.py b/app/api/webhooks/paypal.py index 97c48bf..686c2ae 100644 --- a/app/api/webhooks/paypal.py +++ b/app/api/webhooks/paypal.py @@ -3,6 +3,8 @@ import urllib.parse import uuid +from discord_webhook import AsyncDiscordWebhook +from discord_webhook.webhook import DiscordEmbed from fastapi import APIRouter from fastapi import Header from fastapi import Request @@ -287,6 +289,24 @@ async def process_notification( }, ) + webhook = AsyncDiscordWebhook( + url=settings.DISCORD_WEBHOOK_URL, + content="Granting donation perks to user", + embeds=[ + DiscordEmbed(title="User ID", description=f"{user_id}"), + DiscordEmbed(title="Username", description=f"{username}"), + DiscordEmbed(title="Donation Tier", description=f"{donation_tier}"), + DiscordEmbed(title="Donation Months", description=f"{donation_months}"), + DiscordEmbed(title="Donation Amount", description=f"{donation_amount}"), + DiscordEmbed(title="Donation Currency", description=f"{donation_currency}"), + DiscordEmbed(title="New Privileges", description=f"{privileges}"), + DiscordEmbed(title="New Donor Expire", description=f"{donor_expire}"), + DiscordEmbed(title="New User Badges", description=f"{user_badge_ids}"), + DiscordEmbed(title="Transaction ID", description=f"{transaction_id}"), + ], + ) + await webhook.execute() + # make writes to the database if settings.SHOULD_WRITE_TO_USERS_DB: async with clients.database.transaction(): diff --git a/app/settings.py b/app/settings.py index 5e1749d..5b65f01 100644 --- a/app/settings.py +++ b/app/settings.py @@ -26,6 +26,8 @@ def read_bool(value: str) -> bool: PAYPAL_BUSINESS_EMAIL = os.environ["PAYPAL_BUSINESS_EMAIL"] +DISCORD_WEBHOOK_URL = os.environ["DISCORD_WEBHOOK_URL"] + # temp/feature flags SHOULD_WRITE_TO_USERS_DB = read_bool(os.environ["SHOULD_WRITE_TO_USERS_DB"]) SHOULD_ENFORCE_UNIQUE_PAYMENTS = read_bool(os.environ["SHOULD_ENFORCE_UNIQUE_PAYMENTS"])