mirror of
https://github.com/getnamingo/registry.git
synced 2025-05-17 10:06:59 +02:00
Added new pricing calculation method; testing needed
This commit is contained in:
parent
a07c407543
commit
a8a4c44590
10 changed files with 250 additions and 92 deletions
|
@ -48,7 +48,8 @@ try {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[$price] = $dbh->query("SELECT m$date_add FROM domain_price WHERE tldid = '$tld_id' AND command = 'transfer' LIMIT 1")->fetch(PDO::FETCH_NUM);
|
$returnValue = getDomainPrice($dbh, $name, $tld_id, $date_add, 'transfer');
|
||||||
|
$price = $returnValue['price'];
|
||||||
|
|
||||||
if (($registrar_balance + $creditLimit) < $price) {
|
if (($registrar_balance + $creditLimit) < $price) {
|
||||||
$log->notice($name . ': The registrar who took over this domain has no money to pay the renewal period that resulted from the transfer request');
|
$log->notice($name . ': The registrar who took over this domain has no money to pay the renewal period that resulted from the transfer request');
|
||||||
|
|
|
@ -44,7 +44,8 @@ try {
|
||||||
|
|
||||||
if ($set_autorenewPeriod) {
|
if ($set_autorenewPeriod) {
|
||||||
list($registrar_balance, $creditLimit) = $dbh->query("SELECT accountBalance, creditLimit FROM registrar WHERE id = '$clid' LIMIT 1")->fetch(PDO::FETCH_NUM);
|
list($registrar_balance, $creditLimit) = $dbh->query("SELECT accountBalance, creditLimit FROM registrar WHERE id = '$clid' LIMIT 1")->fetch(PDO::FETCH_NUM);
|
||||||
$price = $dbh->query("SELECT m12 FROM domain_price WHERE tldid = '$tldid' AND command = 'renew' LIMIT 1")->fetchColumn();
|
$returnValue = getDomainPrice($dbh, $name, $tldid, 12, 'renew');
|
||||||
|
$price = $returnValue['price'];
|
||||||
|
|
||||||
if (($registrar_balance + $creditLimit) > $price) {
|
if (($registrar_balance + $creditLimit) > $price) {
|
||||||
$dbh->exec("UPDATE domain SET rgpstatus = 'autoRenewPeriod', exdate = DATE_ADD(exdate, INTERVAL 12 MONTH), autoRenewPeriod = '12', renewedDate = exdate WHERE id = '$domain_id'");
|
$dbh->exec("UPDATE domain SET rgpstatus = 'autoRenewPeriod', exdate = DATE_ADD(exdate, INTERVAL 12 MONTH), autoRenewPeriod = '12', renewedDate = exdate WHERE id = '$domain_id'");
|
||||||
|
|
|
@ -103,3 +103,66 @@ function processUrlhausData($data) {
|
||||||
function checkUrlhaus($domain, Map $urlhausData) {
|
function checkUrlhaus($domain, Map $urlhausData) {
|
||||||
return $urlhausData->get($domain, false);
|
return $urlhausData->get($domain, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getDomainPrice($pdo, $domain_name, $tld_id, $date_add = 12, $command = 'create') {
|
||||||
|
// Check if the domain is a premium domain
|
||||||
|
$stmt = $pdo->prepare("
|
||||||
|
SELECT c.category_price
|
||||||
|
FROM premium_domain_pricing p
|
||||||
|
JOIN premium_domain_categories c ON p.category_id = c.category_id
|
||||||
|
WHERE p.domain_name = ? AND p.tld_id = ?
|
||||||
|
");
|
||||||
|
$stmt->execute([$domain_name, $tld_id]);
|
||||||
|
if ($stmt->rowCount() > 0) {
|
||||||
|
return ['type' => 'premium', 'price' => $stmt->fetch()['category_price']];
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check if there is a promotion for the domain
|
||||||
|
$currentDate = date('Y-m-d');
|
||||||
|
$stmt = $pdo->prepare("
|
||||||
|
SELECT discount_percentage, discount_amount
|
||||||
|
FROM promotion_pricing
|
||||||
|
WHERE tld_id = ?
|
||||||
|
AND promo_type = 'full'
|
||||||
|
AND status = 'active'
|
||||||
|
AND start_date <= ?
|
||||||
|
AND end_date >= ?
|
||||||
|
");
|
||||||
|
$stmt->execute([$tld_id, $currentDate, $currentDate]);
|
||||||
|
if ($stmt->rowCount() > 0) {
|
||||||
|
$promo = $stmt->fetch();
|
||||||
|
$discount = null;
|
||||||
|
|
||||||
|
// Determine discount based on percentage or amount
|
||||||
|
if (!empty($promo['discount_percentage'])) {
|
||||||
|
$discount = $promo['discount_percentage']; // Percentage discount
|
||||||
|
} elseif (!empty($promo['discount_amount'])) {
|
||||||
|
$discount = $promo['discount_amount']; // Fixed amount discount
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$discount = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get regular price for the specified period
|
||||||
|
$priceColumn = "m" . $date_add;
|
||||||
|
$stmt = $pdo->prepare("SELECT $priceColumn FROM domain_price WHERE tldid = ? AND command = '$command' LIMIT 1");
|
||||||
|
$stmt->execute([$tld_id]);
|
||||||
|
|
||||||
|
if ($stmt->rowCount() > 0) {
|
||||||
|
$regularPrice = $stmt->fetch()[$priceColumn];
|
||||||
|
|
||||||
|
if ($discount !== null) {
|
||||||
|
if (isset($promo['discount_percentage'])) {
|
||||||
|
$discountAmount = $regularPrice * ($promo['discount_percentage'] / 100);
|
||||||
|
} else {
|
||||||
|
$discountAmount = $discount;
|
||||||
|
}
|
||||||
|
$price = $regularPrice - $discountAmount;
|
||||||
|
return ['type' => 'promotion', 'price' => $price];
|
||||||
|
}
|
||||||
|
|
||||||
|
return ['type' => 'regular', 'price' => $regularPrice];
|
||||||
|
}
|
||||||
|
|
||||||
|
return ['type' => 'not_found', 'price' => 0];
|
||||||
|
}
|
|
@ -193,11 +193,8 @@ class DomainsController extends Controller
|
||||||
$registrar_balance = $result['accountBalance'];
|
$registrar_balance = $result['accountBalance'];
|
||||||
$creditLimit = $result['creditLimit'];
|
$creditLimit = $result['creditLimit'];
|
||||||
|
|
||||||
$priceColumn = "m" . $date_add;
|
$returnValue = getDomainPrice($db, $domainName, $tld_id, $date_add, 'create');
|
||||||
$price = $db->selectValue(
|
$price = $returnValue['price'];
|
||||||
'SELECT ' . $db->quoteIdentifier($priceColumn) . ' FROM domain_price WHERE tldid = ? AND command = "create" LIMIT 1',
|
|
||||||
[$tld_id]
|
|
||||||
);
|
|
||||||
|
|
||||||
if (!$price) {
|
if (!$price) {
|
||||||
return view($response, 'admin/domains/createDomain.twig', [
|
return view($response, 'admin/domains/createDomain.twig', [
|
||||||
|
@ -1473,11 +1470,8 @@ class DomainsController extends Controller
|
||||||
$registrar_balance = $result['accountBalance'];
|
$registrar_balance = $result['accountBalance'];
|
||||||
$creditLimit = $result['creditLimit'];
|
$creditLimit = $result['creditLimit'];
|
||||||
|
|
||||||
$priceColumn = "m" . $date_add;
|
$returnValue = getDomainPrice($db, $domainName, $tld_id, $date_add, 'renew');
|
||||||
$price = $db->selectValue(
|
$price = $returnValue['price'];
|
||||||
'SELECT ' . $db->quoteIdentifier($priceColumn) . ' FROM domain_price WHERE tldid = ? AND command = "renew" LIMIT 1',
|
|
||||||
[$tld_id]
|
|
||||||
);
|
|
||||||
|
|
||||||
if (!$price) {
|
if (!$price) {
|
||||||
$this->container->get('flash')->addMessage('error', 'The price, period and currency for such TLD are not declared');
|
$this->container->get('flash')->addMessage('error', 'The price, period and currency for such TLD are not declared');
|
||||||
|
@ -1773,11 +1767,8 @@ class DomainsController extends Controller
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
if ($addPeriod_id) {
|
if ($addPeriod_id) {
|
||||||
$priceColumn = "m" . $addPeriod;
|
$returnValue = getDomainPrice($db, $domainName, $tld_id, $addPeriod, 'create');
|
||||||
$price = $db->selectValue(
|
$price = $returnValue['price'];
|
||||||
'SELECT ' . $db->quoteIdentifier($priceColumn) . ' FROM domain_price WHERE tldid = ? AND command = "create" LIMIT 1',
|
|
||||||
[$tld_id]
|
|
||||||
);
|
|
||||||
|
|
||||||
if (!$price) {
|
if (!$price) {
|
||||||
$this->container->get('flash')->addMessage('error', 'The price, period and currency for such TLD are not declared');
|
$this->container->get('flash')->addMessage('error', 'The price, period and currency for such TLD are not declared');
|
||||||
|
@ -1901,11 +1892,8 @@ class DomainsController extends Controller
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
if ($autoRenewPeriod_id) {
|
if ($autoRenewPeriod_id) {
|
||||||
$priceColumn = "m" . $autoRenewPeriod;
|
$returnValue = getDomainPrice($db, $domainName, $tld_id, $autoRenewPeriod, 'renew');
|
||||||
$price = $db->selectValue(
|
$price = $returnValue['price'];
|
||||||
'SELECT ' . $db->quoteIdentifier($priceColumn) . ' FROM domain_price WHERE tldid = ? AND command = "renew" LIMIT 1',
|
|
||||||
[$tld_id]
|
|
||||||
);
|
|
||||||
|
|
||||||
if (!$price) {
|
if (!$price) {
|
||||||
$this->container->get('flash')->addMessage('error', 'The price, period and currency for such TLD are not declared');
|
$this->container->get('flash')->addMessage('error', 'The price, period and currency for such TLD are not declared');
|
||||||
|
@ -1931,11 +1919,8 @@ class DomainsController extends Controller
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
if ($renewPeriod_id) {
|
if ($renewPeriod_id) {
|
||||||
$priceColumn = "m" . $renewPeriod;
|
$returnValue = getDomainPrice($db, $domainName, $tld_id, $renewPeriod, 'renew');
|
||||||
$price = $db->selectValue(
|
$price = $returnValue['price'];
|
||||||
'SELECT ' . $db->quoteIdentifier($priceColumn) . ' FROM domain_price WHERE tldid = ? AND command = "renew" LIMIT 1',
|
|
||||||
[$tld_id]
|
|
||||||
);
|
|
||||||
|
|
||||||
if (!$price) {
|
if (!$price) {
|
||||||
$this->container->get('flash')->addMessage('error', 'The price, period and currency for such TLD are not declared');
|
$this->container->get('flash')->addMessage('error', 'The price, period and currency for such TLD are not declared');
|
||||||
|
@ -1961,11 +1946,8 @@ class DomainsController extends Controller
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
if ($transferPeriod_id) {
|
if ($transferPeriod_id) {
|
||||||
$priceColumn = "m" . $transferPeriod;
|
$returnValue = getDomainPrice($db, $domainName, $tld_id, $transferPeriod, 'renew');
|
||||||
$price = $db->selectValue(
|
$price = $returnValue['price'];
|
||||||
'SELECT ' . $db->quoteIdentifier($priceColumn) . ' FROM domain_price WHERE tldid = ? AND command = "renew" LIMIT 1',
|
|
||||||
[$tld_id]
|
|
||||||
);
|
|
||||||
|
|
||||||
if (!$price) {
|
if (!$price) {
|
||||||
$this->container->get('flash')->addMessage('error', 'The price, period and currency for such TLD are not declared');
|
$this->container->get('flash')->addMessage('error', 'The price, period and currency for such TLD are not declared');
|
||||||
|
@ -2150,11 +2132,8 @@ class DomainsController extends Controller
|
||||||
$registrar_balance = $result['accountBalance'];
|
$registrar_balance = $result['accountBalance'];
|
||||||
$creditLimit = $result['creditLimit'];
|
$creditLimit = $result['creditLimit'];
|
||||||
|
|
||||||
$priceColumn = "m" . $date_add;
|
$returnValue = getDomainPrice($db, $domainName, $tldid, $date_add, 'transfer');
|
||||||
$price = $db->selectValue(
|
$price = $returnValue['price'];
|
||||||
'SELECT ' . $db->quoteIdentifier($priceColumn) . ' FROM domain_price WHERE tldid = ? AND command = "transfer" LIMIT 1',
|
|
||||||
[$tldid]
|
|
||||||
);
|
|
||||||
|
|
||||||
if (!$price) {
|
if (!$price) {
|
||||||
$this->container->get('flash')->addMessage('error', 'The price, period and currency for such TLD are not declared');
|
$this->container->get('flash')->addMessage('error', 'The price, period and currency for such TLD are not declared');
|
||||||
|
@ -2381,11 +2360,8 @@ class DomainsController extends Controller
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
|
||||||
$priceColumn = "m" . $date_add;
|
$returnValue = getDomainPrice($db, $domainName, $tldid, $date_add, 'transfer');
|
||||||
$price = $db->selectValue(
|
$price = $returnValue['price'];
|
||||||
'SELECT ' . $db->quoteIdentifier($priceColumn) . ' FROM domain_price WHERE tldid = ? AND command = "transfer" LIMIT 1',
|
|
||||||
[$tldid]
|
|
||||||
);
|
|
||||||
|
|
||||||
if (($registrar_balance + $creditLimit) < $price) {
|
if (($registrar_balance + $creditLimit) < $price) {
|
||||||
$this->container->get('flash')->addMessage('error', 'The registrar who took over this domain has no money to pay the renewal period that resulted from the transfer request');
|
$this->container->get('flash')->addMessage('error', 'The registrar who took over this domain has no money to pay the renewal period that resulted from the transfer request');
|
||||||
|
|
|
@ -308,3 +308,63 @@ function extractDomainAndTLD($urlString) {
|
||||||
|
|
||||||
return ['domain' => $sld, 'tld' => $tld];
|
return ['domain' => $sld, 'tld' => $tld];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getDomainPrice($db, $domain_name, $tld_id, $date_add = 12, $command = 'create') {
|
||||||
|
// Check if the domain is a premium domain
|
||||||
|
$premiumDomain = $db->selectRow(
|
||||||
|
'SELECT c.category_price
|
||||||
|
FROM premium_domain_pricing p
|
||||||
|
JOIN premium_domain_categories c ON p.category_id = c.category_id
|
||||||
|
WHERE p.domain_name = ? AND p.tld_id = ?',
|
||||||
|
[$domain_name, $tld_id]
|
||||||
|
);
|
||||||
|
|
||||||
|
if ($premiumDomain) {
|
||||||
|
return ['type' => 'premium', 'price' => $premiumDomain['category_price']];
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check if there is a promotion for the domain
|
||||||
|
$currentDate = date('Y-m-d');
|
||||||
|
$promo = $db->selectRow(
|
||||||
|
"SELECT discount_percentage, discount_amount
|
||||||
|
FROM promotion_pricing
|
||||||
|
WHERE tld_id = ?
|
||||||
|
AND promo_type = 'full'
|
||||||
|
AND status = 'active'
|
||||||
|
AND start_date <= ?
|
||||||
|
AND end_date >= ?",
|
||||||
|
[$tld_id, $currentDate, $currentDate]
|
||||||
|
);
|
||||||
|
|
||||||
|
$discount = null;
|
||||||
|
if ($promo) {
|
||||||
|
if (!empty($promo['discount_percentage'])) {
|
||||||
|
$discount = $promo['discount_percentage']; // Percentage discount
|
||||||
|
} elseif (!empty($promo['discount_amount'])) {
|
||||||
|
$discount = $promo['discount_amount']; // Fixed amount discount
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get regular price for the specified period
|
||||||
|
$priceColumn = "m" . $date_add;
|
||||||
|
$regularPrice = $db->selectValue(
|
||||||
|
"SELECT $priceColumn FROM domain_price WHERE tldid = ? AND command = ? LIMIT 1",
|
||||||
|
[$tld_id, $command]
|
||||||
|
);
|
||||||
|
|
||||||
|
if ($regularPrice !== false) {
|
||||||
|
if ($discount !== null) {
|
||||||
|
if (isset($promo['discount_percentage'])) {
|
||||||
|
$discountAmount = $regularPrice * ($promo['discount_percentage'] / 100);
|
||||||
|
} else {
|
||||||
|
$discountAmount = $discount;
|
||||||
|
}
|
||||||
|
$price = $regularPrice - $discountAmount;
|
||||||
|
return ['type' => 'promotion', 'price' => $price];
|
||||||
|
}
|
||||||
|
|
||||||
|
return ['type' => 'regular', 'price' => $regularPrice];
|
||||||
|
}
|
||||||
|
|
||||||
|
return ['type' => 'not_found', 'price' => 0];
|
||||||
|
}
|
|
@ -672,11 +672,8 @@ function processDomainCreate($conn, $db, $xml, $clid, $database_type, $trans) {
|
||||||
$registrar_balance = $result['accountBalance'];
|
$registrar_balance = $result['accountBalance'];
|
||||||
$creditLimit = $result['creditLimit'];
|
$creditLimit = $result['creditLimit'];
|
||||||
|
|
||||||
$priceColumn = "m" . $date_add;
|
$returnValue = getDomainPrice($db, $domainName, $tld_id, $date_add, 'create');
|
||||||
$stmt = $db->prepare("SELECT $priceColumn FROM domain_price WHERE tldid = :tld_id AND command = 'create' LIMIT 1");
|
$price = $returnValue['price'];
|
||||||
$stmt->bindParam(':tld_id', $tld_id, PDO::PARAM_INT);
|
|
||||||
$stmt->execute();
|
|
||||||
$price = $stmt->fetchColumn();
|
|
||||||
|
|
||||||
if (!$price) {
|
if (!$price) {
|
||||||
sendEppError($conn, $db, 2400, 'The price, period and currency for such TLD are not declared', $clTRID, $trans);
|
sendEppError($conn, $db, 2400, 'The price, period and currency for such TLD are not declared', $clTRID, $trans);
|
||||||
|
|
|
@ -174,6 +174,13 @@ function processDomainDelete($conn, $db, $xml, $clid, $database_type, $trans) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$invalid_domain = validate_label($domainName, $db);
|
||||||
|
|
||||||
|
if ($invalid_domain) {
|
||||||
|
sendEppError($conn, $db, 2306, 'Invalid domain:name', $clTRID, $trans);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
$stmt = $db->prepare("SELECT id, tldid, registrant, crdate, exdate, clid, crid, upid, trdate, trstatus, reid, redate, acid, acdate, rgpstatus, addPeriod, autoRenewPeriod, renewPeriod, renewedDate, transferPeriod FROM domain WHERE name = :name LIMIT 1");
|
$stmt = $db->prepare("SELECT id, tldid, registrant, crdate, exdate, clid, crid, upid, trdate, trstatus, reid, redate, acid, acdate, rgpstatus, addPeriod, autoRenewPeriod, renewPeriod, renewedDate, transferPeriod FROM domain WHERE name = :name LIMIT 1");
|
||||||
$stmt->execute([':name' => $domainName]);
|
$stmt->execute([':name' => $domainName]);
|
||||||
$result = $stmt->fetch(PDO::FETCH_ASSOC);
|
$result = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||||
|
@ -246,9 +253,8 @@ function processDomainDelete($conn, $db, $xml, $clid, $database_type, $trans) {
|
||||||
$addPeriod_id = $stmt->fetchColumn();
|
$addPeriod_id = $stmt->fetchColumn();
|
||||||
|
|
||||||
if ($addPeriod_id) {
|
if ($addPeriod_id) {
|
||||||
$stmt = $db->prepare("SELECT m$addPeriod FROM domain_price WHERE tldid = ? AND command = 'create' LIMIT 1");
|
$returnValue = getDomainPrice($db, $domainName, $tldid, $addPeriod, 'create');
|
||||||
$stmt->execute([$tldid]);
|
$price = $returnValue['price'];
|
||||||
$price = $stmt->fetchColumn();
|
|
||||||
|
|
||||||
if (!isset($price)) {
|
if (!isset($price)) {
|
||||||
sendEppError($conn, $db, 2400, 'The price, period and currency for such TLD are not declared', $clTRID, $trans);
|
sendEppError($conn, $db, 2400, 'The price, period and currency for such TLD are not declared', $clTRID, $trans);
|
||||||
|
@ -305,9 +311,8 @@ function processDomainDelete($conn, $db, $xml, $clid, $database_type, $trans) {
|
||||||
$autoRenewPeriod_id = $stmt->fetchColumn();
|
$autoRenewPeriod_id = $stmt->fetchColumn();
|
||||||
|
|
||||||
if ($autoRenewPeriod_id) {
|
if ($autoRenewPeriod_id) {
|
||||||
$stmt = $db->prepare("SELECT m$autoRenewPeriod FROM domain_price WHERE tldid = ? AND command = 'renew' LIMIT 1");
|
$returnValue = getDomainPrice($db, $domainName, $tldid, $autoRenewPeriod, 'renew');
|
||||||
$stmt->execute([$tldid]);
|
$price = $returnValue['price'];
|
||||||
$price = $stmt->fetchColumn();
|
|
||||||
|
|
||||||
if (!isset($price)) {
|
if (!isset($price)) {
|
||||||
sendEppError($conn, $db, 2400, 'The price, period and currency for such TLD are not declared', $clTRID, $trans);
|
sendEppError($conn, $db, 2400, 'The price, period and currency for such TLD are not declared', $clTRID, $trans);
|
||||||
|
@ -329,9 +334,8 @@ function processDomainDelete($conn, $db, $xml, $clid, $database_type, $trans) {
|
||||||
$renewPeriod_id = $stmt->fetchColumn();
|
$renewPeriod_id = $stmt->fetchColumn();
|
||||||
|
|
||||||
if ($renewPeriod_id) {
|
if ($renewPeriod_id) {
|
||||||
$stmt = $db->prepare("SELECT m$renewPeriod FROM domain_price WHERE tldid = ? AND command = 'renew' LIMIT 1");
|
$returnValue = getDomainPrice($db, $domainName, $tldid, $renewPeriod, 'renew');
|
||||||
$stmt->execute([$tldid]);
|
$price = $returnValue['price'];
|
||||||
$price = $stmt->fetchColumn();
|
|
||||||
|
|
||||||
if (!isset($price)) {
|
if (!isset($price)) {
|
||||||
sendEppError($conn, $db, 2400, 'The price, period and currency for such TLD are not declared', $clTRID, $trans);
|
sendEppError($conn, $db, 2400, 'The price, period and currency for such TLD are not declared', $clTRID, $trans);
|
||||||
|
@ -355,9 +359,8 @@ function processDomainDelete($conn, $db, $xml, $clid, $database_type, $trans) {
|
||||||
if ($transferPeriod_id) {
|
if ($transferPeriod_id) {
|
||||||
// Return money if a transfer was also a renew
|
// Return money if a transfer was also a renew
|
||||||
if ($transferPeriod > 0) {
|
if ($transferPeriod > 0) {
|
||||||
$stmt = $db->prepare("SELECT m$transferPeriod FROM domain_price WHERE tldid = ? AND command = 'renew' LIMIT 1");
|
$returnValue = getDomainPrice($db, $domainName, $tldid, $transferPeriod, 'renew');
|
||||||
$stmt->execute([$tldid]);
|
$price = $returnValue['price'];
|
||||||
$price = $stmt->fetchColumn();
|
|
||||||
|
|
||||||
if (!isset($price)) {
|
if (!isset($price)) {
|
||||||
sendEppError($conn, $db, 2400, 'The price, period and currency for such TLD are not declared', $clTRID, $trans);
|
sendEppError($conn, $db, 2400, 'The price, period and currency for such TLD are not declared', $clTRID, $trans);
|
||||||
|
|
|
@ -43,7 +43,7 @@ function processDomainRenew($conn, $db, $xml, $clid, $database_type, $trans) {
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
$clid = $stmt->fetch(PDO::FETCH_ASSOC);
|
$clid = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||||
|
|
||||||
$stmt = $db->prepare("SELECT id, tldid, exdate, clid FROM domain WHERE name = :domainName LIMIT 1");
|
$stmt = $db->prepare("SELECT id, name, tldid, exdate, clid FROM domain WHERE name = :domainName LIMIT 1");
|
||||||
$stmt->bindParam(':domainName', $domainName, PDO::PARAM_STR);
|
$stmt->bindParam(':domainName', $domainName, PDO::PARAM_STR);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
$domainData = $stmt->fetch(PDO::FETCH_ASSOC);
|
$domainData = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||||
|
@ -113,11 +113,8 @@ function processDomainRenew($conn, $db, $xml, $clid, $database_type, $trans) {
|
||||||
$registrar_balance = $row['accountBalance'];
|
$registrar_balance = $row['accountBalance'];
|
||||||
$creditLimit = $row['creditLimit'];
|
$creditLimit = $row['creditLimit'];
|
||||||
|
|
||||||
$columnName = "m$date_add";
|
$returnValue = getDomainPrice($db, $domainData['name'], $domainData['tldid'], $date_add, 'renew');
|
||||||
$stmt = $db->prepare("SELECT $columnName FROM domain_price WHERE tldid = :tldid AND command = 'renew' LIMIT 1");
|
$price = $returnValue['price'];
|
||||||
$stmt->bindParam(':tldid', $domainData['tldid'], PDO::PARAM_INT);
|
|
||||||
$stmt->execute();
|
|
||||||
$price = $stmt->fetchColumn();
|
|
||||||
|
|
||||||
if (($registrar_balance + $creditLimit) < $price) {
|
if (($registrar_balance + $creditLimit) < $price) {
|
||||||
sendEppError($conn, $db, 2104, 'There is no money on the account to renew', $clTRID, $trans);
|
sendEppError($conn, $db, 2104, 'There is no money on the account to renew', $clTRID, $trans);
|
||||||
|
|
|
@ -466,9 +466,8 @@ function processDomainTransfer($conn, $db, $xml, $clid, $database_type, $trans)
|
||||||
$stmt->execute([$domainName]);
|
$stmt->execute([$domainName]);
|
||||||
$date_add = $stmt->fetchColumn();
|
$date_add = $stmt->fetchColumn();
|
||||||
|
|
||||||
$stmt = $db->prepare("SELECT m$date_add FROM domain_price WHERE tldid = ? AND command = 'transfer' LIMIT 1");
|
$returnValue = getDomainPrice($db, $domainName, $tldid, $date_add, 'transfer');
|
||||||
$stmt->execute([$tldid]);
|
$price = $returnValue['price'];
|
||||||
$price = $stmt->fetchColumn();
|
|
||||||
|
|
||||||
if (($registrar_balance + $creditLimit) < $price) {
|
if (($registrar_balance + $creditLimit) < $price) {
|
||||||
sendEppError($conn, $db, 2104, 'The registrar who took over this domain has no money to pay the renewal period that resulted from the transfer request', $clTRID, $trans);
|
sendEppError($conn, $db, 2104, 'The registrar who took over this domain has no money to pay the renewal period that resulted from the transfer request', $clTRID, $trans);
|
||||||
|
@ -866,10 +865,8 @@ function processDomainTransfer($conn, $db, $xml, $clid, $database_type, $trans)
|
||||||
$registrar_balance = $result["accountBalance"];
|
$registrar_balance = $result["accountBalance"];
|
||||||
$creditLimit = $result["creditLimit"];
|
$creditLimit = $result["creditLimit"];
|
||||||
|
|
||||||
$stmt = $db->prepare("SELECT m$date_add FROM domain_price WHERE tldid = :tldid AND command = 'transfer' LIMIT 1");
|
$returnValue = getDomainPrice($db, $domainName, $tldid, $date_add, 'transfer');
|
||||||
$stmt->execute([':tldid' => $tldid]);
|
$price = $returnValue['price'];
|
||||||
$result = $stmt->fetch(PDO::FETCH_ASSOC);
|
|
||||||
$price = $result["m$date_add"];
|
|
||||||
|
|
||||||
if (($registrar_balance + $creditLimit) < $price) {
|
if (($registrar_balance + $creditLimit) < $price) {
|
||||||
sendEppError($conn, $db, 2104, 'The registrar who wants to take over this domain has no money', $clTRID, $trans);
|
sendEppError($conn, $db, 2104, 'The registrar who wants to take over this domain has no money', $clTRID, $trans);
|
||||||
|
|
|
@ -491,3 +491,66 @@ function updatePermittedIPs($pool, $permittedIPsTable) {
|
||||||
$permittedIPsTable->set($ip, ['addr' => $ip]);
|
$permittedIPsTable->set($ip, ['addr' => $ip]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getDomainPrice($pdo, $domain_name, $tld_id, $date_add = 12, $command = 'create') {
|
||||||
|
// Check if the domain is a premium domain
|
||||||
|
$stmt = $pdo->prepare("
|
||||||
|
SELECT c.category_price
|
||||||
|
FROM premium_domain_pricing p
|
||||||
|
JOIN premium_domain_categories c ON p.category_id = c.category_id
|
||||||
|
WHERE p.domain_name = ? AND p.tld_id = ?
|
||||||
|
");
|
||||||
|
$stmt->execute([$domain_name, $tld_id]);
|
||||||
|
if ($stmt->rowCount() > 0) {
|
||||||
|
return ['type' => 'premium', 'price' => $stmt->fetch()['category_price']];
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check if there is a promotion for the domain
|
||||||
|
$currentDate = date('Y-m-d');
|
||||||
|
$stmt = $pdo->prepare("
|
||||||
|
SELECT discount_percentage, discount_amount
|
||||||
|
FROM promotion_pricing
|
||||||
|
WHERE tld_id = ?
|
||||||
|
AND promo_type = 'full'
|
||||||
|
AND status = 'active'
|
||||||
|
AND start_date <= ?
|
||||||
|
AND end_date >= ?
|
||||||
|
");
|
||||||
|
$stmt->execute([$tld_id, $currentDate, $currentDate]);
|
||||||
|
if ($stmt->rowCount() > 0) {
|
||||||
|
$promo = $stmt->fetch();
|
||||||
|
$discount = null;
|
||||||
|
|
||||||
|
// Determine discount based on percentage or amount
|
||||||
|
if (!empty($promo['discount_percentage'])) {
|
||||||
|
$discount = $promo['discount_percentage']; // Percentage discount
|
||||||
|
} elseif (!empty($promo['discount_amount'])) {
|
||||||
|
$discount = $promo['discount_amount']; // Fixed amount discount
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$discount = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get regular price for the specified period
|
||||||
|
$priceColumn = "m" . $date_add;
|
||||||
|
$stmt = $pdo->prepare("SELECT $priceColumn FROM domain_price WHERE tldid = ? AND command = '$command' LIMIT 1");
|
||||||
|
$stmt->execute([$tld_id]);
|
||||||
|
|
||||||
|
if ($stmt->rowCount() > 0) {
|
||||||
|
$regularPrice = $stmt->fetch()[$priceColumn];
|
||||||
|
|
||||||
|
if ($discount !== null) {
|
||||||
|
if (isset($promo['discount_percentage'])) {
|
||||||
|
$discountAmount = $regularPrice * ($promo['discount_percentage'] / 100);
|
||||||
|
} else {
|
||||||
|
$discountAmount = $discount;
|
||||||
|
}
|
||||||
|
$price = $regularPrice - $discountAmount;
|
||||||
|
return ['type' => 'promotion', 'price' => $price];
|
||||||
|
}
|
||||||
|
|
||||||
|
return ['type' => 'regular', 'price' => $regularPrice];
|
||||||
|
}
|
||||||
|
|
||||||
|
return ['type' => 'not_found', 'price' => 0];
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue