Spaces:
Running
Running
| 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."} |