forked from andela-sjames/paystack-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtransfer.py
More file actions
108 lines (81 loc) · 2.67 KB
/
transfer.py
File metadata and controls
108 lines (81 loc) · 2.67 KB
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
"""Script used to define the paystack Transfer class."""
from paystackapi.base import PayStackBase
class Transfer(PayStackBase):
"""docstring for Transfer."""
@classmethod
def initiate(cls, **kwargs):
"""
Initiate a transfer.
Args:
source: Where should we transfer from? Only balance for now
amount: Amount to transfer in kobo
currency: Currency type to use
recipient: Code for transfer recipient
Returns:
Json data from paystack API.
"""
return cls().requests.post('transfer', data=kwargs)
@classmethod
def list(cls, **kwargs):
"""
List a transfer.
Args:
perPage: records you want to retrieve per page (Integer)
page: what page you want to retrieve (Integer)
Returns:
Json data from paystack API.
"""
return cls().requests.get('transfer', qs=kwargs,)
@classmethod
def fetch(cls, id_or_code):
"""
Fetch a transfer.
Args:
id_or_code: An ID or code for the transfer whose details you want to retrieve.
Returns:
Json data from paystack API.
"""
return cls().requests.get(f"transfer/{id_or_code}")
@classmethod
def finalize(cls, **kwargs):
"""
Finalize a transfer.
NB: This step is not required if OTP is disabled
Args:
transfer_code: Transfer code
otp: OTP sent to business phone to verify transfer
Returns:
Json data from paystack API.
"""
return cls().requests.post('transfer/finalize_transfer', data=kwargs)
@classmethod
def initiate_bulk_transfer(cls, **kwargs):
"""
Initiate bulk transfer.
Args:
currency: Currency type to use
source: Where should we transfer from? Only balance for now
transfers: Array of transfer objects [
{
amount: Amount to transfer in kobo
recipient: Code for transfer recipient
},
{
amount: Amount to transfer in kobo
recipient: Code for transfer recipient
}
]
Returns:
Json data from paystack API.
"""
return cls().requests.post('transfer/bulk', data=kwargs)
@classmethod
def verify(cls, reference):
"""
Verify a transfer.
Args:
reference: Transfer reference
Returns:
Json data from paystack API.
"""
return cls().requests.get(f"verify/{reference}")