Changeset 43

Show
Ignore:
Timestamp:
04/15/08 22:09:33 (4 years ago)
Author:
tim
Message:

Implements GetTransaction?

Location:
trunk/fpys
Files:
3 modified

Legend:

Unmodified
Added
Removed
  • trunk/fpys/client.py

    r42 r43  
    4444            self.dateInstalled = datetime.strptime(di, 
    4545                                                   "%Y-%m-%dT%H:%M:%S") 
     46 
     47class Transaction(object): 
     48    def __init__(self, transaction_element): 
     49        for element in transaction_element.getchildren(): 
     50            attr_name = element.tag[0].lower() + element.tag[1:] 
     51            setattr(self, attr_name, element.text) 
    4652 
    4753class TransactionResponse(object): 
     
    9096        if document.find("Token"): 
    9197            self.token = Token(document.find("Token")) 
     98 
     99        if document.find("Transaction"): 
     100            self.transaction = Transaction(document.find("Transaction")) 
    92101 
    93102        if document.find("AccountBalance"): 
     
    293302        return self.execute(params) 
    294303 
    295     def getTransaction(self): 
    296         pass 
     304    def getTransaction(self, transaction_id): 
     305        params = {'Action': 'GetTransaction', 
     306                  'TransactionId': transaction_id} 
     307        return self.execute(params) 
    297308 
    298309    def installPaymentInstruction(self,  
  • trunk/fpys/tests/client_test.py

    r42 r43  
    155155    # TODO sample, please? 
    156156    pass 
     157 
     158def test_getTransaction(): 
     159    response = fps_client.getTransaction("135AHMQA9H3NEFJL73GQ33873PLPNGLQZP1") 
     160    assert response.success == True 
     161    assert response.transaction.transactionId == "135AHMQA9H3NEFJL73GQ33873PLPNGLQZP1" 
     162    assert response.transaction.senderName == "Kate M DeHaven" 
     163    assert response.transaction.operation == "Pay" 
     164    assert response.transaction.paymentMethod == "CC" 
    157165 
    158166def test_pay(): 
  • trunk/fpys/tests/wsgi_responder.py

    r42 r43  
    6161        return [response] 
    6262 
     63    def GetTransaction(self, environ): 
     64        response = """<ns0:GetTransactionResponse xmlns:ns0="http://fps.amazonaws.com/doc/2007-01-08/"><Transaction><TransactionId>135AHMQA9H3NEFJL73GQ33873PLPNGLQZP1</TransactionId><CallerTransactionDate>2008-04-15T19:43:01.000-07:00</CallerTransactionDate><DateReceived>2008-04-15T19:41:09.000-07:00</DateReceived><DateCompleted>2008-04-15T19:41:10.000-07:00</DateCompleted><TransactionAmount><CurrencyCode>USD</CurrencyCode><Amount>1.000000</Amount></TransactionAmount><Fees><CurrencyCode>USD</CurrencyCode><Amount>0.100000</Amount></Fees><CallerTokenId>Z34XMGF4GCILGV7EV2D45DDO4Q6WXEJZ9175UNR5I9LFEC1H8MMX3R6NBJUJH8MQ</CallerTokenId><SenderTokenId>2446UQQZ1KJ6RPCB7CM774RH1TCAP7GA2VU9ATJ345N7JFGLXLEP3Y2HTDBRXRGR</SenderTokenId><RecipientTokenId>ZS4X4GK4GDIFGVDED2DF54DOTQAWX8JC91I5UNR7I4LFFCUH8KM53RKNDJUMHFM3</RecipientTokenId><Operation>Pay</Operation><PaymentMethod>CC</PaymentMethod><Status>Success</Status><SenderName>Kate M DeHaven</SenderName><CallerName>Timothy P. Freund</CallerName><RecipientName>Timothy P. Freund</RecipientName><TransactionParts><AccountId>JMXHWUQJONDR53DM28EHVCGFILGI4RGNX541Z9</AccountId><Role>Caller</Role><Name>Timothy P. Freund</Name><Reference>FPeS Invoice #10</Reference><FeePaid><CurrencyCode>USD</CurrencyCode><Amount>0.000000</Amount></FeePaid></TransactionParts><TransactionParts><AccountId>GGPXABTDHHRY73MECXBLPFR7JN14ZJQT694V22</AccountId><Role>Sender</Role><Name>Kate M DeHaven</Name><FeePaid><CurrencyCode>USD</CurrencyCode><Amount>0.000000</Amount></FeePaid></TransactionParts><TransactionParts><AccountId>JMXHWUQJONDR53DM28EHVCGFILGI4RGNX541Z9</AccountId><Role>Recipient</Role><Name>Timothy P. Freund</Name><FeePaid><CurrencyCode>USD</CurrencyCode><Amount>0.100000</Amount></FeePaid></TransactionParts><StatusHistory><Date>2008-04-15T19:41:10.000-07:00</Date><Status>Initiated</Status></StatusHistory><StatusHistory><Date>2008-04-15T19:41:10.000-07:00</Date><Status>Success</Status></StatusHistory></Transaction><Status>Success</Status><RequestId>cb093851-e322-4396-acc1-7618bdff81eb:0</RequestId></ns0:GetTransactionResponse>""" 
     65        return [response] 
     66 
    6367    def InstallPaymentInstruction(self, environ): 
    6468        if environ['fps.params']['PaymentInstruction'][0].find("Invalid") != -1: