Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

FPS API 2010-08-28 #628

Merged
merged 5 commits into from

2 participants

@theju

Updates boto FPS for version released on 2010-08-28.

@garnaat
Owner

I'm not an FPS user and it's difficult for me to evaluate this patch. Are you currently using this? Can you think of any way to create a test for FPS?

Thanks

@theju

@garnaat It's being used on http://merchant.agiliq.com/offsite/amazon_fps/ and you can try setting up the merchant example from https://github.com/agiliq/merchant and use the upstream boto library and the enclosed pull request and test for yourself.

I am willing to write a test but am not sure how and what I should test because part of the flow occurs on the amazon site and the signature is dynamic and expires in a short period of time.

Please advice.

@garnaat garnaat merged commit a15b946 into boto:master
@garnaat garnaat referenced this pull request
Closed

FPS module is out of date #359

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Mar 24, 2011
  1. @theju
  2. @theju
Commits on Mar 29, 2011
  1. @theju

    Removed a stray print statement.

    theju authored
  2. @theju

    Removed a stray comma

    theju authored
Commits on Mar 9, 2012
  1. @theju

    Merged upstream boto.

    theju authored
This page is out of date. Refresh to see the latest.
Showing with 36 additions and 29 deletions.
  1. +26 −29 boto/fps/connection.py
  2. +10 −0 boto/fps/response.py
View
55 boto/fps/connection.py
@@ -20,9 +20,6 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
# IN THE SOFTWARE.
-import base64
-import hmac
-import hashlib
import urllib
import xml.sax
import uuid
@@ -32,10 +29,11 @@
from boto.connection import AWSQueryConnection
from boto.resultset import ResultSet
from boto.exception import FPSResponseError
+from boto.fps.response import FPSResponse
class FPSConnection(AWSQueryConnection):
- APIVersion = '2007-01-08'
+ APIVersion = '2010-08-28'
def __init__(self, aws_access_key_id=None, aws_secret_access_key=None,
is_secure=True, port=None, proxy=None, proxy_port=None,
@@ -218,7 +216,7 @@ def make_url(self, returnURL, paymentReason, pipelineName,
return final
def pay(self, transactionAmount, senderTokenId,
- recipientTokenId=None, callerTokenId=None,
+ recipientTokenId=None,
chargeFeeTo="Recipient",
callerReference=None, senderReference=None, recipientReference=None,
senderDescription=None, recipientDescription=None,
@@ -230,20 +228,16 @@ def pay(self, transactionAmount, senderTokenId,
"""
params = {}
params['SenderTokenId'] = senderTokenId
- # this is for 2008-09-17 specification
- params['TransactionAmount.Amount'] = str(transactionAmount)
+ # this is for 2010-08-28 specification
+ params['TransactionAmount.Value'] = str(transactionAmount)
params['TransactionAmount.CurrencyCode'] = "USD"
- #params['TransactionAmount'] = str(transactionAmount)
params['ChargeFeeTo'] = chargeFeeTo
-
- 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 recipientTokenId:
+ params['RecipientTokenId'] = (
+ recipientTokenId if recipientTokenId is not None
+ else boto.config.get("FPS", "recipient_token")
+ )
if(transactionDate != None):
params['TransactionDate'] = transactionDate
if(senderReference != None):
@@ -263,12 +257,13 @@ def pay(self, transactionAmount, senderTokenId,
params['CallerReference'] = callerReference
if reserve:
- response = self.make_request("Reserve", params)
+ action = "Reserve"
else:
- response = self.make_request("Pay", params)
+ action = "Pay"
+ response = self.make_request(action, params)
body = response.read()
if(response.status == 200):
- rs = ResultSet()
+ rs = ResultSet([("%sResponse" %action, FPSResponse)])
h = handler.XmlHandler(rs, self)
xml.sax.parseString(body, h)
return rs
@@ -285,7 +280,7 @@ def get_transaction_status(self, transactionId):
response = self.make_request("GetTransactionStatus", params)
body = response.read()
if(response.status == 200):
- rs = ResultSet()
+ rs = ResultSet([("GetTransactionStatusResponse", FPSResponse)])
h = handler.XmlHandler(rs, self)
xml.sax.parseString(body, h)
return rs
@@ -297,14 +292,14 @@ def cancel(self, transactionId, description=None):
Cancels a reserved or pending transaction.
"""
params = {}
- params['transactionId'] = transactionId
+ params['TransactionId'] = transactionId
if(description != None):
params['description'] = description
response = self.make_request("Cancel", params)
body = response.read()
if(response.status == 200):
- rs = ResultSet()
+ rs = ResultSet([("CancelResponse", FPSResponse)])
h = handler.XmlHandler(rs, self)
xml.sax.parseString(body, h)
return rs
@@ -318,12 +313,13 @@ def settle(self, reserveTransactionId, transactionAmount=None):
params = {}
params['ReserveTransactionId'] = reserveTransactionId
if(transactionAmount != None):
- params['TransactionAmount'] = transactionAmount
+ params['TransactionAmount.Value'] = transactionAmount
+ params['TransactionAmount.CurrencyCode'] = "USD"
response = self.make_request("Settle", params)
body = response.read()
if(response.status == 200):
- rs = ResultSet()
+ rs = ResultSet([("SettleResponse", FPSResponse)])
h = handler.XmlHandler(rs, self)
xml.sax.parseString(body, h)
return rs
@@ -340,14 +336,15 @@ def refund(self, callerReference, transactionId, refundAmount=None,
params['CallerReference'] = callerReference
params['TransactionId'] = transactionId
if(refundAmount != None):
- params['RefundAmount'] = refundAmount
+ params['RefundAmount.Value'] = refundAmount
+ params['RefundAmount.CurrencyCode'] = "USD"
if(callerDescription != None):
params['CallerDescription'] = callerDescription
response = self.make_request("Refund", params)
body = response.read()
if(response.status == 200):
- rs = ResultSet()
+ rs = ResultSet([("RefundResponse", FPSResponse)])
h = handler.XmlHandler(rs, self)
xml.sax.parseString(body, h)
return rs
@@ -387,7 +384,7 @@ def get_token_by_caller_reference(self, callerReference):
return rs
else:
raise FPSResponseError(response.status, response.reason, body)
-
+
def get_token_by_caller_token(self, tokenId):
"""
Returns details about the token specified by 'TokenId'.
@@ -414,7 +411,7 @@ def verify_signature(self, end_point_url, http_parameters):
body = response.read()
if(response.status != 200):
raise FPSResponseError(response.status, response.reason, body)
- rs = ResultSet()
+ rs = ResultSet([("VerifySignatureResponse", FPSResponse)])
h = handler.XmlHandler(rs, self)
xml.sax.parseString(body, h)
return rs
View
10 boto/fps/response.py
@@ -0,0 +1,10 @@
+class FPSResponse(object):
+ def __init__(self, connection=None):
+ self.connection = connection
+
+ def startElement(self, name, attrs, connection):
+ return None
+
+ def endElement(self, name, value, connection):
+ if not name == "ResponseMetadata":
+ setattr(self, name, value)
Something went wrong with that request. Please try again.