Added Account section
This commit is contained in:
96
account/make_a_payment/index.shtml
Normal file
96
account/make_a_payment/index.shtml
Normal file
@ -0,0 +1,96 @@
|
||||
<!--
|
||||
This file is part of Linode Manager Classic.
|
||||
|
||||
Linode Manager Classic is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Linode Manager Classic is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Linode Manager Classic. If not, see <https://www.gnu.org/licenses/>.
|
||||
-->
|
||||
<!DOCTYPE HTML>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||
<title>LMC - Account // Make a Payment</title>
|
||||
<link rel="shortcut icon" type="image/x-icon" href="/favicon.ico" />
|
||||
<link rel="stylesheet" type="text/css" href="make_a_payment.css" />
|
||||
<script src="make_a_payment.js" type="module"></script>
|
||||
</head>
|
||||
<body>
|
||||
<!--#include virtual="/include/header.html"-->
|
||||
<!--#include virtual="/include/account_subnav.html"-->
|
||||
<div id="main-content" class="wrapper">
|
||||
<div id="make-a-payment">
|
||||
<table class="lmc-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<td colspan="3">Make a Payment</td>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr class="lmc-tr3">
|
||||
<td>Current Balance</td>
|
||||
<td id="balance" class="balance-positive"></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
<tbody class="lmc-tbody-head">
|
||||
<tr class="noshow">
|
||||
<td colspan="3"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="3">Make a Payment - via Credit Card</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
<tbody>
|
||||
<tr class="lmc-tr3">
|
||||
<td>Current Card</td>
|
||||
<td>xxxxxxxxxxxx<span id="cc-number"></span> Exp: <span id="cc-exp"></span></td>
|
||||
<td class="info"><a href="/account/creditcard">(update credit card)</a></td>
|
||||
</tr>
|
||||
<tr class="lmc-tr3">
|
||||
<td>Amount to Charge</td>
|
||||
<td><input id="cc-amount" type="number" min="0" max="50000" step="0.01" value="0.00" /> <span class="info">(USD)</span></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr class="lmc-tr3">
|
||||
<td>CVV</td>
|
||||
<td><input id="cvv" type="text" size="8" /> <span class="info">(optional)</span></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr class="lmc-tr3">
|
||||
<td></td>
|
||||
<td colspan="2"><button disabled id="cc-charge" type="button">Charge Credit Card</button></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
<tbody class="lmc-tbody-head">
|
||||
<tr class="noshow">
|
||||
<td colspan="3"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="3">Make a Payment - via PayPal</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
<tbody>
|
||||
<tr class="lmc-tr3">
|
||||
<td>Amount to Pay</td>
|
||||
<td><input id="paypal-amount" type="number" min="0" max="10000" step="0.01" value="0.00" /> <span class="info">(USD)</span></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr class="lmc-tr3">
|
||||
<td></td>
|
||||
<td colspan="2"><button disabled id="paypal-charge" type="button">Continue...</button></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
43
account/make_a_payment/make_a_payment.css
Normal file
43
account/make_a_payment/make_a_payment.css
Normal file
@ -0,0 +1,43 @@
|
||||
/*
|
||||
* This file is part of Linode Manager Classic.
|
||||
*
|
||||
* Linode Manager Classic is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Linode Manager Classic is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Linode Manager Classic. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
@import url('/global.css');
|
||||
|
||||
#balance {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.balance-negative {
|
||||
color: #F00;
|
||||
}
|
||||
|
||||
.balance-positive {
|
||||
color: #008000;
|
||||
}
|
||||
|
||||
input[type="number"] {
|
||||
width: 80px;
|
||||
}
|
||||
|
||||
#make-a-payment {
|
||||
padding: 15px 15px 15px;
|
||||
}
|
||||
|
||||
tbody:not(.lmc-tbody-head) tr td:first-of-type {
|
||||
font-weight: bold;
|
||||
text-align: right;
|
||||
}
|
125
account/make_a_payment/make_a_payment.js
Normal file
125
account/make_a_payment/make_a_payment.js
Normal file
@ -0,0 +1,125 @@
|
||||
/*
|
||||
* This file is part of Linode Manager Classic.
|
||||
*
|
||||
* Linode Manager Classic is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Linode Manager Classic is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Linode Manager Classic. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import { settings, elements, apiGet, apiPost, parseParams, setupHeader } from "/global.js";
|
||||
|
||||
(function()
|
||||
{
|
||||
// Element names specific to this page
|
||||
elements.balance = "balance";
|
||||
elements.balanceNegative = "balance-negative";
|
||||
elements.ccAmount = "cc-amount";
|
||||
elements.ccCharge = "cc-charge";
|
||||
elements.ccExp = "cc-exp";
|
||||
elements.ccNumber = "cc-number";
|
||||
elements.cvv = "cvv";
|
||||
elements.paypalAmount = "paypal-amount";
|
||||
elements.paypalCharge = "paypal-charge";
|
||||
|
||||
// Data received from API calls
|
||||
var data = {};
|
||||
|
||||
// Static references to UI elements
|
||||
var ui = {};
|
||||
ui.balance = {};
|
||||
ui.ccAmount = {};
|
||||
ui.ccCharge = {};
|
||||
ui.ccExp = {};
|
||||
ui.ccNumber = {};
|
||||
ui.cvv = {};
|
||||
ui.paypalAmount = {};
|
||||
ui.paypalCharge = {};
|
||||
|
||||
// Callback for account details API call
|
||||
var displayAccount = function(response)
|
||||
{
|
||||
ui.balance.innerHTML = "$";
|
||||
if (response.balance < 0) {
|
||||
ui.balance.innerHTML += (-response.balance).toFixed(2) + " credit";
|
||||
} else if (response.balance > 0) {
|
||||
ui.balance.innerHTML += response.balance.toFixed(2) + " outstanding";
|
||||
ui.balance.className = elements.balanceNegative;
|
||||
} else {
|
||||
ui.balance.innerHTML += response.balance.toFixed(2);
|
||||
}
|
||||
|
||||
if (response.credit_card) {
|
||||
ui.ccNumber.innerHTML = response.credit_card.last_four;
|
||||
ui.ccExp.innerHTML = response.credit_card.expiry;
|
||||
}
|
||||
|
||||
ui.ccCharge.disabled = false;
|
||||
//ui.paypalCharge.disabled = false;
|
||||
};
|
||||
|
||||
// Click handler for CC charge button
|
||||
var handleCharge = function(event)
|
||||
{
|
||||
if (event.currentTarget.disabled)
|
||||
return;
|
||||
|
||||
if (!confirm("Charge $" + parseInt(ui.ccAmount.value).toFixed(2) + " against your credit card?"))
|
||||
return;
|
||||
|
||||
var req = {
|
||||
"usd": ui.ccAmount.value
|
||||
};
|
||||
if (ui.cvv.value.length)
|
||||
req.cvv = ui.cvv.value;
|
||||
|
||||
apiPost("/account/payments", req, function(response)
|
||||
{
|
||||
location.href = "/account";
|
||||
});
|
||||
};
|
||||
|
||||
// Click handler for PayPal button
|
||||
var handlePayPal = function(event)
|
||||
{
|
||||
if (event.currentTarget.disabled)
|
||||
return;
|
||||
};
|
||||
|
||||
// Initial setup
|
||||
var setup = function()
|
||||
{
|
||||
// Parse URL parameters
|
||||
data.params = parseParams();
|
||||
|
||||
setupHeader();
|
||||
|
||||
// Get element references
|
||||
ui.balance = document.getElementById(elements.balance);
|
||||
ui.ccAmount = document.getElementById(elements.ccAmount);
|
||||
ui.ccCharge = document.getElementById(elements.ccCharge);
|
||||
ui.ccExp = document.getElementById(elements.ccExp);
|
||||
ui.ccNumber = document.getElementById(elements.ccNumber);
|
||||
ui.cvv = document.getElementById(elements.cvv);
|
||||
ui.paypalAmount = document.getElementById(elements.paypalAmount);
|
||||
ui.paypalCharge = document.getElementById(elements.paypalCharge);
|
||||
|
||||
// Register event handlers
|
||||
ui.ccCharge.addEventListener("click", handleCharge);
|
||||
ui.paypalCharge.addEventListener("click", handlePayPal);
|
||||
|
||||
// Get data from API
|
||||
apiGet("/account", displayAccount, null);
|
||||
};
|
||||
|
||||
// Attach onload handler
|
||||
window.addEventListener("load", setup);
|
||||
})();
|
Reference in New Issue
Block a user