Created
May 31, 2012 10:53
-
-
Save mindsocket/2842623 to your computer and use it in GitHub Desktop.
2Checkout.com Instant Notification Service - simple CGI processor - python
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# Simple cgi script to process 2checkout.com's Instant Notification Service | |
# See: https://www.2checkout.com/static/va/documentation/INS/index.html | |
# This script is intended to demonstrate validation of the md5_hash and assumes a Fraud State Changed notification | |
# Disclaimer: YMMV | |
import cgi | |
print "Content-type: text/html" | |
print """ | |
<html> | |
<head><title>rego processor</title></head> | |
<body> | |
""" | |
form = cgi.FieldStorage() | |
md5_hash = form.getvalue("md5_hash") | |
sale_id = form.getvalue("sale_id") | |
vendor_id = form.getvalue("vendor_id") | |
invoice_id = form.getvalue("invoice_id") | |
fraud_status = form.getvalue("fraud_status") | |
secret = "----fill in----" | |
import hashlib | |
check = hashlib.md5(sale_id + vendor_id + invoice_id + secret).hexdigest().upper() | |
if check == md5_hash and fraud_status == 'pass': | |
# MD5 checks out and order has passed fraud check, now check the other order fields to determine what to do | |
# TODO | |
name = form.getvalue("customer_name") | |
email = form.getvalue("customer_email") | |
pass | |
print """</body></html>""" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment