Permalink
Browse files

CC handler

  • Loading branch information...
1 parent 8e6879c commit 6de367048c033296afa19f2364d9eef9c7bc5280 @dustball dustball committed Apr 19, 2012
View
@@ -1 +1,2 @@
*.pyc
+keys.py
View
@@ -0,0 +1,2 @@
+auth_net_login_id = ""
+auth_net_trans_key = ""
View
24 main.py
@@ -25,6 +25,9 @@
import util
from util import Pacific
import os
+from quix.pay.gateway.authorizenet import AimGateway
+from quix.pay.transaction import CreditCard
+from keys import auth_net_login_id, auth_net_trans_key
MAX_SIGNIN_TIME = 60 * 60 * 8
@@ -370,6 +373,25 @@ def get(self,format):
self.response.out.write("0")
self.response.out.write("\n")
+class ChargeHandler(webapp.RequestHandler):
+ def get(self):
+ card = CreditCard(
+ number = self.request.get('cc'),
+ month = self.request.get('month'),
+ year = "20"+self.request.get('year'),
+ first_name = '',
+ last_name = '',
+ code = ''
+ )
+ gateway = AimGateway(auth_net_login_id, auth_net_trans_key)
+ gateway.use_test_mode = True
+ gateway.use_test_url = False
+ response = gateway.sale(10.00, card)
+ self.response.out.write(simplejson.dumps({"trans_id":response.trans_id,
+ "status":response.status_strings[response.status],
+ "status_code": response.status,
+ "message": response.message}))
+
# Used by /staffjson (not sure what uses it)
class JSONHandler(webapp.RequestHandler):
def get(self):
@@ -416,8 +438,8 @@ def main():
('/eventmode', EventModeHandler),
('/ministaff', MiniStaffHandler),
('/signin', SigninHandler),
- ('/staff', StaffHandler),
('/open', OpenHandler),
+ ('/api/charge', ChargeHandler),
('/sstats/?', StatHandler),
('/sstats/(.+)', StatsHandler),
('/log', LogHandler),
View
@@ -0,0 +1,7 @@
+""" Python module namespace for Quixotix Software, LLC """
+try:
+ import pkg_resources
+ pkg_resources.declare_namespace(__name__)
+except ImportError:
+ import pkgutil
+ __path__ = pkgutil.extend_path(__path__, __name__)
View
@@ -0,0 +1 @@
+""" Abstract interfacing with online payment gateways. """
View
@@ -0,0 +1,4 @@
+from exceptions import Exception
+
+class ValidationError(Exception): pass
+class NotSupportedError(Exception): pass
@@ -0,0 +1,10 @@
+def gateway_factory(name):
+ if name == 'AimGateway':
+ import authorizenet
+ return authorizenet.AimGateway()
+ if name == 'AimEmulationGateway':
+ import quantam
+ return quantam.AimEmulationGateway()
+ if name == 'XmlMessengerGateway':
+ import psigate
+ return psigate.XmlMessengerGateway()
Oops, something went wrong.

0 comments on commit 6de3670

Please sign in to comment.