Route checkout through public BTCPay domain
This commit is contained in:
9
app.py
9
app.py
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user