Skip to content

Commit

Permalink
Merge pull request #83 from PayTechUz/feat/nakapitel
Browse files Browse the repository at this point in the history
(hotfix) convert amount
  • Loading branch information
Muhammadali-Akbarov authored Nov 1, 2024
2 parents da88a47 + 22ecd4d commit 0015587
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
17 changes: 12 additions & 5 deletions payme/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,11 +126,18 @@ def validate_amount(self, account, amount):
"""
Validates if the amount matches for one-time payment accounts.
"""
if settings.PAYME_ONE_TIME_PAYMENT:
account_amount = getattr(account, settings.PAYME_AMOUNT_FIELD)
if Decimal(account_amount) != Decimal(amount):
message = f"Invalid amount. Expected: {account_amount}, received: {amount}"
raise exceptions.IncorrectAmount(message)
if not settings.PAYME_ONE_TIME_PAYMENT:
return True

expected_amount = Decimal(getattr(account, settings.PAYME_AMOUNT_FIELD)) * 100
received_amount = Decimal(amount)

if expected_amount != received_amount:
raise exceptions.IncorrectAmount(
f"Invalid amount. Expected: {expected_amount}, received: {received_amount}"
)

return True

@handle_exceptions
def check_perform_transaction(self, params) -> response.CheckPerformTransaction:
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

setup(
name='payme-pkg',
version='3.0.0b8',
version='3.0.0b9',
license='MIT',
author="Muhammadali Akbarov",
author_email='[email protected]',
Expand Down

0 comments on commit 0015587

Please sign in to comment.