Generate reference on form submit rather than build
Paraphrased from an end user
I tried to sign up for membership. Something went wrong. When I went back and re-tried, I got the message: 'Payment validation error A Live DDI already exists for Reference Number ***'
It looks like this is because CRM_Smartdebit_Base::getDDIReference()
generates the ID in CRM_Core_Payment_Smartdebit::buildForm.
Maybe it would make more sense to do this in CRM_Core_Payment_Smartdebit::doPayment()
so we only avoid submitting the same reference twice?
Also, for what it is worth, we are 'wasting' lots of smart debit reference numbers / inserting lots of unecessary rows into the veda_smartdebit
table by invoking getDDIReference()
in buildForm.
Additionally, the code that creates the reference is a bit convoluted (the use of $tempDDIReference
). This could be neated up with use of DB_DataObject->insert()
.
Let me know your initial thoughts on the above. We can create a PR for this if you like.