We recently added invoices to Browserling. I thought I'd share how we did it as it's another interesting story.

Our customers keep asking for invoices all the time so we made it simple to create them. They can now just go to their Browserling accounts and download them. Here's how an invoice looks like:


Example invoice. (Download example.)

And here are the implementation details.

We use a node module called invoice. The invoice module takes a hash of invoice details, internally spawns pdflatex that creates a pdf invoice, and then calls a callback with the path to the pdf file, like this:

var invoice = require('invoice');
invoice(
    {
        template: 'browserling-dev-plan.tex',
        from: "Browserling inc\\\\3276 Logan Street\\\\Oakland, CA 94601\\\\USA",
        to: "John Smith\\\\Corporation Inc.",
        period: "2/2013",
        amount: "$20"
    },
    function (err, pdf) {
        if (err) {
            console.log("Failed creating the invoice: " + err);
            return;
        }
        console.log("Pdf invoice: " + pdf);
    }
);

The browserling-dev-plan.tex latex template contains %to%, %from%, %period%, and %amount% place holders that the invoice module simply replaces with the given data:

\documentclass[12pt]{article}

\pagenumbering{gobble}

\begin{document}

\begin{center}
\Large{\textbf{Invoice}} \\
\vspace{0.5cm}
\large{Subscription to Browserling's Developer Plan}
\end{center}

\vspace{1cm}

\section*{Invoice from:}
%from%

\section*{Invoice to:}
%to%

\section*{Period:}
%period%

\section*{Amount:}
%amount%

\end{document}

Once the pdf invoice is generated, we create a token that maps to the pdf file, and once it's requested, we send it to the customer as an application/pdf.

Until next time!

Comments

February 27, 2014, 17:12

Did you put the all important Invoice # on the actual invoices?

I guess I could login and check but it's more fun to be the first to comment.

February 27, 2014, 19:33

Hmm, no I don't. All these payments are automatic so we can track what's been paid. I guess it would matter if the invoices were paid by check. Then it would be harder to track, which payment is for which invoice. Is that right?

February 28, 2014, 16:03

Did you put the all important Invoice # on the actual invoices?
indian escort in dubai //
indian pakistani escort in dubai //
pakistani escort in dubai //

March 03, 2014, 10:25

Really nice idea so maybe try it....

March 24, 2014, 12:20

Super idea is that

March 25, 2014, 11:58

So amazing is the point of view

March 30, 2014, 13:38

I am fascinated about that subject

April 08, 2014, 10:12

Very nice Idea...I really want to learn more about that.
Proweb365 is a Minneapolis web design firm!

April 14, 2014, 04:48

It goes like this: Your company puts out an ad for a position and someone "answers" it, but also installs malicious software on a small business computer and uses it to log into the company online bank account. They then set up fraudulent fund transfers, adding fake employees or payees, and finally move the money to offshore havens. government.

Leave a new comment

(why do I need your e-mail?)

(Your twitter name, if you have one. (I'm @pkrumins, btw.))

Type the first letter of your name: (just to make sure you're a human)

Please preview the comment before submitting to make sure it's OK.

Advertisements