Skip to content

Instantly share code, notes, and snippets.

@guerrerocarlos
Created November 9, 2012 20:43
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save guerrerocarlos/4048118 to your computer and use it in GitHub Desktop.
Save guerrerocarlos/4048118 to your computer and use it in GitHub Desktop.
Paypal payment checking function
import urllib
import urllib2
def paypal_check(tx,at):
success = False
post_data = [('cmd','_notify-synch'),('tx',tx),('at',at)] # a sequence of two element tuples
result = urllib2.urlopen('https://www.paypal.com/cgi-bin/webscr', urllib.urlencode(post_data))
content = result.read().split('\n')
results = {}
for each in content[1:]:
print each
try:
key, value = each.split("=")
print key
results[key] = value
except:
pass
if content[0].find('SUCCESS') >= 0:
success = True
return success, results
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment