예제 #1
0
파일: fields.py 프로젝트: Python3pkg/PayLib
    def set_handling_amount(self, amount):
        """Total handling costs for this order."""

        validator = util.Validator()
        validator.is_new_valid_amount(amount)

        self._set_fieldamount('PAYMENTREQUEST_%d_HANDLINGAMT', amount)
예제 #2
0
파일: fields.py 프로젝트: Python3pkg/PayLib
    def set_amount(self, amount):
        """Cost of item. This field is required when 
        L_PAYMENTREQUEST_n_ITEMCATEGORYm is passed.You can specify 
        up to 10 payments, where n is a digit between 0 and 9, 
        inclusive, and m specifies the list item within the payment 
        except for digital goods, which supports single payments only. 
        These parameters must be ordered sequentially beginning with 0 
        (for example L_PAYMENTREQUEST_n_AMT0, L_PAYMENTREQUEST_n_AMT1).
        
        NOTE:If you specify a value for L_PAYMENTREQUEST_n_AMTm , 
        you must specify a value for PAYMENTREQUEST_n_ITEMAMT.
        
        Character length and limitations: Value is a positive number 
        which cannot exceed $10,000 USD in any currency. It includes 
        no currency symbol. It must have 2 decimal places, the decimal 
        separator must be a period (.), and the optional thousands 
        separator must be a comma (,)."""

        v = util.Validator()
        if not v.is_valid_amount(amount):
            sb = io.StringIO()
            sb.write('Amount {0} is not valid. '.format(amount))
            sb.write('Amount has to have exactly two decimal ')
            sb.write('places seaprated by \".\" ')
            sb.write('- example: \"50.00\"')
            raise ValueError(sb.getvalue())

        self._nvp_request['L_PAYMENTREQUEST_%d_AMT%d'] = amount
예제 #3
0
파일: fields.py 프로젝트: Python3pkg/PayLib
 def set_email(self, email):
     v = util.Validator()
     if not v.is_valid_email(email):
         raise ValueError('Email is not valid')
     if email is None or len(email) > 127:
         raise ValueError('Email can be maximum 127 characters long')
     self._nvp_request['EMAIL'] = email
예제 #4
0
파일: fields.py 프로젝트: Python3pkg/PayLib
 def set_initial_amount(self, amount):
     v = util.Validator()
     if not v.is_valid_amount(amount):
         raise ValueError(
             'Amount has to have exactly two decimal places separated by \'.\' - example: \'50.00\''
         )
     self._nvp_request['INITAMT'] = amount
예제 #5
0
    def set_payflow_color(self, hex_color):
        """Sets the background color for the payment page.
        By default, the color is white.

        Character length and limitation: 

            Six character HTML hexadecimal color code in ASCII."""
        vldtor = util.Validator()
        if not vldtor.is_valid_hexcolor(hex_color):
            raise ValueError('Hex color {0} is not valid.'.format(hex_color))

        self._nvp_request['PAYFLOWCOLOR'] = hex_color
예제 #6
0
    def set_border_color(self, hex_color):
        """Sets the border color around the header of the payment page.
        The border is a 2-pixel perimeter around the header space, which is 
        750 pixels wide by 90 pixels high. By default, the color is black.

        Character length and limitation: Six character HTML hexadecimal 
        color code in ASCII."""

        vldtor = util.Validator()
        if not vldtor.is_valid_hexcolor(hex_color):
            raise ValueError('Hex color {0} is not valid.'.format(hex_color))

        self._nvp_request['HDRBORDERCOLOR'] = hex_color
예제 #7
0
파일: fields.py 프로젝트: Python3pkg/PayLib
    def _set_fieldamount(self, field, amount):
        v = util.Validator()
        if not v.is_new_valid_amount(amount):
            sb = io.StringIO()
            sb.write('Amount {0} is not valid. '.format(amount))
            sb.write('Amount has to have exactly two decimal ')
            sb.write('places seaprated by \".\" ')
            sb.write('- example: \"50.00\"')
            raise ValueError(sb.getvalue())
        del (v)

        ff = util.FormatFields()
        amount = ff.get_new_amount_field(amount)
        self._nvp_request[field] = amount
예제 #8
0
파일: fields.py 프로젝트: Python3pkg/PayLib
    def set_tax_amount(self, amount):
        """(Optional) Item sales tax. You can specify up to 10 payments, 
        where n is a digit between 0 and 9, inclusive, and m specifies 
        the list item within the payment except for digital goods, 
        which only supports single payments. These parameters must be 
        ordered sequentially beginning with 0 
        (for example L_PAYMENTREQUEST_n_TAXAMT0, L_PAYMENTREQUEST_n_TAXAMT1)."""
        v = util.Validator()
        if not v.is_valid_amount(amount):
            sb = io.StringIO()
            sb.write('Amount {0} is not valid. '.format(amount))
            sb.write('Amount has to have exactly two decimal ')
            sb.write('places seaprated by \".\" ')
            sb.write('- example: \"50.00\"')
            raise ValueError(sb.getvalue())

        self._nvp_request['L_PAYMENTREQUEST_%d_TAXAMT%d'] = amount
예제 #9
0
파일: fields.py 프로젝트: Python3pkg/PayLib
    def __init__(self, period, frequency, amount, currency):

        billing_frequency = str(frequency)

        if frequency < 0:
            raise ValueError('Billing frequency cannot be 0')

        if period == 'Year' and frequency > 365:
            raise ValueError(
                'The combination of billing frequency (%s) and billing period (%s) must be less than or equal to one year.'
                % (billing_frequency, period))
        elif period == 'Month' and frequency > 12:
            raise ValueError(
                'The combination of billing frequency (%s) and billing period (%s) must be less than or equal to one year.'
                % (billing_frequency, period))
        elif period == 'Week' and frequency > 52:
            raise ValueError(
                'The combination of billing frequency (%s) and billing period (%s) must be less than or equal to one year.'
                % (billing_frequency, period))
        elif period == 'Day' and frequency > 1:
            raise ValueError(
                'The combination of billing frequency (%s) and billing period (%s) must be less than or equal to one year.'
                % (billing_frequency, period))
        elif period == 'SemiMonth' and frequency is not 1:
            raise ValueError(
                'When billing period is set to Semi month, then billing frequency has to be 1: (%s, %s)'
                % (billing_frequency, str(period)))

        v = util.Validator()
        if not v.is_valid_amount(amount):
            raise ValueError(
                'Amount has to have exactly two decimal places separated by \'.\' - example: \'50.00\''
            )

        if currency not in static.currency_set:
            raise ValueError('Invalid currency')

        self._nvp_request = dict()

        self._nvp_request['BILLINGPERIOD'] = period
        self._nvp_request['BILLINGFREQUENCY'] = frequency
        self._nvp_request['AMT'] = amount
        self._nvp_request['CURRENCYCODE'] = currency
예제 #10
0
파일: fields.py 프로젝트: Python3pkg/PayLib
    def set_shipping_amount(self, amount):
        """The shipping amount that was chosen by the buyer 
        Limitations:

            - Must not exceed $10,000 USD in any currency.
            - No currency symbol. 
            - Must have two decimal places, decimal separator must be a period (.)."""
        v = util.Validator()
        if not v.is_valid_amount(amount):
            sb = io.StringIO()
            sb.write('Amount {0} is not valid. '.format(amount))
            sb.write('Amount has to have exactly two decimal ')
            sb.write('places seaprated by \".\" ')
            sb.write('- example: \"50.00\"')
            raise ValueError(sb.getvalue())
        del (v)

        ff = util.FormatFields()
        amount = ff.get_amount_field(amount)
        self._nvp_request['SHIPPINGOPTIONAMOUNT'] = amount
예제 #11
0
파일: fields.py 프로젝트: Python3pkg/PayLib
    def set_shipping_amount(self, amount):
        """Required if specifying the Callback URL. 
        The amount of the flat rate shipping option. 

        Limitations: 

            - Must not exceed $10,000 USD in any currency.
            - No currency symbol.
            - Must have two decimal places, decimal separator must be a period (.)."""

        v = util.Validator()
        if not v.is_valid_amount(amount):
            sb = io.StringIO()
            sb.write('Amount {0} is not valid. '.format(amount))
            sb.write('Amount has to have exactly two decimal ')
            sb.write('places seaprated by \".\" ')
            sb.write('- example: \"50.00\"')
            raise ValueError(sb.getvalue())

        self._nvp_request['L_SHIPPINGOPTIONAMOUNT'] = amount
예제 #12
0
    def set_max_amount(self, max_amount):
        """
        The expected maximum total amount of the complete 
        order, including shipping cost and tax charges.

        If the transaction does not include a one-time purchase, this field is ignored.

        Limitations: 
    
            - Must not exceed $10,000 USD in any currency.
            - No currency symbol. 
            - Must have two decimal places, decimal separator must be a period (.), 
              and no thousands separator."""
        vldtor = util.Validator()
        if not vldtor.is_valid_amount(max_amount):
            sb = io.StringIO()
            sb.write('Amount {0} is not valid. '.format(max_amount))
            sb.write('Amount has to have exactly two decimal ')
            sb.write('places seaprated by \".\" ')
            sb.write('- example: \"50.00\"')
            raise ValueError(sb.getvalue())
        del (vldtor)

        self._nvp_request['MAXAMT'] = max_amount