Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/avour/kivypaystack
https://github.com/avour/kivypaystack
Last synced: 27 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/avour/kivypaystack
- Owner: avour
- License: mit
- Created: 2019-07-06T13:25:58.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2019-07-08T21:56:25.000Z (over 5 years ago)
- Last Synced: 2024-10-14T06:36:21.351Z (2 months ago)
- Language: Python
- Size: 24.4 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# kivypaystack
A port of paystack payment system to support the kivy framework
It uses the builtin UrlRequest class to make asynchronous requests on the web and get the result when the
request is completed, so no external module is needed- Charge the customer
- Verify a transaction
- Create Plans
- Get a single or all transactions
- Get a single or all customers##Installation
pip it away```python
pip install -U kivypaystack
```Register on the paystack website https://www.paystack.com and get your Authorization key.
you can store your authorization key in your environment variable as "PAYSTACK_AUTHORIZATION_KEY" or pass it into the
any kivypaystack objects at initiatialization.##Examples
```python
from kivypaystack import Transaction, Customer, Plan"""
All objects at initialization, recieves an optional callback func
"""def transaction_callback(action, result_type, request, result):
''' action: reponse action performed EG: transaction.charge("[email protected]", "CustomerAUTHcode", 10000)
on callback action will be 'charge'result_type: can be 'success', 'failure', 'redirect', 'error'
request: instance of kivy.urlrequest.UrlRequest
result: a decided json dictionary
'''
if action == 'charge': # if a charge transaction was passed
print(result_type, result)if action == 'verify':
print(result_type, result)#Instantiate the transaction object to handle transactions.
#Pass in your authorization key - if not set as environment variable PAYSTACK_AUTHORIZATION_KEY
# warning use public key not your secret key
transaction = Transaction(authorization_key="pk_myauthorizationkeyfromthepaystackguys", callback=transaction_callback)
response = transaction.charge("[email protected]", "CustomerAUTHcode", 10000) #Charge a customer N100.
response = transaction.verify(refcode) #Verify a transaction given a reference code "refcode".#Instantiate the customer class to manage customers
customer = Customer(authorization_key="pk_myauthorizationkeyfromthepaystackguys")
response = customer.create("[email protected]", "John", "Doe", phone="080123456789") #Add new customer
response = customer.getone(1234) #Get customer with id of 1234
response = customer.getall() #Get all customers#Instantiate the plan class to manage plans
plan = Plan(authorization_key="pk_myauthorizationkeyfromthepaystackguys")
response = plan.create("Test Plan", 150000, 'Weekly') #Add new plan
response = plan.getone(240) #Get plan with id of 240
response = plan.getall() #Get all plans```