PayPal link
  • seesawseesaw August 2008

    Hi all

    I have been looking at getting a PayPal link to work on my invoices, which I have managed to do (to a point).

    <tr align=center>{if $invoice.owing == 0.00 }<td colspan=6>...</td>
    {else}<td width=100% colspan=6><div align="center" style="font-family: arial; font-size: 12pt; color: blue">
    Secure Online Payment via PayPal

    <form action="https://www.paypal.com/cgi-bin/webscr" target="_blank">

    <input name="amount" value="{$invoice.total}" type="hidden">

    <input name="cmd" value="_xclick" type="hidden">

    <input name="item_name" value="{$customer.name} - Invoice No: {$invoice.id}" type="hidden">


    <input name="business" value="[email protected]" type="hidden">

    <input name="currency_code" value="GBP" type="hidden">

    <input name="submit" src="https://www.paypal.com/en_GB/i/btn/btn_paynow_LG.gif" align="baseline" border="0" type="image">
    </form>
    </div></td>
    {/if}</tr>


    I have put this code in my custom template at the end of the table (before the footer include).

    The code checks to see if there's any amount owing, if not it displays nothing, if there is an amount owing it displays the PayPal button. On pressing the button a new window opens and the customer name, invoice number and amount are passed to PayPal.

    It works perfectly in Print Preview, but I need it to work in PDF, but the form is not active in PDF format.

    Is there any way to change the form into a hyperlink to pass the data to PayPal?

    I know this is a feature a lot of people would like, and I feel that it's almost there except for PDF.

    Any ideas anyone?

    Chris

  • seesawseesaw August 2008

    Just had a thought, is it possible to export or email a HTML file? I know you can just goto "File - Save As", but if you could export with {$invoice.id} or {$customer.name} as the filename that would be better.

    Chris

  • justinjustin August 2008

    Hey Chris

    easist option is to use a hyperlink to pass to paypal

    refer: http://zerodollarchallenge.blogspot.com/2008/05/paypal-donate-link-instead-button.html for details on how to do this

    if you can get this working ok with Simple Invoices please post the details

    Cheers

    Justin

    SmarterInvoices.com :: Simple Invoices hosting | Kelly.org.au :: Simple Invoices custom development | justin.kelly.org.au
  • seesawseesaw August 2008

    Ha! Done it! It's taken most of the day, but it finally works...

    It puts a PayPal button link in your invoice and it works both in Print Preview and PDF.

    It passes the invoice number and the amount to PayPal.

    Here is the code for anyone who wants it.


    {php} echo '<a

    href="https://www.paypal.com/cgi-bin/webscr?cmd=_xclick&business=email@domain%2ecom&item_name

    =' .'Invoice No: ' .

    $invoice[id].'&amount='.$invoice[total].'&no_shipping=0&no_note=1&currency_code=GBP&lc=GB&bn=PP%2dBu

    yNowBF&charset=UTF%2d8" target="_blank"><img

    src="https://www.paypal.com/en_GB/i/btn/btn_paynow_LG.gif" border=0></a>' {/php}


    for the default template it needs to go in
    /templates/invoices/default/template.tpl - make sure you do a back up first

    or for your custom template, use
    /templates/invoices/customfolder/template.tpl

    EDIT: Don't forget to change the &business=email@domain%2ecom portion of the link to include your email address :)

    Have fun

    Happy payment receiving ;)

    Chris

  • seesawseesaw August 2008

    If you want to hide the PayPal button when the invoice is paid, use the IF statement below to surround the above code


    {if $invoice.owing != 0.00 } //this checks to see if owing is NOT equal to 0 ie something owing

    paste paypal link code here

    {/if}


    EDIT: I've just realised I put the wrong "if" statement in. It's all correct now.

    Chris

  • justinjustin August 2008

    Awesome work Chris!,

    When i get to do the paypal integration i'll try and make this alot easier for the end user to setup

    Cheers

    Justin

    SmarterInvoices.com :: Simple Invoices hosting | Kelly.org.au :: Simple Invoices custom development | justin.kelly.org.au
  • seesawseesaw August 2008

    This is wierd... If I add $customer[name] into the link, it doesn't display it, but it doesn't produce an error either.

    When I used the form above, I included {$customer.name} and it worked perfectly.

    Any ideas, anyone?

    Chris

  • justinjustin August 2008

    hey chris

    i would say rewrite the above link using just smarty code (instead of normal php code) if possible

    <a href="https://www.paypal.com/cgi-bin/webscr?cmd=_xclick&business=email@domain%2ecom&item_name=Invoice No:{$invoice.id}&amount={$invoice.total}&no_shipping=0&no_note=1&currency_code=GBP&lc=GB&bn=PP%2dBuyNowBF&charset=UTF%2d8" target="_blank">
    <img src="https://www.paypal.com/en_GB/i/btn/btn_paynow_LG.gif" border=0></a>'

    then stick {$customer.name} in there and hopefulyl it'll work ok

    let us know how you go

    cheers

    justin

    SmarterInvoices.com :: Simple Invoices hosting | Kelly.org.au :: Simple Invoices custom development | justin.kelly.org.au
  • seesawseesaw August 2008

    Justin

    I tried that way first but paypal threw an error up. That's why I went for the form, I know what I'm doing with HTML - but that failed in the PDF. So I went for the crash course in PHP and got a result. I'm just puzzled as to why it will use one variable, but not another. Especially when they're already used in the page.

    Oh well, at least the id and amount work... :)

    Chris

  • seesawseesaw August 2008

    Update:

    I have tried quite a few of the $customer variables, and none of them work. Yet all of the $invoice variables work fine. Could there be something blocking it from passing the data in a link??!!? Just guessing here, I'm not really sure how I got this far ;-)

    Chris

  • justinjustin August 2008

    Hey Chris

    re $customers

    im not to sure re the {php} tag in smarty but referring to http://www.smarty.net/manual/en/language.function.php.php you may need to specify that variable as a global in that section of code

    ie.

    {php}
    global $customer;
    ...
    {/php}


    let me know if this works

    Cheers

    Justin

    SmarterInvoices.com :: Simple Invoices hosting | Kelly.org.au :: Simple Invoices custom development | justin.kelly.org.au
  • seesawseesaw August 2008

    Hi Justin

    That was it, works perfectly now... Thanks

    Here's the new link code with $customer.name included.

    {php} print '<a href="https://www.paypal.com/cgi-bin/webscr?cmd=_xclick&business=payments@it-repairs%2ecom&item_name='.$customer[name].' -

    Invoice No: ' .

    $invoice[id].'&amount='.$invoice[total].'&no_shipping=0&no_note=1&currency_code=GBP&lc=GB&bn=PP%2dBuyNowBF&charset=UTF%2d8"

    target="_blank"><img src="https://www.paypal.com/en_GB/i/btn/btn_paynow_LG.gif" border=0></a>'; {/php}


    At the top of the template.tpl after paste this:
    {php}
    global $customer;
    {/php}


    Chris

  • magdevmagdev August 2008

    What type of paypal payment solution i need setup for this?

  • seesawseesaw August 2008

    This works with a standard paypal account - no extras are required for it to work. Obviously PayPal charge you per transaction.

    The only thing extra I have done is set up a "Custom Payment Page" with my banner in my PayPal account. In PayPal goto Profile - Custom Payment Pages

    Chris

  • justinjustin August 2008

    Thanks for the update Chris,

    i'll try and integrate PayPal into Simple Invoices in the near future so its easy for a normal user to add in paypal links etc..

    Cheers

    Justin

    SmarterInvoices.com :: Simple Invoices hosting | Kelly.org.au :: Simple Invoices custom development | justin.kelly.org.au
  • seesawseesaw April 2009

    This now needs altering for Beta 3

    Replace the above code with this:


    <a href="https://www.paypal.com/cgi-bin/webscr?cmd=_xclick&business={$biller.email}&item_name={$customer.name}
    - Invoice No:{$invoice.id}&amount={$invoice.total}&no_shipping=0&no_note=1&currency_code=GBP&lc=GB&
    bn=PP%2dBuyNowBF&charset=UTF%2d8" target="_blank"><img src="https://www.paypal.com/en_GB/i/btn
    /btn_paynow_LG.gif" border=0></a>

  • justinjustin April 2009

    Thanks for the update Chris

    Cheers

    Justin

    SmarterInvoices.com :: Simple Invoices hosting | Kelly.org.au :: Simple Invoices custom development | justin.kelly.org.au
  • cjohnsoncjohnson May 2009

    thank you for the Paypal info.

    I am getting an error from Paypal when I click on the "Pay Now" Button.
    I get
    "The link you have used to enter the PayPal system contains an incorrectly formatted item amount."

    I am working in USD and have changed the paypal link to the correct codes as below.

    Any Ideas what might be going on?

    Thanks

    a href="https://www.paypal.com/cgi-bin/webscr?cmd=_xclick&business=johnson03055@msn%2ecom&item_name={$customer.name}
    - Invoice No:{$invoice.id}&amount={$invoice.owing}&no_shipping=0&no_note=1&currency_code=USD&lc=US&
    bn=PP%2dBuyNowBF&charset=UTF%2d8" target="_blank">image

  • justinjustin June 2009

    Hey CJohnson,

    I would say the @ in the email address is the problem
    - can't say for sure but try changing the @ to @

    let us know how you go

    refer: http://www.ascii.cl/htmlcodes.htm

    Cheers

    Justin

    SmarterInvoices.com :: Simple Invoices hosting | Kelly.org.au :: Simple Invoices custom development | justin.kelly.org.au
  • cjohnsoncjohnson June 2009

    Sorry I have been away for a bit. I will try what you suggest and post back.

    Thanks again

  • cjohnsoncjohnson June 2009

    Justin,

    I tried what you suggested. It did not fix the problem but I think I know what is going on, but not how to fix it.

    It seems like when the url is generated it is putting a ' mark before teh amount. I found this by simply typing into the code a hard price like amount=5.95. it shows up in the url as
    amount=%275%2e95.

    The %27 is the tick mark. if I copy the generated url created by teh PPay Now Button and simply delete the tick mark in front of the amount then the payment can be made. I do not know what is puttin the tick mark into the generated URL?????

    Any thoughts????

  • seesawseesaw July 2009

    Hi cjohnson

    The code you have listed above
    a href="https://www.paypal.com/cgi-bin/webscr?cmd=_xclick&business=johnson03055@msn%2ecom&item_name={$customer.name}
    - Invoice No:{$invoice.id}&amount={$invoice.owing}&no_shipping=0&no_note=1&currency_code=USD&lc=US&
    bn=PP%2dBuyNowBF&charset=UTF%2d8" target="_blank"><img src="https://www.paypal.com/en_US/i/btn/btn_paynow_LG.gif" border=0>


    has the field {invoice.owing} but this should be {invoice.total}

    Try changing it and it should work fine...

    Chris

  • seesawseesaw July 2009

    As for getting the email address in correctly, the way I have done it is to add a custom field in my Biller section called PayPal Payee. This is set to the email address I use for payments, which is different from my main address.

    Then in the link code change the email address to {$biller.custom_field2}
    just make sure you use the correct number for the custom field code

    Hope this helps

    Chris

  • cjohnsoncjohnson July 2009

    SeeSaw,

    I originally had invoice.total and had the same problem. I had changed it to invoice.owing to see if it would work and it is really the amount you want to charge the person since there can be partial payments.

    Thanks for taking the time to respond

  • justinjustin July 2009

    hey guys

    thanks seesaw for the replies - do you the paypal link working with the latest 2009.1 beta 5 release?

    cheers

    justin

    SmarterInvoices.com :: Simple Invoices hosting | Kelly.org.au :: Simple Invoices custom development | justin.kelly.org.au
  • seesawseesaw September 2009

    Hi Justin

    I haven't got around to trying beta 5 yet so I don't know... As soon as I get the time I will try it out.

    Cheers

    Chris

  • noticznoticz November 2009

    Ok after an hour or scratching my head I found a great work around for this paypal integration on the invoices..

    first modify your tables for some reason the database structure is setup for 6 decimal points which I have no clue why at all.

    alter table si_products modify unit_price decimal(25,2) default '0.00';
    alter table si_invoice_items modify gross_total decimal(25,2) default '0.00';
    alter table si_invoice_items modify tax_amount decimal(25,2) default '0.00';
    alter table si_invoice_items modify unit_price decimal(25,2) default '0.00';
    alter table si_invoice_items modify quantity decimal(25,2) default '0.00';
    alter table si_invoice_item_tax modify tax_rate decimal(25,2) default '0.00';
    alter table si_invoice_item_tax modify tax_amount decimal(25,2) default '0.00';
    alter table si_payment_types modify ac_amount decimal(25,2) default '0.00';
    alter table si_tax modify tax_percentage decimal(25,2) default '0.00';

    second insert the following code in the footer of the file templates/invoices/default/template.tpl and substitute and spaces with a + sign you don't have to worry about periods just spaces.

    {if $invoice.owing != 0.00 }
    Pay your Invoice, Quote or Estimate with PayPal

    image
    {/if}

  • justinjustin November 2009

    thanks noticz forthe paypal code

    re 6 decimal places
    - some people where complaining that 2 wasn't enough for them

    instead of removing the 6 decimal places in the db you can use the siLocal_number smarty modifier to do the same on the value

    {$invoice.total|siLocal_number}

    thanks again

    cheers

    SmarterInvoices.com :: Simple Invoices hosting | Kelly.org.au :: Simple Invoices custom development | justin.kelly.org.au
  • imzimz February 2010

    Thanks Noticz, I've implemented your solution to adding a PayPal link into the invoice and it works great.

  • justinjustin February 2010

    @imz
    - great to hear it worked
    - in Simple Invoices 2010.2 Paypal payment and receipts will be integrated into Simple Invoices

    cheers

    justin

    SmarterInvoices.com :: Simple Invoices hosting | Kelly.org.au :: Simple Invoices custom development | justin.kelly.org.au
  • parkerparker July 2010

    Great work and good idea.I like it so much.

  • justinjustin July 2010

    thanks parkers

    refer http://www.simpleinvoices.org/wiki/paypal for more infor

    cheers

    justin

    SmarterInvoices.com :: Simple Invoices hosting | Kelly.org.au :: Simple Invoices custom development | justin.kelly.org.au
  • mjnshostingmjnshosting December 2011

    For anyone who came to this page because of the %27 aka the tick mark (') in the front of the amount that messes up your paypal link. I had the same issue and used the code that was posted in the "No Labels" template. I posted my full code on the "No Labels" template page as well to act as a point of reference. The issue I had with the fix though was possibly due to browser misinterpreting double quotes and other characters causing more of a headache due to mangled code that was good to begin with. I hope this helps cut down on the time it takes to get your instance running. Now all exported docs work properly, but more testing to be done.

    http://www.simpleinvoices.org/wiki/template_-_no_labels

    <a href="https://www.paypal.com/cgi-bin/webscr?cmd=_xclick&business=email@domain%2ecom&item_name={$customer.name} - Invoice No: {$invoice.id}&amount={$invoice.total}&no_shipping=0&no_note=1&currency_code=USD&lc=US&bn=PP%2dBuyNowBF&charset=UTF%2d8" target="_blank"><img src="https://www.paypal.com/en_US/i/btn/btn_paynow_LG.gif" border=0></a>

    Running on a Ubunu 10.04 LTS server VM

    A+,CCENT,CCNA and business owner tired of exporting XLS to PDF to a SMB share and calling it accounting! :)
    Ubuntu 10.04 LTS in VM on Proxmox (sweet!)
  • modirmodir December 2011

    Thank you. But be aware that this is the old wiki. We have a new one here:
    http://code.google.com/p/simpleinvoices/w/list

    The old one will be shut down soon.

  • mjnshostingmjnshosting December 2011

    Yes i noticed the post talking about the move. But i still find alot here so i post of both pages to make sure people actually see the fixes/work-arounds that I have seen myself. Plus thats where i found the link in my previous post. By the way,THANKS for all the good work you guys have done.

    A+,CCENT,CCNA and business owner tired of exporting XLS to PDF to a SMB share and calling it accounting! :)
    Ubuntu 10.04 LTS in VM on Proxmox (sweet!)
  • dhumphryesdhumphryes January 29

    i have gotten it to work, except it wont pass the invoice number or a total to paypal

    below is what i have

    {if $invoice.owing != 0.00 }
    {php} print '
    Invoice No: ' .

    $invoice[id].'&amount='.$invoice[owing].'&no_shipping=0&no_note=1&currency_code=USD&lc=US&bn=PP%2dBuyNowBF&charset=UTF%2d8"

    target="_blank">image
    '; {/php}
    {/if}

  • mjnshostingmjnshosting February 7

    Nice. I decided to just add the code from the included template that comes with SI to the no labels template. Check out my post there for examples. I love the no labels template so much. Also i couldn't get that either and gave up on it. The name is cool i guess the number is just nice looking. Also when paypal posts the payment it does it to the right invoice because the invoice ID is different than the invoice number.

    A little annoying but not a big deal and i can change it via phpmyadmin anyway. So Invoice 33 has the ID 19 and paypal will post it properly. Also the button in the default template is cooler, well to me at least

    A+,CCENT,CCNA and business owner tired of exporting XLS to PDF to a SMB share and calling it accounting! :)
    Ubuntu 10.04 LTS in VM on Proxmox (sweet!)

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Sign In Apply for Membership

Categories