Skip to content

Commit

Permalink
Get rid of implicit DAI handling
Browse files Browse the repository at this point in the history
  • Loading branch information
davesque committed Jul 11, 2019
1 parent 06b410d commit 8d566f6
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions pretix_eth/payment.py
Expand Up @@ -119,16 +119,18 @@ def payment_is_valid_session(self, request):
)

def execute_payment(self, request: HttpRequest, payment: OrderPayment):
currency = request.session['payment_ethereum_fm_currency']

payment.info_data = {
'sender_address': request.session['payment_ethereum_fm_address'],
'currency': request.session['payment_ethereum_fm_currency'],
'currency': currency,
'time': request.session['payment_ethereum_time'],
'amount': request.session['payment_ethereum_amount'],
}
payment.save(update_fields=['info'])

try:
if request.session['payment_ethereum_fm_currency'] == 'ETH':
if currency == 'ETH':
response = requests.get(
f'https://api.ethplorer.io/getAddressTransactions/{self.settings.ETH}?apiKey=freekey' # noqa: E501
)
Expand All @@ -141,7 +143,7 @@ def execute_payment(self, request: HttpRequest, payment: OrderPayment):
payment.confirm()
except Quota.QuotaExceededException as e:
raise PaymentException(str(e))
else:
elif currency == 'DAI':
response = requests.get(
f'https://blockscout.com/poa/dai/api?module=account&action=txlist&address={self.settings.DAI}' # noqa: E501
)
Expand All @@ -155,6 +157,8 @@ def execute_payment(self, request: HttpRequest, payment: OrderPayment):
payment.confirm()
except Quota.QuotaExceededException as e:
raise PaymentException(str(e))
else:
raise ImproperlyConfigured(f'Unrecognized currency: {currency}')
except (NameError, TypeError, AttributeError):
pass

Expand Down

0 comments on commit 8d566f6

Please sign in to comment.