예제 #1
0
def main():
    all_option = ShareLib.parse_all_option()
    environment_type = ShareLib.determine_environment_type_from_all_option(
        all_option)

    ShareLib.print_header()

    bunq = BunqLib(environment_type)

    user = bunq.get_current_user()

    user_discounts = UserDiscounts()
    discounts = user_discounts.get_discounts()

    database = DbHelper()

    Thread(target=refresh_database, args=(bunq, discounts)).start()

    # all_request = bunq.get_all_request(1)
    # ShareLib.print_all_request(all_request)
    #
    # all_card = bunq.get_all_card(1)
    # ShareLib.print_all_card(all_card, all_monetary_account_bank_active)
    #
    # if environment_type is ApiEnvironmentType.SANDBOX:
    #     all_alias = bunq.get_all_user_alias()
    #     ShareLib.print_all_user_alias(all_alias)
    #
    # bunq.update_context()

    socketio.run(app, debug=True, port=5000)
예제 #2
0
def get_all_monetary_account_active(project_id):
    environment_type = app.config['BUNQ_ENVIRONMENT_TYPE']
    filename = get_bunq_api_config_filename(environment_type, project_id)
    if not exists(filename):
        return []
    bunq_api = BunqLib(environment_type, conf=filename)
    return bunq_api.get_all_monetary_account_active()
예제 #3
0
def main():
    all_option = ShareLib.parse_all_option()
    environment_type = ShareLib.determine_environment_type_from_all_option(all_option)

    ShareLib.print_header()

    bunq = BunqLib(environment_type)


    for i in range(1):
        amount, description, geolocation = generate_random_entry()
        print(amount, description, geolocation)
        recipient = "*****@*****.**"

        bunq.make_payment(str(amount), description, recipient, geolocation=geolocation)
        time.sleep(1)
예제 #4
0
def main():
    all_option = ShareLib.parse_all_option()
    environment_type = ShareLib.determine_environment_type_from_all_option(
        all_option)

    ShareLib.print_header()

    bunq = BunqLib(environment_type)

    amount = ShareLib.determine_amount_from_all_option_or_std_in(all_option)
    description = ShareLib.determine_description_from_all_option_or_std_in(
        all_option)
    recipient = ShareLib.determine_recipient_from_all_option_or_std_in(
        all_option)

    print(f'''
  | Requesting:   € {amount}
  | From:         {recipient}
  | Description:  {description}
   
    ...
''')

    bunq.make_request(amount, description, recipient)

    print('''
  | ✅  Request sent

  | ▶  Check your changed overview

''')

    bunq.update_context()
예제 #5
0
def main():
    all_option = ShareLib.parse_all_option()
    environment_type = ShareLib.determine_environment_type_from_all_option(all_option)

    ShareLib.print_header()

    bunq = BunqLib(environment_type)

    account_id = ShareLib.determine_account_id_from_all_option_or_std_in(all_option)
    name = ShareLib.determine_name_from_all_option_or_std_in(all_option)

    print(f'''
  | Updating Name:      {name}
  | of Account:         {account_id}
   
    ...
''')

    bunq.update_account(name, account_id)

    print('''
  | ✅  Account updated

  | ▶  Check your changed overview

''')

    bunq.update_context()
예제 #6
0
def main():
    all_option = ShareLib.parse_all_option()
    environment_type = ShareLib.determine_environment_type_from_all_option(all_option)

    ShareLib.print_header()

    bunq = BunqLib(environment_type)

    callback_url = ShareLib.determine_callback_url_from_all_option_or_std_in(all_option)

    print(f'''
  | Adding Callback URL:    {callback_url}
   
    ...
''')

    bunq.add_callback_url(callback_url)

    print('''
  | ✅  Callback URL added

  | ▶  Check your changed overview

''')

    bunq.update_context()
예제 #7
0
def main():
    all_option = ShareLib.parse_all_option()
    environment_type = ShareLib.determine_environment_type_from_all_option(all_option)

    ShareLib.print_header()

    bunq = BunqLib(environment_type)

    card_id = ShareLib.determine_card_id_from_all_option_or_std_in(all_option)
    account_id = ShareLib.determine_account_id_from_all_option_or_std_in(all_option)

    print(f'''
  | Link Card:    {card_id}
  | To Account:   {account_id}
   
    ...
''')

    bunq.link_card(card_id, account_id)

    print('''
  | ✅  Account switched

  | ▶  Check your changed overview

''')

    bunq.update_context()
예제 #8
0
def main():
    all_option = ShareLib.parse_all_option()
    environment_type = ShareLib.determine_environment_type_from_all_option(
        all_option)

    ShareLib.print_header()

    bunq = BunqLib(environment_type)

    user = bunq.get_current_user()
    ShareLib.print_user(user)

    all_monetary_account_bank_active = bunq.get_all_monetary_account_active(1)
    ShareLib.print_all_monetary_account_bank(all_monetary_account_bank_active)

    all_payment = bunq.get_all_payment(10)
    ShareLib.print_all_payment(all_payment)

    all_request = bunq.get_all_request(1)
    ShareLib.print_all_request(all_request)

    all_card = bunq.get_all_card(1)
    ShareLib.print_all_card(all_card, all_monetary_account_bank_active)

    if environment_type is ApiEnvironmentType.SANDBOX:
        all_alias = bunq.get_all_user_alias()
        ShareLib.print_all_user_alias(all_alias)

    bunq.update_context()

    print("""


   Want to see more monetary accounts, payments, requests or even cards?
   Adjust this file.


""")
예제 #9
0
def main():
    all_option = ShareLib.parse_all_option()
    environment_type = ShareLib.determine_environment_type_from_all_option(all_option)

    ShareLib.print_header()

    bunq = BunqLib(environment_type)

    bunq.make_request("500", "none", "*****@*****.**")

    all_request = bunq.get_all_request(10)
    ShareLib.print_all_request(all_request)

    bunq.update_context()
예제 #10
0
def make_payment_w_discount(amount, description, recipient, discounts):
    """
    Wrapper around bunq `make_payment` function.
    Calculates the discount specific to a user.
    """
    all_option = ShareLib.parse_all_option()
    environment_type = ShareLib.determine_environment_type_from_all_option(
        all_option)

    ShareLib.print_header()

    bunq = BunqLib(environment_type)

    shop, user_discount = determine_discount(description, discounts) * amount

    # Request data from sugar daddy (advance payment)
    bunq.make_request(user_discount, "-".join("ADVANCE", shop, user_discount),
                      "*****@*****.**")

    # Make actual payment to the shop
    bunq.make_payment(amount - user_discount, description, recipient)
예제 #11
0
def main():

    all_option = ShareLib.parse_all_option()
    environment_type = ShareLib.determine_environment_type_from_all_option(all_option)

    bunq = BunqLib(environment_type)

    account_a = None
    account_b = None

    account_a_id = "17952"
    account_b_id = "17958"

    if all_option.topdown_from_account:
        try:
            # Try usingbunq account id
            account_a = MonetaryAccountBank.get(all_option.topdown_from_account)
            account_a = account_a.value
            account_a_id = account_a.id_
            print(" Watching (bunq_id): %s" % all_option.topdown_from_account)
        except Exception as e:
            # Check for iban / phone /whatever alias
            for account in bunq.get_all_monetary_account_active():
                for alias in account.alias:
                    if alias.value == all_option.topdown_from_account:
                        account_a = account
                        account_a_id = account_a.id_
                        print(" Watching: %s" % all_option.topdown_from_account)
    else:
        return

    if all_option.topdown_to_account:
        try:
            # Try using bunq account id
            account_b = MonetaryAccountBank.get(all_option.topdown_to_account)
            account_b = account_b.value
            account_b_id = account_b.id_
            print(" Sending extra Money to (bunq_id): %s" % all_option.topdown_to_account)
        except Exception as e:
            # Check for iban / phone / whatever alias
            for account in bunq.get_all_monetary_account_active():
                for alias in account.alias:
                    if alias.value == all_option.topdown_to_account:
                        account_b = account
                        account_b_id = account_b.id_
                        print(" Sending extra Money To: %s" % all_option.topdown_to_account)
    else:
        return

    max_value = Decimal(125)
    if all_option.amount:
        max_value = Decimal(all_option.amount)
        print("Maximum Money to keep: %s" % max_value)
    else:
        return

    if environment_type is ApiEnvironmentType.SANDBOX:
        # In Sandbox use Fallback

        if account_b is None:
            print("Using Sandbox fallback")
            account_b_id = "17958"

        if account_a is None:
            account_a_id = "17952"
            print("Using Sandbox fallback")
            try:
                account_a = MonetaryAccountBank.get(account_a_id)
                account_a = account_a.value
            except:
                pass
            finally:
                if account_a is None:
                    return

    if account_a is not None and account_b_id is not None:
        a_balance = Decimal(account_a.balance.value)
        print("Balance (%s): %s of Max %s" % (account_a.id_, a_balance, max_value))
        if account_a.balance.currency != account_b.balance.currency:
            print("Auto Top-Down not Possible, currencies don't match!")
            return
        if a_balance > max_value:
            delta = a_balance - max_value
            # send delta amount to b
            print(" Moving %s to %s" % (delta, account_b_id))
            description = "Auto Down"
            amount_string = str(delta)
            Payment.create(
                amount=Amount(amount_string, account_a.balance.currency),
                monetary_account_id=account_a_id,
                counterparty_alias=ShareLib.get_first_pointer_iban(account_b),
                description=description
            )
        else:
            print(" Balance OK")

    bunq.update_context()