コード例 #1
0
def test_missing_data_error():
    """Testing MissingDataError"""
    try:
        raise MissingDataError("Your data is incomplete fool!")
    except MissingDataError as error:
        assert_equals("'Your data is incomplete fool!'", str(error))

    raise MissingDataError("Your data is incomplete fool!")
コード例 #2
0
    def capture(self,
                amount,
                credit_card=None,
                billing_info=None,
                shipping_info=None):
        """
        Sends transaction for auth + capture (same day settlement) based on amount.
        """

        super(PlugnPay, self).set(self.REQUEST_FIELDS['trans_type'],
                                  'authpostauth')
        super(PlugnPay, self).set(self.REQUEST_FIELDS['trans_mode'], 'auth')
        super(PlugnPay, self).set(self.REQUEST_FIELDS['amount'], amount)

        # validating or building up request
        if not credit_card:
            debug_string = "paython.gateways.plugnpay.capture()  -- No CreditCard object present. You passed in %s " % (
                credit_card)
            logger.debug(debug_string)

            raise MissingDataError(
                'You did not pass a CreditCard object into the auth method')
        else:
            super(PlugnPay, self).use_credit_card(credit_card)

        if billing_info:
            super(PlugnPay, self).set_billing_info(**billing_info)

        if shipping_info:
            super(PlugnPay, self).set_shipping_info(**shipping_info)

        response, response_time = self.request()
        return self.parse(response, response_time)
コード例 #3
0
    def capture(self, amount, credit_card=None, billing_info=None, shipping_info=None):
        """
        Sends transaction for capture (same day settlement) based on amount.
        """
        #set up transaction
        self.charge_setup() # considering turning this into a decorator?

        #setting transaction data
        super(InnovativeGW, self).set(self.REQUEST_FIELDS['amount'], amount)
        super(InnovativeGW, self).set(self.REQUEST_FIELDS['trans_type'], 'sale')

        # validating or building up request
        if not credit_card:
            if self.debug: 
                debug_string = "paython.gateways.innovative_gw.capture()  -- No CreditCard object present. You passed in %s " % (credit_card)
                print debug_string

            raise MissingDataError('You did not pass a CreditCard object into the auth method')
        else:
            super(InnovativeGW, self).use_credit_card(credit_card)

        if billing_info:
            super(InnovativeGW, self).set_billing_info(**billing_info)

        if shipping_info:
            super(InnovativeGW, self).set_shipping_info(**shipping_info)

        # send transaction to gateway!
        response, response_time = self.request()
        return self.parse(response, response_time)
コード例 #4
0
    def auth(self,
             amount,
             credit_card=None,
             billing_info=None,
             shipping_info=None):
        """
        Sends charge for authorization only based on amount
        """

        super(PlugnPay, self).set(self.REQUEST_FIELDS['trans_type'],
                                  'authonly')
        super(PlugnPay, self).set(self.REQUEST_FIELDS['trans_mode'], 'auth')
        super(PlugnPay, self).set(self.REQUEST_FIELDS['amount'], amount)

        # validating or building up request
        if not credit_card:
            if self.debug:
                debug_string = "paython.gateways.plugnpay.auth()  -- No CreditCard object present. You passed in %s " % (
                    credit_card)
                print debug_string

            raise MissingDataError(
                'You did not pass a CreditCard object into the auth method')
        else:
            super(PlugnPay, self).use_credit_card(credit_card)

        if billing_info:
            super(PlugnPay, self).set_billing_info(**billing_info)

        if shipping_info:
            super(PlugnPay, self).set_shipping_info(**shipping_info)

        response, response_time = self.request()
        return self.parse(response, response_time)
コード例 #5
0
    def auth(self, amount, credit_card=None, billing_info=None, shipping_info=None, is_partial=False, split_id=None):
        """
        Sends charge for authorization based on amount
        """
        #set up transaction
        self.charge_setup() # considering turning this into a decorator?

        #setting transaction data
        super(AuthorizeNet, self).set(self.REQUEST_FIELDS['amount'], amount)
        super(AuthorizeNet, self).set(self.REQUEST_FIELDS['trans_type'], 'AUTH_ONLY')

        # support for partial auths
        if is_partial:
            super(AuthorizeNet, self).set(self.REQUEST_FIELDS['is_partial'], 'true')
            super(AuthorizeNet, self).set(self.REQUEST_FIELDS['split_tender_id'], split_id)

        # validating or building up request
        if not credit_card:
            if self.debug: 
                debug_string = "paython.gateways.authorize_net.auth()  -- No CreditCard object present. You passed in %s " % (credit_card)
                print debug_string

            raise MissingDataError('You did not pass a CreditCard object into the auth method')
        else:
            super(AuthorizeNet, self).use_credit_card(credit_card)

        if billing_info:
            super(AuthorizeNet, self).set_billing_info(**billing_info)

        if shipping_info:
            super(AuthorizeNet, self).set_shipping_info(**shipping_info)

        # send transaction to gateway!
        response, response_time = self.request()
        return self.parse(response, response_time)
コード例 #6
0
    def auth(self,
             amount,
             credit_card=None,
             billing_info=None,
             shipping_info=None):
        """
        Sends charge for authorization based on amount
        """
        #check for cvv
        self.cvv_present = True if credit_card.verification_value else False
        #set up transaction
        self.charge_setup()  # considering turning this into a decorator?

        #setting transaction data
        super(FirstDataLegacy, self).set(self.REQUEST_FIELDS['amount'], amount)
        super(FirstDataLegacy, self).set(self.REQUEST_FIELDS['trans_type'],
                                         'Preauth')
        #special treatment to make peoples lives easier (extracting addrnum from address)
        try:
            matches = re.match('\d+', billing_info['address'])
        except KeyError:
            raise DataValidationError(
                'Unable to find a billing address to extract a number from for gateway'
            )

        if matches:
            super(FirstDataLegacy, self).set(
                'order/billing/addrnum',
                matches.group())  #hardcoded because of uniqueness to gateway
        else:
            raise DataValidationError(
                'Unable to find a number at the start of provided billing address'
            )

        # validating or building up request
        if not credit_card:
            debug_string = "paython.gateways.firstdata_legacy.auth()  -- No CreditCard object present. You passed in %s " % (
                credit_card)
            logger.debug(debug_string)

            raise MissingDataError(
                'You did not pass a CreditCard object into the auth method')
        else:
            credit_card._exp_yr_style = True
            super(FirstDataLegacy, self).use_credit_card(credit_card)

        if billing_info:
            super(FirstDataLegacy, self).set_billing_info(**billing_info)

        if shipping_info:
            super(FirstDataLegacy, self).set_shipping_info(**shipping_info)

        # send transaction to gateway!
        response, response_time = self.request()
        return self.parse(response, response_time)
コード例 #7
0
    def capture(self,
                amount,
                credit_card=None,
                billing_info=None,
                shipping_info=None):
        """
        Sends transaction for capture (same day settlement) based on amount.
        """
        #set up transaction
        self.charge_setup()  # considering turning this into a decorator?

        #setting transaction data
        super(FirstDataLegacy, self).set(self.REQUEST_FIELDS['amount'], amount)
        super(FirstDataLegacy, self).set(self.REQUEST_FIELDS['trans_type'],
                                         'Sale')

        #special treatment to make peoples lives easier (extracting addrnum from address)
        matches = re.match('\d+', billing_info['address'])
        if matches:
            super(FirstDataLegacy, self).set(
                'order/billing/addrnum',
                matches.group())  #hardcoded because of uniqueness to gateway
        else:
            raise DataValidationError(
                'Unable to find a number at the start of provided billing address'
            )

        # validating or building up request
        if not credit_card:
            logger.debug(
                "paython.gateways.firstdata_legacy.capture()  -- No CreditCard object present. You passed in %s "
                % (credit_card))

            raise MissingDataError(
                'You did not pass a CreditCard object into the auth method')
        else:
            credit_card._exp_yr_style = True
            super(FirstDataLegacy, self).use_credit_card(credit_card)

        if billing_info:
            super(FirstDataLegacy, self).set_billing_info(**billing_info)

        if shipping_info:
            super(FirstDataLegacy, self).set_shipping_info(**shipping_info)

        # send transaction to gateway!
        response, response_time = self.request()
        return self.parse(response, response_time)
コード例 #8
0
    def capture(self, token, amount, credit_card=None):

        if not credit_card:
            debug_string = "paython.gateways.payway.capture()  -- No CreditCard object present. You passed in %s "\
                           % (credit_card)
            logger.debug(debug_string)
            raise MissingDataError(
                'You did not pass a CreditCard object into the auth method')

        response = requests.post(self.BASE_URL + '/Payment/CreditCard',
                                 json=self.format_data(token, amount,
                                                       credit_card))
        obj = response.json()

        if int(obj['paywayCode']) != 5000:
            raise PaywayException(int(obj['paywayCode']), obj['paywayMessage'])
        return obj
コード例 #9
0
    def capture(self,
                amount,
                credit_card=None,
                billing_info=None,
                shipping_info=None):
        """
        Sends transaction for capture (same day settlement) based on amount.
        """
        #set up transaction
        self.charge_setup()

        #setting transaction data
        self.set(self.REQUEST_FIELDS['amount'], amount)
        self.set(self.REQUEST_FIELDS['trans_type'], 'cc:sale')

        # validating or building up request
        if not credit_card:
            debug_string = self._get_debug_str_base(
            ) + 'capture()  -- No CreditCard object present. You passed in ' + str(
                credit_card)
            logger.debug(debug_string)

            raise MissingDataError(
                'You did not pass a CreditCard object into the auth method')
        else:
            self.use_credit_card(credit_card)

        if billing_info:
            self.set_billing_info(**billing_info)

        if shipping_info:
            self.set_shipping_info(**shipping_info)

        # send transaction to gateway
        response, response_time = self.request()
        return self.parse(response, response_time)