from hashlib import md5import urllib2import loggingfrom urllib import urlencodefrom collections import OrderedDict
POSTBACK_URL = '/eng/query/validate'POSTBACK_SERVER = 'https://www.payfast.co.za'
def _values_to_encode(data): return [ (k, unicode(data[k]).strip().encode('utf8'),) for k in data if data[k] and k != 'signature' ] def _signature_string(data): values = _values_to_encode(data) return urlencode(values)
def signature(data): """ Calculates PayFast signature. 'data' should be an OrderedDict instance. """ text = _signature_string(data) print text return md5(text).hexdigest()
def get_data(): data = OrderedDict() data['merchant_id'] = 'XXXXXXXXX' data['merchant_key'] = 'XXXXXXXXX' data['m_payment_id'] = '2' data['amount'] = '234' data['item_name'] = 'Order' data['item_description'] = 'Some description here'--
You received this message because you are subscribed to the Google Groups "Gauteng Python User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to gpugsa+un...@googlegroups.com.
To post to this group, send email to gpu...@googlegroups.com.
Visit this group at https://groups.google.com/group/gpugsa.
For more options, visit https://groups.google.com/d/optout.