I'm developing a system where user can buy scratch card number using pre-paid balance. I already created balance system using user meta. Now I need to delivery card number to users upon payment. As payment system is ready, I need an idea which will help me to deliver card number. Card numbers will be stored in database. I'll deliver them. Custom post type can be used probably but couldn't recognize how I deliver them.
For instance, User want buy a card of $10. I already stored 5 cards of $10, 3 cards of $20. If user make payment, system will deliver the card number which wasn't previously sold.
I need idea. Please suggest me.
Update: I got an idea. I'll create a custom post type called 'Card' with three meta key fields called 'Amount', 'Number' and 'Status'. When a specific function will run, a query will be run for searching the post type for certain amount and where Status will be "Unused". Then an email will be sent to the user with the card number and custom field 'Status' will be updated to "Used". Now I need an idea to search the post. I appreciate your help.