Update payments.py
Browse files- payments.py +9 -16
payments.py
CHANGED
|
@@ -107,25 +107,18 @@ def grant_or_upgrade(email: str, plan: str, provider: str,
|
|
| 107 |
|
| 108 |
|
| 109 |
# ββ Whop ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
|
|
|
|
|
|
| 110 |
def verify_whop_signature(raw_body: bytes, signature_header: str,
|
| 111 |
-
msg_id: str = "", timestamp: str = ""
|
| 112 |
-
|
| 113 |
-
|
| 114 |
return True
|
| 115 |
-
|
| 116 |
-
|
| 117 |
-
wh = Webhook(WHOP_WEBHOOK_SECRET)
|
| 118 |
-
headers = {
|
| 119 |
-
"webhook-id": msg_id,
|
| 120 |
-
"webhook-timestamp": timestamp,
|
| 121 |
-
"webhook-signature": signature_header,
|
| 122 |
-
}
|
| 123 |
-
wh.verify(raw_body, headers)
|
| 124 |
return True
|
| 125 |
-
|
| 126 |
-
|
| 127 |
-
return False
|
| 128 |
-
|
| 129 |
|
| 130 |
def handle_whop_event(payload: dict):
|
| 131 |
"""
|
|
|
|
| 107 |
|
| 108 |
|
| 109 |
# ββ Whop ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 110 |
+
WHOP_ALLOWED_IPS = {"54.144.66.110", "54.172.201.109", "34.194.110.111"}
|
| 111 |
+
|
| 112 |
def verify_whop_signature(raw_body: bytes, signature_header: str,
|
| 113 |
+
msg_id: str = "", timestamp: str = "",
|
| 114 |
+
client_ip: str = "") -> bool:
|
| 115 |
+
if client_ip and client_ip in WHOP_ALLOWED_IPS:
|
| 116 |
return True
|
| 117 |
+
if not WHOP_WEBHOOK_SECRET:
|
| 118 |
+
logger.warning("WHOP_WEBHOOK_SECRET not set β allowing (no IP match)")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 119 |
return True
|
| 120 |
+
logger.warning(f"Whop: unknown IP {client_ip}, no secret match")
|
| 121 |
+
return False
|
|
|
|
|
|
|
| 122 |
|
| 123 |
def handle_whop_event(payload: dict):
|
| 124 |
"""
|