forked from andela-sjames/paystack-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinvoice.py
More file actions
151 lines (118 loc) · 4.04 KB
/
invoice.py
File metadata and controls
151 lines (118 loc) · 4.04 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
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
"""Script used to define the paystack Invoice class."""
from paystackapi.base import PayStackBase
class Invoice(PayStackBase):
"""docstring for Invoice."""
@classmethod
def create(cls, **kwargs):
"""
Method defined to create a new invoice.
Args:
customer: customer id or code
amount: payment request amount.(Integer)
Only useful if line items and tax values are ignored.
Endpoint will throw a friendly warning if neither is available.
due_date: ISO 8601 representation of request due date.
**kwargs
Returns:
Json data from paystack API.
"""
return cls().requests.post('paymentrequest', data=kwargs,)
@classmethod
def list(cls, **kwargs):
"""
Method defined to list a new invoice.
Args:
customer: filter by customer ID
status: filter by invoice status
currency: filter by currency
paid: filter by paid invoice
include_archive: include_archive
Returns:
Json data from paystack API.
"""
return cls().requests.get('paymentrequest', qs=kwargs,)
@classmethod
def view(cls, invoice_id_or_code):
"""
Method defined to view an invoice
Args:
invoice_id_or_code: invoice ID or Code (string)
Returns:
Json data from paystack API.
"""
return cls().requests.get(f'paymentrequest/{invoice_id_or_code}')
@classmethod
def verify(cls, invoice_code):
"""
Method defined to verify an invoice
Args:
invoice_code: invoice Code (string)
Returns:
Json data from paystack API.
"""
return cls().requests.get(f'paymentrequest/verify/{invoice_code}')
@classmethod
def send_notification(cls, id_or_code):
"""
Method defined to send notification
Args:
id_or_code: id or code (string)
Returns:
Json data from paystack API.
"""
return cls().requests.post(f'paymentrequest/notify/{id_or_code}')
@classmethod
def dashboard_metrics(cls):
"""
Method defined to get Dashboard metrics.
Args:
No Arguments required
Returns:
Json data from paystack API.
"""
return cls().requests.get('paymentrequest/totals')
@classmethod
def finalize_draft(cls, id_or_code, **kwargs):
"""
Method defined to finalize a draft.
Args:
id_or_code: ID or Code (string)
send_notification: Indicates whether Paystack sends an email notification to customer.
Defaults to true. (Boolean)
Returns:
Json data from paystack API.
"""
return cls().requests.post(f'paymentrequest/finalize/{id_or_code}', data=kwargs)
@classmethod
def update(cls, id_or_code, **kwargs):
"""
Method defined to update a draft.
Args:
id_or_code: ID or Code
**kwargs
Returns:
Json data from paystack API.
"""
return cls().requests.put(f'paymentrequest/{id_or_code}', data=kwargs)
@classmethod
def archive(cls, id_or_code):
"""
Method defined to archive a draft.
Args:
id_or_code: ID or Code
Returns:
Json data from paystack API.
"""
return cls().requests.post(f'invoice/archive/{id_or_code}')
@classmethod
def update_transfer_recipient(cls, recipient_code_or_id, **kwargs):
"""
Method defined to Update transfer recipient a draft.
Args:
recipient_code_or_id: recipient code or ID
name: a name for the recipient (string)
email: the email address of the recipient (string)
Returns:
Json data from paystack API.
"""
return cls().requests.post(f'transferrecipient/{recipient_code_or_id}', data=kwargs)