Esempio n. 1
0
def create_client_subscriptions():  #and request client auth
    print(f'{Fore.LIGHTWHITE_EX}create client subscriptions:')
    start_time = datetime.datetime.now()

    dbsession = db.get_dbsession(**_process_call_area)
    emails = [
        '*****@*****.**', '*****@*****.**', 'bell@gmail',
        '*****@*****.**'
    ]
    for email in emails:
        client = dbsession.get(db.CLIENT, {'email': email},
                               caller_area=_process_call_area)
        if client:
            client_id = client.client_id
            bank_id = 'bankofcyprus'
            res = api.banksubscription_register(
                dbsession,
                client_id=client_id,
                bank_id=bank_id,
                application_name=application_name,
                allow_transactionHistory=True,
                allow_balance=True,
                allow_details=True,
                allow_checkFundsAvailability=False,
                payments_limit=0,
                payments_currency='EUR',
                payments_amount=0)
            print(res)
    dbsession.close(**_process_call_area)

    diff = datetime.datetime.now() - start_time
    duration = diff.days * 24 * 60 * 60 + diff.seconds
    print(f'{Fore.MAGENTA}duration :', duration)
Esempio n. 2
0
def unregister_banksubscription():
    print(f'{Fore.LIGHTWHITE_EX}unregister bank subscriptions:')
    start_time = datetime.datetime.now()

    dbsession = db.get_dbsession(**_process_call_area)
    sid = '6ab80c36-e9de-11e9-8aae-fbff3f03e211'
    res = api.banksubscription_unregister(dbsession,
                                          client_id={},
                                          bank_id={},
                                          application_name={},
                                          subscription_id=sid,
                                          caller_area={})
    print(res.get('api_message'))
    sid = '28ddd8c6-e9db-11e9-bae8-e105a87466ca'
    res = api.banksubscription_unregister(dbsession,
                                          client_id={},
                                          bank_id={},
                                          application_name={},
                                          subscription_id=sid,
                                          caller_area={})
    print(res.get('api_message'))
    dbsession.close(**_process_call_area)

    diff = datetime.datetime.now() - start_time
    duration = diff.days * 24 * 60 * 60 + diff.seconds
    print(f'{Fore.MAGENTA}duration :', duration)
def request_authorization_from_client_only():
    print(f'{Fore.LIGHTWHITE_EX}request athorization from client only:')
    start_time = datetime.datetime.now()
    
    dbsession = db.get_dbsession(**_process_call_area)
    bank_id = 'bankofcyprus'
    application_name='scanandpay_client'
    emails = ['*****@*****.**', '*****@*****.**', 'bell@gmail', '*****@*****.**']
    for email in emails:
        client = dbsession.get(db.CLIENT, {'email': email}, caller_area=_process_call_area)
        client_id=client.client_id
    reply=api.banksubscription_create(dbsession, client_id, bank_id, application_name, allow_transactionHistory=True, allow_balance=True, allow_details=True, allow_checkFundsAvailability=True, payments_limit=1000, payments_currency='EUR', payments_amount=100, caller_area=_process_call_area)
    if not reply.get('api_status') == 'success':
        msg = 'create subs FAILED.'
        print(Fore.RED, msg)
    else:
        api_data = reply.get('api_data', {})        
        subscription_id = api_data.get('bank_subscriptionID')
        client_id = api_data.get('client_id')
        bank_id = api_data.get('bank_id')
        application_name = api_data.get('application_name')
        
        reply = api.banksubscription_request_authorization_from_client(dbsession, client_id, bank_id, subscription_id, application_name, caller_area=_process_call_area)
        print(reply.get('api_message'))

    dbsession.close(**_process_call_area)

    diff = datetime.datetime.now() - start_time
    duration = diff.days * 24 * 60 * 60 + diff.seconds
    print(f'{Fore.MAGENTA}duration :',duration)
def receive_authorizations_from_clients():
    print(f'{Fore.LIGHTWHITE_EX}receive authorizations from clients:')
    start_time=datetime.datetime.now()

    dbsession = db.get_dbsession(**_process_call_area)
    bank_id = 'bankofcyprus'
    authorization_code = '1212122121simulated_authorization_code2121212112121'
    _process_call_area.update({'simulation_enabled':True})
    reply=api.banksubscription_receive_authorization_from_client(dbsession, bank_id, authorization_code, caller_area=_process_call_area)
    print(reply.get('api_message'))
    dbsession.close(**_process_call_area)

    diff = datetime.datetime.now() - start_time
    duration = diff.days * 24 * 60 * 60 + diff.seconds
    print(f'{Fore.MAGENTA}duration :',duration)
def create_merchant_subscriptions():  #and request client authorization
    print(f'{Fore.LIGHTWHITE_EX}create merchant subscriptions:')
    start_time=datetime.datetime.now()
    
    dbsession = db.get_dbsession(**_process_call_area)
    merchant_id = '6d1d1a14-e91b-11e9-aae5-33b843d61993'
    bank_id = 'bankofcyprus'
    dbreply = db.dbapi_merchant(dbsession,'get',{'merchant_id':merchant_id},caller_area=_process_call_area)
    client_id = dbreply.get('api_data', {}).get('client_id')
    if not client_id:
        msg = f'merchant {merchant_id} not found'
        print(msg)
    else:
        res = api.banksubscription_register(dbsession, 
            client_id=client_id, bank_id=bank_id, application_name=application_name,
            allow_transactionHistory=True, allow_balance=True,
            allow_details=True, allow_checkFundsAvailability=False,
            payments_limit=0, payments_currency='EUR', payments_amount=0
            )
        print(res)

    banks = dbsession.get_rows(db.BANK, {'status':'Active'}, caller_area=_process_call_area)
    merchants = dbsession.get_rows(db.MERCHANT, {}, caller_area=_process_call_area)
    for ix1 in range(0, len(merchants)):
        merchant = merchants[ix1]
        dbreply = db.dbapi_merchant(dbsession,'get',{'merchant_id':merchant.merchant_id},caller_area=_process_call_area)
        client_id = dbreply.get('api_data', {}).get('client_id')
        if not client_id:
            msg = f'merchant {merchant_id} not found'
            print(msg)
        else:
            for ix2 in range(0,len(banks)):
                bank = banks[ix2]
                bank_id = bank.bank_id
                res = api.banksubscription_register(dbsession, 
                    client_id=client_id, bank_id=bank_id, application_name=application_name,
                    allow_transactionHistory=True, allow_balance=True,
                    allow_details=True, allow_checkFundsAvailability=False,
                    payments_limit=0, payments_currency='EUR', payments_amount=0
                    )
                print(res)
    dbsession.close(**_process_call_area)

    diff = datetime.datetime.now() - start_time
    duration = diff.days * 24 * 60 * 60 + diff.seconds
    print(f'{Fore.MAGENTA}duration :',duration)
def create_banksubscription_only():
    print(f'{Fore.LIGHTWHITE_EX}create bank subscription only:')
    start_time=datetime.datetime.now()

    dbsession = db.get_dbsession(**_process_call_area)
    application_name='scanandpay_client'
    emails = ['*****@*****.**', '*****@*****.**', 'bell@gmail', '*****@*****.**']
    for email in emails:
        client = dbsession.get(db.CLIENT, {'email': email}, caller_area=_process_call_area)
        client_id=client.client_id
    # client_id='685e0b46-e91b-11e9-bea1-2db812eac691'
    bank_id = 'bankofcyprus'
    reply=api.banksubscription_create(dbsession, client_id, bank_id, application_name, allow_transactionHistory=True, allow_balance=True, allow_details=True, allow_checkFundsAvailability=True, payments_limit=1000, payments_currency='EUR', payments_amount=100, caller_area=_process_call_area)
    subscription_id = reply.get('bank_subscriptionID')
    print(reply.get('api_message'),'created subscription_id:',subscription_id)
    dbsession.close(**_process_call_area)


    diff = datetime.datetime.now() - start_time
    duration = diff.days * 24 * 60 * 60 + diff.seconds
    print(f'{Fore.MAGENTA}duration :',duration)
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
if __name__ == '__main__':
    #tests/research
    print(__file__)
    # caller_area={'aaaa': '11111'}
    # print('0caller_area=', caller_area)
    # test_api(caller_area, call_level=-1)
    # print('4caller_area=', caller_area)
    # sms_message='hi. confirm http://127.0.0.1:5555/confirmation/71CD00E6C50F/mobile'
    # sms_message='hi. confirm 127.0.0.5555confirmation71CD00E6C50Fmobile'
    # sms_result = send_sms(From='', To=client.mobile, Message=sms_message, data_record=client_record, caller_area=_process_call_area)
    # print(smsapi_send_mobile_confirmation_sms(dbsession, client_id, application_name, confirmation_url, caller_area={}))

    _process_call_area = {'debug_level': 99}
    dbsession = db.get_dbsession(**_process_call_area)
    application_name = 'scanandpay'
    # template = {'application_name': application_name, 'template_name': 'mobile_confirmation_sms', 'language': 'En',
    # 'text':'your otp to confirm your mobile is #OTP#. click #CONFIRMATION_URL#'}
    # db.dbapi_application_template(dbsession,'refresh',template,caller_area=_process_call_area)

    # template = {'application_name': application_name, 'template_name': 'mobile_confirmation_sms', 'language': 'Gr',
    # 'text':'ο κωδικός για επιβεβεβαιωση του κινητου σας ειναι: #OTP#. πατηστε #CONFIRMATION_URL#'}
    # db.dbapi_application_template(dbsession,'refresh',template,caller_area=_process_call_area)

    # template = {'application_name': '', 'template_name': 'mobile_confirmation_sms', 'language': 'En',
    # 'text':'your otp to confirm your mobile is #OTP#. click #CONFIRMATION_URL#'}
    # db.dbapi_application_template(dbsession,'refresh',template,caller_area=_process_call_area)

    # template = {'application_name': '', 'template_name': 'mobile_confirmation_sms', 'language': 'Gr',
    # 'text':'ο κωδικός για επιβεβεβαιωση του κινητου σας ειναι: #OTP#. πατηστε #CONFIRMATION_URL#'}