Pesepay online payment gateway integration
Project description
Installation
pip install pesepay
Getting Started
Import the library into your project/application
from pesepay import Pesepay
Create an instance of the Pesepay
class using your integration key and encryption key as supplied by Pesepay.
pesepay = Pesepay("INTEGRATION KEY", "ENCRYPTION KEY");
Set return and result urls
pesepay.result_url = 'https://example.com/result'
pesepay.return_url = 'https://example.com/return'
Make seamless payment
Create the payment
NB: Customer email or number should be provided
payment = pesepay.create_payment('CURRECNCY_CODE', 'PAYMENT_METHOD_CODE', 'CUSTOMER_EMAIL',
'CUSTOMER_PHONE_NUMBER(OPTIONAL)', 'CUSTOMER_NAME(OPTIONAL)')
Create a dict
of the required fields (if any)
required_fields = {'requiredFieldName': 'requiredFieldValue'}
Send of the payment
response = pesepay.make_seamless_payment(payment, 'PAYMENT_REASON', 1.00, required_fields)
if response.success:
# Save the reference number and/or poll url (used to check the status of a transaction)
poll_url = response.pollUrl
reference_number = response.referenceNumber
else:
# Get Error Message
message = response.message
Make redirect payment
Create a transaction
transaction = pesepay.create_transaction(amount, 'CURRENCY_CODE', 'PAYMENT_REASON')
Initiate the transaction
response = pesepay.initiate_transaction(transaction)
if response.success:
# Save the reference number and/or poll url (used to check the status of a transaction)
poll_url = response.pollUrl
reference_number = response.referenceNumber
# Get the redirect url and redirect user to complete transaction
redirect_url = response.redirectUrl
else:
# Get Error Message
message = response.message
Check Payment Status
Method 1: Check using reference number
response = pesepay.check_payment(reference_number)
if response.success:
if response.paid:
# Payment was successful
else:
# Get Error Message
message = response.message
Method 2: Check using poll url
response = pesepay.poll_transaction(poll_url)
if response.success:
if response.paid:
# Payment was successful
else:
# Get Error Message
message = response.message
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
pesepay-1.0.8.tar.gz
(4.3 kB
view hashes)