Skip to content

Commit

Permalink
Merge pull request #15 from yoomoney/release/v2.3.0
Browse files Browse the repository at this point in the history
Release/2.3.0
  • Loading branch information
tonchik-tm authored Mar 22, 2022
2 parents d8e2bda + 4a31e14 commit bde5a27
Show file tree
Hide file tree
Showing 9 changed files with 55 additions and 2 deletions.
5 changes: 4 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
language: python
dist: bionic
python:
- "3.10"
- "3.9"
- "3.8"
- "3.7"
- "3.6"
- "3.5"
- "3.4"
matrix:
include:
- python: 3.4
dist: xenial
- python: 2.7
before_install:
- pip install -U mock
Expand Down
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
### v2.3.0 от 22.03.2022
* Добавлен метод оплаты через СБП

### v2.2.3 от 30.12.2021
* Небольшой рефакторинг

Expand Down
2 changes: 1 addition & 1 deletion src/yookassa/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@

__author__ = "YooMoney"
__email__ = '[email protected]'
__version__ = '2.2.3'
__version__ = '2.3.0'
2 changes: 2 additions & 0 deletions src/yookassa/domain/common/payment_method_type.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ class PaymentMethodType:
* yookassa.domain.common.PaymentMethodType.B2B_SBERBANK
* yookassa.domain.common.PaymentMethodType.TINKOFF_BANK
* yookassa.domain.common.PaymentMethodType.WECHAT
* yookassa.domain.common.PaymentMethodType.SBP
"""
YOO_MONEY = 'yoo_money'
BANK_CARD = 'bank_card'
Expand All @@ -36,3 +37,4 @@ class PaymentMethodType:
B2B_SBERBANK = 'b2b_sberbank'
TINKOFF_BANK = 'tinkoff_bank'
WECHAT = 'wechat'
SBP = 'sbp'
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
PaymentDataWechat as RequestPaymentDataWechat
from yookassa.domain.models.payment_data.request.payment_data_yoomoney_wallet import \
PaymentDataYooMoneyWallet as RequestPaymentDataYooMoneyWallet
from yookassa.domain.models.payment_data.request.payment_data_sbp import \
PaymentDataSbp as RequestPaymentDataSbp
from yookassa.domain.models.payment_data.response.payment_data_alfabank import \
PaymentDataAlfabank as ResponsePaymentDataAlfabank
from yookassa.domain.models.payment_data.response.payment_data_applepay import \
Expand Down Expand Up @@ -59,6 +61,8 @@
PaymentDataWechat as ResponsePaymentDataWechat
from yookassa.domain.models.payment_data.response.payment_data_yoomoney_wallet import \
PaymentDataYooMoneyWallet as ResponsePaymentDataYooMoneyWallet
from yookassa.domain.models.payment_data.response.payment_data_sbp import \
PaymentDataSbp as ResponsePaymentDataSbp


class PaymentDataClassMap(DataContext):
Expand All @@ -82,6 +86,7 @@ def request(self):
PaymentMethodType.B2B_SBERBANK: RequestPaymentDataB2bSberbank,
PaymentMethodType.TINKOFF_BANK: RequestPaymentDataTinkoffBank,
PaymentMethodType.WECHAT: RequestPaymentDataWechat,
PaymentMethodType.SBP: RequestPaymentDataSbp,
}

@property
Expand All @@ -102,4 +107,5 @@ def response(self):
PaymentMethodType.B2B_SBERBANK: ResponsePaymentDataB2bSberbank,
PaymentMethodType.TINKOFF_BANK: ResponsePaymentDataTinkoffBank,
PaymentMethodType.WECHAT: ResponsePaymentDataWechat,
PaymentMethodType.SBP: ResponsePaymentDataSbp,
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# -*- coding: utf-8 -*-
from yookassa.domain.common.payment_method_type import PaymentMethodType
from yookassa.domain.models.payment_data.payment_data import PaymentData


class PaymentDataSbp(PaymentData):
def __init__(self, *args, **kwargs):
super(PaymentDataSbp, self).__init__(*args, **kwargs)
if self.type is None or self.type is not PaymentMethodType.SBP:
self.type = PaymentMethodType.SBP
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# -*- coding: utf-8 -*-
from yookassa.domain.common.payment_method_type import PaymentMethodType
from yookassa.domain.models.payment_data.payment_data import ResponsePaymentData


class PaymentDataSbp(ResponsePaymentData):
def __init__(self, *args, **kwargs):
super(PaymentDataSbp, self).__init__(*args, **kwargs)
if self.type is None or self.type is not PaymentMethodType.SBP:
self.type = PaymentMethodType.SBP
15 changes: 15 additions & 0 deletions test/unit/test_payment_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
PaymentDataQiwi as RequestPaymentDataQiwi
from yookassa.domain.models.payment_data.request.payment_data_sberbank import \
PaymentDataSberbank as RequestPaymentDataSberbank
from yookassa.domain.models.payment_data.request.payment_data_sbp import \
PaymentDataSbp as RequestPaymentDataSbp
from yookassa.domain.models.payment_data.response.credit_card import CreditCard as ResponseCreditCard
from yookassa.domain.models.payment_data.response.payment_data_alfabank import \
PaymentDataAlfabank as ResponsePaymentDataAlfabank
Expand All @@ -48,6 +50,8 @@
PaymentDataQiwi as ResponsePaymentDataQiwi
from yookassa.domain.models.payment_data.response.payment_data_sberbank import \
PaymentDataSberbank as ResponsePaymentDataSberbank
from yookassa.domain.models.payment_data.response.payment_data_sbp import \
PaymentDataSbp as ResponsePaymentDataSbp


class TestPaymentData(unittest.TestCase):
Expand Down Expand Up @@ -304,3 +308,14 @@ def test_installments_cast(self):
def test_psb_cast(self):
payment_data = ResponsePaymentDataPsb()
self.assertEqual({'type': PaymentMethodType.PSB}, dict(payment_data))

def test_sbp_cast(self):
payment_data = RequestPaymentDataSbp()
payment_data.type = PaymentMethodType.SBP

self.assertEqual({'type': PaymentMethodType.SBP}, dict(payment_data))

payment_data = ResponsePaymentDataSbp()
payment_data.type = PaymentMethodType.SBP

self.assertEqual({'type': PaymentMethodType.SBP}, dict(payment_data))
4 changes: 4 additions & 0 deletions test/unit/test_payment_data_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from yookassa.domain.models.payment_data.payment_data_factory import PaymentDataFactory
from yookassa.domain.models.payment_data.request.payment_data_yoomoney_wallet import PaymentDataYooMoneyWallet
from yookassa.domain.models.payment_data.response.payment_data_webmoney import PaymentDataWebmoney
from yookassa.domain.models.payment_data.response.payment_data_sbp import PaymentDataSbp


class TestPaymentDataFactory(unittest.TestCase):
Expand All @@ -16,3 +17,6 @@ def test_factory_method(self):

response_payment_data = factory.create({'type': PaymentMethodType.WEBMONEY}, DataContext.RESPONSE)
self.assertIsInstance(response_payment_data, PaymentDataWebmoney)

response_payment_data = factory.create({'type': PaymentMethodType.SBP}, DataContext.RESPONSE)
self.assertIsInstance(response_payment_data, PaymentDataSbp)

0 comments on commit bde5a27

Please sign in to comment.