Skip to content

Commit

Permalink
Merge pull request #58 from TimNekk/develop (v1.7.6)
Browse files Browse the repository at this point in the history
Add Qiwi Card
  • Loading branch information
TimNekk authored Oct 10, 2023
2 parents 06dcac1 + da4bdc6 commit 4fd184c
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions pypayment/providers/betatransfer.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,11 +111,19 @@ class BetaTransferPaymentType(Enum):
QIWI = BetaTransferGateway(
name="Qiwi",
currency=BetaTransferCurrency.RUB,
commission_in_percent=14,
min_amount=100,
commission_in_percent=12,
min_amount=300,
max_amount=50000
)
"""Qiwi payment type."""
QIWI_CARD = BetaTransferGateway(
name="Qiwi2",
currency=BetaTransferCurrency.RUB,
commission_in_percent=12,
min_amount=100,
max_amount=50000
)
"""Qiwi Card payment type."""
# RUB_CARD = BetaTransferGateway(
# name="Card",
# currency=BetaTransferCurrency.RUB,
Expand Down Expand Up @@ -186,7 +194,8 @@ def __init__(self,
url_success: Optional[str] = None,
url_fail: Optional[str] = None,
locale: Optional[BetaTransferLocale] = None,
charge_commission: Optional[ChargeCommission] = None) -> None:
charge_commission: Optional[ChargeCommission] = None,
payer_id: Optional[str] = None) -> None:
"""
You need to BetaTransferPayment.authorize() first!
Expand Down Expand Up @@ -214,6 +223,7 @@ def __init__(self,
self._locale = BetaTransferPayment._locale if locale is None else locale
self._charge_commission = BetaTransferPayment._charge_commission if charge_commission is None \
else charge_commission
self.payer_id = payer_id

super().__init__(amount, description, id)

Expand All @@ -234,6 +244,9 @@ def _validate_params(self):
raise PaymentCreationError(f"Amount for {payment_type_name} must be between "
f"{min_amount} and {max_amount} {currency_name}!")

if self._payment_type == BetaTransferPaymentType.QIWI_CARD and not self.payer_id:
raise PaymentCreationError("You should specify payer_id for Qiwi Card (Qiwi2)")

@classmethod
def authorize(cls,
public_key: str,
Expand Down Expand Up @@ -289,7 +302,8 @@ def _create_url(self) -> str:
"urlSuccess": self._url_success,
"urlFail": self._url_fail,
"locale": self._locale.value,
"fullCallback": 1
"fullCallback": 1,
"payerId": self.payer_id
}

try:
Expand Down

0 comments on commit 4fd184c

Please sign in to comment.