Skip to content

Commit

Permalink
Merge pull request #4 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 Apr 8, 2021
2 parents e95becd + c8577a5 commit 833b198
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 28 deletions.
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 от 08.04.2021
* Для DepositionRequest paymentParams.pof_offerAccepted обязателен

### v2.2.0 от 01.04.2021
* Добавлен параметр -noverify для расшифровки ответа кассы
* Генерация CSR со старым закрытым ключом
Expand Down
2 changes: 1 addition & 1 deletion src/yookassa_payout/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

__author__ = "YooMoney"
__email__ = 'cms@yoomoney.ru'
__version__ = '2.2.0'
__version__ = '2.3.0'
1 change: 1 addition & 0 deletions src/yookassa_payout/domain/models/recipients/recipient.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ def set_validation_error(self, message):
raise ValueError(message)

def map(self):
self.validate()
return {
"pof_offerAccepted": [str(int(self.pof_offer_accepted))]
}
21 changes: 20 additions & 1 deletion src/yookassa_payout/domain/request/deposition_request.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# -*- coding: utf-8 -*-
from yookassa_payout.domain.models.recipients.recipient import Recipient
from yookassa_payout.domain.models.recipients.recipient_factory import RecipientFactory
from yookassa_payout.domain.request.request_object import RequestObject


Expand All @@ -10,6 +12,7 @@ class DepositionRequest(RequestObject):
__amount = None
__currency = None
__contract = None
__payment_params = None

def __init__(self, *args, **kwargs):
super(DepositionRequest, self).__init__(*args, **kwargs)
Expand Down Expand Up @@ -63,14 +66,30 @@ def contract(self):
def contract(self, value):
self.__contract = str(value)

@property
def payment_params(self):
return self.__payment_params

@payment_params.setter
def payment_params(self, value):
if isinstance(value, Recipient):
self.__payment_params = value
elif isinstance(value, dict):
self.__payment_params = RecipientFactory.factory(value)
else:
raise TypeError('Invalid payment_params value type')

def validate(self):
super(DepositionRequest, self).validate()
if not self.agent_id:
self.set_validation_error('Deposition agent_id not specified')
if not self.client_order_id:
self.set_validation_error('Deposition client_order_id not specified')
if not self.payment_params:
self.set_validation_error('Deposition payment_params not specified')

def map(self):
self.validate()
_map = super(DepositionRequest, self).map()
_map.update({
"agentId": self.agent_id,
Expand All @@ -79,6 +98,6 @@ def map(self):
"amount": format(self.amount, ".2f"),
"currency": self.currency,
"contract": self.contract,
"paymentParams": self.payment_params.map()
})
return _map

27 changes: 1 addition & 26 deletions src/yookassa_payout/domain/request/make_deposition_request.py
Original file line number Diff line number Diff line change
@@ -1,39 +1,14 @@
# -*- coding: utf-8 -*-
from yookassa_payout.domain.models.recipients.recipient import Recipient
from yookassa_payout.domain.models.recipients.recipient_factory import RecipientFactory
from yookassa_payout.domain.request.deposition_request import DepositionRequest


class MakeDepositionRequest(DepositionRequest):

__payment_params = None

def __init__(self, *args, **kwargs):
super(MakeDepositionRequest, self).__init__(*args, **kwargs)
self.request_name = 'makeDeposition'

@property
def payment_params(self):
return self.__payment_params

@payment_params.setter
def payment_params(self, value):
if isinstance(value, Recipient):
self.__payment_params = value
elif isinstance(value, dict):
self.__payment_params = RecipientFactory.factory(value)
else:
raise TypeError('Invalid payment_params value type')

def validate(self):
super(MakeDepositionRequest, self).validate()
if not self.payment_params:
self.set_validation_error('Deposition payment_params not specified')

def map(self):
self.validate()
_map = super(MakeDepositionRequest, self).map()
if self.payment_params:
_map.update({
"paymentParams": self.payment_params.map()
})
return {self.request_name + 'Request': _map}
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@ def __init__(self, *args, **kwargs):
self.request_name = 'testDeposition'

def map(self):
self.validate()
_map = super(TestDepositionRequest, self).map()
return {self.request_name + 'Request': _map}
6 changes: 6 additions & 0 deletions tests/unit/test_test_deposition_request.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,9 @@ def test_request_map(self):
"amount": format(10.0, ".2f"),
"currency": Currency.RUB,
"contract": "Зачисление на кошелек",
"paymentParams": {
"pof_offerAccepted": ['1'],
}
}
})

Expand All @@ -83,4 +86,7 @@ def create_test_params():
"amount": 10.00,
"currency": Currency.RUB,
"contract": "Зачисление на кошелек",
"payment_params": {
"pof_offer_accepted": True,
}
}

0 comments on commit 833b198

Please sign in to comment.