# Zagel (SMS) [send sms system, payment system] ## Idea: - We will install mobile Application on user's mobile; so that we can send sms(OTP service) with his pre-approved permission on user's mobile application. - **User's benfites**: User will sell his unused SMS to be used by us and exchange it with an asset (Token) ## Technically What will happen as a user story [send sms system]: - A customer(Developer [The potential customer]) wants to verify a mobile numbers with his application He will use three APIs from Us * **Send SMS**: This API will take The Mobile number which we will send the OTP to. #### API scenario: 1- Get mobile numbe fom request body 2- Validte the mobile is really a mobile number or not based on [E.164](https://en.wikipedia.org/wiki/E.164) standard 3- Generate OTP and sms body 4- Based on mobile network we will get a pool (vodafone, Orange, etc..) I will send sms with first user in my list till his 5 sms Quota run out which I will preset every 24 hour in database using MySQL Scheduled feature [We will find socket connection Id of the sender with mobile number xxx from onlineUsers Table] 5- Create item in a queue with OTP, SMS body(which will be fixed), and sender mobile number 6- Queue will be configured to host item in the queue by maximum 10 min, and then it will be released if no verification call done 7 - send socket Event to the mobile application to send sms on behave of the user 8- check with socket sent from mobile if the sms sent correctly or not if it was sent, fine, if not then I will drop the user socket to keep availble users to send sms from provider pool. * **Verify OTP with Mobile** This API will verify OTP sent to a specified mobile number with 10 min after sending the sms from our system #### API scenario: 1- Get the Mobile number Which received the sms, and the OTP sent 2- find item in The queue with Mobile number (receiver) and OTP number 3- If found, we would delete this item from the queue. 4- Issue Token for (sms sender [delivery]) 5- send a response with a verification message to API consumer 6 If we did not the item in the queue then maybe item expired or consumer used **resend sms API** * **~~Resend SMS~~** ~~This API will be used if the sms did not be delivered or expired on the queue~~ #### ~~API scenario:~~ ~~1- Get mobile numbe fom request body 2- Validte the mobile is really a mobile number or not based on [E.164](https://en.wikipedia.org/wiki/E.164) standard 3- Generate OTP and sms body 4- Based on mobile network we will get a pool (vodafone, Orange, etc..) (to get sender mobile number but randomly because I will send sms with the first user in my pool list which may has an issue in his mobile and that may restrict the operations and I will keep in mind the till the 5 sms Quota which I will preset every 24 hour in database using MySQL Scheduled feature) [We will find socket connection Id of the sender with mobile number xxx from onlineUsers Table] 5- find and edit the item in the queue which has the OTP n the SMS body(which will be fixed), receiver mobile number, and update sender mobile number 6- Queue will be configured to host item in the queue by maximum 10 min, and then it will be released if no verification call done 7 - send socket Event to the mobile application to send sms on behave of the user~~ ## Notes 1- This system will use redis as a scheduled queue system 2- SocketIO for sockets and maybe later AWS websocket from API Gateway Service 3- A senstive permission for the mobile APP which allow us to send SMS on behave of the user ## Technically What will happen as a user story [payment system]: briefly, This system is created to register our potential customers and check their Quota of sms they will use for OTP service. and manage the payment. This system will integrate with **Send SMS system** to call the mentioned two APIs Above ### Use Case: - Customer wants to Recharge his balance to send OTP. - Customer wants to send OTP so; we will check his balance first and then send the sms if it is enough balance. - payment will be through checkoutjs. #### Technically: - Create APIs for user auth/login/register/profile - Create API to send OTP * Check user's balance if available then send OTP (by calling send OTP api in `OTP system`). * Create API to verify the OTP.