Payment transactions referenceis have a unique constraint which was problematic when a payment was cancelled from the acquirer's page. To stick the to DRY principle, I factorized a method that checks for existing references and happens a numerical suffix if necessary. This was already implemented in website_payment but was moved to payment and used in website_sale.