예제 #1
0
def activate_pay_card(account_id,  card_id, pin):

    now = datetime.datetime.now()
    
    return_value = "CARD_NOT_FOUND"
    account = Account.objects.get(id=account_id)
    if pin and card_id and account_id:
        return_value = ''
        if settings.HOTSPOT_ONLY_PIN:
            card = Card.objects.filter(pin=pin,  disabled=False)
        else:
            card = Card.objects.filter(type=0, id=card_id, pin=pin,  disabled=False)
        if card:
            card = card[0]            
            if not card.salecard: 
                return_value = "CARD_NOT_SOLD"                
            elif card.activated: 
                return_value = "CARD_ALREADY_ACTIVATED"                
            elif card.start_date>now or card.end_date<now: 
                return_value =  "CARD_EXPIRED"
            if not return_value:           
    
                transaction = Transaction()
                  
                transaction.bill = _(u'Активация карты оплаты')
                transaction.account=account
                transaction.type = TransactionType.objects.get(internal_name='PAY_CARD')
                
                transaction.approved = True
                transaction.summ=card.nominal
                transaction.created=now
                transaction.save()            
                
                card.activated=now
                card.activated_by=account
                card.save()
                return_value = "CARD_ACTIVATED"
        else:
             return_value =  "CARD_NOT_FOUND"
            
              
    return return_value
예제 #2
0
파일: cardlib.py 프로젝트: brat002/ebscab
def activate_pay_card(account_id,  card_id, pin):

    now = datetime.datetime.now()
    
    return_value = "CARD_NOT_FOUND"
    account = Account.objects.get(id=account_id)
    if pin and (settings.HOTSPOT_ONLY_PIN or card_id) and account_id:
        return_value = ''
        if settings.HOTSPOT_ONLY_PIN:
            card = Card.objects.filter(pin=pin,  disabled=False)
        else:
            card = Card.objects.filter(type=0, id=card_id, pin=pin,  disabled=False)
        if card:
            card = card[0]            
            if not card.salecard and not settings.HOTSPOT_ONLY_PIN:
                return_value = "CARD_NOT_SOLD"                
            elif card.activated: 
                return_value = "CARD_ALREADY_ACTIVATED"                
            elif card.start_date>now or card.end_date<now: 
                return_value =  "CARD_EXPIRED"
            if not return_value:           
    
                transaction = Transaction()
                  
                transaction.bill = _(u'Активация карты оплаты')
                transaction.account=account
                transaction.type = TransactionType.objects.get(internal_name='PAY_CARD')
                
                transaction.approved = True
                transaction.summ=card.nominal
                transaction.created=now
                transaction.save()            
                
                card.activated=now
                card.activated_by=account
                card.save()
                return_value = "CARD_ACTIVATED"
        else:
             return_value =  "CARD_NOT_FOUND"
            
              
    return return_value
예제 #3
0
            payment_date = datetime.datetime(
                *time.strptime(date, "%Y%m%d%H%M%S")[0:5])
        except Exception, e:
            print e
            import traceback
            response = u"""<?xml version="1.0" encoding="utf-8"?>
            <response>
            <osmp_txn_id>%s</osmp_txn_id>
            <result>300</result>
            <comment>Ошибка передачи параметров. смотри дату.</comment>
            </response>
            """ % reciept
            return HttpResponse(response)

        try:
            model = Transaction()
            model.summ = amount
            model.account = account
            model.approved = True
            model.created = payment_date
            model.promise = False
            model.bill = reciept
            model.description = u"Автоматический платёж через систему OSMP пользовательские провайдеры %s" % reciept

            model.type_id = 'OSMP_CUSTOM_BILL'
            model.save()
            response = u"""<?xml version="1.0" encoding="utf-8"?>
            <response>
            <osmp_txn_id>%s</osmp_txn_id>
            <prv_txn>%s</prv_txn>
            <result>0</result>
예제 #4
0
파일: views.py 프로젝트: brat002/ebscab
            return HttpResponse(response)
        try:
            payment_date = datetime.datetime(*time.strptime(date, "%Y-%m-%dT%H:%M:%S")[0:5])
        except Exception, e:
            print e
            import traceback
            response=u"""<?xml version="1.0" encoding="utf-8"?>
            <response>
            <code>1</code>
            <message>Ошибка передачи параметров. смотри дату.</message>
            </response>
            """
            return HttpResponse(response)
        
        try:    
            model=Transaction()
            model.summ=amount
            model.account=account
            model.approved=True
            #model.bill=u'kPay'
            model.created=payment_date
            model.promise=False
            model.bill=reciept
            model.description=u"Автоматический платёж через систему QuickPay %s" % reciept

            model.type_id='QUICKPAY_BILL'
            model.save()
            response=u"""<?xml version="1.0" encoding="utf-8"?>
            <response>
            <code>0</code>
            <message>Оплата успешно произведена.</message>
예제 #5
0
파일: views.py 프로젝트: brat002/ebscab
        return HttpResponse(response)
    
    if action=='pay':
        if not date:
            response = response_check % (txn_id, 300, u"Дата не указана")        
            return HttpResponse(response)        
        try:
            payment_date = datetime.datetime(*time.strptime(date, "%Y%m%d%H%M%S")[0:5])
        except Exception, e:
            #print e
            #import traceback
            response = response_check % (txn_id, 300, u"Неверный формат даты")        
            return HttpResponse(response)
        
        try:    
            model=Transaction()
            model.summ=amount*(-1)
            model.account=account
            model.approved=True
            #model.bill=u'kPay'
            model.created=payment_date
            model.promise=False
            model.bill=reciept
            #model.description=u"Автоматический платёж через систему  %s" % reciept

            model.type_id='RAPIDA_PAYMENT'
            model.save()
            response = response_pay % (txn_id, model.id, 0, u"Оплата произведена успешно.")
            return HttpResponse(response)
        except Exception, e:
            #print e
예제 #6
0
            return HttpResponse(BODY % (response, genSign(response)))

        try:
            payment_date = datetime.datetime(
                *time.strptime(pay_date, "%Y-%m-%dT%H:%M:%S")[0:5])
        except Exception, e:
            response = CHECK_BODY_ERROR % (
                {
                    "ERR_CODE": 11,
                    "ERR_TEXT": u"Неверный формат даты %s" % e,
                })

            return HttpResponse(BODY % (response, genSign(response)))

        try:
            model = Transaction()
            model.summ = amount
            model.account = account
            model.approved = True
            #model.bill=u'kPay'
            model.created = payment_date
            model.promise = False
            model.bill = reciept
            model.type_id = 'SBERBANK_BILL'
            model.save()
            response = PAYMENT_BODY % (
                {
                    "REG_ID": model.id,
                    "REG_DATE": model.created.strftime("%Y-%m-%dT%H:%M:%S"),
                    "ERR_CODE": 0,
                    "ERR_TEXT": ERRCODES.get("0"),
예제 #7
0
파일: views.py 프로젝트: brat002/ebscab
 
 if action==PAYMENT:
     if not (pay_date and reciept):
         response = CHECK_BODY_ERROR % ({"ERR_CODE": 11, "ERR_TEXT": ERRCODES.get("11"),})
 
         return HttpResponse(BODY % (response, genSign(response)) )
 
     try:
         payment_date = datetime.datetime(*time.strptime(pay_date, "%Y-%m-%dT%H:%M:%S")[0:5])
     except Exception, e:
         response = CHECK_BODY_ERROR % ({"ERR_CODE": 11, "ERR_TEXT": u"Неверный формат даты %s" % e,})
 
         return HttpResponse(BODY % (response, genSign(response)) )
     
     try:    
         model=Transaction()
         model.summ=amount
         model.account=account
         model.approved=True
         #model.bill=u'kPay'
         model.created=payment_date
         model.promise=False
         model.bill=reciept
         model.type_id='SBERBANK_BILL'
         model.save()
         response = PAYMENT_BODY % ({"REG_ID": model.id, "REG_DATE": model.created.strftime("%Y-%m-%dT%H:%M:%S"), "ERR_CODE": 0, "ERR_TEXT": ERRCODES.get("0"), "ACCOUNT": account.username, })
         return HttpResponse(BODY % (response, genSign(response)) )
     except Exception, e:
         print e
         import traceback
         traceback.print_exc()
예제 #8
0
def activate_card(login, pin):
    status_ok = 1
    status_bad_userpassword = 2
    status_card_was_activated =3
    status_bad_card = 4
    now = datetime.datetime.now()
    cur=connection.cursor()
    if login and pin:

        return_status = 0
        
        card = Card.objects.filter(type=2, login=login, pin=pin, salecard__isnull=False, disabled=False)
        if not card: 
            return  status_bad_userpassword      
        if len(card)>1:
            return  status_bad_card
        card=card[0]
        if card.activated or card.start_date>now or card.end_date<now: 
            return  status_card_was_activated
  

        account = Account()
        account.username = login
        account.password = pin
        account.status = 1
        account.created = now
        account.allow_webcab = True
        account.allow_expresscards = True
        account.save()
        
        subaccount = SubAccount()
        subaccount.account = account
        subaccount.username = login
        subaccount.password = pin
        subaccount.ipv4_vpn_pool = card.ippool
        subaccount.nas = card.nas
        subaccount.save()

        ac = AccountTarif()
        ac.account=account
        ac.tarif = card.tarif
        ac.datetime = now
        ac.save()

        transaction = Transaction()
          
        transaction.bill = _(u'Активация карты доступа')
        transaction.account=account
        transaction.accounttarif=ac
        transaction.type =  TransactionType.objects.get(internal_name= 'ACCESS_CARD')
        
        transaction.approved = True
        transaction.tarif=card.tarif
        transaction.summ=card.nominal
        transaction.created=now
        transaction.save()

        card.activated = now
        card.activated_by = account
        card.save()
        return status_ok
                
    return
예제 #9
0
파일: views.py 프로젝트: brat002/ebscab
        try:
            payment_date = datetime.datetime(*time.strptime(date, "%Y%m%d%H%M%S")[0:5])
        except Exception, e:
            print e
            import traceback
            response=u"""<?xml version="1.0" encoding="utf-8"?>
            <response>
            <osmp_txn_id>%s</osmp_txn_id>
            <result>300</result>
            <comment>Ошибка передачи параметров. смотри дату.</comment>
            </response>
            """ % reciept
            return HttpResponse(response)
        
        try:    
            model=Transaction()
            model.summ=amount
            model.account=account
            model.approved=True
            model.created=payment_date
            model.promise=False
            model.bill=reciept
            model.description=u"Автоматический платёж через систему OSMP пользовательские провайдеры %s" % reciept

            model.type_id='OSMP_CUSTOM_BILL'
            model.save()
            response=u"""<?xml version="1.0" encoding="utf-8"?>
            <response>
            <osmp_txn_id>%s</osmp_txn_id>
            <prv_txn>%s</prv_txn>
            <result>0</result>
예제 #10
0
        try:
            payment_date = datetime.datetime(
                *time.strptime(date, "%Y-%m-%dT%H:%M:%S")[0:5])
        except Exception, e:
            print e
            import traceback
            response = u"""<?xml version="1.0" encoding="utf-8"?>
            <response>
            <code>1</code>
            <message>Ошибка передачи параметров. смотри дату.</message>
            </response>
            """
            return HttpResponse(response)

        try:
            model = Transaction()
            model.summ = amount
            model.account = account
            model.approved = True
            #model.bill=u'kPay'
            model.created = payment_date
            model.promise = False
            model.bill = reciept
            model.description = u"Автоматический платёж через систему QuickPay %s" % reciept

            model.type_id = 'QUICKPAY_BILL'
            model.save()
            response = u"""<?xml version="1.0" encoding="utf-8"?>
            <response>
            <code>0</code>
            <message>Оплата успешно произведена.</message>
예제 #11
0
    if action == 'pay':
        if not date:
            response = response_check % (txn_id, 300, u"Дата не указана")
            return HttpResponse(response)
        try:
            payment_date = datetime.datetime(
                *time.strptime(date, "%Y%m%d%H%M%S")[0:5])
        except Exception, e:
            #print e
            #import traceback
            response = response_check % (txn_id, 300, u"Неверный формат даты")
            return HttpResponse(response)

        try:
            model = Transaction()
            model.summ = amount * (-1)
            model.account = account
            model.approved = True
            #model.bill=u'kPay'
            model.created = payment_date
            model.promise = False
            model.bill = reciept
            #model.description=u"Автоматический платёж через систему  %s" % reciept

            model.type_id = 'RAPIDA_PAYMENT'
            model.save()
            response = response_pay % (txn_id, model.id, 0,
                                       u"Оплата произведена успешно.")
            return HttpResponse(response)
        except Exception, e:
예제 #12
0
파일: cardlib.py 프로젝트: brat002/ebscab
def activate_card(login, pin):
    status_ok = 1
    status_bad_userpassword = 2
    status_card_was_activated =3
    status_bad_card = 4
    now = datetime.datetime.now()
    cur=connection.cursor()
    if login and pin:

        return_status = 0
        
        card = Card.objects.filter(type=2, login=login, pin=pin, salecard__isnull=False, disabled=False)
        if not card: 
            return  status_bad_userpassword      
        if len(card)>1:
            return  status_bad_card
        card=card[0]
        if card.activated or card.start_date>now or card.end_date<now: 
            return  status_card_was_activated
  

        account = Account()
        account.username = login
        account.password = pin
        account.status = 1
        account.created = now
        account.allow_webcab = True
        account.allow_expresscards = True
        account.save()
        
        subaccount = SubAccount()
        subaccount.account = account
        subaccount.username = login
        subaccount.password = pin
        subaccount.ipv4_vpn_pool = card.ippool
        subaccount.nas = card.nas
        subaccount.save()

        ac = AccountTarif()
        ac.account=account
        ac.tarif = card.tarif
        ac.datetime = now
        ac.save()

        transaction = Transaction()
          
        transaction.bill = _(u'Активация карты доступа')
        transaction.account=account
        transaction.accounttarif=ac
        transaction.type =  TransactionType.objects.get(internal_name= 'ACCESS_CARD')
        
        transaction.approved = True
        transaction.tarif=card.tarif
        transaction.summ=card.nominal
        transaction.created=now
        transaction.save()

        card.activated = now
        card.activated_by = account
        card.save()
        return status_ok
                
    return
예제 #13
0
def index(request):
    message=''
    if request.method == 'POST':
        form = PayForm(request.POST)
        if form.is_valid():
            username=form.cleaned_data['username']
            password=form.cleaned_data['password']
            summ=form.cleaned_data['summ']
            account_username=form.cleaned_data['account_username']
            description=form.cleaned_data['description']
            promise=form.cleaned_data['promise']
            try:
                user=SystemUser.objects.get(username=username, text_password=password)
            except:
                return {'form':form,'message':u'Пользователя с таким логином и паролем не существует',}

            try:
                account=Account.objects.get(username=account_username)
            except:
                return {'form':form,'message':u'Пользователя с таким логином и паролем не существует',}
            
            t=Transaction()
            t.account=account
            t.type=TransactionType.objects.get(internal_name='MANUAL_TRANSACTION')
            t.approved=True
            t.summ=-1*summ
            t.description=description
            t.created=datetime.datetime.now()
            t.promise=promise
            t.systemuser=user
            t.save()
            account=Account.objects.get(username=account_username)
            
            message=u'Платёж успешно выполнен. Новый баланс пользователя %s' % account.ballance
            
    else:
        form = PayForm()
        
    return {'form':form,'message':message}