Skip to content

Commit

Permalink
Logging
Browse files Browse the repository at this point in the history
  • Loading branch information
dustball committed Apr 20, 2012
1 parent ef98217 commit ceba93d
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 13 deletions.
25 changes: 19 additions & 6 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,14 @@
def parse_json(data):
return simplejson.loads(data.replace('/*-secure-','').replace('*/', ''))

class Donation(db.Model):
amount = db.FloatProperty()
donation_time = db.DateTimeProperty(auto_now_add=True)
transaction_id = db.StringProperty()
name = db.StringProperty()
status = db.StringProperty()
status_code = db.IntegerProperty()

# An event. Usually contains zero rows ("regular mode") or ONE row ("event mode")
class Event(db.Model):
event_name = db.StringProperty()
Expand Down Expand Up @@ -375,26 +383,31 @@ def get(self,format):

class ChargeHandler(webapp.RequestHandler):
def post(self):
first_name = self.request.get('first_name')
last_name = self.request.get('last_name')
card = CreditCard(
number = self.request.get('cc'),
month = self.request.get('month'),
year = "20"+self.request.get('year'),
first_name = '',
last_name = '',
first_name = first_name,
last_name = last_name,
code = ''
)
name = first_name + " " + last_name
gateway = AimGateway(auth_net_login_id, auth_net_trans_key)
gateway.use_test_mode = False
gateway.use_test_url = False
amount = float(int(random.random()*2000))/100
dollar_amount = '$%.2f' % amount
response = gateway.sale(amount, card)
self.response.out.write(simplejson.dumps({"trans_id":response.trans_id,
d = Donation(amount=amount, transaction_id=response.trans_id, status=response.status_strings[response.status], status_code=response.status, name=name)
d.put()
self.response.out.write(simplejson.dumps({"trans_id": response.trans_id,
"amount": amount,
"dollar_amount": dollar_amount,
"status":response.status_strings[response.status],
"dollar_amount": dollar_amount,
"status": response.status_strings[response.status],
"status_code": response.status,
"message": response.message}))
"message": response.message}))

# Used by /staffjson (not sure what uses it)
class JSONHandler(webapp.RequestHandler):
Expand Down
16 changes: 9 additions & 7 deletions static/signin.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@ function autosignin(x) {
}


function charge(cc,month,year) {
function charge(cc,month,year,first,last) {
$("input[name=email]").val("");
$('#ajaxloading').fadeIn();
$.ajax({
url: '/api/charge',
data: 'cc='+cc+'&month='+month+'&year='+year,
data: 'cc='+cc+'&month='+month+'&year='+year+'&first_name='+first+'&last_name='+last,
dataType: "json",
type: "post",
timeout: 14 * 1000,
Expand Down Expand Up @@ -92,14 +92,16 @@ function stopRKey(evt) {
var month = m[3];
var year = m[2];
var cc = m[1];
charge(cc,month,year);
charge(cc,month,year,"","");
return;
}
if (m = raw.match(/^%B([0-9]{16})\^.+\^([0-9]{2})([0-9]{2}).+\?/)) {
var month = m[3];
var year = m[2];
if (m = raw.match(/^%B([0-9]{16})\^(.+)\/(.+)\^([0-9]{2})([0-9]{2}).+\?/)) {
var month = m[5];
var year = m[4];
var first = m[3];
var last = m[2];
var cc = m[1];
charge(cc,month,year);
charge(cc,month,year, first, last);
return;
}
if (m = raw.match(/^[;%]E.*\?/)) {
Expand Down

0 comments on commit ceba93d

Please sign in to comment.