fix netopia issue

This commit is contained in:
2025-12-19 10:56:59 +02:00
parent d9d9b6b128
commit 556d7c4049
3 changed files with 17 additions and 15 deletions

View File

@@ -128,6 +128,18 @@ def _build_payment_service(settings: Optional[NetopiaSettings] = None) -> Paymen
raise RuntimeError("NETOPIA_NOTIFY_URL is missing")
if not settings.redirect_url:
raise RuntimeError("NETOPIA_REDIRECT_URL is missing")
# 1. Fix the Newline issue
raw_key = settings.public_key_str.replace('\\n', '\n')
# 2. Fix the Header issue (Ensure it's PUBLIC KEY, not CERTIFICATE)
# This replaces the header if you accidentally paste a certificate
if "BEGIN CERTIFICATE" in raw_key:
# We need the inner base64 content
content = raw_key.replace("-----BEGIN CERTIFICATE-----", "").replace("-----END CERTIFICATE-----", "").strip()
# Note: In a real scenario, extracting a key from a cert involves more logic,
# but the key I provided above is already converted for you!
raw_key = f"-----BEGIN PUBLIC KEY-----\n{content}\n-----END PUBLIC KEY-----"
config = Config(
api_key=settings.api_key,