-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathypmn_classes_payout.py
301 lines (210 loc) · 7.37 KB
/
ypmn_classes_payout.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
from typing import List
from random import randint
import json
with open('configs.json', 'r') as file:
data = json.load(file)
class Amount:
"""
Класс создающий блок amount, необходим для генерации тела запроса на выплату
"""
value: float
def __init__(
self,
value: float = 0
) -> None:
self.value = value
def to_dict(self):
amount_dict = {
"currency": data.get('Currency'),
"value": self.value
}
return {key: value for key, value in amount_dict.items() if value}
class Card:
"""
Класс создающий блок card, необходим для генерации тела запроса на выплату с использованием карточных данных
"""
card_number: str
def __init__(
self,
card_number: str = ""
) -> None:
self.card_number = card_number
def to_dict(self):
card_dict = {
"cardNumber": self.card_number
}
return {key: value for key, value in card_dict.items() if value}
class Token:
"""
Класс создающий блок token, необходим для генерации тела запроса на выплату с использованием токена
"""
token_hash: str
def __init__(
self,
token_hash: str = ""
) -> None:
self.token_hash = token_hash
def to_dict(self):
token_dict = {
"tokenHash": self.token_hash
}
return {key: value for key, value in token_dict.items() if value}
class Recipient:
"""
Класс создающий блок recipient, необходим для генерации тела запроса на выплату с использованием токена
"""
type: str
email: str
city: str
address: str
postal_code: int
first_name: str
last_name: str
def __init__(
self,
type: str = "",
email: str = "",
city: str = "",
address: str = "",
postal_code: int = 0,
first_name: str = "",
last_name: str = ""
) -> None:
self.type = type
self.email = email
self.city = city
self.address = address
self.postal_code = postal_code
self.first_name = first_name
self.last_name = last_name
def to_dict(self):
recipient_dict = {
"type": self.type,
"email": self.email,
"city": self.city,
"address": self.address,
"postalCode": self.postal_code,
"countryCode": data.get('CountryCode'),
"firstName": self.first_name,
"lastName": self.last_name
}
return {key: value for key, value in recipient_dict.items() if value}
class Destination:
"""
Класс создающий блок destination, необходим для генерации тела запроса на выплату с использованием токена
"""
card: Card
recipient: Recipient
def __init__(
self,
card: Card = None,
recipient: Recipient = ""
) -> None:
self.type = type
self.card = Card
self.recipient = Recipient
def to_dict(self):
destination_dict = {
"type": "card",
"card": self.card,
"recipient": self.recipient
}
return {key: value for key, value in destination_dict.items() if value}
class DestinationToken:
"""
Класс создающий блок destinationToken, необходим для генерации тела запроса на выплату с использованием токена
"""
token: Token
recipient: Recipient
def __init__(
self,
token: Token = None,
recipient: Recipient = ""
) -> None:
self.type = type
self.token = Token
self.recipient = Recipient
def to_dict(self):
destination_token_dict = {
"type": "token",
"token": self.token,
"recipient": self.recipient
}
return {key: value for key, value in destination_token_dict.items() if value}
class Sender:
"""
Класс создающий блок sender, необходим для генерации тела запроса на выплату с использованием токена
"""
first_name: str
last_name: str
email: str
phone: str
def __init__(
self,
phone: str = "",
first_name: str = "",
last_name: str = "",
email: str = ""
) -> None:
self.first_name = first_name
self.last_name = last_name
self.email = email
self.phone = phone
def to_dict(self):
sender_dict = {
"firstName": self.first_name,
"lastName": self.last_name,
"email": self.email,
"phone": self.phone
}
return {key: value for key, value in sender_dict.items() if value}
class Source:
"""
Класс создающий блок source, необходим для генерации тела запроса на выплату с карточными данными
В блоке входит CVV карты, срок действия карты разделен на месяц и год, номер карты и держатель карты
"""
type: str
sender: Sender
def __init__(
self,
sender: Sender = None
) -> None:
self.sender = Sender
def to_dict(self):
source_dict = {
"type": "merchantBalance",
"sender": self.sender
}
return {key: value for key, value in source_dict.items() if value}
class PayoutRequest:
"""
Класс создающий тело запроса, необходим для генерации тела запроса на выплату
"""
merchant_payout_reference: str
amount: Amount
description: str
destination: Destination
source: Source
def __init__(
self,
merchant_payout_reference: str = "",
amount: Amount = None,
description: str = "",
destination: Destination = None,
source: Source = None
) -> None:
self.merchant_payout_reference = merchant_payout_reference
self.amount = Amount
self.description = description
self.destination = Destination
self.source = Source
def to_dict(self):
payout_request_dict = {
"merchantPayoutReference": self.merchant_payout_reference,
"amount": self.amount,
"description": self.description,
"destination": self.destination,
"source": self.source
}
return {key: value for key, value in payout_request_dict.items() if value}
#print(PayoutRequest.__doc__)