Open octopusinvitro opened 6 years ago
At the moment this gem calculates the number just generating the random last 9 numbers plus the prefix.
def generate_number(number_prefix)
number_prefix + Array.new(9) { Random.rand(9) }.join
end
The original code searches in the database to check that the generated code is not repeated. Rather than opening yet another connection to Salesforce to look up the payment number, coupling a Salesforce class with the generator, a simplest solution could be to use a text file containing all numbers used to date (this can be downloaded from the CMS finantials).
P123456789
MC123456789
... etc.
Everytime the generator generates a number it reads from this file to check that it is not in use. Then the generator or another class upstream could write down the new number if the payment went through successfully.
We would also need a file for development probably.
See our contributing guides.
The old site calls
payment.number
, which is defined in thePayment
model as:Credit card mandate:
Direct debit mandate:
Generic direct debit mandate:
Paypal mandate:
Spendenbank direct debit mandate:
Investigate why it needs this format and if there is a better way to implement this code. Implement this in the
StripeWrapper::FieldsGenerator
class