pyCryptomusAPI 0.0.8__tar.gz → 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {pyCryptomusAPI-0.0.8/pyCryptomusAPI.egg-info → pyCryptomusAPI-0.1.0}/PKG-INFO +1 -1
- {pyCryptomusAPI-0.0.8 → pyCryptomusAPI-0.1.0}/pyCryptomusAPI/api.py +170 -7
- {pyCryptomusAPI-0.0.8 → pyCryptomusAPI-0.1.0}/pyCryptomusAPI/cryto_types.py +43 -1
- {pyCryptomusAPI-0.0.8 → pyCryptomusAPI-0.1.0}/pyCryptomusAPI/tests.py +1 -0
- {pyCryptomusAPI-0.0.8 → pyCryptomusAPI-0.1.0}/pyCryptomusAPI/version.py +1 -1
- {pyCryptomusAPI-0.0.8 → pyCryptomusAPI-0.1.0/pyCryptomusAPI.egg-info}/PKG-INFO +1 -1
- {pyCryptomusAPI-0.0.8 → pyCryptomusAPI-0.1.0}/LICENSE +0 -0
- {pyCryptomusAPI-0.0.8 → pyCryptomusAPI-0.1.0}/MANIFEST.in +0 -0
- {pyCryptomusAPI-0.0.8 → pyCryptomusAPI-0.1.0}/README.md +0 -0
- {pyCryptomusAPI-0.0.8 → pyCryptomusAPI-0.1.0}/pyCryptomusAPI/__init__.py +0 -0
- {pyCryptomusAPI-0.0.8 → pyCryptomusAPI-0.1.0}/pyCryptomusAPI.egg-info/SOURCES.txt +0 -0
- {pyCryptomusAPI-0.0.8 → pyCryptomusAPI-0.1.0}/pyCryptomusAPI.egg-info/dependency_links.txt +0 -0
- {pyCryptomusAPI-0.0.8 → pyCryptomusAPI-0.1.0}/pyCryptomusAPI.egg-info/top_level.txt +0 -0
- {pyCryptomusAPI-0.0.8 → pyCryptomusAPI-0.1.0}/setup.cfg +0 -0
- {pyCryptomusAPI-0.0.8 → pyCryptomusAPI-0.1.0}/setup.py +0 -0
|
@@ -41,7 +41,7 @@ class pyCryptomusAPI:
|
|
|
41
41
|
self.print_errors = print_errors
|
|
42
42
|
self.timeout = timeout
|
|
43
43
|
self.add_request_params = add_request_params
|
|
44
|
-
if not
|
|
44
|
+
if (not self.payment_api_key) and (not self.payout_api_key):
|
|
45
45
|
raise Exception("You must specify at least one API key.")
|
|
46
46
|
|
|
47
47
|
def __request(self, method_url, mode, **kwargs):
|
|
@@ -63,11 +63,11 @@ class pyCryptomusAPI:
|
|
|
63
63
|
base_resp = None
|
|
64
64
|
try:
|
|
65
65
|
key = self.payment_api_key if (mode == 1) else self.payout_api_key
|
|
66
|
-
if not
|
|
66
|
+
if not key:
|
|
67
67
|
raise pyCryptomusAPIException(-6, "Key is empty")
|
|
68
68
|
if not(key.isascii()):
|
|
69
69
|
raise pyCryptomusAPIException(-6, "Key contains non-ascii characters")
|
|
70
|
-
if not
|
|
70
|
+
if not self.merchant_uuid:
|
|
71
71
|
raise pyCryptomusAPIException(-6, "Merchant UUID is empty")
|
|
72
72
|
if not(self.merchant_uuid.isascii()):
|
|
73
73
|
raise pyCryptomusAPIException(-6, "Merchant UUID contains non-ascii characters")
|
|
@@ -244,7 +244,7 @@ class pyCryptomusAPI:
|
|
|
244
244
|
method = "wallet/block-address"
|
|
245
245
|
params = {
|
|
246
246
|
}
|
|
247
|
-
if not
|
|
247
|
+
if (not wallet_uuid) and (not order_id):
|
|
248
248
|
raise pyCryptomusAPIException(0, "You need to pass one of the required parameters")
|
|
249
249
|
if wallet_uuid:
|
|
250
250
|
params["uuid"] = wallet_uuid
|
|
@@ -273,7 +273,7 @@ class pyCryptomusAPI:
|
|
|
273
273
|
params = {
|
|
274
274
|
"address": address,
|
|
275
275
|
}
|
|
276
|
-
if not
|
|
276
|
+
if (not wallet_uuid) and (not order_id):
|
|
277
277
|
raise pyCryptomusAPIException(0, "You need to pass one of the required parameters")
|
|
278
278
|
if wallet_uuid:
|
|
279
279
|
params["uuid"] = wallet_uuid
|
|
@@ -298,7 +298,7 @@ class pyCryptomusAPI:
|
|
|
298
298
|
method = "payment/info"
|
|
299
299
|
params = {
|
|
300
300
|
}
|
|
301
|
-
if not
|
|
301
|
+
if (not invoice_uuid) and (not order_id):
|
|
302
302
|
raise pyCryptomusAPIException(0, "You need to pass one of the required parameters")
|
|
303
303
|
if invoice_uuid:
|
|
304
304
|
params["uuid"] = invoice_uuid
|
|
@@ -327,7 +327,7 @@ class pyCryptomusAPI:
|
|
|
327
327
|
"address": address,
|
|
328
328
|
"is_subtract": is_subtract,
|
|
329
329
|
}
|
|
330
|
-
if not
|
|
330
|
+
if (not invoice_uuid) and (not order_id):
|
|
331
331
|
raise pyCryptomusAPIException(0, "You need to pass one of the required parameters")
|
|
332
332
|
if invoice_uuid:
|
|
333
333
|
params["uuid"] = invoice_uuid
|
|
@@ -440,6 +440,169 @@ class pyCryptomusAPI:
|
|
|
440
440
|
resp = self.__request(method, 1).get("result")
|
|
441
441
|
return [Service.de_json(i) for i in resp]
|
|
442
442
|
|
|
443
|
+
"""
|
|
444
|
+
Request
|
|
445
|
+
Query parameters
|
|
446
|
+
NAME PARAMETER TYPE DEFAULT VALUE DEFINITION
|
|
447
|
+
amount* string Payout amount
|
|
448
|
+
currency* string
|
|
449
|
+
Currency code for the payout
|
|
450
|
+
If Currency if fiat, the to_currency parameter is required.
|
|
451
|
+
order_id*
|
|
452
|
+
string
|
|
453
|
+
min:1
|
|
454
|
+
max:100
|
|
455
|
+
alpha_dash
|
|
456
|
+
Order ID in your system
|
|
457
|
+
The parameter should be a string consisting of alphabetic characters, numbers, underscores, and dashes. It should not contain any spaces or special characters.
|
|
458
|
+
The order_id must be unique within the merchant payouts
|
|
459
|
+
When we find an existing payout with order_id, we return its details, a new payout will not be created.
|
|
460
|
+
address* string The address of the wallet to which the withdrawal will be made
|
|
461
|
+
is_subtract* boolean
|
|
462
|
+
Defines where the withdrawal fee will be deducted
|
|
463
|
+
true - from your balance
|
|
464
|
+
false - from payout amount, the payout amount will be decreased
|
|
465
|
+
network* string
|
|
466
|
+
Blockchain network code
|
|
467
|
+
Not required when the currency/to_currency is a cryptocurrency and has only one network, for example BTC
|
|
468
|
+
url_callback URL to which webhooks with payout status will be sent
|
|
469
|
+
to_currency Cryptocurrency code in which the payout will be made. It is used when the currency parameter is fiat. See examples below
|
|
470
|
+
course_source string
|
|
471
|
+
Available values
|
|
472
|
+
-
|
|
473
|
+
Binance
|
|
474
|
+
-
|
|
475
|
+
BinanceP2p
|
|
476
|
+
-
|
|
477
|
+
Exmo
|
|
478
|
+
-
|
|
479
|
+
Kucoin
|
|
480
|
+
-
|
|
481
|
+
Garantexio
|
|
482
|
+
Value from merchant's settings
|
|
483
|
+
The service from which the exchange rates are taken for conversion in the invoice.
|
|
484
|
+
The parameter is applied only if the currency is fiat, otherwise the default value is taken from the merchant's settings.
|
|
485
|
+
from_currency string null Allows to automatically convert the withdrawal amount and use the from_currency balance. Only USDT is available.
|
|
486
|
+
priority
|
|
487
|
+
string
|
|
488
|
+
min: 4
|
|
489
|
+
max: 11
|
|
490
|
+
Available values
|
|
491
|
+
-
|
|
492
|
+
recommended
|
|
493
|
+
-
|
|
494
|
+
economy
|
|
495
|
+
-
|
|
496
|
+
high
|
|
497
|
+
-
|
|
498
|
+
highest
|
|
499
|
+
recommended
|
|
500
|
+
The parameter for selecting the withdrawal priority. The cost of the withdrawal fee depends on the selected parameter.
|
|
501
|
+
This parameter is applied only in case of using the BTC, ETH, POLYGON, and BSC networks.
|
|
502
|
+
memo
|
|
503
|
+
string
|
|
504
|
+
min: 1
|
|
505
|
+
max: 30
|
|
506
|
+
Additional identifier for TON, used to specify a particular recipient or target
|
|
507
|
+
* - mandatory parameter
|
|
508
|
+
"""
|
|
509
|
+
|
|
510
|
+
def create_payout(self,
|
|
511
|
+
amount, currency, order_id, address, is_subtract, network,
|
|
512
|
+
url_callback = None, to_currency = None, course_source = None,
|
|
513
|
+
from_currency = None, priority = None, memo = None):
|
|
514
|
+
"""
|
|
515
|
+
Creating a payout
|
|
516
|
+
https://doc.cryptomus.com/payouts/creating-payout
|
|
517
|
+
Requires PAYOUT API key
|
|
518
|
+
|
|
519
|
+
amount: (String) Payout amount
|
|
520
|
+
currency: (String) Currency code for the payout. If Currency if fiat, the to_currency parameter is required.
|
|
521
|
+
order_id: (String[1..100]) Order ID in your system. The parameter should be a string consisting of alphabetic characters, numbers, underscores, and dashes. It should not contain any spaces or special characters. The order_id must be unique within the merchant payouts. When we find an existing payout with order_id, we return its details, a new payout will not be created.
|
|
522
|
+
address: (String) The address of the wallet to which the withdrawal will be made
|
|
523
|
+
is_subtract: (Bool) Defines where the withdrawal fee will be deducted. true - from your balance. false - from payout amount, the payout amount will be decreased.
|
|
524
|
+
network: (String) Blockchain network code.Not required when the currency/to_currency is a cryptocurrency and has only one network, for example BTC
|
|
525
|
+
url_callback: (String, Optional) URL to which webhooks with payout status will be sent
|
|
526
|
+
to_currency: (String, Optional) Cryptocurrency code in which the payout will be made. It is used when the currency parameter is fiat.
|
|
527
|
+
course_source: (String, Optional) The service from which the exchange rates are taken for conversion in the invoice. The parameter is applied only if the currency is fiat, otherwise the default value is taken from the merchant's settings.
|
|
528
|
+
from_currency: (String, Optional) Allows to automatically convert the withdrawal amount and use the from_currency balance. Only USDT is available.
|
|
529
|
+
priority: (String, Optional) The parameter for selecting the withdrawal priority. The cost of the withdrawal fee depends on the selected parameter. This parameter is applied only in case of using the BTC, ETH, POLYGON, and BSC networks. Available values: recommended, economy, high, highest
|
|
530
|
+
memo: (String, Optional) Additional identifier for TON, used to specify a particular recipient or target
|
|
531
|
+
"""
|
|
532
|
+
method = "payout"
|
|
533
|
+
params = {
|
|
534
|
+
"amount": str(amount),
|
|
535
|
+
"currency": currency,
|
|
536
|
+
"order_id": str(order_id),
|
|
537
|
+
"address": address,
|
|
538
|
+
"is_subtract": is_subtract,
|
|
539
|
+
"network": network,
|
|
540
|
+
}
|
|
541
|
+
if url_callback:
|
|
542
|
+
params["url_callback"] = url_callback
|
|
543
|
+
if to_currency:
|
|
544
|
+
params["to_currency"] = to_currency
|
|
545
|
+
if course_source:
|
|
546
|
+
params["course_source"] = course_source
|
|
547
|
+
if from_currency:
|
|
548
|
+
params["from_currency"] = from_currency
|
|
549
|
+
if priority:
|
|
550
|
+
params["priority"] = priority
|
|
551
|
+
if memo:
|
|
552
|
+
params["memo"] = memo
|
|
553
|
+
resp = self.__request(method, 2, **params).get("result")
|
|
554
|
+
return Payout.de_json(resp)
|
|
555
|
+
|
|
556
|
+
def payout_information(self,
|
|
557
|
+
payout_uuid = None, order_id = None):
|
|
558
|
+
"""
|
|
559
|
+
Payout information
|
|
560
|
+
https://doc.cryptomus.com/payouts/payout-information
|
|
561
|
+
You need to pass one of the required parameters, if you pass both, the account will be identified by order_id
|
|
562
|
+
Requires PAYOUT API key
|
|
563
|
+
|
|
564
|
+
payout_uuid: (String, Optional if order_id set) Payout UUID
|
|
565
|
+
order_id: (String[1..128], Optional if wallet_uuid set) Payout order ID
|
|
566
|
+
|
|
567
|
+
* To get the payout information you need to pass one of the parameters, if you pass both, the payout will be identified by order_id
|
|
568
|
+
"""
|
|
569
|
+
method = "payout/info"
|
|
570
|
+
params = {
|
|
571
|
+
}
|
|
572
|
+
if (not payout_uuid) and (not order_id):
|
|
573
|
+
raise pyCryptomusAPIException(0, "You need to pass one of the required parameters")
|
|
574
|
+
if payout_uuid:
|
|
575
|
+
params["uuid"] = payout_uuid
|
|
576
|
+
if order_id:
|
|
577
|
+
params["order_id"] = order_id
|
|
578
|
+
resp = self.__request(method, 1, **params).get("result")
|
|
579
|
+
return Payout.de_json(resp)
|
|
580
|
+
|
|
581
|
+
def payout_history(self, date_from = None, date_to = None, cursor = None):
|
|
582
|
+
"""
|
|
583
|
+
Payout history
|
|
584
|
+
https://doc.cryptomus.com/payments/payment-history
|
|
585
|
+
Requires PAYOUT API key
|
|
586
|
+
|
|
587
|
+
date_from: (String, Optional) Filtering by creation date, from
|
|
588
|
+
date_to: (String, Optional) Filtering by creation date, to
|
|
589
|
+
cursor: (String, Optional) Page cursor (hash)
|
|
590
|
+
"""
|
|
591
|
+
params = {
|
|
592
|
+
}
|
|
593
|
+
if date_from:
|
|
594
|
+
params["date_from"] = date_from.strftime(CryptomusDateFormat)
|
|
595
|
+
if date_to:
|
|
596
|
+
params["date_to"] = date_to.strftime(CryptomusDateFormat)
|
|
597
|
+
if cursor:
|
|
598
|
+
params["cursor"] = cursor
|
|
599
|
+
method = "payment/list"
|
|
600
|
+
if params:
|
|
601
|
+
resp = self.__request(method, 1, **params).get("result")
|
|
602
|
+
else:
|
|
603
|
+
resp = self.__request(method, 1).get("result")
|
|
604
|
+
return PayoutHistory.de_json(resp)
|
|
605
|
+
|
|
443
606
|
def payout_services(self):
|
|
444
607
|
"""
|
|
445
608
|
Get collection of all available payout services
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import datetime
|
|
2
1
|
import json
|
|
3
2
|
from abc import ABC
|
|
4
3
|
|
|
@@ -130,9 +129,11 @@ class Balance(JsonDeserializable):
|
|
|
130
129
|
raise ValueError("Not a balance")
|
|
131
130
|
if "merchant" in data:
|
|
132
131
|
for item in data["merchant"]:
|
|
132
|
+
# noinspection PyUnresolvedReferences
|
|
133
133
|
instance.merchant.append(BalanceItem.de_json(item))
|
|
134
134
|
if "user" in data:
|
|
135
135
|
for item in data["user"]:
|
|
136
|
+
# noinspection PyUnresolvedReferences
|
|
136
137
|
instance.user.append(BalanceItem.de_json(item))
|
|
137
138
|
return instance
|
|
138
139
|
|
|
@@ -304,3 +305,44 @@ class PaymentsHistory(JsonDeserializable):
|
|
|
304
305
|
instance.items = [Invoice.de_json(i) for i in instance.items]
|
|
305
306
|
instance.paginate = PaymentPaginate.de_json(instance.paginate)
|
|
306
307
|
return instance
|
|
308
|
+
|
|
309
|
+
# noinspection PyMethodOverriding
|
|
310
|
+
class Payout(JsonDeserializable):
|
|
311
|
+
def __init__(self):
|
|
312
|
+
self.uuid = None
|
|
313
|
+
self.amount = None
|
|
314
|
+
self.currency = None
|
|
315
|
+
self.network = None
|
|
316
|
+
self.address = None
|
|
317
|
+
self.txid = None
|
|
318
|
+
self.status = None
|
|
319
|
+
self.is_final = None
|
|
320
|
+
self.balance = None
|
|
321
|
+
self.payer_currency = None
|
|
322
|
+
self.payer_amount = None
|
|
323
|
+
|
|
324
|
+
@classmethod
|
|
325
|
+
def de_json(cls, json_dict):
|
|
326
|
+
data = cls.check_json(json_dict)
|
|
327
|
+
instance = super(Payout, cls).de_json(data, process_mode=2)
|
|
328
|
+
if instance.amount is not None:
|
|
329
|
+
instance.amount = float(instance.amount)
|
|
330
|
+
if instance.payer_amount is not None:
|
|
331
|
+
instance.payer_amount = float(instance.payer_amount)
|
|
332
|
+
if instance.balance is not None:
|
|
333
|
+
instance.balance = float(instance.balance)
|
|
334
|
+
return instance
|
|
335
|
+
|
|
336
|
+
# noinspection PyMethodOverriding
|
|
337
|
+
class PayoutHistory(JsonDeserializable):
|
|
338
|
+
def __init__(self):
|
|
339
|
+
self.items = []
|
|
340
|
+
self.paginate = PaymentPaginate()
|
|
341
|
+
|
|
342
|
+
@classmethod
|
|
343
|
+
def de_json(cls, json_dict):
|
|
344
|
+
data = cls.check_json(json_dict)
|
|
345
|
+
instance = super(PayoutHistory, cls).de_json(data, process_mode=2)
|
|
346
|
+
instance.items = [Payout.de_json(i) for i in instance.items]
|
|
347
|
+
instance.paginate = PaymentPaginate.de_json(instance.paginate)
|
|
348
|
+
return instance
|
|
@@ -50,6 +50,7 @@ def test_api_functions():
|
|
|
50
50
|
run_and_print(lambda: client.payment_history())
|
|
51
51
|
run_and_print(lambda: client.payment_history_filtered(is_final=True))
|
|
52
52
|
run_and_print(lambda: client.payout_services())
|
|
53
|
+
run_and_print(lambda: client.payout_history())
|
|
53
54
|
run_and_print(lambda: client.balance())
|
|
54
55
|
|
|
55
56
|
test_api_functions()
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|