Route checkout through public BTCPay domain

This commit is contained in:
drjones
2026-09-01 02:46:25 -07:00
parent 0d5252cf4f
commit 2e9f78e3a9

9
app.py
View File

@@ -32,7 +32,7 @@ def create_btcpay_invoice(order_id):
"amount": PRICE_USD,
"currency": "USD",
"metadata": {"orderId": order_id},
"checkout": {"redirectURL": f"/?paid=1&order={order_id}"},
"checkout": {"redirectURL": f"https://nocturne.thetempleofdoom.com/?paid=1&order={order_id}"},
}).encode()
req = urllib.request.Request(
f"{BTCPAY_URL}/api/v1/stores/{BTCPAY_STORE}/invoices",
@@ -42,7 +42,12 @@ def create_btcpay_invoice(order_id):
try:
with urllib.request.urlopen(req, timeout=20, context=ctx) as r:
data = json.loads(r.read())
return data.get("checkoutLink") or data.get("checkout_url")
url = data.get("checkoutLink") or data.get("checkout_url")
if url:
# API returns a LAN address; rewrite to the public BTCPay domain
# so customers outside the network can reach the checkout.
url = url.replace("10.30.20.140", "btcpay.thetempleofdoom.com")
return url
except Exception as e:
app.logger.error(f"BTCPay invoice error: {e}")
return None