Archived
Allow Inside to get purchase date by identified by number and activation_code
This commit is contained in:
1 parent
2d3cb6af6a
commit
2b3bffdc83
2 files changed
+37
-3
No files matched your search
@@ -14,6 +14,9 @@ INSIDE_DB_USER = ''
|
||||
INSIDE_DB_PASS = ''
|
||||
INSIDE_DB_NAME = 'inside'
|
||||
|
||||
# Authenticates Inside
|
||||
INSIDE_API_KEY = ''
|
||||
|
||||
MEMBERSHIP_PRICE_KR = 1
|
||||
|
||||
|
||||
|
||||
+34
-3
@@ -375,9 +375,35 @@ def new_membership_delivered(incoming_id=None, dlr_id=None):
|
||||
return 'OK'
|
||||
|
||||
|
||||
@app.route('/')
|
||||
def main():
|
||||
return 'Tekstmelding!'
|
||||
def get_activation_code_purchase_date(number, activation_code):
|
||||
row = query_db("""
|
||||
SELECT event.timestamp FROM incoming, event
|
||||
WHERE incoming.msisdn = %s
|
||||
AND incoming.id = event.incoming_id
|
||||
AND event.action = 'new_membership'
|
||||
AND event.activation_code = %s""", [number, activation_code], one=True)
|
||||
return str(row.get('timestamp')) if row else None
|
||||
|
||||
|
||||
@app.route('/inside-code-purchase-date')
|
||||
def inside_code_purchase_date():
|
||||
number = request.args.get('number')
|
||||
activation_code = request.args.get('activation_code')
|
||||
api_key = request.args.get('api_key')
|
||||
|
||||
if api_key != app.config['INSIDE_API_KEY']:
|
||||
abort(403) # Forbidden
|
||||
|
||||
if None in (number, activation_code):
|
||||
return ''
|
||||
|
||||
purchase_date = get_activation_code_purchase_date(number, activation_code)
|
||||
|
||||
app.logger.info(
|
||||
'Checked purchase date for number=%s activation_code=%s purchase_date=%s',
|
||||
number, activation_code, purchase_date)
|
||||
|
||||
return purchase_date or ''
|
||||
|
||||
|
||||
@app.route('/sendega-incoming')
|
||||
@@ -481,6 +507,11 @@ def dlr():
|
||||
|
||||
app.logger.error('Unhandled DLR, dlr_id=%s', dlr_id)
|
||||
|
||||
|
||||
@app.route('/')
|
||||
def main():
|
||||
return 'Tekstmelding!'
|
||||
|
||||
if __name__ == '__main__':
|
||||
app.run()
|
||||
|
||||
|
||||
Reference in new issue
Block a user