forked from andela-sjames/paystack-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcharge.py
More file actions
90 lines (69 loc) · 2.18 KB
/
charge.py
File metadata and controls
90 lines (69 loc) · 2.18 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
"""Script used to define the paystack Charge class."""
from paystackapi.base import PayStackBase
class Charge(PayStackBase):
"""docstring for Charge."""
@classmethod
def start_charge(cls, **kwargs):
"""
Start a charge.
Args:
email: Customer's email address
amount: Amount in kobo
Returns:
Json data from paystack API.
"""
return cls().requests.post('charge', data=kwargs,)
@classmethod
def submit_pin(cls, **kwargs):
"""
Submit PIN to continue a charge.
Args:
pin: PIN submitted by user
reference: reference for transaction that requested pin
Returns:
Json data from paystack API.
"""
return cls().requests.post('charge/submit_pin', data=kwargs,)
@classmethod
def submit_otp(cls, **kwargs):
"""
Submit OTP to complete a charge.
Args:
otp: OTP submitted by user
reference: reference for ongoing transaction
Returns:
Json data from paystack API.
"""
return cls().requests.post('charge/submit_otp', data=kwargs,)
@classmethod
def submit_phone(cls, **kwargs):
"""
Submit Phone when requested.
Args:
phone: Phone submitted by user
reference: reference for ongoing transaction
Returns:
Json data from paystack API.
"""
return cls().requests.post('charge/submit_phone', data=kwargs,)
@classmethod
def submit_birthday(cls, **kwargs):
"""
Submit Birthday when requested.
Args:
birthday: Birthday submitted by user
reference: reference for ongoing transaction
Returns:
Json data from paystack API.
"""
return cls().requests.post('charge/submit_birthday', data=kwargs,)
@classmethod
def check_pending(cls, reference):
"""
Check pending charge
Args:
reference: The reference to check
Returns:
Json data from paystack API.
"""
return cls().requests.get(f"charge/{reference}")