Skip to content

Commit

Permalink
user custom withdrawal fees and finger print
Browse files Browse the repository at this point in the history
  • Loading branch information
pinhopro committed Feb 11, 2015
1 parent 93a9ec6 commit badfd26
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 4 deletions.
18 changes: 17 additions & 1 deletion apps/trade/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -449,6 +449,15 @@ def set_verified(self, session, verified, verification_data, bonus_account):
return True
return False

class FingerPrints(Base):
__tablename__ = 'finger_prints'
id = Column(Integer, primary_key=True)
user_id = Column(Integer, ForeignKey('users.id') ,nullable=False)
broker_id = Column(Integer, ForeignKey('users.id') ,nullable=False)
finger_print = Column(Integer, nullable=False)
remote_ip = Column(String, nullable=False)



class Position(Base):
__tablename__ = 'position'
Expand Down Expand Up @@ -1615,7 +1624,8 @@ def get_list(session, broker_id, account_id, status_list, page_size, offset, fil
return query

@staticmethod
def create(session, user, broker, currency, amount, method, data, client_order_id, email_lang):
def create(session, user, broker, currency, amount, method, data, client_order_id, email_lang,
user_withdraw_percent_fee=None, user_withdraw_fixed_fee=None):
import uuid
confirmation_token = uuid.uuid4().hex

Expand All @@ -1629,6 +1639,12 @@ def create(session, user, broker, currency, amount, method, data, client_order_
fixed_fee = withdraw_method['fixed_fee']
break

if user_withdraw_percent_fee is not None:
percent_fee = min(percent_fee, user_withdraw_percent_fee)

if user_withdraw_fixed_fee is not None:
fixed_fee = min(fixed_fee, user_withdraw_fixed_fee)

withdraw_record = Withdraw(user_id = user.id,
account_id = user.id,
username = user.username,
Expand Down
9 changes: 7 additions & 2 deletions apps/trade/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -942,6 +942,9 @@ def processWithdrawRequest(session, msg):

verification_level = session.user.verified

user_withdraw_percent_fee = session.user.withdraw_percent_fee
user_withdraw_fixed_fee = session.user.withdraw_fixed_fee

withdraw_structure = json.loads(session.broker.withdraw_structure)
limits = None
for withdraw_method in withdraw_structure[msg.get('Currency')]:
Expand Down Expand Up @@ -977,7 +980,9 @@ def processWithdrawRequest(session, msg):
msg.get('Method'),
msg.get('Data', {} ),
client_order_id,
session.email_lang)
session.email_lang,
user_withdraw_percent_fee,
user_withdraw_fixed_fee)

TradeApplication.instance().db_session.commit()

Expand Down Expand Up @@ -1428,7 +1433,7 @@ def processProcessDeposit(session, msg):
found_deposit_by_secret = True
break

if not found_deposit_by_secret and deposit_list:
if not found_deposit_by_secret and deposit is not None:
# we found deposits using the same secret, but with different data.
# this means that the user reused the deposit address. Let's create another
# deposit record based on the last deposit we found and process it.
Expand Down
4 changes: 4 additions & 0 deletions apps/ws_gateway/verification_webhook_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ def post(self, *args, **kwargs):
address_postal = None
address_country = None
address_country_code = None
finger_print = None

photo_fields = []
id_fields = []
Expand Down Expand Up @@ -96,6 +97,8 @@ def post(self, *args, **kwargs):
address_country = value['country']
address_country_code = get_country_code(address_country)

if 'finger_print' in key:
finger_print = value

#form stack
if 'name-first' in key:
Expand Down Expand Up @@ -173,6 +176,7 @@ def post(self, *args, **kwargs):
'formID': formID,
'submissionID': submissionID,
'created_at': createdAt,
'browser_finger_print': finger_print,
'name': {
'first': first_name,
'middle': middle_name,
Expand Down
3 changes: 2 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ appdirs
mailchimp
pycountry
pyboleto
mock
mock
yowsup2

0 comments on commit badfd26

Please sign in to comment.