top of page

Calculated Merge Fields

Actionstep has an awesome feature called "Calculated Merge Fields" which allows you, or your implementation partner create custom merge fields for your Actionstep documents and emails.

To implement the "Pay Now" button,  you must have the following:

  • An active Actionstep instance

  • An active LegalCollect instance; with

    • Email reminders active; and​

    • A subscription to the LegalCollect FatZebra payment gateway

Using Calculated Merge Fields we can create a "Pay Now" link or button that can be used in invoices generated from Actionstep. 

Note this Actionstep feature is typically only available to users with "Admin" access and is considered an advanced feature - if you don't have experience working with Actionstep's merge fields, or document assembly it is recommended that you ask your Actionstep implementation partner, or us for assistance. 

Below you will find technical instructions for how to create the calculated merge fields that can be used in your documents (invoices) and emails - this page does not cover creating/editing the document themselves as it's assumed you have the knowledge to do that already.

Invoice Word No Frame.png

Pay Now Button

Add a "Pay Now" button to your Actionstep invoices & emails.

Step 1. Balance Due Merge Field

You'll need to create two "Calculated Merge Fields" to facilitate a "Pay Now" button, the first is to determine the current amount due on an invoice formatted in a way that doesn't include a dollar sign or thousand separator - this is important as the amount is used as a parameter in an API call and must not include any special characters.

  1. Login to Actionstep

  2. Navigate to "Admin > Document Assembly"

  3. Click on "Merge Field List"

 

Here you will see a list of all your existing merge fields in Actionstep that can be used in documents and emails.

  1. Click "Add Calculated Field" (top right)

  2. Set the "Merge Field Name" to "SP_BalanceDueInvoice"

  3. Copy and paste the below code (all the green text) in the "Calculation Code" section

//Author: Leslie Leahy
//Date: 26/02/2024
//Purpose: This field generates the balance due on an invoice without a dollar sign or thousand separator

$A = (floatval(str_replace(array('$', ','), '', '[[SP_TotalInclusive]]')));
$B = (floatval(str_replace(array('$', ','), '', '[[SP_FeeDiscountAmount]]')));
$X = $A + $B;
$Y = (floatval(str_replace(array('$', ','), '', '[[SP_FeeDiscountAmount]]')));
$Z = (floatval(str_replace(array('$', ','), '', '[[SP_TrustTotalAppliedOnInvoiceCreatedDate]]')));
$calculation = $X - $Y - $Z;
echo '$' . number_format($calculation, 2);

  1. It should look the same as the screenshot on the right

  2. Click "Save" to save your new merge field

SP_BalanceDue.png

Instructions

Next we need to create the merge field for the actual "Pay Now" button/link.

  1. Click "Add Calculated Field" (top right)

  2. Set the "Merge Field Name" to "LegalCollectPayNowLink"

  3. Copy and paste the below code (all the green text) in the "Calculation Code" section

//Author: Leslie Leahy
//Date: 26/02/2024
//Purpose: This field generates the URL required for the LegalCollect payment gateway

//Set the LegalCollect base URL from the Payment Gateway settings screen
$BaseURL = '
<<YOUR PAYMENT GATEWAY LINK GOES HERE>>/';

//The invoice number of the ActionStep invoice
$INVNo = '[[SP_OurReference]]';

//Gets the amount of an invoice and removes the dollar sign and comma
$Amount = str_replace(["$",","], '', '[[SP_BalanceDueInvoice]]');

//Concatenates the variables to create the final URL
$LinkURL = $BaseURL . $INVNo . '/' . $Amount;

//Return the final URL
echo $LinkURL;

Be sure to replace the text <<YOUR PAYMENT GATEWAY LINK GOES HERE>> with your payment gateway link from LegalCollect. This is found on the "Settings > Payment Gateway" screen in LegalCollect and should look similar to the below:

The string indicated in dark red font above is your unique payment gateway key, it's important this is taken directly from the LegalCollect Payment Gateway settings screen. 

  1. It should look the same as the screenshot on the right

  2. Click "Save" to save your new merge field

Step 2. Pay Now Merge Field

LegalCollect pay now merge field.png

You can now use your new merge field in document and email templates, with your "invoice" template being the most likely place you'll want to use it. You can just insert the merge field to add a normal "link" to your invoice, or you can insert an image to add a fancy "Pay Now" button!

  1. Navigate to "Admin > Document Assembly"

  2. Download your template

  3. Add your button

  4. Right click on the button and add the link as the name of the merge field you created on step 2 (if you used the recommended naming convention this should be <<LegalCollectPayNowLink>>)

  5. Upload your document to Actionstep to update your template

Note every firm has slightly different invoice and email templates, if you're not sure how to proceed here we recommend getting advice from your Actionstep implementation partner. 

Step 3. Use Your Merge Field

Invoice Word.png
bottom of page