<?php
if (!defined("WHMCS")) {
exit("This file cannot be accessed directly");
}
function dplbinance_MetaData()
{
return ["DisplayName" => "Binance Pay", "APIVersion" => "1.1"];
}
function dplbinance_config()
{
return ["FriendlyName" => ["Type" => "System", "Value" => "Binance Pay"], "licensekey" => ["FriendlyName" => "License Key", "Type" => "text", "Size" => "25", "Default" => "", "Description" => "License Key from Deploymentcode.com"], "publickey" => ["FriendlyName" => "API Key", "Type" => "text", "Size" => "25", "Default" => ""], "privatekey" => ["FriendlyName" => "Secret Key", "Type" => "password", "Size" => "25", "Default" => ""], "bcurrency" => ["FriendlyName" => "Order Currency", "Type" => "dropdown", "Options" => ["BUSD" => "BUSD", "USDT" => "USDT"]], "paymentLinkMode" => ["FriendlyName" => "Payment Link Mode", "Type" => "dropdown", "Options" => ["qrcode" => "QR Code", "button" => "\"Pay Now\" Button"]], "statementDescription" => ["FriendlyName" => "Statement Description", "Type" => "text", "Size" => "25", "Default" => "Invoice {{invoiceid}} - {{companyname}}", "Description" => "This does appear on yours client statement."]];
}
function dplbinance_link($params)
{
$licenseCheck = dplbinance_callLicenseCheck("dplbinancepay", $params["licensekey"], "Vvieri882ka8bkjkit56");
if ($licenseCheck["licensestatus"] !== "OK") {
logActivity("License for Binance Pay is invalid. Please contact [email protected] if you have questions.");
return "";
}
try {
require_once __DIR__ . "/dplbinance/class.php";
$binancePay = new dpl_binancepayClass($params);
$paymentLink = $binancePay->generatePaymentlink();
if ($paymentLink["status"] !== "SUCCESS") {
return "<div class='alert alert-danger'>Please try again</div>";
}
if ($params["paymentLinkMode"] === "qrcode") {
return "\n <a href='" . $paymentLink["data"]["checkoutUrl"] . "' target='_blank'>\n <img height='128px' src='" . $paymentLink["data"]["qrcodeLink"] . "'>\n </a>\n ";
}
return "\n <a class='btn btn-success btn-sm' href='" . $paymentLink["data"]["checkoutUrl"] . "'>\n " . $params["langpaynow"] . "\n </a>\n ";
} catch (Exception $ex) {
logTransaction($params["name"], $e->getMessage(), "error");
return "<div class='alert alert-danger'>An error occured. Please try again.</div>";
}
}
function dplbinance_check_license($licensekey, $localkey = "")
{
$results["status"] = "Active";
return $results;
}
function dplbinance_callLicenseCheck($module, $licensekey, $secret)
{
Illuminate\Database\Capsule\Manager::statement("CREATE TABLE IF NOT EXISTS `deploymentcode_licenses` (\n `id` int(11) NOT NULL AUTO_INCREMENT,\n `module` text NOT NULL,\n `license` text NOT NULL,\n `localkey` text NOT NULL,\n PRIMARY KEY (`id`)\n ) ENGINE=InnoDB DEFAULT CHARSET=latin1;");
$licenseCache = Illuminate\Database\Capsule\Manager::table("deploymentcode_licenses")->where("module", $module)->first();
$localkey = "";
if (empty($licenseCache->id)) {
Illuminate\Database\Capsule\Manager::table("deploymentcode_licenses")->insert(["module" => $module, "license" => "", "localkey" => ""]);
}
if (!empty($licenseCache->license)) {
if (empty($licensekey)) {
$licensekey = $licenseCache->license;
}
$localkey = $licenseCache->localkey;
}
if ((string) $secret !== "Vvieri882ka8bkjkit56") {
exit;
}
$results = dplbinance_check_license($licensekey, $localkey);
switch ($results["status"]) {
case "Active":
Illuminate\Database\Capsule\Manager::table("deploymentcode_licenses")->where("module", $module)->update(["license" => $licensekey]);
if (!empty($results["localkey"])) {
Illuminate\Database\Capsule\Manager::table("deploymentcode_licenses")->where("module", $module)->update(["localkey" => $results["localkey"]]);
}
return ["licensestatus" => "OK"];
break;
case "Invalid":
return ["licensestatus" => "Invalid"];
break;
case "Expired":
return ["licensestatus" => "Expired"];
break;
case "Suspended":
return ["licensestatus" => "Suspended"];
break;
default:
return ["licensestatus" => "InvalidResponse"];
}
}
?>