No project description provided
Project description
PyPaystack2
A fork of PyPaystack. A simple python wrapper for Paystack API.
This package works as you'd expect pypaystack package to work, except
that all imports are from pypaystack2
instead of pypaystack
e.g
from pypaystack2 import Transaction
instead of
from pypaystack import Transaction
Features
- Charge customers
- Verify transactions
- Create Plans
- Get single or multiple transactions
- Get single or multiple customers
Installation
- Create your Paystack account to get your Authorization key that is required to use this package.
- Store your authorization key in your environment variable as "PAYSTACK_AUTHORIZATION_KEY" or pass it into the
pypaystack objects at initiatialization. - Install pypaystack2 package.
pip install -U pypaystack2
Examples
from pypaystack2 import Transaction, Customer, Plan, Interval
"""
Note
=====
All Response objects are namedtuples containing status_code, status, message and data
e.g
transaction = Transaction(authorization_key="sk_myauthorizationkeyfromthepaystackguys")
response = transaction.charge(email="customer@domain.com", auth_code="CustomerAUTHcode", amount=10000)
print(response.status_code)
print(response.status)
print(respons.data)
"""
#Instantiate the transaction object to handle transactions.
#Pass in your authorization key - if not set as environment variable PAYSTACK_AUTHORIZATION_KEY
transaction = Transaction(authorization_key="sk_myauthorizationkeyfromthepaystackguys")
response = transaction.charge(email="customer@domain.com", auth_code="CustomerAUTHcode", amount=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="sk_myauthorizationkeyfromthepaystackguys")
response = customer.create(email="customer2@gmail.com", first_name="John", last_name="Doe", phone="080123456789") #Add new customer
response = customer.getone("CUS_xxxxyy") # Get customer with customer code of CUS_xxxxyy
response = customer.getall() # Get all customers
#Instantiate the plan class to manage plans
plan = Plan(authorization_key="sk_myauthorizationkeyfromthepaystackguys")
response = plan.create(name="Test Plan", amount=150000, interval=Interval.WEEKLY) # Add new plan
response = plan.getone(240) # Get plan with id of 240
response = plan.getall() # Get all plans
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
pypaystack2-0.2.0.tar.gz
(7.0 kB
view hashes)
Built Distribution
Close
Hashes for pypaystack2-0.2.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a25e295bc1a7606a06da8efb344bfca537ac80dbdfb7175cea66685d75e9c1eb |
|
MD5 | de97cea4440f6949dd5668beb5643e88 |
|
BLAKE2b-256 | 641ec86141a43d45cdcd5905b695378f0c0a7eca3e734023e7a1c4f1c45d175a |