If you’re a small-time consultant, you can’t afford to be nickel-and-dimed out of your earnings. Many small businesses add a credit card surcharge if you want to pay in plastic, some only accept cash in the first place. If you want to offer your customers flexibility of payment methods, but can’t afford the the financial hit of payment services because you’re already running on thin margins, you might consider adopting a similar strategy.
I’ve recently set up FusionInvoice 1.3.4 (version 1.x is open-source freeware, while the newer 2.0 is a paid product) in order to invoice for my consulting jobs. This software supports payment by PayPal natively, but has no option to add a PayPal surcharge. Thus, the goal here is to apply a surcharge to PayPal purchases such that, after PayPal’s cut, I receive the amount totaled on the invoice (of course, my customer could always pay via check or cash to avoid the fee). It can be done easily with a bit of HTML and PHP knowledge.
- Edit the file: application/libraries/merchant/merchant_paypal_base.php
- Find the two lines that start with: $request[‘AMT’] = and $request[$prefix.’AMT’] =
- After the equal sign, remove or comment out the string: $this->amount_dollars();
- Replace it with: (floor(($this->amount_dollars() + .3) / .00971) / 100);
- Open for editing your invoice and quote templates, including the PDF versions; four files total. Unless you’ve added custom templates, these will be here: application/views/[invoice,quote]_templates/[pdf,public]/default.php
- Anywhere you wish, you can represent the total with the PayPal fee with the code: <?php echo format_currency(floor(($invoice->invoice_balance + .3) / .00971) / 100) ?>
- And you can represent the fee itself with: <?php echo format_currency(floor(($invoice->invoice_balance + .3) * (1 / .971 – 1) * 100) / 100 + .3) ?>
- For the quote page, you will need to change: $invoice->invoice_balance to $quote->quote_total
That’s it. Enjoy.
Since I don’t want to have to come back and edit this post every time PayPal hikes their fees (at the time of this writing, 2.9% + $0.30), I’ll tell you how I arrived at these numbers.
First, I want to know how much to charge in order to receive amount “m” after PayPal fees.
m = “my money”, p = “payment billed”, .3 = PayPal’s base fee, .029 = PayPal’s percentage fee
m = p - .029*p - .3 m + .3 = p - .029*p m + .3 = p (1 - .029) m + .3 = p * 0.971 (m + .3)/0.971 = p
Next, consolidate variables so that I only need to call “m” once in programming code.
f = “fee, by itself”
f = (m + .3)/0.971 - m f - .3 = (m + .3)/0.971 - m - .3 f - .3 = (m + .3)/0.971 - (m + .3) f - .3 = (m + .3)(1 / 0.971 - 1) f = (m + .3)(1 / 0.971 - 1) + .3
It is not enough to simply add the amount that PayPal would charge in fees, because PayPal would charge fees on that amount as well, and you’d undershoot your net target. Hence, the more complicated calculation. I chose not to finish resolving the numbers, because they result in a repeating decimal which I would rather the computer resolve at the time of calculation.
PayPal rounds down fractions of a cent when calculating its fees. The floor() function truncates a number after the decimal. Therefore, we multiply by 100, floor() it, then divide again to get a rounded-down value. Dividing by .00971 is the same as dividing by .971 and then multiplying by 100.