refactor: simplify listing fee to fixed 1 USD, remove multi-currency logic
This commit is contained in:
@@ -10,7 +10,6 @@ if ($_SERVER['REQUEST_METHOD'] !== 'POST') {
|
|||||||
$input = json_decode(file_get_contents('php://input'), true);
|
$input = json_decode(file_get_contents('php://input'), true);
|
||||||
|
|
||||||
$listingId = $input['listingId'] ?? null;
|
$listingId = $input['listingId'] ?? null;
|
||||||
$currency = $input['currency'] ?? 'EUR';
|
|
||||||
|
|
||||||
if (!$listingId) {
|
if (!$listingId) {
|
||||||
http_response_code(400);
|
http_response_code(400);
|
||||||
@@ -18,18 +17,9 @@ if (!$listingId) {
|
|||||||
exit;
|
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([
|
$payload = json_encode([
|
||||||
'amount' => $amount,
|
'amount' => LISTING_FEE,
|
||||||
'currency' => $currency,
|
'currency' => LISTING_FEE_CURRENCY,
|
||||||
'metadata' => [
|
'metadata' => [
|
||||||
'listingId' => $listingId,
|
'listingId' => $listingId,
|
||||||
'orderId' => 'listing-' . $listingId,
|
'orderId' => 'listing-' . $listingId,
|
||||||
|
|||||||
@@ -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_API_KEY', getenv('BTCPAY_API_KEY') ?: 'CHANGE_ME');
|
||||||
define('BTCPAY_STORE_ID', getenv('BTCPAY_STORE_ID') ?: 'CHANGE_ME');
|
define('BTCPAY_STORE_ID', getenv('BTCPAY_STORE_ID') ?: 'CHANGE_ME');
|
||||||
define('BTCPAY_WEBHOOK_SECRET', getenv('BTCPAY_WEBHOOK_SECRET') ?: '');
|
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_URL', getenv('DIRECTUS_URL') ?: 'https://api.kashilo.com');
|
||||||
define('DIRECTUS_TOKEN', getenv('DIRECTUS_TOKEN') ?: 'CHANGE_ME');
|
define('DIRECTUS_TOKEN', getenv('DIRECTUS_TOKEN') ?: 'CHANGE_ME');
|
||||||
|
|||||||
@@ -723,7 +723,7 @@ class PageCreate extends HTMLElement {
|
|||||||
|
|
||||||
if (!invoiceId) {
|
if (!invoiceId) {
|
||||||
if (submitBtn) submitBtn.textContent = t('payment.paying')
|
if (submitBtn) submitBtn.textContent = t('payment.paying')
|
||||||
const invoice = await createInvoice(listingId, currency)
|
const invoice = await createInvoice(listingId)
|
||||||
invoiceId = invoice.invoiceId
|
invoiceId = invoice.invoiceId
|
||||||
savePendingInvoice(listingId, invoiceId)
|
savePendingInvoice(listingId, invoiceId)
|
||||||
|
|
||||||
|
|||||||
@@ -29,14 +29,13 @@ async function ensureModalLoaded() {
|
|||||||
/**
|
/**
|
||||||
* Create a payment invoice for a listing
|
* Create a payment invoice for a listing
|
||||||
* @param {string} listingId - The listing UUID
|
* @param {string} listingId - The listing UUID
|
||||||
* @param {string} [currency='EUR'] - Payment currency
|
|
||||||
* @returns {Promise<Object>} { invoiceId, checkoutLink, status, expirationTime }
|
* @returns {Promise<Object>} { invoiceId, checkoutLink, status, expirationTime }
|
||||||
*/
|
*/
|
||||||
export async function createInvoice(listingId, currency = 'EUR') {
|
export async function createInvoice(listingId) {
|
||||||
const response = await fetch(`${POW_SERVER}/btcpay/invoice`, {
|
const response = await fetch(`${POW_SERVER}/btcpay/invoice`, {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: { 'Content-Type': 'application/json' },
|
headers: { 'Content-Type': 'application/json' },
|
||||||
body: JSON.stringify({ listingId, currency })
|
body: JSON.stringify({ listingId })
|
||||||
})
|
})
|
||||||
|
|
||||||
if (!response.ok) {
|
if (!response.ok) {
|
||||||
|
|||||||
Reference in New Issue
Block a user