Пример #1
0
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)
Пример #2
0
def check_balance(intent_request):
    account = intent_request['currentIntent']['slots']['account']
    print (account)
    source = intent_request['invocationSource']
    if source == 'DialogCodeHook':
      slots = intent_request['currentIntent']['slots']
      intent_name = intent_request['currentIntent']['name']
      if (account == None):
        return elicit_slot(intent_name,slots,'account')
      print (account)
      validation_result = validate_account(account)
      if validation_result == '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']
                print (balance)
                message = "Your account balance is $"+ balance
                mess = message + 10*" "+ "\n Would you like to know anything?"
                #return close(intent_request,message)
                return elicit_intent(mess)
      else:
          message = "Invalid Account Number"
          return close(intent_request,message)
Пример #3
0
# Get accounts for a specific bank
print(" --- Private accounts")

accounts = obp.getPrivateAccounts(our_bank)

for a in accounts:
    print(a['id'])

# Just picking first account
our_account = accounts[1]['id']
print("our account: {0}".format(our_account))

# Reload account
print("")
print(" --- Load our account data")
account_data = obp.getAccount(our_bank, our_account)
print("our account data:\n{0}".format(account_data))

print("")
print(" --- Modify account label")
new_label = "New label %s" % time.strftime("%d/%m/%Y %I:%M:%S")
print(new_label)

# Prepare post data and set new label value
post_data = {
    'id': '%s' % our_account,
    'label': '%s' % new_label,
    'bank_id': '%s' % OUR_BANK
}

# Send post request with attached json with new label value
Пример #4
0
# 11 Get Counterparties of one Account.-- V220

print(
    "#########################Step 1 : Direct Login process.################")
obp = lib.obp
obp.setBaseUrl(BASE_URL)
obp.setApiVersion(API_VERSION_V210)

# login and set authorized token
print("Call API - 0 'DirectLogin'")
obp.login(USERNAME, PASSWORD, CONSUMER_KEY)

# set fromAccount info:
from_bank_id = FROM_BANK_ID
from_account_id = FROM_ACCOUNT_ID
getAccount_response_before = obp.getAccount(FROM_BANK_ID, FROM_ACCOUNT_ID)

# set fromAccount info:
from_bank_id = FROM_BANK_ID
from_account_id = FROM_ACCOUNT_ID

print("")
print("")
print(
    "######################### Step2 - make a payment - SANDBOX_TAN ########")
# set the toAccount for SANDBOX_TAN
to_bank_id = TO_BANK_ID
to_account_id = TO_ACCOUNT_ID

TRANSACTION_REQUEST_TYPE_SANDBOX_TAN = "SANDBOX_TAN"
print("--------- TRANSACTION_REQUEST_TYPE : {0}".format(