From 98d0da7b184a052f4547c45e6aa6387c0aa0d1c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D0=BD=D1=82=D0=BE=D0=BD=20=D0=9D=2E=20=D0=9D=D0=B8?= =?UTF-8?q?=D0=BA=D0=BE=D0=BB=D0=B0=D0=B5=D0=B2?= Date: Fri, 29 Oct 2021 18:18:19 +0300 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=D0=B0=20=D0=BF=D0=BE=D0=B4=D0=B4=D0=B5=D1=80=D0=B6=D0=BA?= =?UTF-8?q?=D0=B0=20Confirmation.mobile=5Fapplication?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 3 +++ src/yookassa/__init__.py | 2 +- .../domain/common/confirmation_type.py | 2 ++ .../confirmation/confirmation_class_map.py | 10 +++++-- .../confirmation_mobile_application.py | 27 +++++++++++++++++++ .../confirmation_mobile_application.py | 23 ++++++++++++++++ test/unit/test_payment_request.py | 2 +- 7 files changed, 65 insertions(+), 4 deletions(-) create mode 100644 src/yookassa/domain/models/confirmation/request/confirmation_mobile_application.py create mode 100644 src/yookassa/domain/models/confirmation/response/confirmation_mobile_application.py diff --git a/CHANGELOG.md b/CHANGELOG.md index 2095ee9..99aa065 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +### v2.1.5 от 29.10.2021 +* Добавлена поддержка Confirmation.mobile_application + ### v2.1.4 от 19.10.2021 * Добавлена поддержка параметра on_behalf_of для метода /me diff --git a/src/yookassa/__init__.py b/src/yookassa/__init__.py index 5a2dcd1..a27703a 100644 --- a/src/yookassa/__init__.py +++ b/src/yookassa/__init__.py @@ -10,4 +10,4 @@ __author__ = "YooMoney" __email__ = 'cms@yoomoney.ru' -__version__ = '2.1.4' +__version__ = '2.1.5' diff --git a/src/yookassa/domain/common/confirmation_type.py b/src/yookassa/domain/common/confirmation_type.py index b26f26e..76e3d10 100644 --- a/src/yookassa/domain/common/confirmation_type.py +++ b/src/yookassa/domain/common/confirmation_type.py @@ -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' diff --git a/src/yookassa/domain/models/confirmation/confirmation_class_map.py b/src/yookassa/domain/models/confirmation/confirmation_class_map.py index 69caa4d..197985d 100644 --- a/src/yookassa/domain/models/confirmation/confirmation_class_map.py +++ b/src/yookassa/domain/models/confirmation/confirmation_class_map.py @@ -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 \ @@ -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): @@ -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 @@ -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 } diff --git a/src/yookassa/domain/models/confirmation/request/confirmation_mobile_application.py b/src/yookassa/domain/models/confirmation/request/confirmation_mobile_application.py new file mode 100644 index 0000000..e7cf551 --- /dev/null +++ b/src/yookassa/domain/models/confirmation/request/confirmation_mobile_application.py @@ -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') diff --git a/src/yookassa/domain/models/confirmation/response/confirmation_mobile_application.py b/src/yookassa/domain/models/confirmation/response/confirmation_mobile_application.py new file mode 100644 index 0000000..2d9c814 --- /dev/null +++ b/src/yookassa/domain/models/confirmation/response/confirmation_mobile_application.py @@ -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 diff --git a/test/unit/test_payment_request.py b/test/unit/test_payment_request.py index 540c98a..b68596c 100644 --- a/test/unit/test_payment_request.py +++ b/test/unit/test_payment_request.py @@ -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",