Skip to content

How to conditionally display the payment link?

← PDF and Email FAQ

When integrating with a payment provider using JustOn Cash Management, you can add the link to the relevant payment page to the invoice email or invoice PDF document, as described in Adding Link to Email or PDF.

However, you may want to display the link only on certain conditions, for example, only on invoices where the payment method is set Online Payment.

This requires

  • A custom formula field that produces the payment link if there is an associated contact
  • An allowlist entry for the custom formula field
  • A custom placeholder for the formula field to included in the address field of your invoice template

Following the example, the configuration involves these steps:

  1. Create the custom formula field ShowPaymentPageURL (return type Text) on the Invoice object.

    Specify this formula:

    IF (AND (TEXT(ONB2__Template__r.ONB2__Language__c) = 'de', TEXT(ONB2__PaymentMethod__c) = 'Online Payment'), 'Sie können ganz einfach über unsere Bezahlseite bezahlen - ' + ONB2__PaymentPageUrl__c,IF (AND (TEXT(ONB2__Template__r.ONB2__Language__c) = 'en', TEXT(ONB2__PaymentMethod__c) = 'Online Payment'), 'You can easily pay using our payment page - ' + ONB2__PaymentPageUrl__c,' '))
    

    This formula checks whether the template language is German or English and whether the payment method is set Online Payment. If so, it returns the (locale-specific) introduction text together with the retrieved payment page URL. Otherwise, it leaves the field blank.

    Make sure to select Treat blank fields as blanks.

  2. Allowlist the new formula field to make it accessible for custom placeholders.

    For details, see Field Whitelist.

  3. Create the custom placeholder [ShowPaymentPageURL], setting it up to retrieve the ShowPaymentPageURL field on the invoice.

    For details, see Custom Placeholders.

  4. Add the new placeholder to the intended text field of your invoice template.

    Possible target text fields may be Text 2 or Text 3 for the PDF and Email Body or Email HTML Body for the email.

    Make sure to apply the placeholder filter no-persist to the placeholder, like

    [ShowPaymentPageURL|no-persist]
    

Related information:

Handling Payment Page Links
How to selectively display a field on the PDF?