aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorstuppie2026-10-30 13:15:55 -0600
committerstuppie2026-10-30 13:15:55 -0600
commit98ea9eb52a348a763a9862f829e3dfc652925630 (patch)
tree454106e63836e457bee3189ecd9381206fb612a9
parent015398d887198f7bcd05b74954b4054ec91f3f71 (diff)
downloadgeneralresearch-98ea9eb52a348a763a9862f829e3dfc652925630.tar.gz
generalresearch-98ea9eb52a348a763a9862f829e3dfc652925630.zip
add giftbit to cashout methods
-rw-r--r--generalresearch/managers/thl/wallet/__init__.py14
-rw-r--r--generalresearch/managers/thl/wallet/user_payout.py11
2 files changed, 23 insertions, 2 deletions
diff --git a/generalresearch/managers/thl/wallet/__init__.py b/generalresearch/managers/thl/wallet/__init__.py
index fe25a13..e41a501 100644
--- a/generalresearch/managers/thl/wallet/__init__.py
+++ b/generalresearch/managers/thl/wallet/__init__.py
@@ -1,6 +1,7 @@
from decimal import Decimal
from typing import TYPE_CHECKING, Any
+from generalresearch.managers.thl.giftbit import GiftbitManager
from generalresearch.managers.thl.ipinfo import GeoIpInfoManager
from generalresearch.managers.thl.virtual_incentives_api import VirtualIncentivesManager
from generalresearch.managers.thl.wallet.approve import (
@@ -38,7 +39,8 @@ def manage_pending_cashout(
order_data: dict[str, Any] | CashMailOrderData | None = None,
tango_client: TangoClient | None = None,
paypal_client: PayPalPayoutManager | None = None,
- virtual_incentives_manager: VirtualIncentivesManager | None = None
+ virtual_incentives_manager: VirtualIncentivesManager | None = None,
+ giftbit_manager: GiftbitManager | None = None
) -> UserPayoutEvent:
"""
Called by a UI actions performed by Todd. This rejects/approves/cancels
@@ -95,6 +97,16 @@ def manage_pending_cashout(
ledger_manager=ledger_manager,
)
+ elif pe.payout_type == PayoutType.GIFTBIT:
+ assert giftbit_manager is not None
+
+ giftbit_manager.complete_order(
+ user=user,
+ payout_event=pe,
+ user_payout_event_manager=user_payout_event_manager,
+ ledger_manager=ledger_manager,
+ )
+
elif pe.payout_type == PayoutType.PAYPAL:
assert paypal_client is not None
diff --git a/generalresearch/managers/thl/wallet/user_payout.py b/generalresearch/managers/thl/wallet/user_payout.py
index ce1a3c5..56daead 100644
--- a/generalresearch/managers/thl/wallet/user_payout.py
+++ b/generalresearch/managers/thl/wallet/user_payout.py
@@ -12,6 +12,7 @@ from redis import Redis
from generalresearch.currency import USDCent, format_usd_cent
from generalresearch.managers.thl.cashout_method import CashoutMethodManager
+from generalresearch.managers.thl.giftbit import GiftbitManager
from generalresearch.managers.thl.ledger_manager.exceptions import (
LedgerTransactionCreateError,
)
@@ -31,6 +32,7 @@ from generalresearch.models.thl.wallet.cashout_method import (
CashoutMethod,
CashoutMethodOut,
CashoutRequestDetail,
+ GiftbitCashoutMethodRequestData,
PaypalCashoutMethodRequestData,
TangoCashoutMethodRequestData,
VICashoutMethodRequestData,
@@ -494,6 +496,7 @@ class UserPayoutEventManager(PayoutEventManager):
redis_client: Redis,
slack_client: slack.WebClient | None = None,
virtual_incentives_manager: VirtualIncentivesManager | None = None,
+ giftbit_manager: GiftbitManager | None = None,
) -> tuple[UserPayoutEvent | None, str | None]:
try:
return self.user_request_redeem(
@@ -506,7 +509,8 @@ class UserPayoutEventManager(PayoutEventManager):
user_ip_history_manager=user_ip_history_manager,
redis_client=redis_client,
slack_client=slack_client,
- virtual_incentives_manager=virtual_incentives_manager
+ virtual_incentives_manager=virtual_incentives_manager,
+ giftbit_manager=giftbit_manager,
), None
except (AssertionError, LedgerTransactionCreateError) as e:
return None, str(e)
@@ -523,6 +527,7 @@ class UserPayoutEventManager(PayoutEventManager):
redis_client: Redis,
slack_client: slack.WebClient | None = None,
virtual_incentives_manager: VirtualIncentivesManager | None = None,
+ giftbit_manager: GiftbitManager | None = None,
) -> UserPayoutEvent:
"""
A user has requested to be paid from their wallet balance.
@@ -624,6 +629,10 @@ class UserPayoutEventManager(PayoutEventManager):
request_data: VICashoutMethodRequestData = (
virtual_incentives_manager.make_request(amount, cashout_method, pe_uuid)
)
+ elif payout_type == PayoutType.GIFTBIT:
+ request_data: GiftbitCashoutMethodRequestData = (
+ giftbit_manager.make_request(amount, cashout_method, pe_uuid)
+ )
else:
raise ValueError(f"unknown {payout_type=}")