Can you please tell me how to create a way that users can

Can you please tell me how to create a way that users can pay for a code. I will like the users to pay for a code (epin). Once the Epin is purchase than a code is sent to the user to their email. User can not register for the website without have an Epin.

Thank you in advance for your help