Utilizing a payment field in your forms is a great way to capture payment information from your customers while gathering other pertinent information. But as we know, not all payments are made equal and you need a more flexible way to collect payments without the manual back end processes.
Adding Payment Formulas to your Payment Processor will allow you to customize the amount values based off of different values selected in the form.
💡If you have not already done so, start by creating a form with a configured payment field.
On your Payment Processor after entering your credentials, select the "Payment Settings" tab. You have the option to set formulas for the Amount, Shipping, and Taxes payment fields.
Select which field you would like to set a formula for. Scroll down to option "3- Calculate subtotal" and select "Set total using a custom formula".
💡Payment Formula Validation Tips
Make sure all the fields have a value
Use an IF statement to avoid empty fields
Use numbers without quotes: 25
Show percentages as decimals: 0.5
Available operators: +, -, *, /
Enclose field value API names in double quotes with square brackets: [“Account.Active__c”]
Checkbox and Picklist fields should end with .amount to retrieve the numerical value: [“Account.Active__c”].amount
Number fields should end with .val: [“Account.Price__c”].val
Using a payment formula will provide a picklist of fields from your form that you can add to the formula box to create your custom payment formula. Notice that when you select a field and click the "add" button, the field label comes through in square brackets along with a .val extension. This format is important to remember when referencing fields in your formula.
You can add another field into the payment formula using the field picklist and the "add" button. It will automatically add a plus sign prior to the field to add the values from the fields together. This can be changed with a different mathematical symbol depending on your payment scenario. Supported operators are '+', '-', '*', '/'.
You also have the option to add a hardcoded value instead of a field in the formula.
You will also see a .amount extension option for your picklist and checkbox fields in your form.
💡 .val vs .amount extensions:
The .val extension specifies the value from the text box where the end-user will enter to submit the form. The .amount extension references the value from the picklist/checkbox field and set the values for the picklist /checkbox option from payment settings.
Using IF Statements in your Payment Formula
You can add IF Statements to create more complexed and flexible Payment Formulas based off of values in your forms.
The format of your IF Statement will be dependent on the values you want considered in the formula, but the basic structure should look similar to this:
IF((["FIELD.LABEL"].val= "CUSTOM VALUE"), STATEMENT 1, STATEMENT 2)
FIELD.LABEL - added field
CUSTOM VALUE - This parameter specified your If Statement. For example, if you want the If Statement based off of a null value, you'll leave the CUSTOM VALUE blank in between the quotations.
STATEMENT 1 - This triggers if the IF Statement is met.
STATEMENT 2 - This triggers if the IF Statement is not met.
IF((["Account.Amount__c"].val= "18"), 0.25, 0.50)
This If Statement is saying if the Amount field is equal to 18, then the value should be Amount payment field should 0.25. Otherwise, if the field is not equal to 18, the Amount payment field will be 0.50.
The Check Syntax button will check your formula's syntax and validate if it's set up correctly. If you're formula has ben set appropriately, you will receive a "No syntax errors" message notifying that your payment formula is ready to use.
If there are errors, you can use the Validation Tips to modify your syntax errors.