We're a community of 1076K IT Pros here for help, advice, solutions, professional growth and fun. Join us!
1,075,590 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Start New Discussion Reply to this Discussion

more math than php...

I know this is more of a math question, but since I'm trying to evaluate it in a script, maybe I can squeeze it in here.
I know there is an easy way to do this, but for the life of me, I can't seem to get it clear.

If a payment processor is charging a per transaction fee of $1.50 plus a 6.5% processing fee, that come off of the total payment..

And I want to end up with a Net of $2 in my account, how do I determine what the Gross charge would be to send them?

BTW, they are charging the 6.5% on the transaction fee as well as on the actual payment itself.

what they are doing on their end when they receive it is they take the Gross payment and multiply it by the 6.5% rate, then add the $1.50 trans fee to determine the fee, and back that out of the gross payment to determine the net that goes into the account.

$fee=($gross x .065) + 1.5;
$net=$gross-$fee;

So, the basic question is...
How do I determine what the Gross needs to be to end up with the net where I want it. In this case it is $2, but I need to be able to calculate it with a single calculation no matter what the net is.

This is what I thought would work, but apparently I was wrong...

    $fund_amount=2;
    $cc_fee= (ceil(((($fund_amount+1.5)*.065)+1.5)*100)/100);
    $cc=(ceil(($fund_amount+$cc_fee)*100)/100);

Any clarification or enlightenment on this matter would be greatly appreciated.

Douglas

3
Contributors
6
Replies
2 Hours
Discussion Span
3 Months Ago
Last Updated
7
Views
Question
Answered
showman13
Posting Whiz
303 posts since Feb 2010
Reputation Points: 27
Solved Threads: 3
Skill Endorsements: 0

I'm going to go on the basis I have the right idea for what you want, the calculation is as follows:

You want the fee (referred to as $outcome, what you get) to equal a certain amount, lets take your example for $2, so...

(($gross x 0.065) + 1.5) must equal $2 ... and you want to know what $gross is? so you would do the following:

(2 - 1.5) / 0.065 = 7.6923... - That's what you have to charge your customer, in order for you to receive $2 in fees.

Now, for that to work on any calculation with pluggable values in PHP:

$outcome = 2;
$charge = 1.5;
$processing_fee = 0.065;

$gross = ($outcome - $charge) / $processing_fee;

// Gross is now 7.6923...
Smeagel13
Junior Poster
104 posts since Oct 2011
Reputation Points: 15
Solved Threads: 10
Skill Endorsements: 7

Sorry, but that is not what I was trying to explain...

In my example, the gross should end up at $3.74 for them to take away their 6.5% and then their $1.50 and leave the $2.00 net

What I need is to figure out what the Gross should be so they can take their 6.5% and their $1.50, and leave me with the net that I want in my account. (in example the net is $2.00)

showman13
Posting Whiz
303 posts since Feb 2010
Reputation Points: 27
Solved Threads: 3
Skill Endorsements: 0

Ah see, you want them to absorb the charges, the $1.50 throws the equation I know off :/ ... if they applied it before, then it would have been ok.

Smeagel13
Junior Poster
104 posts since Oct 2011
Reputation Points: 15
Solved Threads: 10
Skill Endorsements: 7

OK, I have come up with the solution, although it was a long drawn out process to come up with the factor to use to represent the 6.5% they would deduct...

Here is a little snippet to show the solution.
And it actually works no matter what the funding amount is.
(Well almost) Tested from $2 to 35,000 with accuracy, but when you hit $40K it gains a penny... but since the funding amount will never approach that figure, I think I'll deal with it.

   $fund_amount=2;
   $trans_fee=1.5;
   $factor=.06526; // represents 6.5% fee deducted after payment

   $fee=(($fund_amount+$trans_fee)*$factor)+((($fund_amount+$trans_fee)*$factor)*$factor);
   $total_charge=$fund_amount+$fee+$trans_fee;
print "<br />To fund $".number_format($fund_amount,2);
print "<br />The fee is $".number_format(($fee+$trans_fee),2);
print "<br />For a total Charge of $".number_format($total_charge,2);

print"<br /><br />So when the processor receives the payment of $".number_format($total_charge,2);
print"<br />They determine the fee to be gross X .065 plus $1.50, which is ".number_format((($total_charge * .065) + 1.5),2);
print"<br />Leaving a Net of $".number_format(($total_charge-(($total_charge * .065) + 1.5)),2);
showman13
Posting Whiz
303 posts since Feb 2010
Reputation Points: 27
Solved Threads: 3
Skill Endorsements: 0

I believe the penny gained at 40K was coming from 0.00026 . $factor minus the actual value used (0.065)..

veedeoo
Master Poster
735 posts since Oct 2011
Reputation Points: 298
Solved Threads: 129
Skill Endorsements: 13

sorry, for the double post..how did it happen??????

veedeoo
Master Poster
735 posts since Oct 2011
Reputation Points: 298
Solved Threads: 129
Skill Endorsements: 13
Question Answered as of 3 Months Ago by veedeoo and Smeagel13

This question has already been solved: Start a new discussion instead

Post: Markdown Syntax: Formatting Help
 
You
 
© 2013 DaniWeb® LLC
Page rendered in 0.3630 seconds using 2.77MB