A python library to work with the Pesapal payment API.
API Methods
-
PesapalDirectOrderV4
import pesapal consumer_key ='lhiP9QWtQQsXWU+G5HdFHEUr41COHMiI' # Demo key. Replace with your own, provided by Pesapal consumer_secret = '5k6xJ7E0G5JFgUowlc+13SFEfkY=' # Demo consumer secret. Replace with your own. oauth_consumer = pesapal.OAuthConsumer(consumer_key, consumer_secret) reference = 123 # Order reference number description = 'An order' # Order description amount = 1199.00 # The total cost of the order callback='http://example.com' # The URL the user will be redirected to after making a payment email = '[email protected]' # You must supply at least one of either a phone number or email phone_number = '012345678' direct_order = pesapal.DirectOrder( oauth_consumer, reference, description, amount, callback, email=email, phone_number=phone_number) print direct_order.url # This is the URL for the payment page
-
QueryPaymentStatus
import pesapal consumer_key ='lhiP9QWtQQsXWU+G5HdFHEUr41COHMiI' # Demo key. Replace with your own, provided by Pesapal consumer_secret = '5k6xJ7E0G5JFgUowlc+13SFEfkY=' # Demo consumer secret. Replace with your own. oauth_consumer = pesapal.OAuthConsumer(consumer_key, consumer_secret) pesapal_merchant_reference = 1234 # Order reference number pesapal_transaction_tracking_id = '4321' # Tracking id returned by Pesapal as callback param payment_status = pesapal.PaymentStatus( consumer, pesapal_merchant_reference, pesapal_transaction_tracking_id) print payment_status.message # Message returned by API call. This requires urllib2
Implement the remaining api methods, namely
QueryPaymentStatus
QueryPaymentDetails
Pesapal.py is Open Source Software, released under the terms of the MIT License.
© Okal Otieno, 2012.