From 3bbd777fe12abbe6cd3d02396fb6631e76feeb9b Mon Sep 17 00:00:00 2001 From: Alexander Schmidt Date: Wed, 11 Feb 2026 17:54:00 +0100 Subject: [PATCH] refactor: simplify listing fee to fixed 1 USD, remove multi-currency logic --- docs/pow-server/btcpay-invoice.php | 14 ++------------ docs/pow-server/config.php | 3 ++- js/components/pages/page-create.js | 2 +- js/services/btcpay.js | 5 ++--- 4 files changed, 7 insertions(+), 17 deletions(-) diff --git a/docs/pow-server/btcpay-invoice.php b/docs/pow-server/btcpay-invoice.php index f15d43d..c279332 100644 --- a/docs/pow-server/btcpay-invoice.php +++ b/docs/pow-server/btcpay-invoice.php @@ -10,7 +10,6 @@ if ($_SERVER['REQUEST_METHOD'] !== 'POST') { $input = json_decode(file_get_contents('php://input'), true); $listingId = $input['listingId'] ?? null; -$currency = $input['currency'] ?? 'EUR'; if (!$listingId) { http_response_code(400); @@ -18,18 +17,9 @@ if (!$listingId) { exit; } -$fees = LISTING_FEE; -if (!isset($fees[$currency])) { - http_response_code(400); - echo json_encode(['error' => 'Unsupported currency', 'supported' => array_keys($fees)]); - exit; -} - -$amount = $fees[$currency]; - $payload = json_encode([ - 'amount' => $amount, - 'currency' => $currency, + 'amount' => LISTING_FEE, + 'currency' => LISTING_FEE_CURRENCY, 'metadata' => [ 'listingId' => $listingId, 'orderId' => 'listing-' . $listingId, diff --git a/docs/pow-server/config.php b/docs/pow-server/config.php index cc036ac..0c1c049 100644 --- a/docs/pow-server/config.php +++ b/docs/pow-server/config.php @@ -7,7 +7,8 @@ define('BTCPAY_BASE_URL', getenv('BTCPAY_BASE_URL') ?: 'https://pay.xmr.rocks'); define('BTCPAY_API_KEY', getenv('BTCPAY_API_KEY') ?: 'CHANGE_ME'); define('BTCPAY_STORE_ID', getenv('BTCPAY_STORE_ID') ?: 'CHANGE_ME'); define('BTCPAY_WEBHOOK_SECRET', getenv('BTCPAY_WEBHOOK_SECRET') ?: ''); -define('LISTING_FEE', ['EUR' => 1, 'USD' => 1, 'CHF' => 1, 'GBP' => 1, 'JPY' => 200]); +define('LISTING_FEE', 1); +define('LISTING_FEE_CURRENCY', 'USD'); define('DIRECTUS_URL', getenv('DIRECTUS_URL') ?: 'https://api.kashilo.com'); define('DIRECTUS_TOKEN', getenv('DIRECTUS_TOKEN') ?: 'CHANGE_ME'); diff --git a/js/components/pages/page-create.js b/js/components/pages/page-create.js index 745f52c..9ae49a2 100644 --- a/js/components/pages/page-create.js +++ b/js/components/pages/page-create.js @@ -723,7 +723,7 @@ class PageCreate extends HTMLElement { if (!invoiceId) { if (submitBtn) submitBtn.textContent = t('payment.paying') - const invoice = await createInvoice(listingId, currency) + const invoice = await createInvoice(listingId) invoiceId = invoice.invoiceId savePendingInvoice(listingId, invoiceId) diff --git a/js/services/btcpay.js b/js/services/btcpay.js index 432cb65..52dbfbd 100644 --- a/js/services/btcpay.js +++ b/js/services/btcpay.js @@ -29,14 +29,13 @@ async function ensureModalLoaded() { /** * Create a payment invoice for a listing * @param {string} listingId - The listing UUID - * @param {string} [currency='EUR'] - Payment currency * @returns {Promise} { invoiceId, checkoutLink, status, expirationTime } */ -export async function createInvoice(listingId, currency = 'EUR') { +export async function createInvoice(listingId) { const response = await fetch(`${POW_SERVER}/btcpay/invoice`, { method: 'POST', headers: { 'Content-Type': 'application/json' }, - body: JSON.stringify({ listingId, currency }) + body: JSON.stringify({ listingId }) }) if (!response.ok) {