-
Notifications
You must be signed in to change notification settings - Fork 0
/
Usage.py
executable file
·42 lines (31 loc) · 1.3 KB
/
Usage.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# Import the QuickPayAPI class
from QuickPayAPI import QuickPayAPI, QuickPayAPIException
from datetime import datetime
import time
import web
from web import form
class Usage:
def POST(self):
#Set the QuickPayAPI credentials
username = "QuickPayAPIUsername"
apikey = "QuickPayAPIKey"
api = QuickPayAPI(username, apikey)
try:
form = web.input()
#form = cgi.FieldStorage()
#token = form["Token"]
date = time.strftime("%Y-%m-%d %X") #datetime.now()
print 'Date: ', date
referenceNo = date
orderInfo = date
amount = '10'
print "Form: ",form
card = form["Card Number"].encode("ascii","ignore")
expiry = form["Card Expiry Date"].encode("ascii","ignore")
cvv = form["Card CVV/CVV2"].encode("ascii","ignore")
currency = 'KES'
#print 'date: %s, referenceNo: %s, orderInfo: %s, amount: %s, card: %s, currency: %s' % (date, referenceNo, orderInfo, amount, card, currency)
results = api.sendRequest(referenceNo, orderInfo, amount, card, currency,expiry,cvv)
return 'responseCode: %s, authId: %s, receiptNo: %s' % (results['responseCode'], results['authId'], results['receiptNo'])
except QuickPayAPIException, e:
return 'Encountered an error while sending: %s' % str(e)