File size: 1,366 Bytes
11b58e4 | 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 34 35 36 | """
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}
|