When submitting a payment form to the commerce/payments/pay
controller action there are three potential sources of error messages.
If you are submitting via a normal form submission (not ajax) you will be able to get access to the errors in the following manner from your template.
General Errors
{% set flashError = craft.app.session.getFlash('error') %}
For general errors e.g. requireBillingAddressAtCheckout
is set to true and there is no billing address on the order.
Order Save Errors
{% set orderErrors = order.getErrors() %}
The order is recalculated and saved during the pay process to make sure something has not changed elsewhere. The order is validated and therefore errors will be returned if there are validation issues.
Payment Form Errors
{% set paymentFormErrors = paymentForm.getErrors() %}
The payment form errors will contain any errors related to the payment form and, dependant on gateway, may also return payment gateway errors.