[PostFinance] How to fix the «This order has already been processed» failure?

Sometimes you can encounter the «This order has already been processed» message in the PostFinance’s error log:

To fix it, set a non-empty «Payment ID prefix» value to the the PostFinance’s settings section of your Magento 2 backend:

This option allows you to define a prefix for the payment identificators (the values of the ORDERID API parameter).

In the most cases you do not need any prefix and can leave this option empty.

But there are some (rare) cases when your PostFinance payment identifiers can potentially overlap with the previous ones:

  • If you have changed (e.g., reset) your Magento order numeration scheme.
  • If you use a single PostFinance merchant account for multiple shops.

If PostFinance encounters a payment identifier which has been already used for another payment, it fails with the message: «This order has already been processed».

So to evade such situation you can define a prefix for the payment identifiers.
Please note that the full payment identifier length (prefix + order number) should be not greater than 40 characters.