Download services/omnipay_payment_processor.py from AnthropicallyHuggingFaces/legalsync: direct link, hf CLI and curl.
- Browser
- Download file 1.37 kB
-
https://huggingface.co/spaces/AnthropicallyHuggingFaces/legalsync/resolve/main/services/omnipay_payment_processor.py
- Command line
-
hf download hf://spaces/AnthropicallyHuggingFaces/legalsync/services/omnipay_payment_processor.py
-
curl -L -o omnipay_payment_processor.py https://huggingface.co/spaces/AnthropicallyHuggingFaces/legalsync/resolve/main/services/omnipay_payment_processor.py
1.37 kB
| """ | |
| OmniPay Payment Processor — Deduped v4. | |
| Single authoritative processor for Stripe/PayPal/ACH per | |
| config/omnipay_integration_policy.json (config is the single source of truth). | |
| """ | |
| import json | |
| from pathlib import Path | |
| CONFIG = json.loads( | |
| (Path(__file__).resolve().parents[1] / "config" / "omnipay_integration_policy.json").read_text() | |
| ) | |
| class OmniPayProcessor: | |
| def process(self, amount, method="ach", inmate_id=None): | |
| # Validate NACHA before ACH settlement | |
| if method == "ach" and CONFIG.get("compliance", {}).get("nacha_validation"): | |
| if amount <= 0: | |
| raise ValueError("amount must be positive") | |
| # Gateway routing (stripe/paypal/ach) | |
| gateway = method if method in CONFIG.get("gateways", []) else "ach" | |
| return { | |
| "status": "processed", | |
| "gateway": gateway, | |
| "amount": amount, | |
| "method": method, | |
| "inmate_id": inmate_id, | |
| "nacha": bool(CONFIG.get("compliance", {}).get("nacha_validation")), | |
| } | |
| def handle_return(self, return_code): | |
| """ACH return — triggers RUNBOOK_ach_payment_failure if rate > 15%.""" | |
| threshold = CONFIG.get("compliance", {}).get("return_rate_threshold", 0.15) | |
| return {"return_code": return_code, "action": "runbook_ach_payment_failure", "threshold": threshold} | |