Overview
When an authentication refresh fails, Payments2Us creates an Error Log - Payments2Us record. The record may include an error similar to:
Program Area: payments2Us.DML.performOAuthRefresh
Subject: Response error
Description:
Error: invalid_grant
Error Desc: expired access/refresh tokenThis article explains how to create a Salesforce Flow that emails your nominated administrators whenever a related error log is created. This allows your team to re-authorise Payments2Us promptly (How to authorise Payments2Us).
Steps
1. Create a record-triggered Flow
- In Salesforce, go to Setup.
- Search for and open Flows.
- Select New Flow.
- Choose Record-Triggered Flow.
- Select Error Log - Payments2Us as the object.
- Set the trigger to A record is created.

2. Add the entry conditions
Configure the Flow to run when Any Condition Is Met (OR).
Add these conditions:
| Field | Operator | Value |
|---|---|---|
| Program Area | Contains | payments2UsDML.refreshToken |
| Program Area | Contains | payments2UsDML.performOAuthRefresh |
These conditions ensure the Flow monitors Payments2Us token-refresh and OAuth-refresh errors.
The exact Program Area text may vary by package version. Confirm the value from an existing relevant Error Log - Payments2Us record and update the Flow condition if needed.
Set Optimize the Flow For to Actions and Related Records, then select Done.


3. Add a Send Email action
- Under Run Immediately, select the + icon.
- Select Action.
- Search for and select Send Email.
- Enter a label, for example: Send Email Error Alert Action.
- Configure the recipient details with the email address or addresses for the team responsible for Payments2Us administration.
- Configure the sender detail with the org-wide email address responsible for sending the alert


Use a clear subject, for example:
Action required: Payments2Us authorisation may have expiredUse an email body similar to the following:
Refresh Token Error, please action immediately:
https://help.payments2us.com/installation-security/how-to-authorise-payments2us-for-public-website4. Save and activate the Flow
- Select Save.
- Enter a clear Flow label, for example:
Payments2Us Send an Alert for Token Authorisation Failure - Select Activate.
5. Test the alert
After activation, confirm that the nominated recipients receive an email when a matching Error Log - Payments2Us record is created.
When you receive an alert, review the Error Log. If it confirms an expired access or refresh token, re-authorise Payments2Us promptly to restore authentication. (How to authorise Payments2Us)
This alert helps you respond quickly, but it does not automatically re-authorise Payments2Us. Re-authorisation must be completed by an authorised Salesforce administrator.