def transfer(intent_request): account = intent_request['currentIntent']['slots']['account'] cpname = intent_request['currentIntent']['slots']['name'] amount = intent_request['currentIntent']['slots']['amount'] account_check=validate_account(account) if account_check=='valid': our_bank =obp.getBanks() for i in our_bank: for j in obp.getPrivateAccounts(i['id']): if (j['id']==account): bank = i['id'] our_account = obp.getAccount(bank,account) balance = our_account['balance']['amount'] if float(amount)>float(balance): message = "insufficient balance" return close(intent_request, message) cp_check = validate_counterparty(account,cpname) if cp_check == 'valid': obp.setPaymentDetails('USD',str(amount)) cp=obp.getCounterparties('cb.44.us.cb',account) cpid = "" for j in cp: if (j['name']==cpname): cpid = j['counterparty_id'] obp.createTransactionRequestV210('cb.44.us.cb',str(account),'COUNTERPARTY','cb.44.us.cb','19630908',cpid,'cb.44.us.cb') message = "Your transaction is successful" content = message + "\n Would you like to know anything?" #return close(intent_request, message) return elicit_intent(content) else: message = "Invalid Counterparty name" return close(intent_request, message) else: message = "Invalid Account number" return close(intent_request, message)
from_account_id = FROM_ACCOUNT_ID print("") print("Set toAccount info: to_bank_id = {0} and to_account_id= {1}.".format( TO_BANK_ID, TO_ACCOUNT_ID)) to_bank_id = TO_BANK_ID to_account_id = TO_ACCOUNT_ID print("") challenge_type_sandbox_tan = "SANDBOX_TAN" print("--------- TRANSACTION_REQUEST_TYPE : {0}".format( challenge_type_sandbox_tan)) print("") print("Set up the OUR_CURRENCY = {0} and OUR_VALUE_LARGE = {1} ".format( OUR_CURRENCY, OUR_VALUE_LARGE)) obp.setPaymentDetails(OUR_CURRENCY, OUR_VALUE_LARGE) print("Call API - 1 'Create Transaction Request. -- V210' (with challenge)") initiate_response = obp.createTransactionRequestV210( from_bank_id=FROM_BANK_ID, from_account_id=FROM_ACCOUNT_ID, transaction_request_type=challenge_type_sandbox_tan, to_bank_id=to_bank_id, # for SANDBOX_TAN to_account_id=to_account_id, # for SANDBOX_TAN to_counterparty_id="", # used for SEPA to_counterparty_iban="") # used for COUNTERPARTY obp.printMessageWithChallenge(initiate_response) print("") print("Call API - 2 'Answer Transaction Request Challenge. -- V210'") challenge_query = initiate_response['challenge']['id']