ussdtim.py 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188
  1. import time
  2. import sys
  3. print('Welcome To fastrack USSD Banking Project...')
  4. time.sleep(8)
  5. bank_list="""
  6. 1. Access Bank
  7. 2. Fidelity Bank
  8. 3. Guarantee Trust Bank
  9. 4. Heritage Bank
  10. 5. Polaris Bank
  11. 6. Stanbic IBTC
  12. 7. Unity Bank
  13. 8. Wema Bank
  14. """
  15. gen_bvn = " "
  16. def BVN_checker( ):
  17. global gen_bvn
  18. bvn = [str(i) for i in range (5)]
  19. gen_bvn= "".join(bvn)
  20. def open_acct( ):
  21. global gen_bvn
  22. print("Welcome to our online Account opening services.")
  23. print("loading...")
  24. # creating an empty list to serve as a temporary place holder.
  25. temp_storage= [ ]
  26. f_name= input("Enter your first name:")
  27. s_name= input ("Enter your second name:")
  28. sex = input("Enter sex [M/F]:")
  29. BVN_checker( )
  30. temp_storage.append(f_name)
  31. temp_storage.append(s_name)
  32. temp_storage.append(sex)
  33. temp_storage.append(gen_bvn)
  34. details= " ".join(temp_storage)
  35. split_details = details.split(" ")
  36. #print(split_details)
  37. print(split_details[0]+" "+split_details[1])
  38. print(split_details[2])
  39. print("Your bvn is :"+split_details[3])
  40. print("1. Press # to go back to options menu\n2. Press * to exit")
  41. bck=input(":")
  42. if bck=='#':
  43. options_menu( )
  44. else:
  45. sys.exit( )
  46. exit( )
  47. def upgrade_migrate( ):
  48. print("Welcome to our online Upgrade/Migration services.\n 1. Ugrade\n 2. Migrate")
  49. print("press # is go back to the Main Menu.")
  50. prompt = input("Enter preferred Choice:")
  51. if prompt=="1":
  52. time.sleep(5)
  53. print("Upgrading...")
  54. exit( )
  55. elif prompt == "2":
  56. time.sleep(5)
  57. print("Migrating...")
  58. exit( )
  59. elif prompt == "#":
  60. options_menu( )
  61. else:
  62. sys.exit( )
  63. def balance ( ):
  64. print("ACCOUNT\tBALANCE\n CHECKER")
  65. print("press # is go back to the Main Menu.")
  66. pin=input("Enter your 4 digit pin:")
  67. # isdigit( ) is used to check for digits within a str while the nested if is used to make sure the user inputs 4 digits.
  68. ###```i am to put the pin trial in a while loop```###REMINDER!!!
  69. if len(pin)!=4:
  70. print("Make sure its a 4digit pin.")
  71. time.sleep(5)
  72. balance( )
  73. else:
  74. if pin.isdigit( ):
  75. time.sleep(5)
  76. print("Loading...")
  77. exit( )
  78. elif pin== "#":
  79. options_menu( )
  80. else:
  81. time.sleep(15)
  82. print("wrong pin")
  83. sys.exit( )
  84. def transf( ):
  85. print("1. Transfer self\n2. Transfer others")
  86. print("press # is go back to the Main Menu.")
  87. trnsf=input(":")
  88. if trnsf == "#" :
  89. options_menu( )
  90. elif trnsf == "1":
  91. time.sleep(5)
  92. print("Sending...")
  93. exit( )
  94. elif trnsf=="2":
  95. time.sleep(5)
  96. num=int(input("Enter receivers mobile number:"))
  97. print("Transferring to",num)
  98. exit( )
  99. else:
  100. if trnsf.isdigit( )!= True:
  101. time.sleep(5)
  102. print("Not an option")
  103. sys.exit( )
  104. elif trnsf.isdigit( ) and len(trnsf)>2:
  105. time.sleep( 5)
  106. print("wrong password.")
  107. sys.exit( )
  108. else:
  109. time.sleep(10)
  110. print("An error has occurred")
  111. sys.exit( )
  112. def funds( ):
  113. time.sleep(3)
  114. print(bank_list)
  115. bnk = input("Select receipients Bank:")
  116. acc_num= input("Entet account number:")
  117. print("Sending to",acc_num)
  118. hash= input("1.Press # to go back to options menu\n2. Press * to go exit.")
  119. if hash == "#":
  120. options_menu( )
  121. elif hash == "*":
  122. exit( )
  123. else:
  124. sys.exit( )
  125. #--------------------------------------------------
  126. ###i'm yet to catch an error for non -digit and more than one digit###REMINDER!!! #-#------------------------------------------------------
  127. # This is the function for options.
  128. def options_menu( ) :
  129. print("1. Open Account\n2. Upgrade/Migrate\n3. Balance\n4. Transfer\n5. Funds")
  130. select_options ={
  131. '1':open_acct,
  132. '2':upgrade_migrate,
  133. '3': balance,
  134. '4':transf,
  135. '5':funds}
  136. choice=input("Enter an option:")
  137. if select_options.get(choice):
  138. select_options[choice]()
  139. else:
  140. sys.exit()
  141. # This is the function which prompts the user as to whether the user wishes to continue or stop transaction.
  142. def exit( ):
  143. exit= input("Do you wish to make another transaction [Y/N] :")
  144. if exit== "N":
  145. sys.exit( )
  146. elif exit == "#":
  147. options_menu( )
  148. else:
  149. log_in( )
  150. # This is the function for logging using the fast code *919#
  151. def log_in( ):
  152. try:
  153. a=0
  154. while a<3:
  155. a+=1
  156. USSD=input("ENTER USSD:")
  157. if(USSD !="*919#"):
  158. print("please re-enter USSD ...")
  159. else:
  160. print("Welcome to our online services how may we help you")
  161. options_menu( )
  162. exit( )
  163. else:
  164. time.sleep(10)
  165. print("checking discrepancies...")
  166. time.sleep(5)
  167. print("An error has occured.")
  168. except:
  169. sys.exit( )
  170. log_in( )