Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4020790
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T10:16:19+00:00 2026-05-20T10:16:19+00:00

Lets say you have website that keeps balance for each user. You give each

  • 0

Lets say you have website that keeps balance for each user. You give each user option to deposit money into their balance from PayPal, Amazon FPS, Authorize.NET eCheck and Credit Card and maybe couple of there once.

Each of the above companies charges fee. And since you are the receiver you are responsible for fees (except for Adaptive PayPal API there you can say who will pay the fees).

So lets say website user (sender) will deposit you $1000.00
And lets picker fee of 2.9% plus $0.30 fix fee = -$29.30
So the receiver (the website owner) ends up with $970.70

If you try to charge $1029.30 you end up with $999.1503
If you try to charge $1031.11 you end up with $1000.90781 which is acceptable (this is when the fee is increased by 0.181% to 3.081% + 0.30)

So this question is, what is the best way to calculate the 0.181% in Java method

I know this is more of math problem than Java problem but what would be the best algorithm to use for guessing the best fee percentage so the final value would get as close as possible to the final value of what the website user is try to deposit.

So the method should take the actual fee 2.9% (0.029 for multiplication), the fix fee 0.30 the amount the user is trying to deposit and figure out the final sum to be charged that would be as close as possible to the deposit amount.

The way I have been doing it is trying to increase the 2.9% until I hit slightly higher after the fees are subtracted.

UPDATE

As per bellow answers I coded up this method. Any further suggestions are more than welcome:

public static float includeFees(float percentageFee, float fixedFee, float amount) {
    BigDecimal amountBD = new BigDecimal(amount);
    BigDecimal percentageFeeBD = new BigDecimal(1-percentageFee);
    BigDecimal fixedFeeBD = new BigDecimal(fixedFee);

    return amountBD.add(fixedFeeBD).divide(percentageFeeBD, 10, BigDecimal.ROUND_UP)
            .setScale(2, BigDecimal.ROUND_UP).floatValue();
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T10:16:20+00:00Added an answer on May 20, 2026 at 10:16 am
    amt_you_receive = amt_customer_pays - .029 * amt_customer_pays - .30
    amt_you_receive + .30 = amt_customer_pays * (1 - .029)
    (amt_you_receive + .30) / .971 = amt_customer_pays
    

    So take the amount you want to get, add 30 cents, and divide by .971 (aka multiply by approximately 1.029866) to get the amount you should charge.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Lets say i have a website mysite.com that will store some sensitive personal data
Lets say I have a website that sells widgets. I would like to do
Lets say I have a website with a small application that lists the 10
Let's say you have a website that lets you build an account with up
Lets say you have a website, that uses a function to retrieve data from
So lets say i have a member base website and when the user signs
lets say i have a website that i am developing... the site may have
Lets say I've a website that lists Persons, and each Person has multiple properties,
This is my first question on this wonderful website. Lets say I have a
Lets say you're running a movie database website like IMDb/Netflix and users rate each

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.