Skip to content

Commit

Permalink
Merge pull request #62 from TimNekk/develop (v1.7.10)
Browse files Browse the repository at this point in the history
Add KZT Card For KZT
  • Loading branch information
TimNekk authored Dec 13, 2023
2 parents 8150088 + 3d06975 commit 0a25e09
Showing 1 changed file with 18 additions and 8 deletions.
26 changes: 18 additions & 8 deletions pypayment/providers/betatransfer.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class BetaTransferGateway:
name: str
currency: BetaTransferCurrency
commission_in_percent: float
min_amount: float
min_amount: Optional[float]
max_amount: Optional[float]


Expand Down Expand Up @@ -78,14 +78,22 @@ class BetaTransferPaymentType(Enum):
max_amount=5000
)
"""Crypto payment type."""
KZT_CARD = BetaTransferGateway(
KZT_CARD_USD = BetaTransferGateway(
name="P2R_KZT",
currency=BetaTransferCurrency.USD,
commission_in_percent=12,
min_amount=12,
max_amount=1000
)
"""P2R KZT payment type."""
KZT_CARD = BetaTransferGateway(
name="P2R_KZT",
currency=BetaTransferCurrency.KZT,
commission_in_percent=12,
min_amount=None,
max_amount=None
)
"""P2R KZT payment type."""
UZS_CARD = BetaTransferGateway(
name="Card6",
currency=BetaTransferCurrency.UZS,
Expand Down Expand Up @@ -261,12 +269,14 @@ def _validate_params(self):
if not self._payment_type:
raise PaymentCreationError("You must specify payment_type!")

payment_type_name = f"{self._payment_type.name} ({self._payment_type.value.name})"
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
min_amount = self._payment_type.value.min_amount
max_amount = self._payment_type.value.max_amount

invalid_min_amount = min_amount and self._amount_with_commission < min_amount
invalid_max_amount = max_amount and self._amount_with_commission > max_amount

if invalid_min_amount or invalid_max_amount:
payment_type_name = f"{self._payment_type.name} ({self._payment_type.value.name})"
currency_name = self._payment_type.value.currency.value
raise PaymentCreationError(f"Amount for {payment_type_name} must be between "
f"{min_amount} and {max_amount} {currency_name}!")
Expand Down

0 comments on commit 0a25e09

Please sign in to comment.