Python wrapper for the Winopay Paylense API.
Project description
Paylense API Python SDK
Payment gateway for african businesses
Usage
Installation
Add the latest version of the library to your project using pip:
$ pip install paylense-sdk
This library supports Python 3.4+ (PyPy supported)
Account details
Getting environment API user
Next, we need to get the APP-ID
, username
and password
for use in the product. You can get these details from https://dashboard.paylense.com/register
.
The redentials in the sandbox environment can be used straight away. In production, the credentials are provided for you after KYC requirements are met.
Configuration
Before we can fully utilize the library, we need to specify global configurations. The global configuration must contain the following:
PAYLENSE_ENVIRONMENT
: Optional enviroment, either "sandbox" or "production". Default is 'sandbox'PAYLENSE_APP_ID
: The unique application identity for your appPAYLENSE_USERNAME
: Username used for authenticationPAYLENSE_PASSWORD
: Password used for authentication
The full list of configuration options can be seen in the example below:
config = {
"PAYLENSE_ENVIRONMENT": os.environ.get("PAYLENSE_ENVIRONMENT"),
"PAYLENSE_APP_ID": os.environ.get("PAYLENSE_APP_ID"),
"PAYLENSE_USERNAME": os.environ.get("PAYLENSE_USERNAME"),
"PAYLENSE_PASSWORD": os.environ.get("PAYLENSE_PASSWORD"),
}
Collections
Used for receiving money
You can create a collections client with the following:
import os
from paylense.collections import Collections
client = Collections()
Methods
-
requestToPay
: This operation is used to request a payment from a consumer (Payer). The payer will be asked to authorize the payment. The transaction is executed once the payer has authorized the payment. The transaction will be in status PENDING until it is authorized or declined by the payer or it is timed out by the system. Status of the transaction can be validated by usinggetTransactionStatus
. -
getTransaction
: Retrieve transaction information using thetransactionId
returned byrequestToPay
. You can invoke it at intervals until the transaction fails or succeeds. If the transaction has failed, it will throw an appropriate error.
Sample Code
import os
from paylense.collections import Collections
client = Collections()
client.requestToPay(
mobile="256772123456", amount="600", processing_number="123456789", narration="dd")
Disbursements
Used for sending money to users
You can create a disbursements client with the following
import os
from paylense.disbursements import Disbursements
client = Disbursements()
Methods
-
transfer
: Used to transfer an amount from the owner’s account to a payee account. Status of the transaction can be validated by using thegetTransactionStatus
method. -
getTransactionStatus
: Retrieve transaction information using thetransactionId
returned bytransfer
. You can invoke it at intervals until the transaction fails or succeeds.
Sample Code
import os
from paylense.disbursements import Disbursements
client = Disbursements()
client.transfer(amount="600", mobile="256772123456", processing_number="123456789", narration="dd")
Developer
We use tox
to automate our tests. You can run the test using
tox
Thank you.
Changelog
0.1.0 (2020-05-01)
- First release on PyPI.
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
File details
Details for the file paylense-sdk-1.0.1.tar.gz
.
File metadata
- Download URL: paylense-sdk-1.0.1.tar.gz
- Upload date:
- Size: 18.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.15.0 pkginfo/1.7.0 requests/2.21.0 setuptools/44.1.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/2.7.16
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f0cb1017fa42f2f8485d42dd320028ca10a58176c1dd5d3e27f513bdb192a647 |
|
MD5 | 6b974d9f779a1d1374c614fe174f55ed |
|
BLAKE2b-256 | 90acd65971b164c6746523a3be211a70f8a4df49eb8fe52d05b9d2300c9adc3d |