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

Gravity Forms FreeAgent Integration Add-on

Updated 10 min read Gravity Forms Integrations A–Z
On this page
  1. What you need
  2. Step 1: Create your FreeAgent app
  3. Step 2: Connect (Forms, Settings, FreeAgent)
  4. Step 3: Create a feed (Form, Settings, FreeAgent)
  5. The contact
  6. The invoice
  7. What happens when someone submits the form
  8. Merge tags and notifications
  9. Retries and safety
  10. Entry list actions
  11. For developers
  12. Updating from version 1.0.1
  13. What the add-on does not do
  14. Troubleshooting
  15. Privacy

The Gravity Forms FreeAgent Add-On creates invoices in your FreeAgent account from Gravity Forms entries. For each matching entry a background job finds the customer in your FreeAgent contacts by e-mail address (or creates the contact), then creates an invoice from the form’s product fields or from a table of lines you define. It connects to FreeAgent with your own FreeAgent developer app (OAuth), so the invoices appear in your own account and nothing passes through a GravityExtra server.

What you need

  • WordPress 5.8 or newer, PHP 7.4 or newer, Gravity Forms 2.5 or newer.
  • A FreeAgent account (a sandbox account is enough for testing) and a developer app in the FreeAgent Developer Dashboard (dev.freeagent.com). Creating an app is free; FreeAgent’s API terms apply to the app you create.
  • The FreeAgent user who connects the add-on needs access to invoices (the “Estimates and Invoices” access level or higher). Sending address details of a contact may also need FreeAgent’s Contacts and Projects permission.
  • A Gravity Extra licence key (Forms, Settings, FreeAgent).

Step 1: Create your FreeAgent app

  1. Sign in at dev.freeagent.com and create a new app.
  2. Open Forms, Settings, FreeAgent on your site. The page shows the redirect address of your site (it ends in /wp-json/gravityextra-freeagent/v1/callback). Add exactly that address as a redirect address of your app.
  3. Copy the app’s OAuth identifier and OAuth secret.

Step 2: Connect (Forms, Settings, FreeAgent)

  1. Activate your licence key.
  2. Paste the OAuth identifier and the OAuth secret and click Save Settings. The secret is stored encrypted with your site’s security keys and is never shown again. Leave the box empty on later saves to keep it, type a new one to replace it, or tick Remove the stored OAuth identifier, secret and tokens when saving. If you change the WordPress security keys (AUTH_KEY, SECURE_AUTH_KEY and their salts), enter the secret and connect again.
  3. Click Connect to FreeAgent. FreeAgent asks you to allow the app. When you allow it, you come back to the settings page and it shows the name of your company. The access token and the refresh token are stored encrypted. The access token is renewed automatically when it ends.
  4. Click Check the connection at any time: the add-on reads your FreeAgent company and creates nothing.

FreeAgent connection and licence settings in Gravity Forms

Setting What it does
Use the FreeAgent sandbox Sends every call to api.sandbox.freeagent.com instead of the live service. Use a sandbox app and a sandbox company. Changing it ends the connection. For a sandbox invoice no web link is made.
Default payment terms (days) Used by feeds that set no payment terms. 0 prints “Due on Receipt”. Default 30.
Daily cap of invoices Stops creating invoices for the rest of the day (UTC) once this many were created by all feeds. Empty or 0: no cap.

If the connection ends (you removed the app’s access in FreeAgent, or changed the OAuth identifier), the settings page says “Connect again”, orders that arrive meanwhile get a note and no request is sent, and you connect again with one click.

Step 3: Create a feed (Form, Settings, FreeAgent)

FreeAgent feed settings in Gravity Forms: contact, invoice and lines

The contact

  1. Give the feed a name.
  2. In Contact, map the form fields to the FreeAgent contact: the e-mail is required; FreeAgent also needs an organisation name, or a first and a last name. If your form has one name field, map it to Full name: it is split at the last space. Phone, address lines, town, region, postcode and country are optional.
  3. Choose Existing contacts:
    • Find by e-mail, create when none (recommended): the add-on looks through your active FreeAgent contacts (the first 4,000) for the same main e-mail address and invoices that contact; it creates a contact only when none matches. It never changes an existing contact. A contact it found or made is remembered (as a hash, not the address) and checked with one request the next time.
    • Always create a new contact.

The invoice

  1. Invoice lines from:
    • The form’s product fields: one line per product (name, price, quantity). Option fields add their price to the unit price and their choice to the description, and a shipping field becomes a “Shipping” line. Lines with a price or quantity of 0 are skipped. An order with a negative price is not sent at all, because the invoice total would be wrong.
    • A table of description and amount: each row is one line with quantity 1. Type the description (merge tags work) and pick a field or type an amount (merge tags work; “1,200.50” and “15,5” are read as numbers). A typed description is saved by Gravity Forms as gf_custom with the text in custom_key, and a typed amount as gf_custom with the text in custom_value; the add-on reads both.
  2. Item type (Products, Services, Hours, Days, Weeks, Months, Years, Training, Expenses), an optional sales tax rate (one of the standard rates of your FreeAgent company) and an optional sales category address (for example https://api.freeagent.com/v2/categories/001) are sent with every line.
  3. Invoice date: the date of the entry in your site’s time zone, or the day the invoice is created. Payment terms: the feed’s days, or the default of the settings page.
  4. Currency: the currency of the form is sent with the invoice (FreeAgent refuses it when that currency is not enabled for your company, and the entry note says so), or choose the currency of the FreeAgent company, which sends none.
  5. Optional invoice reference, PO reference and text at the bottom of the invoice, all with merge tags (HTML is removed). With an empty reference FreeAgent uses its next number.
  6. After creating the invoice: leave it as a draft (FreeAgent always creates invoices as drafts), or mark it as sent. Marking as sent sends no e-mail. The add-on never e-mails an invoice.
  7. Use Condition to create the invoice only for some entries. A form can have several feeds.

FreeAgent contact and invoice fields mapped from Gravity Forms fields

What happens when someone submits the form

  1. The entry is saved and the visitor sees the confirmation at once. The add-on only queues a background job; it never makes the visitor wait for FreeAgent and an error never reaches the visitor.
  2. The job builds the contact and the lines from the entry, checks them (an invalid e-mail, a missing name, a negative price, a text that is not an amount or an order with nothing to invoice is refused before anything is sent, with a note on the entry), finds or creates the contact and creates the invoice.
  3. The entry gets a note with the invoice reference, id, total and a link to the invoice in FreeAgent. When FreeAgent’s total differs from the form’s total (because of a tax rate or a rounding) the note says so.
  4. The entry page has a FreeAgent box with the status, invoice and link.

FreeAgent invoice result shown in the Gravity Forms entry

Merge tags and notifications

Merge tag Value
{freeagent_invoice_ref} The invoice reference
{freeagent_invoice_id} The invoice id in FreeAgent
{freeagent_invoice_url} The address of the invoice in your FreeAgent account (live service only)
{freeagent_contact_id} The contact id in FreeAgent
{freeagent_total} The invoice total as FreeAgent has it
{freeagent_status} ok, fail, retrying, queued or sending

Add _<feed id> to a tag to read a particular feed (for example {freeagent_invoice_ref_12}); without it the newest result of the entry is used. The tags are empty until the invoice exists. Two notification events are offered on forms that have a feed: FreeAgent: the invoice is created and FreeAgent: the invoice failed; each is sent once, after the result.

Retries and safety

  • Temporary problems (FreeAgent unreachable, HTTP 5xx, 408, 429) are retried in the background after 1 minute, 5 minutes, 30 minutes, 2 hours and 12 hours (6 attempts); a longer Retry-After from FreeAgent is respected. A contact that was made is reused by the next attempt.
  • Never sent twice after it left: when a request that creates a contact or an invoice may have arrived but the answer did not (a timeout, a connection reset, or a success answer that is not the record), the add-on does not repeat it. The note says to look in FreeAgent, and Send to FreeAgent again in the entry list makes it on purpose. “Skip finished” never redoes such an entry. A later try finds a contact that was made by e-mail, so no duplicate contact appears.
  • Refusals are final and shown with FreeAgent’s own words (for example the currency is not enabled, or the user’s access level is too low).
  • One job per entry and feed at a time; a finished entry is never invoiced again by a repeated job.
  • The FreeAgent limits (120 requests a minute, 3,600 an hour, 15 token renewals a minute per user) are respected: a 429 is waited out, and only one process renews the access token at a time.
  • The OAuth redirect is checked: the return address is only accepted with a signed, single-use state tied to a signed-in administrator, and expires after 15 minutes. Anything else is refused and nothing is exchanged.
  • The OAuth secret and tokens are stored encrypted, never shown, never put in a note or a log, and only sent to api.freeagent.com (api.sandbox.freeagent.com in sandbox mode).

FreeAgent offers no webhooks for invoices, so the add-on has no webhook address to protect and never waits for a call from FreeAgent.

Entry list actions

  • Send to FreeAgent (skip finished) queues entries that have no invoice yet.
  • Send to FreeAgent again (creates another invoice) creates a new invoice for the chosen entries, in groups of 5.

For developers

Hook Use
gform_freeagent_invoice (filter) Receives array( 'contact' => ..., 'invoice' => ... ) (the contact attributes; the invoice items, dated_on, terms, currency, comments, reference, po_reference), the feed and the entry before anything is sent. Return the array, or something that is not an array to cancel (the entry gets a note).
gfa_invoice_created (action) Fires after the invoice exists: the result (contact, invoice address, reference, total, currency, sent), entry, feed, form.
gfa_failed (action) Fires when no invoice could be made: entry, feed, form, message.
gfa_redirect_uri (filter) The OAuth redirect address, for sites whose public address differs from the site address. It must be the address registered in your FreeAgent app.

Updating from version 1.0.1

Version 1.0.1 never created a real invoice: it invented a customer id and posted a made-up body without a working connection. Install this version over the old plugin (same folder and file). Your licence key and your feeds are kept. The access token and the business id typed in 1.0.1 are removed (a notice on the settings page says so); connect with OAuth as described above. An old feed keeps its choice of contact name field, contact e-mail field and product-field lines; open it once and check the mapping. Invoices are no longer marked as paid from the payment status: payments are not recorded in FreeAgent by this add-on.

What the add-on does not do

  • It does not record payments, create estimates, credit notes, bills or expenses, e-mail invoices, attach files or update an existing contact.
  • It does not create projects or price list items, and it does not read invoices back.
  • The accountancy practice API (access to clients’ accounts from a practice dashboard) is not used.

Troubleshooting

Entry note or message What to do
FreeAgent is not connected Save the OAuth identifier and secret, then click Connect to FreeAgent.
FreeAgent did not accept the approval Check the identifier and secret, and that the redirect address of the settings page is registered for your app.
The connection ended / Connect the add-on to FreeAgent again FreeAgent refused to renew the access token (the app’s access was removed or the secret changed). Click Connect again.
FreeAgent refused access (403) The connected FreeAgent user needs the Estimates and Invoices access level (or higher); address details of a contact may also need the Contacts and Projects permission.
FreeAgent did not accept the data (…) The text in brackets is FreeAgent’s reason, for example a currency that is not enabled for your company. Fix the feed or FreeAgent, then use “Send to FreeAgent again”.
The contact needs an organisation name, or a first and a last name Map one of them in the feed.
… may or may not have been created … not repeated Look in FreeAgent. If the record is missing, use “Send to FreeAgent again”.
The daily cap … is reached Raise the cap, or use “Send to FreeAgent again” tomorrow.

Privacy

When a feed is active, the contact details (name, e-mail address, phone, address) and the order lines of a submitted form are sent to FreeAgent (api.freeagent.com) to find or create a contact and create an invoice in your FreeAgent account. FreeAgent processes the data under its own terms. The add-on adds this to the WordPress privacy policy guide.

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