🎉 Celebrate with 10% OFF on All Products! Use Code: GFEX10 Or Buy Any 2+ Items for 30% OFF with Code: GFEX30!

Gravity Forms Invoice Ninja Premium Add-on Setup Guide

Updated 8 min read Gravity Forms Integrations A–Z
On this page
  1. Video walkthrough
  2. What you need
  3. Connect your Invoice Ninja
  4. How the token is protected
  5. Self-hosted Invoice Ninja
  6. Create a feed
  7. What to create
  8. The client
  9. Line items for a quote or invoice
  10. Notes, dates and status
  11. Conditions
  12. What you see after a submission
  13. For developers
  14. Questions
  15. Does it work with the free self-hosted Invoice Ninja?
  16. Can I create a recurring invoice, a payment or a project?
  17. What happens to my data if I remove the add-on?
  18. Does it send anything to GravityExtra?

Video walkthrough

Gravity Forms Invoice Ninja Add-On Setup Guide: API Token, Quote Feed & Products (WordPress Side)
Video setup guide: Gravity Forms Invoice Ninja Watch on YouTube

The Gravity Forms Invoice Ninja Premium Add-on turns a Gravity Forms submission into something in your Invoice Ninja account: a client, a client with a quote, or a client with an invoice. It works with the hosted Invoice Ninja and with a self-hosted Invoice Ninja version 5, and it talks to Invoice Ninja with an API token that you create yourself. The token is stored encrypted on your site.

You set it up once as a feed on each form, in the same way as any other Gravity Forms feed: pick the fields for the client, write the line items, save. From then on every submission that meets your condition creates the records, and the entry gets a note for each step.

What you need

  • WordPress 6.5 or newer and PHP 7.4 or newer, with the PHP openssl extension (it is on almost every host).
  • Gravity Forms 2.9 or newer. The add-on is tested with Gravity Forms 3.1.2 on PHP 8.3 and Gravity Forms 2.9.8 on PHP 7.4.
  • An Invoice Ninja account (hosted or self-hosted version 5) and an API token of a user who may create clients, quotes and invoices.
  • An active license key for this add-on.

If Gravity Forms is missing or older than 2.9, the add-on shows a notice in the WordPress admin and does nothing else.

Connect your Invoice Ninja

  1. Install and activate the add-on after Gravity Forms.
  2. In Invoice Ninja, open Settings → Account management → API tokens and create a token. Copy it.
  3. In WordPress open Forms → Settings → Invoice Ninja and enter your license key.
  4. Type the address of your Invoice Ninja. For the hosted service this is https://invoicing.co, which is already filled in. For your own installation use its address, for example https://billing.yourcompany.com. Do not add /api/v1: the add-on adds it, and removes it if you paste it.
  5. Paste the API token and save. Then press Test connection. A green message with your company and user name means the address and the token work. The test creates nothing in Invoice Ninja.
The Invoice Ninja settings screen with the address, the masked API token and the Test connection button showing Connected
The connection: the address, the API token (stored encrypted) and a test that creates nothing.

How the token is protected

The token is encrypted with AES-256-GCM before it is written to the database, with a key derived from the secret keys of your WordPress site. The settings screen never shows it again, it is never written to a log or to an entry note, and an error message from Invoice Ninja is cleaned of it. If you prefer to keep it out of the database altogether, define GEIN_TOKEN in wp-config.php. The constant is then used, and the settings screen says so.

Self-hosted Invoice Ninja

A self-hosted Invoice Ninja can use any address that starts with https, with a port or a sub folder, for example https://example-host:8443/ninja as the root of the installation. Two protections apply, and they matter on a self-hosted server.

  • Private addresses are refused. An address that points to the inside of a network (localhost, 10.x.x.x, 192.168.x.x, 169.254.x.x, a name ending in .local or .internal, or a name that resolves to such an address) is refused, so a mistyped or hostile setting cannot make your site call something inside your network. If your Invoice Ninja really runs inside your own network, allow that one host with the gein_allow_private_hosts filter.
  • Plain http is refused. The token travels in a header, so https is required. A test setup can allow http with the gein_allow_insecure_http filter.

The add-on also never follows a redirect, so the token cannot be passed on to another address, and it always verifies the certificate.

Create a feed

Open the form, go to Settings → Invoice Ninja and add a feed.

What to create

  • A client: only the client is made.
  • A client and a quote: the client, then a quote for that client.
  • A client and an invoice: the client, then an invoice for that client.

With Existing client ticked (the default) the add-on first asks Invoice Ninja for an active client that has a contact with the same e-mail address. If one exists, no second client is made and the quote or invoice is put on the existing client. Nothing of the existing client is changed. Deleted and archived clients are never reused. Untick it to always create a new client.

The Invoice Ninja feed screen: what to create, the client fields, the line items box and the options for notes, dates, mark as sent and e-mail
One feed: what to create, the client, and the quote or invoice.

The client

Each box takes text and merge tags. Use the merge tag button at the right of the box to pick a field. The client name can be a company field. If it is empty, the first and last name of the contact are used, and if those are empty too, the e-mail address. The e-mail address must be valid to be sent; an invalid one is left out. You can fill the contact first and last name, e-mail and phone, the address in two lines, the city, state, postal code and country, the VAT number and the website.

For the country, give a two letter code such as US or DE. The country of a Gravity Forms Address field is turned into its code for you.

Line items for a quote or invoice

Write one item per line, with the parts separated by a vertical bar:

  • quantity | description | unit price, for example 2 | Website audit | 150
  • description | unit price, for example Setup fee | 50, which means a quantity of 1

Every part accepts merge tags, so {Hours:7} | {Service:6} | 150 bills the hours the visitor typed at a fixed rate for the service they chose. Prices may be written as 1,250.50, 1.250,50 or with a currency sign; negative amounts are refused. The line items are split into lines and parts before the merge tags are replaced, so a visitor who types a vertical bar or a new line in an answer cannot add items or change a price. A line that cannot be used is skipped and the entry note says how many were skipped. If no usable line is left, nothing is created at all, so you never get an empty client or an empty quote.

Tick Product fields to also add the Product fields of the form as line items: each product with its quantity and price, each chosen option on its own line, and the shipping if the form has it. This lets an order form become an invoice without writing any line items.

Notes, dates and status

  • Public notes and Terms are shown to the client on the document. Private notes are only for your team: a good place for the entry number or the answers.
  • PO number, Date and Due date or valid until take merge tags. Dates are sent as year-month-day; the common form date formats are converted. Empty means Invoice Ninja uses today and the payment terms of the client.
  • Mark the document as sent asks Invoice Ninja to set the status to sent, without an e-mail.
  • Let Invoice Ninja e-mail the document asks Invoice Ninja to send it to the client with your own e-mail settings and template. It is off by default so that you can look at the first documents before any customer gets one. It needs a valid client e-mail address.

All text is cleaned to plain text before it is sent: HTML tags and control characters are removed and long text is cut to a safe length.

Conditions

Use the Condition box to create the records only for some submissions, for example only when a field says the visitor wants a quote.

What you see after a submission

The entry gets a note for each step: client created or existing client used, then Quote Q0001 created or Invoice 0001 created with the link of the client portal when Invoice Ninja gives one. The client number and the document number are also kept as entry meta, so you can show them in the entries list or in an export.

A Gravity Forms entry with two notes from the add-on: client created and Quote Q0001 created
The entry keeps a note for every step, so you can see what was made.

If something fails, the note says what and why, with the answer of Invoice Ninja (for example the field it did not accept) and never with the token. A failure after the client was created leaves the client in place and keeps its id on the entry; the next submission by the same person reuses it. Failures are also written to the Gravity Forms log when logging is on.

The visitor sees only your normal confirmation. The calls to Invoice Ninja are made on the server after the submission, and nothing about them is shown on the page.

For developers

  • gein_client_input filters the client data before it is sent; gein_document_input filters the quote or invoice data (line items, notes, dates).
  • gein_client_ready runs when the client id is known, gein_document_created after a quote or invoice was made and gein_failed when a call failed.
  • gein_allow_private_hosts, gein_allow_insecure_http, gein_timeout and gein_http_args control the connection.

Questions

Does it work with the free self-hosted Invoice Ninja?

Yes. It uses the standard version 5 REST API with an API token. Version 5 of Invoice Ninja is the one the API reference describes.

Can I create a recurring invoice, a payment or a project?

Not in this version. It creates clients, quotes and invoices, which is what a form normally starts.

What happens to my data if I remove the add-on?

Deleting the add-on removes its own settings, including the encrypted token. Clients, quotes and invoices already created in Invoice Ninja are left as they are.

Does it send anything to GravityExtra?

Only the license check and the update check. Your form data goes only to the Invoice Ninja address you typed.

Still need help?

Our support team answers tickets every day, usually within a few hours.

0
0
Your Cart
Your cart is emptyReturn to Shop
🔥 FREQUENTLY BOUGHT TOGETHER
Complete Combo & Save 40%!
ITEM IN YOUR CART
Gravity Forms Klaviyo Add-on
$39.00/yr
+
🎁 RECOMMENDED ADD-ON SAVE 40% OFF
Original Price: $39.00/yr
Bundle Special Price: $23.40/yr