Friday, May 31, 2024
paypal fee calculator
function get_float(string) {
var to_return = parseFloat(string);
if (typeof to_return == 'undefined') {
to_return = 0.00
}
if (isNaN(to_return)) {
to_return = 0.00
}
to_return = (to_return / 100) * 100;
return to_return
}
function get_key_code(e) {
if (typeof e == "undefined") {
e = window.event
}
if (e.keyCode) {
return e.keyCode
} else if (e.which) {
return e.which
} else {
return e.charCode
}
}
function has_selection(ele) {
var txt = '',
len = 0,
start = 0,
end = 0;
if (document.selection) {
txt = document.selection.createRange().text
} else if (window.getSelection) {
txt = window.getSelection()
} else if (document.getSelection) {
txt = document.getSelection()
} else {
return false
}
if (ele.selectionStart) {
start = ele.selectionStart
}
if (ele.selectionEnd) {
end = ele.selectionEnd
}
len = end - start;
if (len > 0) {
return true
} else if (typeof txt == "undefined") {
return false
} else if (isNaN(txt)) {
return false
} else if (txt.length > 0) {
return true
} else {
return false
}
}
function textbox_onkeypress(e) {
if (typeof e == "undefined") {
e = window.event
}
var keycode = get_key_code(e);
var to_return = true;
switch (keycode) {
case 8:
break;
case 9:
break;
case 13:
break;
case 37:
case 39:
break;
case 38:
if (this.value != '') {
this.value = (get_float(this.value) + 0.5).toFixed(2)
}
break;
case 40:
if (get_float(this.value) >= 0.5) {
this.value = (get_float(this.value) - 0.5).toFixed(2)
} else {
this.value = '0.00'
}
if (this.id == 'to_receive') {
rp_calc()
} else if (this.id == 'if_you_receive') {
p_calc()
}
break;
case 46:
if (this.value.indexOf(".") != -1) {
if (has_selection(this) == false) {
to_return = false
}
}
break;
case 48:
case 49:
case 50:
case 51:
case 52:
case 53:
case 54:
case 55:
case 56:
case 57:
if ((this.id != 'paypal_fee_percent')) {
if (this.value.length >= 3) {
if (this.value.substr(this.value.length - 3, 1) == '.') {
if (has_selection(this) == false) {
to_return = false
}
}
}
}
break;
default:
to_return = false
}
if ((!e.which) && (keycode == 46)) {
to_return = true
}
if ((typeof e.which == "undefined") && (keycode == 46) && (this.value.indexOf(".") != -1) && (has_selection(this) == false)) {
to_return = false
}
e.returnValue = to_return;
return to_return
}
function set_rate(percent, fixed, sign, name) {
document.forms['ppc'].elements['paypal_fee_percent'].value = percent;
document.forms['ppc'].elements['paypal_fee_fixed'].value = fixed;
document.getElementById('currency_sign').innerHTML = sign;
document.getElementById('currency_name').innerHTML = name;
document.getElementById('currency_symbol_1').innerHTML = sign;
document.getElementById('currency_symbol_2').innerHTML = sign;
document.getElementById('currency_symbol_3').innerHTML = sign;
document.getElementById('currency_symbol_4').innerHTML = sign;
document.getElementById('currency_symbol_5').innerHTML = sign
}
function figure_fees(item_price, fee_percentage, fixed_fee) {
var the_fee_percentage = fee_percentage / 100;
the_fee_percentage = the_fee_percentage.toFixed(4);
the_fee_percentage = get_float(the_fee_percentage);
var to_return = item_price * the_fee_percentage + fixed_fee;
to_return = Math.round(to_return * 100) / 100;
to_return = to_return.toFixed(2);
to_return = get_float(to_return);
if (to_return > item_price) {
to_return = item_price
}
return to_return
}
function p_calc() {
if (document.forms['ppc'].elements['if_you_receive'].value != '') {
var amount_sent = get_float(document.forms['ppc'].elements['if_you_receive'].value);
if (amount_sent == 0) {
document.forms['ppc'].elements['paypal_fees'].value = document.forms['ppc'].elements['you_would_receive'].value = '0.00'
} else {
var the_paypal_fees = figure_fees(amount_sent, get_float(document.forms['ppc'].elements['paypal_fee_percent'].value), get_float(document.forms['ppc'].elements['paypal_fee_fixed'].value));
document.forms['ppc'].elements['paypal_fees'].value = the_paypal_fees.toFixed(2);
var amount_after_fees = amount_sent - get_float(document.forms['ppc'].elements['paypal_fees'].value);
if (amount_after_fees < 0) {
amount_after_fees = 0
}
document.forms['ppc'].elements['you_would_receive'].value = amount_after_fees.toFixed(2)
}
} else {
document.forms['ppc'].elements['paypal_fees'].value = '';
document.forms['ppc'].elements['you_would_receive'].value = ''
}
}
function rp_calc(src) {
if (document.forms['ppc'].elements['to_receive'].value != '') {
var desired_amount = get_float(document.forms['ppc'].elements['to_receive'].value);
if (desired_amount == 0) {
document.forms['ppc'].elements['a_person_would'].value = '0.00'
} else {
var a_person_must_send = (desired_amount + get_float(document.forms['ppc'].elements['paypal_fee_fixed'].value)) / (1 - (get_float(document.forms['ppc'].elements['paypal_fee_percent'].value) / 100).toFixed(4));
document.forms['ppc'].elements['a_person_would'].value = a_person_must_send.toFixed(2);
document.forms['ppc'].elements['if_you_receive'].value = document.forms['ppc'].elements['a_person_would'].value;
p_calc()
}
} else {
if (src != 1) {
document.forms['ppc'].elements['a_person_would'].value = '';
document.forms['ppc'].elements['if_you_receive'].value = ''
}
p_calc()
}
}
if (window.addEventListener) {
window.addEventListener("load", window_onload, false)
} else if (window.attachEvent) {
window.attachEvent("onload", window_onload)
}
function window_onload() {
document.forms['ppc'].elements['to_receive'].onkeypress = textbox_onkeypress;
document.forms['ppc'].elements['if_you_receive'].onkeypress = textbox_onkeypress;
document.forms['ppc'].elements['paypal_fee_percent'].onkeypress = textbox_onkeypress;
document.forms['ppc'].elements['paypal_fee_fixed'].onkeypress = textbox_onkeypress;
document.forms['ppc'].elements['to_receive'].onkeyup = rp_calc;
document.forms['ppc'].elements['if_you_receive'].onkeyup = p_calc;
document.forms['ppc'].elements['to_receive'].focus()
}
paypalfee calculator
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;
@WebServlet("/calculateFee")
public class PayPalFeeCalculator extends HttpServlet {
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
double amount = Double.parseDouble(request.getParameter("amount"));
double feePercentage = 2.9;
double fixedFee = 0.30;
double fee = amount * (feePercentage / 100) + fixedFee;
double total = amount - fee;
response.setContentType("application/json");
PrintWriter out = response.getWriter();
out.println("{");
out.println("\"fee\": " + fee + ",");
out.println("\"total\": " + total);
out.println("}");
out.close();
}
}
PayPal Fee Calculator
body {
font-family: Arial, sans-serif;
background: linear-gradient(to right, #4facfe, #00f2fe);
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
margin: 0;
}
.calculator-container {
background: white;
padding: 20px;
border-radius: 10px;
box-shadow: 0 0 20px rgba(0, 0, 0, 0.1);
text-align: center;
width: 300px;
}
h1 {
font-size: 24px;
margin-bottom: 20px;
}
form {
display: flex;
flex-direction: column;
align-items: center;
}
label {
font-size: 18px;
margin-bottom: 10px;
}
input[type="number"] {
padding: 10px;
font-size: 16px;
border: 1px solid #ccc;
border-radius: 5px;
margin-bottom: 20px;
width: 100%;
}
button {
background-color: #4facfe;
color: white;
border: none;
padding: 10px 20px;
font-size: 16px;
border-radius: 5px;
cursor: pointer;
transition: background-color 0.3s;
}
button:hover {
background-color: #00c3ff;
}
#result {
margin-top: 20px;
font-size: 18px;
}
document.getElementById('calculatorForm').addEventListener('submit', function(e) {
e.preventDefault();
const amount = parseFloat(document.getElementById('amount').value);
fetch('/calculateFee', {
method: 'POST',
headers: {
'Content-Type': 'application/x-www-form-urlencoded'
},
body: 'amount=' + amount
})
.then(response => response.json())
.then(data => {
document.getElementById('fee').textContent = '$' + data.fee.toFixed(2);
document.getElementById('total').textContent = '$' + data.total.toFixed(2);
})
.catch(error => console.error('Error:', error));
});
PayPalFeeCalculator/
├── src/
│ └── PayPalFeeCalculator.java
├── web/
│ ├── index.html
│ ├── styles.css
│ └── scripts.js
└── WEB-INF/
└── web.xml
PayPalFeeCalculator
PayPalFeeCalculator
PayPalFeeCalculator
/calculateFee
PayPal Fee Calculator
Fee:
Total after Fee:
Subscribe to:
Posts (Atom)
screan recoder
Screen Recorder Screen Recorder Tool Start Recording Stop Recording...
-
import javax.servlet.ServletException; import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServlet; import javax.servl...
-
Screen Recorder Screen Recorder Tool Start Recording Stop Recording...
-
import random class ArticleGenerator: def __init__(self): self.templates = [ "The {adj1} {noun} {verb} over th...