summaryrefslogtreecommitdiff
path: root/boto/fps
diff options
context:
space:
mode:
authorChris Moyer <kopertop@MacPro.local>2010-10-12 09:28:41 -0400
committerChris Moyer <kopertop@MacPro.local>2010-10-12 09:28:41 -0400
commit76d00c0e0c31001febd1330805da878337c37245 (patch)
treeae49215a4cb1302db75e324381e14c726f212805 /boto/fps
parent1f78b4b78d68b05e865535edc63da912f13314bf (diff)
parent4b0b3a8854fc93fd70161c6e3588a7b1defd405c (diff)
downloadboto-76d00c0e0c31001febd1330805da878337c37245.tar.gz
Merge branch 'master' of http://github.com/jaraco/boto into jaraco-master
Conflicts: boto/fps/connection.py boto/mturk/test/create_hit_external.py
Diffstat (limited to 'boto/fps')
-rw-r--r--boto/fps/connection.py45
-rw-r--r--boto/fps/test/__init__.py0
-rw-r--r--boto/fps/test/test_verify_signature.py6
3 files changed, 44 insertions, 7 deletions
diff --git a/boto/fps/connection.py b/boto/fps/connection.py
index 51972043..f475cb84 100644
--- a/boto/fps/connection.py
+++ b/boto/fps/connection.py
@@ -1,4 +1,5 @@
# Copyright (c) 2008 Chris Moyer http://coredumped.org/
+# Copyringt (c) 2010 Jason R. Coombs http://www.jaraco.com/
#
# Permission is hereby granted, free of charge, to any person obtaining a
# copy of this software and associated documentation files (the
@@ -134,10 +135,18 @@ class FPSConnection(AWSQueryConnection):
hmac = self.hmac.copy()
hmac.update(canonical)
signature = urllib.quote_plus(base64.encodestring(hmac.digest()).strip())
-
- return "https://authorize.payments-sandbox.amazon.com%s&awsSignature=%s" % (url, signature)
- def pay(self, transactionAmount, senderTokenId, chargeFeeTo="Recipient",
+ # use the sandbox authorization endpoint if we're using the
+ # sandbox for API calls.
+ endpoint_host = 'authorize.payments.amazon.com'
+ if 'sandbox' in self.host:
+ endpoint_host = 'authorize.payments-sandbox.amazon.com'
+ fmt = "https://%(endpoint_host)s%(url)s&awsSignature=%(signature)s"
+ return fmt % vars()
+
+ def pay(self, transactionAmount, senderTokenId,
+ recipientTokenId=None, callerTokenId=None,
+ chargeFeeTo="Recipient",
callerReference=None, senderReference=None, recipientReference=None,
senderDescription=None, recipientDescription=None, callerDescription=None,
metadata=None, transactionDate=None, reserve=False):
@@ -147,12 +156,20 @@ class FPSConnection(AWSQueryConnection):
"""
params = {}
params['SenderTokenId'] = senderTokenId
- params['TransactionAmount.Amount'] = str(transactionAmount)
- params['TransactionAmount.CurrencyCode'] = "USD"
+ # this is for 2008-09-17 specification
+ #params['TransactionAmount.Value'] = str(transactionAmount)
+ #params['TransactionAmount.CurrencyCode'] = "USD"
+ params['TransactionAmount'] = str(transactionAmount)
params['ChargeFeeTo'] = chargeFeeTo
- params['RecipientTokenId'] = boto.config.get("FPS", "recipient_token")
- params['CallerTokenId'] = boto.config.get("FPS", "caller_token")
+ params['RecipientTokenId'] = (
+ recipientTokenId if recipientTokenId is not None
+ else boto.config.get("FPS", "recipient_token")
+ )
+ params['CallerTokenId'] = (
+ callerTokenId if callerTokenId is not None
+ else boto.config.get("FPS", "caller_token")
+ )
if(transactionDate != None):
params['TransactionDate'] = transactionDate
if(senderReference != None):
@@ -310,3 +327,17 @@ class FPSConnection(AWSQueryConnection):
return rs
else:
raise FPSResponseError(response.status, response.reason, body)
+
+ def verify_signature(self, end_point_url, http_parameters):
+ params = dict(
+ UrlEndPoint = end_point_url,
+ HttpParameters = http_parameters,
+ )
+ response = self.make_request("VerifySignature", params)
+ body = response.read()
+ if(response.status != 200):
+ raise FPSResponseError(response.status, response.reason, body)
+ rs = ResultSet()
+ h = handler.XmlHandler(rs, self)
+ xml.sax.parseString(body, h)
+ return rs
diff --git a/boto/fps/test/__init__.py b/boto/fps/test/__init__.py
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/boto/fps/test/__init__.py
diff --git a/boto/fps/test/test_verify_signature.py b/boto/fps/test/test_verify_signature.py
new file mode 100644
index 00000000..10c6b61c
--- /dev/null
+++ b/boto/fps/test/test_verify_signature.py
@@ -0,0 +1,6 @@
+from boto.fps.connection import FPSConnection
+conn = FPSConnection()
+# example response from the docs
+params = 'expiry=08%2F2015&signature=ynDukZ9%2FG77uSJVb5YM0cadwHVwYKPMKOO3PNvgADbv6VtymgBxeOWEhED6KGHsGSvSJnMWDN%2FZl639AkRe9Ry%2F7zmn9CmiM%2FZkp1XtshERGTqi2YL10GwQpaH17MQqOX3u1cW4LlyFoLy4celUFBPq1WM2ZJnaNZRJIEY%2FvpeVnCVK8VIPdY3HMxPAkNi5zeF2BbqH%2BL2vAWef6vfHkNcJPlOuOl6jP4E%2B58F24ni%2B9ek%2FQH18O4kw%2FUJ7ZfKwjCCI13%2BcFybpofcKqddq8CuUJj5Ii7Pdw1fje7ktzHeeNhF0r9siWcYmd4JaxTP3NmLJdHFRq2T%2FgsF3vK9m3gw%3D%3D&signatureVersion=2&signatureMethod=RSA-SHA1&certificateUrl=https%3A%2F%2Ffps.sandbox.amazonaws.com%2Fcerts%2F090909%2FPKICert.pem&tokenID=A5BB3HUNAZFJ5CRXIPH72LIODZUNAUZIVP7UB74QNFQDSQ9MN4HPIKISQZWPLJXF&status=SC&callerReference=callerReferenceMultiUse1'
+endpoint = 'http://vamsik.desktop.amazon.com:8080/ipn.jsp'
+conn.verify_signature(endpoint, params)