Exemplo n.º 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)
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']
transaction_req_id = initiate_response['id']
challenge_response = obp.answerChallengeV210(
    bank_id=from_bank_id,
    account_id=from_account_id,
    transation_req_id=transaction_req_id,
    challenge_type=challenge_type_sandbox_tan,
    challenge_query=challenge_query)
Exemplo n.º 3
0
######################### Step2 - make a payment - SANDBOX_TAN ################
print("")
print("")
# 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(TRANSACTION_REQUEST_TYPE_SANDBOX_TAN))
print("Call API - 1 'Create Transaction Request. -- V210' (no challenge)")
# set up a small value in payment detail
obp.setPaymentDetails(OUR_CURRENCY, OUR_VALUE)
initiate_response = obp.createTransactionRequestV210(from_bank_id=from_bank_id,
                                                     from_account_id=from_account_id,
                                                     transaction_request_type=TRANSACTION_REQUEST_TYPE_SANDBOX_TAN,
                                                     to_bank_id=to_bank_id,
                                                     to_account_id=to_account_id,
                                                     to_counterparty_id="",  # used for SEPA
                                                     to_counterparty_iban="")  # used for COUNTERPARTY

# There was no challenge, transaction was created immediately
obp.printMessageNoChallenge(initiate_response)

#####Case2: with challenge
print("")
print("Call API - 2 'Create Transaction Request. -- V210' (with challenge)")
# set up a large value in payment detail
obp.setPaymentDetails(OUR_CURRENCY, OUR_VALUE_LARGE)
initiate_response = obp.createTransactionRequestV210(from_bank_id=from_bank_id,
                                                     from_account_id=from_account_id,
                                                     transaction_request_type=TRANSACTION_REQUEST_TYPE_SANDBOX_TAN,