Authorize.net integration problem
I am trying to integrate Authorize.net SIM API into django views.
I am facing a problem in the fingerprint generation. I am repeatedly
getting that the fingerprint generated doesn't match the one the
server generates.
I have generated the md5 hash with the key provided as specified in
the SIM documentation.
Here is the code:
params = {
'x_login' : '4ffrBT36La',
'x_amount' : '100.00',
'x_show_form' : 'PAYMENT_FORM',
'x_type' : 'AUTH_CAPTURE',
'x_method' : 'CC',
'x_fp_sequence' : '123',
'x_version' : '3.1',
'x_relay_response' : 'FALSE',
}
params['x_fp_timestamp'] = int(time.time())
msg = '^'.join([params['x_login'],
str(params['x_fp_sequence']),
str(params['x_fp_timestamp']),
str(params['x_amount'])
])+'^'
fingerprint = hmac.new('9LyEU8t87h9Hj49Y',msg).hexdigest()
I would be glad if some one that has dealt with this earlier, points
out what the glitch is. Thanks in advance.
--
http://mail.python.org/mailman/listinfo/python-list
HTTP Authentication
Whats is the python urllib2 equivallent of
curl -u username:password status="abcd" http://example.com/update.json
I did this:
handle = urllib2.Request(url)
authheader = "Basic %s" % base64.encodestring('%s:%s' % (username,
password))
handle.add_header("Authorization", authheader)
Is there a better / simpler way?
--
http://mail.python.org/mailman/listinfo/python-list
HTTP Authentication using urllib2
I am trying to authenticate using urllib2. The basic authentication
works if I hard code authheaders.
def is_follows(follower, following):
theurl = 'http://twitter.com/friendships/exists.json?
user_a='+follower+'&user_b='+following
username = 'uname1'
password = 'pwd1'
handle = urllib2.Request(theurl)
authheader = "Basic %s" % base64.encodestring('%s:%s' %
(username, password))
handle.add_header("Authorization", authheader)
try:
return simplejson.load(urllib2.urlopen(handle))
except IOError, e:
print "Something wrong. This shouldnt happen"
I am trying to refactor this code into how urllib2 expects to do. But
I am getting an error.
def is_follows(follower, following):
url = 'http://twitter.com/friendships/exists.json?user_a=%s&user_b=
%s' %(
follower, following)
#Authenticate once for all
auth_handler = urllib2.HTTPBasicAuthHandler()
auth_handler.add_password(realm='',
uri='http://twitter.com',
user='scorpion032',
passwd='123456')
opener = urllib2.build_opener(auth_handler)
urllib2.install_opener(opener)
try:
return simplejson.load(urllib2.urlopen(url))
except:
print "Something wrong. This shouldnt happen"
return False
Can U please point what I am missing. As I understand, the Auth
Headers are put appropriately in either cases, but the latter one
doesnt work.
--
http://mail.python.org/mailman/listinfo/python-list
Re: Authorize.net integration problem
Yup. Unusual, it is.
But thats how their string specification syntax is. It includes a ^ at the
end.
On Tue, Mar 31, 2009 at 6:13 PM, andrew cooke wrote:
>
> have you printed msg and checked it is formatted correctly? i have node
> idea what the protocol is, but your use of join and string concatenation
> in the generation of msg looks unusual to me.
>
> andrew
>
> Lakshman wrote:
> > I am trying to integrate Authorize.net SIM API into django views.
> >
> > I am facing a problem in the fingerprint generation. I am repeatedly
> > getting that the fingerprint generated doesn't match the one the
> > server generates.
> >
> > I have generated the md5 hash with the key provided as specified in
> > the SIM documentation.
> >
> > Here is the code:
> >
> > params = {
> > 'x_login' : '4ffrBT36La',
> > 'x_amount' : '100.00',
> > 'x_show_form' : 'PAYMENT_FORM',
> > 'x_type' : 'AUTH_CAPTURE',
> > 'x_method' : 'CC',
> > 'x_fp_sequence' : '123',
> > 'x_version' : '3.1',
> > 'x_relay_response' : 'FALSE',
> > }
> > params['x_fp_timestamp'] = int(time.time())
> >
> > msg = '^'.join([params['x_login'],
> >str(params['x_fp_sequence']),
> > str(params['x_fp_timestamp']),
> >str(params['x_amount'])
> >])+'^'
> >
> > fingerprint = hmac.new('9LyEU8t87h9Hj49Y',msg).hexdigest()
> >
> >
> > I would be glad if some one that has dealt with this earlier, points
> > out what the glitch is. Thanks in advance.
> > --
> > http://mail.python.org/mailman/listinfo/python-list
> >
> >
>
>
>
--
Regards,
Lakshman
becomingguru.com
lakshmanprasad.com
--
http://mail.python.org/mailman/listinfo/python-list
