|
| 1 | +import json |
| 2 | + |
| 3 | +import dwollav2 |
| 4 | + |
| 5 | + |
| 6 | +def display_options(): |
| 7 | + print('Choose from the following actions: ') |
| 8 | + action_menu = ''' |
| 9 | + Root (R) |
| 10 | + Retrieve account details (RAD) |
| 11 | + Create account funding source (CAFS) |
| 12 | + Create account VAN (CAVAN) |
| 13 | + List account funding sources (LAFS) |
| 14 | + List and search account transfers (LASAT) |
| 15 | + List account mass payments (LAMP) |
| 16 | + Create receive only customer (CROC) |
| 17 | + Create unverified customer (CUVC) |
| 18 | + Create verified personal customer (CVP) |
| 19 | + Retrieve customer (RC) |
| 20 | + List and search customers (LASC) |
| 21 | + Update customer (UC) |
| 22 | + List customer business classifications (LCBC) |
| 23 | + retrieve business classification (RBC) |
| 24 | + initiate KBA (IKBA) |
| 25 | + retrieve KBA (RKBA) |
| 26 | + verify KBA (VKBA) |
| 27 | + Create beneficial owner (CBO) |
| 28 | + Retrieve beneficial owner (RBO) |
| 29 | + list beneficial owners (LBO) |
| 30 | + update beneficial owner (UBO) |
| 31 | + Remove beneficial owner (DBO) |
| 32 | + Retrieve beneficial ownership status (RBOS) |
| 33 | + Certify beneficial ownership (CBOS) |
| 34 | + Quit (Q) |
| 35 | + ''' |
| 36 | + print(action_menu) |
| 37 | + |
| 38 | +def get_user_input(): |
| 39 | + return input('Enter your action: ') |
| 40 | + |
| 41 | +def handle_input(input, DWOLLA_APP_KEY, DWOLLA_APP_SECRET): |
| 42 | + client = dwollav2.Client(key = DWOLLA_APP_KEY, secret = DWOLLA_APP_SECRET, environment = 'sandbox') |
| 43 | + application_token = client.Auth.client() |
| 44 | + if input == 'R': |
| 45 | + root(application_token) |
| 46 | + elif input == 'RAD': |
| 47 | + get_account_details(application_token) |
| 48 | + elif input == 'CAFS': |
| 49 | + create_account_funding_source(application_token) |
| 50 | + elif input == 'CAVAN': |
| 51 | + create_account_van(application_token) |
| 52 | + elif input == 'LAFS': |
| 53 | + list_account_funding_sources(application_token) |
| 54 | + elif input == 'LASAT': |
| 55 | + list_and_search_account_transfers(application_token) |
| 56 | + elif input == 'LAMP': |
| 57 | + list_account_mass_payments(application_token) |
| 58 | + elif input == 'CROC': |
| 59 | + create_receive_only_customer(application_token) |
| 60 | + elif input == 'CUVC': |
| 61 | + create_unverified_customer(application_token) |
| 62 | + elif input == 'CVP': |
| 63 | + create_verified_personal_customer(application_token) |
| 64 | + elif input == 'RC': |
| 65 | + retrieve_customer(application_token) |
| 66 | + elif input == 'LASC': |
| 67 | + list_and_search_customers(application_token) |
| 68 | + elif input == 'UC': |
| 69 | + update_customer(application_token) |
| 70 | + elif input == 'LCBC': |
| 71 | + list_customer_business_classifications(application_token) |
| 72 | + elif input == 'RBC': |
| 73 | + retrieve_business_classification(application_token) |
| 74 | + elif input == 'IKBA': |
| 75 | + initiate_kba(application_token) |
| 76 | + elif input == 'RKBA': |
| 77 | + retrieve_kba(application_token) |
| 78 | + elif input == 'VKBA': |
| 79 | + verify_kba(application_token) |
| 80 | + elif input == 'CBO': |
| 81 | + create_beneficial_owner(application_token) |
| 82 | + elif input == 'RBO': |
| 83 | + retrieve_beneficial_owner(application_token) |
| 84 | + elif input == 'LBO': |
| 85 | + list_beneficial_owners(application_token) |
| 86 | + elif input == 'UBO': |
| 87 | + update_beneficial_owner(application_token) |
| 88 | + elif input == 'DBO': |
| 89 | + remove_beneficial_owner(application_token) |
| 90 | + elif input == 'RBOS': |
| 91 | + retrieve_beneficial_ownership_status(application_token) |
| 92 | + elif input == 'CBOS': |
| 93 | + certify_beneficial_ownership(application_token) |
| 94 | + elif input == 'Q': |
| 95 | + quit() |
| 96 | + |
| 97 | + |
| 98 | +def print_response(res): |
| 99 | + print(json.dumps(res.body, indent = 4)) |
| 100 | + |
| 101 | +def print_location(res): |
| 102 | + print(res.headers['Location']) |
| 103 | + |
| 104 | +# ROOT RESOURCE |
| 105 | +def root(token): |
| 106 | + res = token.get('/') |
| 107 | + print_response(res) |
| 108 | + |
| 109 | +# ACCOUNT RESOURCE |
| 110 | +def get_account_details(token): |
| 111 | + id = input('Enter your account ID: ') |
| 112 | + res = token.get(f'accounts/{id}') |
| 113 | + print_response(res) |
| 114 | + |
| 115 | +def create_account_funding_source(token): |
| 116 | + accountNumber = input('Enter your account number: ') |
| 117 | + routingNumber = input('Enter your routing number: ') |
| 118 | + bankAccountType = input('Enter your bank account type: ') |
| 119 | + name = input('Enter your funding source nickname: ') |
| 120 | + |
| 121 | + body = { |
| 122 | + 'routingNumber': routingNumber, |
| 123 | + 'accountNumber': accountNumber, |
| 124 | + 'type': bankAccountType, |
| 125 | + 'name': name |
| 126 | + } |
| 127 | + |
| 128 | + res = token.post(f'/funding-sources', body) |
| 129 | + print_location(res) |
| 130 | + |
| 131 | +def create_account_van(token): |
| 132 | + name = input('Enter your account name: ') |
| 133 | + bankAccountType = input('Enter your bank account type: ') |
| 134 | + |
| 135 | + body = { |
| 136 | + 'name': name, |
| 137 | + 'type': 'virtual', |
| 138 | + 'bankAccountType': bankAccountType |
| 139 | + } |
| 140 | + |
| 141 | + res = token.post(f'/funding-sources', body) |
| 142 | + print_location(res) |
| 143 | + |
| 144 | +def list_account_funding_sources(token): |
| 145 | + id = input('Enter your account ID: ') |
| 146 | + res = token.get(f'/accounts/{id}/funding-sources') |
| 147 | + print_response(res) |
| 148 | + |
| 149 | +def list_and_search_account_transfers(token): |
| 150 | + id = input('Enter your account ID: ') |
| 151 | + res = token.get(f'/accounts/{id}/transfers') |
| 152 | + print_response(res) |
| 153 | + |
| 154 | +def list_account_mass_payments(token): |
| 155 | + id = input('Enter your account ID: ') |
| 156 | + res = token.get(f'/accounts/{id}/mass-payments') |
| 157 | + print_response(res) |
| 158 | + |
| 159 | +# CUSTOMER RESOURCE |
| 160 | +def create_receive_only_customer(token): |
| 161 | + firstName = input('Enter customer first name: ') |
| 162 | + lastName = input('Enter customer last name: ') |
| 163 | + email = input('Enter customer email: ') |
| 164 | + type = 'receive-only' |
| 165 | + |
| 166 | + body = { |
| 167 | + 'firstName': firstName, |
| 168 | + 'lastName': lastName, |
| 169 | + 'email': email, |
| 170 | + 'type': type |
| 171 | + } |
| 172 | + |
| 173 | + res = token.post(f'/customers', body) |
| 174 | + print_location(res) |
| 175 | + |
| 176 | +def create_unverified_customer(token): |
| 177 | + firstName = input('Enter customer first name: ') |
| 178 | + lastName = input('Enter customer last name: ') |
| 179 | + email = input('Enter customer email: ') |
| 180 | + |
| 181 | + body = { |
| 182 | + 'firstName': firstName, |
| 183 | + 'lastName': lastName, |
| 184 | + 'email': email, |
| 185 | + } |
| 186 | + |
| 187 | + res = token.post(f'/customers', body) |
| 188 | + print_location(res) |
| 189 | + |
| 190 | +def create_verified_personal_customer(token): |
| 191 | + firstName = input('Enter customer first name: ') |
| 192 | + lastName = input('Enter customer last name: ') |
| 193 | + email = input('Enter customer email: ') |
| 194 | + address1 = input('Enter customer address 1: ') |
| 195 | + city = input('Enter customer city: ') |
| 196 | + state = input('Enter customer state: ') |
| 197 | + postalCode = input('Enter customer postal code: ') |
| 198 | + dateOfBirth = input('Enter customer date of birth: ') |
| 199 | + ssn = input('Enter customer ssn: ') |
| 200 | + type = 'personal' |
| 201 | + |
| 202 | + body = { |
| 203 | + 'firstName': firstName, |
| 204 | + 'lastName': lastName, |
| 205 | + 'email': email, |
| 206 | + 'address1': address1, |
| 207 | + 'city': city, |
| 208 | + 'state': state, |
| 209 | + 'postalCode': postalCode, |
| 210 | + 'dateOfBirth': dateOfBirth, |
| 211 | + 'ssn': ssn, |
| 212 | + 'type': type |
| 213 | + } |
| 214 | + |
| 215 | + res = token.post(f'/customers', body) |
| 216 | + print_location(res) |
| 217 | + |
| 218 | +def retrieve_customer(token): |
| 219 | + id = input('Enter customer ID: ') |
| 220 | + res = token.get(f'/customers/{id}') |
| 221 | + print_response(res) |
| 222 | + |
| 223 | +def list_and_search_customers(token): |
| 224 | + res = token.get('/customers') |
| 225 | + print_response(res) |
| 226 | + |
| 227 | +def update_customer(token): |
| 228 | + id = input('Enter customer ID: ') |
| 229 | + email = input('Enter updated customer email: ') |
| 230 | + |
| 231 | + body = { |
| 232 | + 'email': email, |
| 233 | + } |
| 234 | + |
| 235 | + res = token.post(f'/customers/{id}', body) |
| 236 | + print_response(res) |
| 237 | + |
| 238 | +def list_customer_business_classifications(token): |
| 239 | + res = token.get('/business-classifications') |
| 240 | + print_response(res) |
| 241 | + |
| 242 | +def retrieve_business_classification(token): |
| 243 | + id = input('Enter business classification ID: ') |
| 244 | + res = token.get(f'/business-classifications/{id}') |
| 245 | + print_response(res) |
| 246 | + |
| 247 | +# KBA RESOURCE |
| 248 | +def initiate_kba(token): |
| 249 | + id = input('Enter customer ID: ') |
| 250 | + res = token.post(f'/customers/{id}/kba') |
| 251 | + print_location(res) |
| 252 | + |
| 253 | +def retrieve_kba(token): |
| 254 | + id = input('Enter KBA session ID: ') |
| 255 | + res = token.get(f'/kba/{id}') |
| 256 | + print_response(res) |
| 257 | + |
| 258 | +def verify_kba(token): |
| 259 | + id = input('Enter KBA session ID: ') |
| 260 | + |
| 261 | + answers = [] |
| 262 | + for i in range(4): |
| 263 | + obj = {} |
| 264 | + question_id = input(f'Enter question ID for question {i+1}: ') |
| 265 | + answer_id = input(f'Enter answer ID for answer {i+1}: ') |
| 266 | + obj['questionId'] = question_id |
| 267 | + obj['answerId'] = answer_id |
| 268 | + answers.append(obj) |
| 269 | + |
| 270 | + body = { |
| 271 | + 'answers': answers |
| 272 | + } |
| 273 | + |
| 274 | + res = token.post(f'/kba/{id}', body) |
| 275 | + print_response(res) |
| 276 | + |
| 277 | +# BENEFICIAL OWNERS RESOURCE |
| 278 | +def create_beneficial_owner(token): |
| 279 | + id = input('Enter customer ID: ') |
| 280 | + firstName = input('Enter beneficial owner first name: ') |
| 281 | + lastName = input('Enter beneficial owner last name: ') |
| 282 | + dateOfBirth = input('Enter beneficial owner date of birth: ') |
| 283 | + ssn = input('Enter beneficial owner ssn: ') |
| 284 | + address1 = input('Enter beneficial owner address 1: ') |
| 285 | + city = input('Enter beneficial owner city: ') |
| 286 | + state = input('Enter beneficial owner state: ') |
| 287 | + country = input('Enter beneficial owner country: ') |
| 288 | + postalCode = input('Enter beneficial owner postal code: ') |
| 289 | + |
| 290 | + body = { |
| 291 | + 'firstName': firstName, |
| 292 | + 'lastName': lastName, |
| 293 | + 'dateOfBirth': dateOfBirth, |
| 294 | + 'ssn': ssn, |
| 295 | + 'address': { |
| 296 | + 'address1': address1, |
| 297 | + 'city': city, |
| 298 | + 'stateProvinceRegion': state, |
| 299 | + 'country': country, |
| 300 | + 'postalCode': postalCode |
| 301 | + } |
| 302 | + } |
| 303 | + |
| 304 | + res = token.post(f'/customers/{id}/beneficial-owners', body) |
| 305 | + print_location(res) |
| 306 | + |
| 307 | +def retrieve_beneficial_owner(token): |
| 308 | + id = input('Enter beneficial owner ID: ') |
| 309 | + res = token.get(f'/beneficial-owners/{id}') |
| 310 | + print_response(res) |
| 311 | + |
| 312 | +def list_beneficial_owners(token): |
| 313 | + id = input('Enter customer ID: ') |
| 314 | + res = token.get(f'/customers/{id}/beneficial-owners') |
| 315 | + print_response(res) |
| 316 | + |
| 317 | +def update_beneficial_owner(token): |
| 318 | + id = input('Enter beneficial owner ID: ') |
| 319 | + firstName = input('Enter beneficial owner first name: ') |
| 320 | + lastName = input('Enter beneficial owner last name: ') |
| 321 | + dateOfBirth = input('Enter beneficial owner date of birth: ') |
| 322 | + ssn = input('Enter beneficial owner ssn: ') |
| 323 | + address1 = input('Enter beneficial owner address 1: ') |
| 324 | + city = input('Enter beneficial owner city: ') |
| 325 | + state = input('Enter beneficial owner state: ') |
| 326 | + country = input('Enter beneficial owner country: ') |
| 327 | + postalCode = input('Enter beneficial owner postal code: ') |
| 328 | + |
| 329 | + body = { |
| 330 | + 'firstName': firstName, |
| 331 | + 'lastName': lastName, |
| 332 | + 'dateOfBirth': dateOfBirth, |
| 333 | + 'ssn': ssn, |
| 334 | + 'address': { |
| 335 | + 'address1': address1, |
| 336 | + 'city': city, |
| 337 | + 'stateProvinceRegion': state, |
| 338 | + 'country': country, |
| 339 | + 'postalCode': postalCode |
| 340 | + } |
| 341 | + } |
| 342 | + |
| 343 | + res = token.post(f'/beneficial-owners/{id}', body) |
| 344 | + print_response(res) |
| 345 | + |
| 346 | +def remove_beneficial_owner(token): |
| 347 | + id = input('Enter beneficial owner ID: ') |
| 348 | + res = token.delete(f'/beneficial-owners/{id}') |
| 349 | + print_response(res) |
| 350 | + |
| 351 | +def retrieve_beneficial_ownership_status(token): |
| 352 | + id = input('Enter customer ID: ') |
| 353 | + res = token.get(f'/customers/{id}/beneficial-ownership') |
| 354 | + print_response(res) |
| 355 | + |
| 356 | +def certify_beneficial_ownership(token): |
| 357 | + id = input('Enter customer ID: ') |
| 358 | + body = { |
| 359 | + 'status': 'certified' |
| 360 | + } |
| 361 | + res = token.post(f'/customers/{id}/beneficial-ownership', body) |
| 362 | + print_response(res) |
| 363 | + |
0 commit comments