예제 #1
0
    def prepare_transaction(self, gateway_url, amount, credit_card, customer=None, reference=None):
        """
        Prepare a payment request and send it to eWAY.
        
        @param gateway_url: The gateway url to use for the transaction
        @param amount: The amount to charge
        @param credit_card: An instance of CreditCard
        @param customer: An instance of Customer
        @param reference: A reference for the transaction
        @return: An instance of Response
        
        @author: Alex Hayes <*****@*****.**>
        """
        if not reference:
            prefix = credit_card.last_name
            prefix.replace(" ", "").lower()
            reference = self.get_reference(prefix)
            
        payment = Payment(total_amount=amount,
                          transaction_number=reference)
        
        data = payment.get_data()
        data.update(credit_card.get_data())

        if customer:
            data.update(customer.get_data())
        else:
            customer = Customer()
            data.update(customer.get_data())
        
        request_data = self.build_request(data)
        return self.send_transaction(gateway_url, request_data)
예제 #2
0
    def prepare_transaction(self, gateway_url, amount, credit_card, customer=None, reference=None):
        """
        Prepare a payment request and send it to eWAY.
        
        @param gateway_url: The gateway url to use for the transaction
        @param amount: The amount to charge
        @param credit_card: An instance of CreditCard
        @param customer: An instance of Customer
        @param reference: A reference for the transaction
        @return: An instance of Response
        
        @author: Alex Hayes <*****@*****.**>
        """
        if not reference:
            prefix = credit_card.last_name
            prefix.replace(" ", "").lower()
            reference = self.get_reference(prefix)
            
        payment = Payment(total_amount=amount,
                          transaction_number=reference)
        
        data = payment.get_data()
        data.update(credit_card.get_data())

        if customer:
            data.update(customer.get_data())
        else:
            customer = Customer()
            data.update(customer.get_data())
        
        request_data = self.build_request(data)
        return self.send_transaction(gateway_url, request_data)
예제 #3
0
    def void(self, amount, transaction_id, reference=None):
        """
        Void an existing authorisation
        
        @param amount: The amount to void.
        """
        if self.gateway_url == config.EWAY_PAYMENT_LIVE_REAL_TIME or self.gateway_url == config.EWAY_PAYMENT_LIVE_REAL_TIME_CVN:
            gateway_url = config.EWAY_PAYMENT_LIVE_AUTH_VOID
        elif self.gateway_url == config.EWAY_PAYMENT_LIVE_REAL_TIME_TESTING_MODE or self.gateway_url == config.EWAY_PAYMENT_LIVE_REAL_TIME_CVN_TESTING_MODE:
            gateway_url = config.EWAY_PAYMENT_LIVE_AUTH_VOID_TESTING_MODE
        else:
            raise EwayPaymentError('Could not determine complete method: %s', (method))
        
        if not reference:
            reference = self.get_reference('')
            
        payment = Payment(total_amount=amount,
                          transaction_number=reference)
        
        data = payment.get_data()
        data['ewayAuthTrxnNumber'] = transaction_id
        data['ewayCardExpiryMonth'] = ''
        data['ewayCardExpiryYear'] = ''

        request_data = self.build_request(data)
        return self.send_transaction(gateway_url, request_data)
예제 #4
0
    def void(self, amount, transaction_id, reference=None):
        """
        Void an existing authorisation
        
        @param amount: The amount to void.
        """
        if self.gateway_url == config.EWAY_PAYMENT_LIVE_REAL_TIME or self.gateway_url == config.EWAY_PAYMENT_LIVE_REAL_TIME_CVN:
            gateway_url = config.EWAY_PAYMENT_LIVE_AUTH_VOID
        elif self.gateway_url == config.EWAY_PAYMENT_LIVE_REAL_TIME_TESTING_MODE or self.gateway_url == config.EWAY_PAYMENT_LIVE_REAL_TIME_CVN_TESTING_MODE:
            gateway_url = config.EWAY_PAYMENT_LIVE_AUTH_VOID_TESTING_MODE
        else:
            raise EwayPaymentError('Could not determine complete method: %s', (method))
        
        if not reference:
            reference = self.get_reference('')
            
        payment = Payment(total_amount=amount,
                          transaction_number=reference)
        
        data = payment.get_data()
        data['ewayAuthTrxnNumber'] = transaction_id
        data['ewayCardExpiryMonth'] = ''
        data['ewayCardExpiryYear'] = ''

        request_data = self.build_request(data)
        return self.send_transaction(gateway_url, request_data)