Skip to content

Commit

Permalink
Merge pull request #9 from yoomoney/release/v2.1.5
Browse files Browse the repository at this point in the history
Release/2.1.5
  • Loading branch information
tonchik-tm authored Oct 29, 2021
2 parents abf3814 + 98d0da7 commit e97ba42
Show file tree
Hide file tree
Showing 7 changed files with 65 additions and 4 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
### v2.1.5 от 29.10.2021
* Добавлена поддержка Confirmation.mobile_application

### v2.1.4 от 19.10.2021
* Добавлена поддержка параметра on_behalf_of для метода /me

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

__author__ = "YooMoney"
__email__ = '[email protected]'
__version__ = '2.1.4'
__version__ = '2.1.5'
2 changes: 2 additions & 0 deletions src/yookassa/domain/common/confirmation_type.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@ class ConfirmationType:
* yookassa.domain.common.ConfirmationType.REDIRECT
* yookassa.domain.common.ConfirmationType.EMBEDDED
* yookassa.domain.common.ConfirmationType.QR
* yookassa.domain.common.ConfirmationType.MOBILE_APPLICATION
"""
EMBEDDED = 'embedded'
EXTERNAL = 'external'
REDIRECT = 'redirect'
QR = 'qr'
MOBILE_APPLICATION = 'mobile_application'
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
ConfirmationQr as RequestConfirmationQr
from yookassa.domain.models.confirmation.request.confirmation_redirect import \
ConfirmationRedirect as RequestConfirmationRedirect
from yookassa.domain.models.confirmation.request.confirmation_mobile_application import \
ConfirmationMobileApplication as RequestConfirmationMobileApplication
from yookassa.domain.models.confirmation.response.confirmation_embedded import \
ConfirmationEmbedded as ResponseConfirmationEmbedded
from yookassa.domain.models.confirmation.response.confirmation_external import \
Expand All @@ -17,6 +19,8 @@
ConfirmationQr as ResponseConfirmationQr
from yookassa.domain.models.confirmation.response.confirmation_redirect import \
ConfirmationRedirect as ResponseConfirmationRedirect
from yookassa.domain.models.confirmation.response.confirmation_mobile_application import \
ConfirmationMobileApplication as ResponseConfirmationMobileApplication


class ConfirmationClassMap(DataContext):
Expand All @@ -29,7 +33,8 @@ def request(self):
ConfirmationType.REDIRECT: RequestConfirmationRedirect,
ConfirmationType.EXTERNAL: RequestConfirmationExternal,
ConfirmationType.EMBEDDED: RequestConfirmationEmbedded,
ConfirmationType.QR: RequestConfirmationQr
ConfirmationType.QR: RequestConfirmationQr,
ConfirmationType.MOBILE_APPLICATION: RequestConfirmationMobileApplication
}

@property
Expand All @@ -38,5 +43,6 @@ def response(self):
ConfirmationType.REDIRECT: ResponseConfirmationRedirect,
ConfirmationType.EXTERNAL: ResponseConfirmationExternal,
ConfirmationType.EMBEDDED: ResponseConfirmationEmbedded,
ConfirmationType.QR: ResponseConfirmationQr
ConfirmationType.QR: ResponseConfirmationQr,
ConfirmationType.MOBILE_APPLICATION: ResponseConfirmationMobileApplication
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# -*- coding: utf-8 -*-
from yookassa.domain.common.confirmation_type import ConfirmationType
from yookassa.domain.models.confirmation.request.confirmation_request import ConfirmationRequest


class ConfirmationMobileApplication(ConfirmationRequest):
"""
Class representing mobile_application confirmation data object
"""
__return_url = None

def __init__(self, *args, **kwargs):
super(ConfirmationMobileApplication, self).__init__(*args, **kwargs)
if self.type is None or self.type is not ConfirmationType.MOBILE_APPLICATION:
self.type = ConfirmationType.MOBILE_APPLICATION

@property
def return_url(self):
return self.__return_url

@return_url.setter
def return_url(self, value):
cast_value = str(value)
if cast_value:
self.__return_url = cast_value
else:
raise ValueError('Invalid returnUrl value')
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# -*- coding: utf-8 -*-
from yookassa.domain.common.confirmation_type import ConfirmationType
from yookassa.domain.models.confirmation.confirmation import Confirmation


class ConfirmationMobileApplication(Confirmation):
"""
Class representing mobile_application confirmation data object
"""
__confirmation_url = None

def __init__(self, *args, **kwargs):
super(ConfirmationMobileApplication, self).__init__(*args, **kwargs)
if self.type is None or self.type is not ConfirmationType.MOBILE_APPLICATION:
self.type = ConfirmationType.MOBILE_APPLICATION

@property
def confirmation_url(self):
return self.__confirmation_url

@confirmation_url.setter
def confirmation_url(self, value):
self.__confirmation_url = value
2 changes: 1 addition & 1 deletion test/unit/test_payment_request.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ def test_request_setters(self):
]},
'payment_method_id': '123',
'payment_token': '99091209012',
'confirmation': {'type': ConfirmationType.REDIRECT, 'return_url': 'return.url'},
'confirmation': {'type': ConfirmationType.MOBILE_APPLICATION, 'return_url': 'return.url'},
'client_ip': '192.0.0.0',
"airline": {
"booking_reference": "IIIKRV",
Expand Down

0 comments on commit e97ba42

Please sign in to comment.