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([("VerifySignatureResponse", FPSResponse)])
     h = handler.XmlHandler(rs, self)
     xml.sax.parseString(body, h)
     return rs
    def get_recipient_verification_status(self, recipientTokenId):
        """
        Test that the intended recipient has a verified Amazon Payments account.
        """
        params = {}
        params['RecipientTokenId'] = recipientTokenId

        response = self.make_request("GetRecipientVerificationStatus", params)
        body = response.read()
        if (response.status == 200):
            rs = ResultSet()
            h = handler.XmlHandler(rs, self)
            xml.sax.parseString(body, h)
            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'.
        """
        params = {}
        params['TokenId'] = tokenId

        response = self.make_request("GetTokenByCaller", params)
        body = response.read()
        if (response.status == 200):
            rs = ResultSet()
            h = handler.XmlHandler(rs, self)
            xml.sax.parseString(body, h)
            return rs
        else:
            raise FPSResponseError(response.status, response.reason, body)
    def get_transaction_status(self, transactionId):
        """
        Returns the status of a given transaction.
        """
        params = {}
        params['TransactionId'] = transactionId

        response = self.make_request("GetTransactionStatus", params)
        body = response.read()
        if (response.status == 200):
            rs = ResultSet([("GetTransactionStatusResponse", FPSResponse)])
            h = handler.XmlHandler(rs, self)
            xml.sax.parseString(body, h)
            return rs
        else:
            raise FPSResponseError(response.status, response.reason, body)
    def settle(self, reserveTransactionId, transactionAmount=None):
        """
        Charges for a reserved payment.
        """
        params = {}
        params['ReserveTransactionId'] = reserveTransactionId
        if (transactionAmount != None):
            params['TransactionAmount'] = transactionAmount

        response = self.make_request("Settle", params)
        body = response.read()
        if (response.status == 200):
            rs = ResultSet([("SettleResponse", FPSResponse)])
            h = handler.XmlHandler(rs, self)
            xml.sax.parseString(body, h)
            return rs
        else:
            raise FPSResponseError(response.status, response.reason, body)
    def cancel(self, transactionId, description=None):
        """
        Cancels a reserved or pending transaction.
        """
        params = {}
        params['transactionId'] = transactionId
        if (description != None):
            params['description'] = description

        response = self.make_request("Cancel", params)
        body = response.read()
        if (response.status == 200):
            rs = ResultSet([("CancelResponse", FPSResponse)])
            h = handler.XmlHandler(rs, self)
            xml.sax.parseString(body, h)
            return rs
        else:
            raise FPSResponseError(response.status, response.reason, body)
Example #7
0
	def make_payment(self, amount, sender_token, charge_fee_to="Recipient", reference=None, senderReference=None, recipientReference=None, senderDescription=None, recipientDescription=None, callerDescription=None, metadata=None, transactionDate=None):
		"""
		Make a payment transaction
		You must specify the amount and the sender token.
		"""
		params = {}
		params['RecipientTokenId'] = boto.config.get("FPS", "recipient_token")
		params['CallerTokenId'] = boto.config.get("FPS", "caller_token")
		params['SenderTokenId'] = sender_token
		params['TransactionAmount.Amount'] = str(amount)
		params['TransactionAmount.CurrencyCode'] = "USD"
		params['ChargeFeeTo'] = charge_fee_to

		if(transactionDate != None):
			params['TransactionDate'] = transactionDate
		if(senderReference != None):
			params['SenderReference'] = senderReference
		if(recipientReference != None):
			params['RecipientReference'] = recipientReference
		if(senderDescription != None):
			params['SenderDescription'] = senderDescription
		if(recipientDescription != None):
			params['RecipientDescription'] = recipientDescription
		if(callerDescription != None):
			params['CallerDescription'] = callerDescription
		if(metadata != None):
			params['MetaData'] = metadata
		if(transactionDate != None):
			params['TransactionDate'] = transactionDate
		if(reference == None):
			reference = uuid.uuid4()
		params['CallerReference'] = reference

		response = self.make_request("Pay", params)
		body = response.read()
		if(response.status == 200):
			rs = ResultSet()
			h = handler.XmlHandler(rs, self)
			xml.sax.parseString(body, h)
			return rs
		else:
			raise FPSResponseError(response.status, response.reason, body)
Example #8
0
	def install_caller_instruction(self, token_type="Unrestricted", transaction_id=None):
		"""
		Set us up as a caller
		This will install a new caller_token into the FPS section.
		This should really only be called to regenerate the caller token.
		"""
		response = self.install_payment_instruction("MyRole=='Caller';", token_type=token_type, transaction_id=transaction_id)
		body = response.read()
		if(response.status == 200):
			rs = ResultSet()
			h = handler.XmlHandler(rs, self)
			xml.sax.parseString(body, h)
			caller_token = rs.TokenId
			try:
				boto.config.save_system_option("FPS", "caller_token", caller_token)
			except(IOError):
				boto.config.save_user_option("FPS", "caller_token", caller_token)
			return caller_token
		else:
			raise FPSResponseError(response.status, respons.reason, body)
Example #9
0
 def refund(self, callerReference, transactionId, refundAmount=None, callerDescription=None):
     """
     Refund a transaction. This refunds the full amount by default unless 'refundAmount' is specified.
     """
     params = {}
     params['CallerReference'] = callerReference
     params['TransactionId'] = transactionId
     if(refundAmount != None):
         params['RefundAmount'] = refundAmount
     if(callerDescription != None):
         params['CallerDescription'] = callerDescription
     
     response = self.make_request("Refund", params)
     body = response.read()
     if(response.status == 200):
         rs = ResultSet()
         h = handler.XmlHandler(rs, self)
         xml.sax.parseString(body, h)
         return rs
     else:
         raise FPSResponseError(response.status, response.reason, body)
    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):
        """
        Make a payment transaction. You must specify the amount.
        This can also perform a Reserve request if 'reserve' is set to True.
        """
        params = {}
        params['SenderTokenId'] = senderTokenId
        # this is for 2008-09-17 specification
        params['TransactionAmount.Amount'] = 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 (transactionDate != None):
            params['TransactionDate'] = transactionDate
        if (senderReference != None):
            params['SenderReference'] = senderReference
        if (recipientReference != None):
            params['RecipientReference'] = recipientReference
        if (senderDescription != None):
            params['SenderDescription'] = senderDescription
        if (recipientDescription != None):
            params['RecipientDescription'] = recipientDescription
        if (callerDescription != None):
            params['CallerDescription'] = callerDescription
        if (metadata != None):
            params['MetaData'] = metadata
        if (callerReference == None):
            callerReference = uuid.uuid4()
        params['CallerReference'] = callerReference

        if reserve:
            action = "Reserve"
        else:
            action = "Pay"
        response = self.make_request(action, params)
        body = response.read()
        if (response.status == 200):
            rs = ResultSet([("%sResponse" % action, FPSResponse)])
            h = handler.XmlHandler(rs, self)
            xml.sax.parseString(body, h)
            return rs
        else:
            raise FPSResponseError(response.status, response.reason, body)