示例#1
0
文件: tipi.py 项目: tonioo/eopayment
    def response(self, query_string, **kwargs):
        fields = parse_qs(query_string, True)
        if not set(fields) >= set(['refdet', 'resultrans']):
            raise ResponseError()
        for key, value in fields.iteritems():
            fields[key] = value[0]
        refdet = fields.get('refdet')
        if refdet is None:
            raise ValueError('refdet is missing')
        if 'objet' in fields:
            iso_now = fields['objet']
        else:
            iso_now = isonow()
        transaction_id = '%s_%s' % (iso_now, refdet)

        result = fields.get('resultrans')
        if result == 'P':
            result = PAID
            bank_status = ''
        elif result == 'R':
            result = DENIED
            bank_status = 'refused'
        elif result == 'A':
            result = CANCELLED
            bank_status = 'canceled'
        else:
            bank_status = 'wrong return: %r' % result
            result = ERROR

        test = fields.get('saisie') == 'T'

        return PaymentResponse(
                result=result,
                bank_status=bank_status,
                signed=True,
                bank_data=fields,
                transaction_id=transaction_id,
                test=test)
示例#2
0
    def response(self, query_string, **kwargs):
        fields = parse_qs(query_string, True)
        if not set(fields) >= set(['refdet', 'resultrans']):
            raise ResponseError()
        for key, value in fields.iteritems():
            fields[key] = value[0]
        refdet = fields.get('refdet')
        if refdet is None:
            raise ValueError('refdet is missing')
        if 'objet' in fields:
            iso_now = fields['objet']
        else:
            iso_now = isonow()
        transaction_id = '%s_%s' % (iso_now, refdet)

        result = fields.get('resultrans')
        if result == 'P':
            result = PAID
            bank_status = ''
        elif result == 'R':
            result = DENIED
            bank_status = 'refused'
        elif result == 'A':
            result = CANCELLED
            bank_status = 'canceled'
        else:
            bank_status = 'wrong return: %r' % result
            result = ERROR

        test = fields.get('saisie') == 'T'

        return PaymentResponse(
                result=result,
                bank_status=bank_status,
                signed=True,
                bank_data=fields,
                transaction_id=transaction_id,
                test=test)
示例#3
0
                raise ValueError('OBJET length must be less than 100')
        try:
            mel = str(email)
            if '@' not in mel:
                raise ValueError('no @ in MEL')
            if not (6 <= len(mel) <= 80):
                raise ValueError('len(MEL) is invalid, must be between 6 and 80')
        except Exception, e:
            raise ValueError('MEL is not a valid email, %r' % mel, e)

        saisie = saisie or self.saisie

        if saisie not in ('M', 'T', 'X', 'A'):
            raise ValueError('SAISIE invalid format, %r, must be M, T, X or A' % saisie)

        iso_now = isonow()
        transaction_id = '%s%s' % (iso_now, refdet)
        if objet:
            #objet = objet[:100-len(iso_now)-2] + ' ' + iso_now
             objet = objet[:100-len(transaction_id)-2] + ' ' + transaction_id
        else:
            #objet = iso_now
            objet = transaction_id
        params = {
                'numcli': self.numcli,
                'refdet': refdet,
                'montant': montant,
                'mel': mel,
                'saisie': saisie,
                'objet': objet,
                'urlcl': urlcl,
示例#4
0
文件: tipi.py 项目: tonioo/eopayment
                raise ValueError('OBJET length must be less than 100')
        try:
            mel = str(email)
            if '@' not in mel:
                raise ValueError('no @ in MEL')
            if not (6 <= len(mel) <= 80):
                raise ValueError('len(MEL) is invalid, must be between 6 and 80')
        except Exception, e:
            raise ValueError('MEL is not a valid email, %r' % mel, e)

        saisie = saisie or self.saisie

        if saisie not in ('M', 'T', 'X', 'A'):
            raise ValueError('SAISIE invalid format, %r, must be M, T, X or A' % saisie)

        iso_now = isonow()
        transaction_id = '%s_%s' % (iso_now, refdet)
        if objet:
            objet = objet[:100-len(iso_now)-2] + ' ' + iso_now
        else:
            objet = iso_now
        params = {
                'numcli': self.numcli,
                'refdet': refdet,
                'montant': montant,
                'mel': mel,
                'saisie': saisie,
                'objet': objet,
        }
        if exer:
            params['exer'] = exer