PaystackPyAPI is a Python package designed to simplify and streamline Paystack API integration, enabling secure online payment processing in your Python applications.
You can install the package using pip:
pip install paystackpyAPI1. Obtain API Key:
Sign up for a Paystack account if you don't have one: Paystack Signup.
Log in to your Paystack dashboard and obtain your API key.
- Initialize PaystackAPI:
from paystackpyAPI.transaction import Transaction
# Replace 'your_api_key' with your actual Paystack API key
api_key = 'your_api_key'
transaction = Transaction(api_key)
- Initialize a Transaction
email = 'user@example.com'
amount = 100
initialize_response = transaction.initialize_transaction(email, amount)
print("Initialization Response:", initialize_response)- Verify a Transaction
reference = initialize_response['data']['data']['reference']
verify_response = transaction.verify_transaction(reference)
print("Verification Response:", verify_response)
- Optional parameters
The initialize_transaction method supports the following optional parameters:
-
currency
-
reference
-
callback_url
-
plan
-
invoice_limit
-
metadata
-
channels
-
split_code
-
subaccount
-
transaction_charge
-
bearer
Pass these parameters as keyword arguments when calling the initialize_transaction method.
- Examples
Check the examples directory for sample scripts demonstrating various use cases.
- Contributing
If you find a bug or have a feature request, please open an issue. Contributions are welcome!
1. Fork the repository
2. Create a new branch (git checkout -b feature/awesome-feature).
3. Commit your changes (git commit -am 'Add awesome feature').
4. Push to the branch (git push origin feature/awesome-feature).
5. Open a Pull Request.
- License
This project is licensed under the MIT License - see the LICENSE file for details.