import os
import atexit
import httpx
from oculus_sdk import OculusClient
from oculus_sdk.exceptions import OculusAuthError, TokenRevokedException
client = OculusClient(
client_id=os.environ["AGENT_CLIENT_ID"],
client_secret=os.environ["AGENT_CLIENT_SECRET"],
base_url=os.environ.get("ANTI_AI_URL", "https://api.antiailabs.com"),
)
atexit.register(client.stop)
def fetch_customer(customer_id: str) -> dict:
token = client.get_token(scope="stripe:customer:read")
response = httpx.get(
f"https://api.stripe.com/v1/customers/{customer_id}",
headers={"Authorization": f"Bearer {token}"},
)
response.raise_for_status()
return response.json()
def process_payment(amount: int, currency: str) -> dict:
token = client.get_token(scope="stripe:charge:write")
response = httpx.post(
"https://api.stripe.com/v1/charges",
headers={"Authorization": f"Bearer {token}"},
json={"amount": amount, "currency": currency},
)
response.raise_for_status()
return response.json()