Skip to content

Commit

Permalink
Merge pull request #53 from TimNekk/develop (v1.7.2)
Browse files Browse the repository at this point in the history
Use Amount With Commission in Checks
  • Loading branch information
TimNekk authored Aug 5, 2023
2 parents 99cfa64 + 71ed130 commit f4fc458
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions pypayment/providers/betatransfer.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,8 +225,9 @@ def _validate_params(self):
raise PaymentCreationError("You must specify payment_type!")

payment_type_name = f"{self._payment_type.name} ({self._payment_type.value.name})"
if self.amount < self._payment_type.value.min_amount or \
(self._payment_type.value.max_amount and self.amount > self._payment_type.value.max_amount):
if self._amount_with_commission < self._payment_type.value.min_amount or \
(self._payment_type.value.max_amount and
self._amount_with_commission > self._payment_type.value.max_amount):
min_amount = self._payment_type.value.min_amount
max_amount = self._payment_type.value.max_amount
currency_name = self._payment_type.value.currency.value
Expand Down Expand Up @@ -280,7 +281,7 @@ def _create_url(self) -> str:
}

data = {
"amount": self._sum_with_commission,
"amount": self._amount_with_commission,
"currency": self._payment_type.value.currency.value,
"orderId": self.id,
"paymentSystem": self._payment_type.value.name,
Expand Down Expand Up @@ -362,7 +363,7 @@ def _get_sign(cls, data: Mapping[str, str]) -> str:
return hashlib.md5(sign.encode()).hexdigest()

@property
def _sum_with_commission(self) -> float:
def _amount_with_commission(self) -> float:
if self._charge_commission == ChargeCommission.FROM_CUSTOMER and self._payment_type:
return self.amount + self.amount * self._payment_type.value.commission_in_percent / 100

Expand Down

0 comments on commit f4fc458

Please sign in to comment.