Spaces:
Running
Running
File size: 1,090 Bytes
3241012 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | import requests
import logging
API_ENDPOINT = "https://crypto-payment-api-coding-with-mohits-projects.vercel.app/api/check-payment"
# Optional: Setup logging
logging.basicConfig(level=logging.INFO)
logger = logging.getLogger("crypto_checker")
def check_crypto_payment(receiver: str, amount: float) -> dict:
"""
Checks if a crypto payment has been made to the specified receiver address.
"""
try:
params = {"receiver": receiver, "amount": amount}
logger.info(f"Checking payment for: {params}")
response = requests.get(API_ENDPOINT, params=params, timeout=10)
response.raise_for_status()
result = response.json()
logger.info(f"Payment check result: {result}")
return result
except requests.exceptions.Timeout:
logger.error("Payment check timed out.")
return {"success": False, "message": "Request timed out."}
except requests.exceptions.RequestException as e:
logger.error(f"Payment check failed: {str(e)}")
return {"success": False, "message": "Network error occurred."} |