SDK for integrating with the FIB payment system, enabling user authentication and payment transactions.
Project description
FIB Payment SDK
The FIB Payment SDK provides seamless integration with the FIB payment system, empowering developers to streamline payment transactions and facilitate secure refunds within their applications.
Table of Contents
- Features
- Installation
- Configuration
- Usage of the SDK
- Documentation
- Testing
- Contributing
- License
- Support
- Acknowledgments
- Versioning
- FAQ
Features
- Payment Transactions: Enable users to make payments securely through the FIB payment system.
- Refund Processing: Process refunds securely and efficiently.
- Payment Status Checking: Track the status of payments accurately.
- Payment Cancellation: Cancel payments securely and easily.
Installation
Install the SDK using pip:
pip install fib-python-payment-sdk
Alternative Installation (Without pip)
You can clone the repository and manually include the SDK in your project:
git clone https://github.com/First-Iraqi-Bank/fib-python-payment-sdk.git
Ensure to include the SDK directory in your Python path.
Configuration
Set the following environment variables to configure the SDK:
FIB_API_KEY
: Your FIB payment API key.FIB_API_SECRET
: Your FIB payment API secret.FIB_BASE_URL
: Base URL for the FIB payment API.FIB_GRANT_TYPE
: Authentication grant type (default: client_credentials).FIB_REFUNDABLE_FOR
: Transaction refund period (default: P7D).FIB_CURRENCY
: Transaction currency (default: IQD).FIB_CALLBACK_URL
: Callback URL for handling payment notifications.
Usage of the SDK
Below is a basic example of how to use the SDK to handle payment operations directly within your application.
Payment Operations Example
This example demonstrates how to perform common payment operations, including creating a payment, checking its status, issuing a refund, and canceling a payment.
-
Setup Environment Variables: Ensure you have loaded the necessary environment variables for the SDK.
from dotenv import load_dotenv import os # Load environment variables from the .env file load_dotenv()
-
Full example: Below is a full example of how to use the SDK to handle payment operations:
import asyncio from fib_payments import FIBPaymentsClient, FIBConfig, APIError async def main(): config = FIBConfig( base_url="https://fib.dev.fib.iq", client_id="your token", client_secret="your secret" ) # or config = FIBConfig() async with FIBPaymentsClient(config) as client: try: # Create a payment payment = await client.create_payment(100.00, description="Test payment") payment_details = { 'fib_payment_id': payment['paymentId'], 'readable_code': payment['readableCode'], 'personal_app_link': payment['personalAppLink'], 'valid_until': payment['validUntil'], } print(f"Payment created: {payment_details}") # Check payment status status = await client.get_payment_status(payment['paymentId']) print(f"Payment status: {status}") # Refund the payment refund = await client.refund_payment(payment['paymentId']) print(f"Refund initiated: {refund}") except APIError as e: print(f"An API error occurred: {str(e)}")
Documentation
For more detailed documentation, refer to the FIB Online Payment API Documentation.
Testing
Run the SDK tests using unittest
:
python -m unittest discover -s tests -p 'test_*.py'
Run a specific test case:
python -m unittest tests.test_module.TestClassName
Run a specific test method:
python -m unittest tests.test_module.TestClassName.test_method_name
To run tests with custom formatting, use:
python test.py
Contributing
Contributions are welcome! Please refer to the CONTRIBUTING.md
for guidelines.
License
This project is licensed under the MIT License. See the LICENSE.md file for details.
Support
For support, contact support@fib-payment.com.
Acknowledgments
Thanks to the FIB Payment development team and the requests
library.
Versioning
We follow Semantic Versioning for releases.
FAQ
Q: How do I get an API key for the FIB Payment system?
A: Contact support@fib-payment.com to request an API key.
Q: Can I use this SDK in production?
A: Yes, but ensure it is correctly configured and tested for your environment.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file fib-python-payment-sdk-0.1.10.tar.gz
.
File metadata
- Download URL: fib-python-payment-sdk-0.1.10.tar.gz
- Upload date:
- Size: 10.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.8.18
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | bf86a0ecfbe040532b355613a03b4863640eace8ff07d2f41ecab9039147ae94 |
|
MD5 | f58e87f19116f68daae31199b1fe95d7 |
|
BLAKE2b-256 | a3baa2595ab2791b8c4ceb60e66cdbf80e786ee0a8150d44cb5c76734f591799 |
File details
Details for the file fib_python_payment_sdk-0.1.10-py3-none-any.whl
.
File metadata
- Download URL: fib_python_payment_sdk-0.1.10-py3-none-any.whl
- Upload date:
- Size: 8.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.8.18
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | da8c02f051d46db80cbbb37c38cdf07131c3f2a6456c9e2b3712f40603448f06 |
|
MD5 | 4264d1157916988a71373f03a877df63 |
|
BLAKE2b-256 | c9832b3e22f5b0ce6cd5770fd4b121357b738ffeaf8d587797dcf081f58671d4 |