forked from andela-sjames/paystack-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtransaction.py
More file actions
109 lines (84 loc) · 2.56 KB
/
transaction.py
File metadata and controls
109 lines (84 loc) · 2.56 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
"""Script used to define the paystack Transaction class."""
from paystackapi.base import PayStackBase
class Transaction(PayStackBase):
"""docstring for Transaction."""
@classmethod
def initialize(cls, **kwargs):
"""
Initialize transaction.
Args:
reference: unique transaction reference
amount: amount
email: email address
plan: specified plan(optional)
Returns:
Json data from paystack API.
"""
return cls().requests.post('transaction/initialize', data=kwargs)
@classmethod
def charge(cls, **kwargs):
"""
Charge authorization.
Args:
reference: Unique transaction reference
authorization_code: Authorization code for the transaction
email: Email Address of the user with the authorization code
amount: Amount in kobo
Returns:
Json data from paystack API.
"""
return cls().requests.post('transaction/charge_authorization',
data=kwargs)
@classmethod
def charge_token(cls, **kwargs):
"""
Charge token.
Args:
reference: unique transaction reference
token: paystack token
email: Email Address
amount: Amount in Kobo
Returns:
Json data from paystack API.
"""
return cls().requests.post('transaction/charge_token', data=kwargs)
@classmethod
def get(cls, transaction_id):
"""
Get a single transaction.
Args:
transaction_id: Transaction id(integer).
Returns:
Json data from paystack API.
"""
return cls().requests.get(f"transaction/{transaction_id}")
@classmethod
def list(cls):
"""
List transactions.
Args:
No argument required.
Returns:
Json data from paystack API.
"""
return cls().requests.get('transaction')
@classmethod
def totals(cls):
"""
Get totals.
Args:
No argument required.
Returns:
Json data from paystack API.
"""
return cls().requests.get('transaction/totals')
@classmethod
def verify(cls, reference):
"""
Verify transactions.
Args:
reference: a unique value needed for transaction.
Returns:
Json data from paystack API.
"""
return cls().requests.get(f"transaction/verify/{reference}")