If you have encountered this error during payment:

Payment failed with the following reason: INVALID_CROSS_REFERENCE_KEY: invalid cross reference id

Usually, it can be fixed by following the steps below:

1. Click on the App Launcher and search for Payment Center Settings

2. Go to  Payment Center Settings | Payment Receipt button:

On the page that comes up, click Edit Template:

3. Scroll all the way to the first line of the template and add the following:

renderUsingSystemContextWithoutSharing="true"

For example:

<messaging:emailTemplate subject="{!Relatedto.fw1__Payment_Receipt_Email_Subject__c}" recipientType="Contact" relatedToType="fw1__Payment__c" renderUsingSystemContextWithoutSharing="true">

4. Save your template.

If Invoice Receipt Template is set-up, add the same code to the template.