nBill Community nBill Home Page
21/May/2012, 11:05:13 PM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News: Click Here for the nBill home page, or take a tour.  
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: Adding transaction fees to Paypal Invoices  (Read 2697 times)
ukdub
Jr. Member
**
Offline Offline

Posts: 12


View Profile
« on: 10/February/2010, 04:37:07 PM »

Is it possible to add 3% to paypal net totals, when paying invoices online?

Paypal is the only gateway I use, but some clients pay offline by cheque etc, so I can't enforce a blanket 'tax' on all invoices.

Logged
netshine
Administrator
Hero Member
*****
Offline Offline

Posts: 4,563


View Profile
« Reply #1 on: 10/February/2010, 05:00:46 PM »

You cannot do that with invoices, no. On order forms you could use custom code to add an amount depending on the gateway selected.
Logged
AndrewBucklin
Jr. Member
**
Offline Offline

Posts: 24



View Profile WWW
« Reply #2 on: 02/March/2010, 08:05:26 AM »

I'd like to figure out how to do this on order forms as well (too bad it's not available on invoices though).

When you speak of custom code, are you referring to custom PHP code that needs to be edited or something that can be done somewhere from within the admin panel?

Thanks!
Logged
AndrewBucklin
Jr. Member
**
Offline Offline

Posts: 24



View Profile WWW
« Reply #3 on: 02/March/2010, 08:31:22 AM »

I believe I see the code blocks you are talking about under:

Website -> Order Forms -> [The Form] -> Advanced

Correct me if I'm wrong but what I probably need to do is construct a PHP statement and add to the Pre-Calculate Code box that says
    "IF [payment_processor] drop-down box equals "paypal" THEN add x% to order total"

Now I just have to find those variables.   Smiley
Logged
netshine
Administrator
Hero Member
*****
Offline Offline

Posts: 4,563


View Profile
« Reply #4 on: 02/March/2010, 10:48:59 AM »

Yes, you are on the right lines. You can see some sample code for a similar function here: http://www.nbill.co.uk/help/index.php?page=allow-the-user-to-enter-the-amount-to-pay.html. In that example, the custom code picks up a value that the user enters and uses that as the amount to pay, but it could be adapted to check which gateway was selected and add a new entry to the $orders array to add the fee.
Logged
AndrewBucklin
Jr. Member
**
Offline Offline

Posts: 24



View Profile WWW
« Reply #5 on: 04/March/2010, 10:16:57 AM »

I'm really close to getting this to work, just have some questions:

  • In the Pre-Calculate Code block, is there a way to know what the sub-total is?  I'm guessing the answer to this is no, because it's the "Pre-Calculate" block. If there is, I could get rid of my switch statement and just have one line of code that takes that subtotal, multiplies by 2.9% and adds $0.30
  • Also, for the Transaction Fees item I'm adding to the order; how do I tell it to bill this item on a frequency? It defaults as a one-time or up-front only fee. Is there a $order[xxx] variable I can declare with one of the existing frequency codes, such as "CC" ?
  • Finally, $order['product_id']  -- What do I put here? The product ID of the actual product that is being sold on this order form or do I need to create a new "product" for the transaction fee and enter that ID here? If this used for something later down the road?
.
Here is the code I have so far... I'll remove this once I get my solution and will post the final code later as to keep people from getting confused:

Quote
SEE LATER POST BELOW FOR FINAL CODE

Thanks for your help! My trial is going very well and I'm definitely purchasing this soon.   Smiley
-Andrew
« Last Edit: 05/March/2010, 12:47:09 AM by AndrewBucklin » Logged
netshine
Administrator
Hero Member
*****
Offline Offline

Posts: 4,563


View Profile
« Reply #6 on: 04/March/2010, 12:23:43 PM »

In the Pre-Calculate Code block, is there a way to know what the sub-total is?  I'm guessing the answer to this is no
You are correct, the sub-total is not known at that point.

how do I tell it to bill this item on a frequency?
$order['payment_frequency'] = 'CC';
The frequency code you use must be either 'AA' or the same as the order value. In other words you cannot mix different payment frequencies on the same form - the most you can have is one-off plus one other frequency.

$order['product_id']  -- What do I put here? The product ID of the actual product that is being sold on this order form or do I need to create a new "product" for the transaction fee and enter that ID here?
It is safest to create a new product for the transaction fee and use that ID. The product ID is used on the order record, and if you use a made-up value or no value, it could mess up the order record - especially if you ever go into the order and edit it.
Logged
AndrewBucklin
Jr. Member
**
Offline Offline

Posts: 24



View Profile WWW
« Reply #7 on: 05/March/2010, 12:55:48 AM »

Ok, it seems to be working!  Thanks for your help! I certainly appreciate it!  Below is my final code in case someone comes across this thread and is trying to do the same thing.

Note: For my particular application, I choose NOT to tax the transaction fee. Also, this code is not plug-and-play. The numbers will need to be changed to match what you're selling, how much it is, the billing frequency options, the names of the fields on the order form, and that rates and fees specific to your PayPal account. Also, per netshine you should add a product to your product list for this fee and change the product ID in the code to match that new product. If you have any questions about this code I designed, feel free to reply and I'll do my best to answer them.

P.S. I think it might be against PayPal policy to pass down transaction fees to your buyers. I think this is also against the policy of other merchant account and credit card processing companies. If you are worried about this, you might want to call the fee an administrative fee or something.

-Andrew

Code:
// Setup variables needed later
$qty = $_POST['qty_users'];
$frequency = mosGetParam($_POST, 'frequency');
$rate = 0.029;
$trans_fee = 0.30;

if ($_POST['pay_method'] == "paypal") {
// If user selects PayPal for payment method
$order = array();
switch ($frequency) {
// Figure out what the price per unit is
// The depends upon the payment frequency the user selected
// Example: If the user selected monthly payments, they would pay $5 per month
case "CC":
// Paid 1 month at a time
$price = 5;
break;
case "DX":
// Paid 6 months at a time
$price = 30;
break;
case "EE":
// Paid 1 year at a time
$price = 60;
break;
case "FF":
// Paid 2 years at a time
$price = 120;
break;
case "GG":
// Paid 5 years at a time
$price = 300;
break;
}
$order['net_price'] = $price * $qty * $rate + $trans_fee; // If your locality requires administrative fees/transaction fees to be taxed, you'll need to add sales tax to this total
$order['tax_rate'] = 0;
$order['tax_amount'] = 0;
$order['payment_frequency'] = $frequency;
$order['product_name'] = "Online Payment Processing Fee";
$order['quantity'] = 1;
$order['product_id'] = 5; //Change this to whatever your actual product ID is
$orders[] = $order;
}
else {
// Non-paypal payment was selected; don't add anything
}
Logged
AndrewBucklin
Jr. Member
**
Offline Offline

Posts: 24



View Profile WWW
« Reply #8 on: 05/March/2010, 01:51:01 AM »

Something else I just though of that relates to this topic:

I now have online orders adding the PayPal transaction fees to them just fine, but what about the Pay Invoice feature. When I manually generate an invoice and e-mail to a client, they are able to login to their account and pay online. This takes them to PayPal to pay the bill WITHOUT the transaction fees.  Sometimes I'll use the Create Invoice feature for work I've done so the customer can send a check but if they decide they'd rather pay online, I'd like to allow that but also add those fees. Is there an easy way to do this?

If not, is there a way to disable online payment for invoices that are manually generated?  This way, I could find out beforehand if that particular client would like to pay online. If they do, I just add the "Online Payment Fee" product to the invoice when I'm creating it.  If not, I disable online payment of this particular invoice forcing them to pay via check.

Thanks again for all your help and guidance.
Logged
netshine
Administrator
Hero Member
*****
Offline Offline

Posts: 4,563


View Profile
« Reply #9 on: 05/March/2010, 10:48:43 AM »

As noted in my first reply to the original post, above, you cannot add transaction fees to invoices automatically depending on the payment method. What you can do though, in line with your suggestion, is when you create an ad-hoc invoice, set 'show payment link' to 'no' (that stops them being offered the option of paying online). Then if they want to pay online, you can manually add a line for the fee, and set 'show payment link' back to 'yes'.
Logged
AndrewBucklin
Jr. Member
**
Offline Offline

Posts: 24



View Profile WWW
« Reply #10 on: 05/March/2010, 08:06:22 PM »

As noted in my first reply to the original post, above, you cannot add transaction fees to invoices automatically depending on the payment method.
Ah, yes. I'm sorry. I forgot you said that. That's what I get for only sleeping 3 hours per night for the past week working on this thing! haha.

What you can do though, in line with your suggestion, is when you create an ad-hoc invoice, set 'show payment link' to 'no' (that stops them being offered the option of paying online). Then if they want to pay online, you can manually add a line for the fee, and set 'show payment link' back to 'yes'.
That works out just perfectly. I think I actually already knew I could do that; or I probably could have figure it out. Again, must be the lack of sleep last night. Sorry and thank you for reminding me!  Grin
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.16 | SMF © 2011, Simple Machines Valid XHTML 1.0! Valid CSS!