pip install -e git://github.com/kelonye/python_pesapal.git#egg=pesapal
consumer_key ='consumer_key'
consumer_secret = 'consumer_secret'
testing = False
import pesapal, urllib2
### make client
client = pesapal.PesaPal(consumer_key, consumer_secret, testing)
### post a direct order
request_data = {
'Amount': '',
'Description': '',
'Type': '',
'Reference': '',
'PhoneNumber': ''
}
post_params = {
'oauth_callback': 'www.example.com/post_payment_page'
}
request = client.postDirectOrder(post_params, request_data)
print request.to_url()
### get order status
params = {
'pesapal_merchant_reference': '000',
'pesapal_transaction_tracking_id': '000'
}
request = client.queryPaymentStatus(params)
url = request.to_url()
print url
response = urllib2.urlopen(url)
print response.read()
### get order status by ref
params = {
'pesapal_merchant_reference': '000'
}
request = client.queryPaymentStatusByMerchantRef(params)
print request.to_url()
### get detailed order status
params = {
'pesapal_merchant_reference': '000',
'pesapal_transaction_tracking_id': '000'
}
request = client.queryPaymentDetails(params)
print request.to_url()
testing defaults to true and uses 'http://demo2.pesapal.com/api/'. Pass it as false to use 'https://www.pesapal.com/api/'
returns a oauth.OAuthRequest object
options are a hash containing:
- Amount
- Description
- Type
- Reference
- PhoneNumber ( optional )
- Currency
- FirstName
- LastName
- LineItems
returns a oauth.OAuthRequest object
options are a hash containing:
- pesapal_merchant_reference
- pesapal_transaction_tracking_id
returns a oauth.OAuthRequest object
options are a hash containing:
- pesapal_merchant_reference
returns a oauth.OAuthRequest object
options are a hash containing:
- pesapal_merchant_reference
- pesapal_transaction_tracking_id
make
MIT