forked from andela-sjames/paystack-python
-
Notifications
You must be signed in to change notification settings - Fork 0
/
README.rst
367 lines (240 loc) · 9.98 KB
/
README.rst
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
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
paystack-python
===============
|Coverage Status| |Scrutinizer Code Quality| |Circle CI| |Build Status|
|PyPI version|
| Python plugin for `Paystack <https://paystack.com/>`__
| View on `pypi.python.org <https://pypi.python.org/pypi/paystackapi>`__
Installation
============
::
pip install paystackapi
Instantiate Paystack
====================
.. code:: python
from paystackapi.paystack import Paystack
paystack_secret_key = "5om3secretK3y"
paystack = Paystack(secret_key=paystack_secret_key)
# to use transaction class
paystack.transaction.list()
# to use customer class
paystack.customer.get(transaction_id)
# to use plan class
paystack.plan.get(plan_id)
Other methods can be found below...
'''''''''''''''''''''''''''''''''''
Static Use
==========
To start using the Paystack Python API, you need to start by setting
your secret key.
You can set your secret key in your environment by running:
.. code:: bash
export PAYSTACK_SECRET_KEY = 'your_secret_key'
Don't forget to get your API key from
`Paystack <https://paystack.com/>`__ and assign to the variable
``PAYSTACK_SECRET_KEY``
Transactions
------------
``Transaction.initialize(reference, amount, email, plan)`` - Initialize transaction.
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
*Usage*
.. code:: python
from paystackapi.transaction import Transaction
response = Transaction.initialize(reference='reference',
amount='amount', email='email')
*Arguments*
- ``reference``: Unique transaction reference
- ``amount``: Amount
- ``email``: Email address
- ``plan``: Specified plan (optional)
*Returns*
JSON data from Paystack API.
``Transaction.charge(reference, authorization_code, email, amount)`` - Charge authorization.
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
.. code:: python
from paystackapi.transaction import Transaction
response = Transaction.charge(reference='reference',
authorization_code='authorization_code',
email='email',
amount='amount')
*Arguments*
- ``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.
``Transaction.charge_token(reference, token, email, amount)`` - Charge Token.
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
.. code:: python
from paystackapi.transaction import Transaction
response = Transaction.charge_token(reference='reference',
token='token', email='email',
amount='amount')
*Arguments*
- reference: unique transaction reference
- token: paystack token
- email: Email Address
- amount: Amount in Kobo
*Returns*
JSON data from Paystack API.
``Transaction.get(transaction_id)`` - Get a single transaction.
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
.. code:: python
from paystackapi.transaction import Transaction
response = Transaction.get(transaction_id=23)
*Arguments*
- ``id``: Transaction id(integer).
*Returns*
JSON data from paystack API.
``Transaction.list()`` - List transactions.
'''''''''''''''''''''''''''''''''''''''''''
.. code:: python
from paystackapi.transaction import Transaction
response = Transaction.list()
*Arguments*
No argument required.
*Returns*
JSON data from paystack API.
``Transaction.totals()`` - Get totals.
''''''''''''''''''''''''''''''''''''''
.. code:: python
from paystackapi.transaction import Transaction
response = Transaction.totals()
*Arguments*
No argument required.
*Returns*
JSON data from paystack API.
``Transaction.verify(reference)`` - Verify transactions.
''''''''''''''''''''''''''''''''''''''''''''''''''''''''
.. code:: python
from paystackapi.transaction import Transaction
response = Transaction.verify(reference='reference')
*Arguments*
- ``reference``: a unique value needed for transaction.
*Returns*
JSON data from paystack API.
Plans
-----
``Plan.create(name, description, amount, interval, send_invoices, send_sms, hosted_page, hosted_page_url, hosted_page_summary, currency)`` - Create a plan
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
.. code:: python
from paystackapi.plan import Plan
response = Plan.create(name='value', description='value',
amount=amount, interval='value',
send_invoices='value',
send_sms='value',
hosted_page='value',
hosted_page_url='value',
hosted_page_summary='value',
currency='value')
*Arguments*
- ``name``: plan's name.
- ``description``: description of the plan.
- ``amount``: amount for the plan in kobo
- ``interval``: plan's interval(daily...etc)
- ``send_invoices``: boolean
- ``send_sms``: (optional)
- ``hosted_page``: (optional)
- ``hosted_page_url``: url of hosted page (optional)
- ``hosted_page_summary``: summary of the hosted page
- ``currency``: plans currency (NGN)
*Returns*
JSON data from paystack API.
``Plan.get(plan_id)`` - Get a single plan.
''''''''''''''''''''''''''''''''''''''''''
.. code:: python
from paystackapi.plan import Plan
response = Plan.get(plan_id=25)
*Arguments*
- ``id``: paystack plan id.
*Returns*
JSON data from paystack API.
``Plan.list()`` - List paystack plan
''''''''''''''''''''''''''''''''''''
.. code:: python
from paystackapi.plan import Plan
response = Plan.list()
*Arguments*
No argument required.
*Returns*
JSON data from paystack API.
``Plan.update(plan_id=88, name=None, description=None, amount=None, interval=None, send_invoices=None, send_sms=None, hosted_page=None, hosted_page_url=None, hosted_page_summary=None, currency=None)`` - Update paystack plan
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
.. code:: python
from paystackapi.plan import Plan
response = Plan.update(plan_id=23, name=None, description=None,
amount=None, interval=None,
send_invoices=None, send_sms=None,
hosted_page=None, hosted_page_url=None,
hosted_page_summary=None, currency=None)
*Arguments*
- ``plan_id``: plan identity number.
- ``name``: name of plan
- ``description``: plan description(optional)
- ``amount``: plan amount in Kobo
- ``interval``: plan interval9(monthly, yearly, quarterly...etc)
- ``send_invoice``: (optional)
- ``send_sms``: (optional)
- ``hosted_page``: (optional)
- ``hosted_page_url``: (optional)
- ``hosted_page_summary``: (optional)
- ``currency``: Naira in kobo(NGN)
*Returns*
JSON data from paystack API.
Customers
---------
``Customer.create(first_name, last_name, email, phone)`` - Create customer
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
.. code:: python
from paystackapi.customer import Customer
response = Customer.create(first_name='first_name',
last_name='last_name',
email='email', phone='phone')
*Arguments*
- ``first_name``: customer's first name.
- ``last_name``: customer's last name.
- ``email``: customer's email address.
- ``phone``: customer's phone number.
*Returns*
JSON data from paystack API.
``Customer.get(customer_id)`` - Get customers by id
'''''''''''''''''''''''''''''''''''''''''''''''''''
.. code:: python
from paystackapi.customer import Customer
response = Customer.get(customer_id=24)
*Arguments*
- ``id``: paystack customer id
*Returns*
JSON data from paystack API.
``Customer.list()`` - List paystack customers
'''''''''''''''''''''''''''''''''''''''''''''
.. code:: python
from paystackapi.customer import Customer
response = Customer.list()
*Arguments*
No argument required.
*Returns*
JSON data from paystack API.
``Customer.update(customer_id, first_name=None, last_name=None, email=None, phone=None)`` - Update paystack customer data by id.
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
.. code:: python
from paystackapi.customer import Customer
response = Customer.update(customer_id=24, first_name=None,
last_name=None, email=None,
phone=None)
*Arguments* - ``customer_id``: paystack customer id. - ``first_name``:
customer's first name(optional). - ``last_name``: customer's last
name(optional). - ``email``: customer's email address(optional). -
``phone``: customer's phone number(optional).
*Returns*
JSON data from paystack API.
.. |Coverage Status| image:: https://coveralls.io/repos/github/andela-sjames/paystack-python/badge.svg?branch=develop
:target: https://coveralls.io/github/andela-sjames/paystack-python?branch=master
.. |Scrutinizer Code Quality| image:: https://scrutinizer-ci.com/g/andela-sjames/paystack-python/badges/quality-score.png?b=master
:target: https://scrutinizer-ci.com/g/andela-sjames/paystack-python/?branch=master
.. |Circle CI| image:: https://img.shields.io/badge/license-MIT-blue.svg
:target: https://img.shields.io/badge/license-MIT-blue.svg
.. |Build Status| image:: https://travis-ci.org/andela-sjames/paystack-python.svg?branch=master
:target: https://travis-ci.org/andela-sjames/paystack-python
.. |PyPI version| image:: https://badge.fury.io/py/paystackapi.svg
:target: https://badge.fury.io/py/paystackapi