Code like this shows why you need abstractions. You're copy pasting code all over the place.

Move the creation of a payment_code into a seperate method on Registration (the class) and use that one everywhere.