Example #1
0
def get_transactions(accounts):
    out = []
    for account in accounts:
        ide = account['id']
        transactions = obp.getTransactions(our_bank, ide)
        out.append([account["label"]])
        for t in transactions:
            out[-1].append(float(t['details']['value']['amount']))
    return out
Example #2
0
def getTransactions(bank, accounts):
    # Save Transactions file for faster Access
    if os.path.isfile('transactions.txt'):
        print("Reading...")
        with open("transactions.txt", 'r') as fileToRead:
            transactions = json.load(fileToRead)
    else:
        print("Writing...")
        for account in accounts:
            transactions = obp.getTransactions(bank, account['id'])
        with open("transactions.txt", 'w') as fileToWrite:
            json.dump(transactions, fileToWrite)
    return transactions
Example #3
0
def transactions(intent_request):
    transactions_list=[]
    account = intent_request['currentIntent']['slots']['account']
    our_bank =obp.getBanks()
    check_account=validate_account(account)
    if check_account == 'valid':
      for i in our_bank:
        for j in obp.getPrivateAccounts(i['id']):
          if (j['id']==account):
            details=obp.getTransactions(i['id'],j['id'])
            for n in details:
              transactions_list.append(('Time:', n['details']['completed'],'name:',n['other_account']['holder']['name'],'amount:',n['details']['value']['amount']))
      if (len(transactions_list)>0):
        data = " \n".join(transactions_list[0])
        message = "your last transaction details are:"+data
        content = message + "\n Would you like to know anything?"
        #return close(intent_request, message)
        return elicit_intent(content)
      else:
        message = "you dont have any transactions"
        return close(intent_request, message) 
    else:
        message = "Invalid Account number"
        return close(intent_request, message) 
    to_bank_id="",  # used for SANDBOX_TAN
    to_account_id="",  # used for SANDBOX_TAN
    to_counterparty_id=to_counterparty_id,  # used for COUNTERPARTY
    to_counterparty_iban="")  # used for SEPA
# There was a challenge, transaction was interrupted, and the transaction_request is 'INITIATED'
obp.printMessageWithChallenge(initiate_response)

# we need to answer the challenge
challenge_id = initiate_response['challenge']['id']
transaction_req_id = initiate_response['id']
print("")
print("Call API - 3 'Answer Transaction Request Challenge. -- V210'")
print(
    "Transaction is done , and the transaction_request is 'COMPLETED' and new Transaction id is created: :"
)
challenge_response = obp.answerChallengeV210(from_bank_id, from_account_id,
                                             transaction_req_id,
                                             challenge_type_counterparty,
                                             challenge_id)
if "error" in challenge_response:
    sys.exit("Got an error: " + str(challenge_response))

obp.printMessageAfterAnswerChallenge(challenge_response)

######################### Step4 - Print all transactions ################
print("")
print("Then we need to check the get Transactions")
print("Call API - 1 'Get Transactions for Account (Full)-- V210'")
new_transaction_id = challenge_response["transaction_ids"]
getTransactions_response = obp.getTransactions(FROM_BANK_ID, FROM_ACCOUNT_ID)
obp.printGetTransactions(getTransactions_response)
Example #5
0
    'id': '%s' % our_account,
    'label': '%s' % new_label,
    'bank_id': '%s' % OUR_BANK
}

# Send post request with attached json with new label value
response = requests.post(u"{0}/obp/{1}/banks/{2}/accounts/{3}".format(
    BASE_URL, API_VERSION, our_bank, our_account),
                         json=post_data,
                         headers=obp.mergeHeaders(obp.DL_TOKEN,
                                                  obp.CONTENT_JSON))

# Print result
print("")
print(response.status_code)
print(response.text)

# Reload account again for comparison
account = obp.getAccount(our_bank, our_account)
print("")
print(" --- Reload account data")
print("our account data after label update:\n{0}".format(account))

print("")
print(" --- Get owner transactions")
transactions = obp.getTransactions(our_bank, our_account)
print("Got {0} transactions".format(len(transactions)))
for t in transactions:
    print('{0} ({1} {2})'.format(t['id'], t['details']['value']['currency'],
                                 t['details']['value']['amount']))