aboutsummaryrefslogtreecommitdiff
path: root/jb/managers/thl.py
diff options
context:
space:
mode:
authorstuppie2026-09-23 13:42:03 -0600
committerstuppie2026-09-23 13:42:03 -0600
commit064a55c754e02da54b13c47028b233b265327518 (patch)
treee8e2eef6a138c750640dab6b2239c3d8a6eb4191 /jb/managers/thl.py
parentb1af1375578e41a240a4eedff73209e212a31051 (diff)
downloadamt-jb-064a55c754e02da54b13c47028b233b265327518.tar.gz
amt-jb-064a55c754e02da54b13c47028b233b265327518.zip
upon login: create_paypal_cashout_method_if_not_exists using user's ip. Upon cashout request: send_cashout_confirmation_email using cashout method info looked up
Diffstat (limited to 'jb/managers/thl.py')
-rw-r--r--jb/managers/thl.py29
1 files changed, 19 insertions, 10 deletions
diff --git a/jb/managers/thl.py b/jb/managers/thl.py
index 59bd2ab..4d6b23a 100644
--- a/jb/managers/thl.py
+++ b/jb/managers/thl.py
@@ -5,6 +5,7 @@ from generalresearch.models.thl.definitions import PayoutStatus
from generalresearch.models.thl.payout import UserPayoutEvent
from generalresearch.models.thl.task_status import TaskStatusResponse
from generalresearch.models.thl.wallet.cashout_method import (
+ CashoutMethodOut,
CashoutRequestInfo,
CashoutRequestResponse,
)
@@ -63,17 +64,16 @@ def manage_pending_cashout(
return UserPayoutEvent.model_validate(d)
-def get_paypal_cashout_method_if_exists(product_user_id: str) -> str | None:
+def get_paypal_cashout_method_if_exists(
+ product_user_id: str, client_ip: str
+) -> str | None:
"""
- Todo: This does not work right now for new users, in that this endpoint expects the user
- to have IP history or the request made from the client
- (b/c it needs their country to know which tango card are available).
- We don't care about that for paypal, but, it expects it anyways.
- Once a user can change their paypal email, this needs to change to avoid overwriting it
- every time they login.
+ Make sure a paypal cashout method exists for this user. Use their login email.
+ We check if it exists first, so that once a user can change their paypal email,
+ we do not overwrite it.
"""
url = f"{settings.fsb_host}{settings.product_id}/cashout_methods/"
- params = {"bpuid": product_user_id}
+ params = {"bpuid": product_user_id, "ip": client_ip}
res = requests.get(url, params=params)
assert res.status_code == status.HTTP_200_OK, res.text
cms = res.json()["cashout_methods"]
@@ -92,12 +92,21 @@ def create_paypal_cashout_method(product_user_id: str, email: str) -> dict:
def create_paypal_cashout_method_if_not_exists(
- product_user_id: str, email: str
+ product_user_id: str, email: str, client_ip: str
) -> None:
- if not get_paypal_cashout_method_if_exists(product_user_id):
+ if not get_paypal_cashout_method_if_exists(product_user_id, client_ip=client_ip):
create_paypal_cashout_method(product_user_id, email)
+def get_cashout_method(cashout_method_id: str) -> CashoutMethodOut:
+ url = (
+ f"{settings.fsb_host}{settings.product_id}/cashout_methods/{cashout_method_id}/"
+ )
+ res = requests.get(url)
+ assert res.status_code == status.HTTP_200_OK, res.text
+ return CashoutMethodOut.model_validate(res.json()["cashout_method"])
+
+
def get_wallet_balance(amt_worker_id: str) -> USDCent:
# This will raise an Exception if wallet balance is negative
url = f"{settings.fsb_host}{settings.product_id}/wallet/"