示例#1
0
def liqpay_transfer_withdraw_submit(Req):
    Form = LiqPayTransferForm(Req.POST, user=Req.user)
    Dict = {}
    if Form.is_valid():
        # Save 
        Key = generate_key("liqpay_withdraw")
        transfer = LiqPayTrans(
            debit_credit="out",
            phone=Form.cleaned_data["phone"],
            description=Form.cleaned_data["description"],
            currency=Form.currency_instance,
            amnt=Form.cleaned_data["amnt"],
            user=Req.user,
            pub_date=datetime.datetime.now(),
            comission="0.000",
            confirm_key=Key
        )
        transfer.save()
        #if settings.DEBUG is False:
        send_mail(_(u'Подтверждение вывода  ') + settings.BASE_HOST,
                  confirm_liqpay_withdraw_email(Form.cleaned_data, Key),
                  [Req.user.email],
                  fail_silently=False)
        return redirect("/finance/confirm_withdraw_msg")
    else:
        t = loader.get_template("simple_form.html")
        Dict["title"] = settings.withdraw_title_liqpay
        Dict["form"] = Form.as_p()
        Dict["common_help_text"] = settings.attention_be_aware
        Dict["action"] = "/finance/liqpay_transfer_withdraw_submit"
        Dict["action_title"] = settings.withdraw_transfer
        return tmpl_context(Req, t, Dict)
示例#2
0
文件: finance.py 项目: kostyll/stock2
def liqpay_transfer_withdraw_submit(Req):
    Form = LiqPayTransferForm(Req.POST, user=Req.user)
    Dict = {}
    if Form.is_valid():
        # Save 
        Key = generate_key("liqpay_withdraw")
        transfer = LiqPayTrans(
            debit_credit="out",
            phone=Form.cleaned_data["phone"],
            description=Form.cleaned_data["description"],
            currency=Form.currency_instance,
            amnt=Form.cleaned_data["amnt"],
            user=Req.user,
            pub_date=datetime.datetime.now(),
            comission="0.000",
            confirm_key=Key
        )
        transfer.save()
        #if settings.DEBUG is False:
        send_mail(_(u'Подтверждение вывода  ') + settings.BASE_HOST,
                  confirm_liqpay_withdraw_email(Form.cleaned_data, Key),
                  settings.EMAIL_HOST_USER,
                  [Req.user.email],
                  fail_silently=False)
        return redirect("/finance/confirm_withdraw_msg")
    else:
        t = loader.get_template("simple_form.html")
        Dict["title"] = settings.withdraw_title_liqpay
        Dict["form"] = Form.as_p()
        Dict["common_help_text"] = settings.attention_be_aware
        Dict["action"] = "/finance/liqpay_transfer_withdraw_submit"
        Dict["action_title"] = settings.withdraw_transfer
        return tmpl_context(Req, t, Dict)
示例#3
0
文件: liqpay.py 项目: kostyll/stock2
    def api_callback_pay(self, Params):
           PublicKey = Params["public_key"] 
           Amount =  Params["amount"] 
           CurrencyStr = Params["currency"] 
           Desc = Params["description"]
           Type = Params["type"]
           OrderId = Params["order_id"]
           Status = Params["status"]
           OutOrderId = Params["transaction_id"]
           Phone = Params["sender_phone"]
           Signature = Params["signature"]
           Comission = Decimal(Params["receiver_commission"])
           m = hashlib.sha1(self.__private_key + 
                         Amount +
                         CurrencyStr  +
                         self.__public_key +
                         OrderId +
                         self.__type +
                         self.__description +
                         Status +
                         OutOrderId +
                         Phone
                         )
           
           signature = b64encode( m.digest() )       
           if signature != Signature: 
                    raise TransError("Invalid Signature")
             
           if Status == "failure":
                     order = Orders.objects.get( id = int(OrderId) )
                     order.status = "order_cancel"
                     order.save()
                     Response =  HttpResponse( json.JSONEncoder().encode({"status":True,"signature":True}) )
                     Response['Content-Type'] = 'application/json'
                     return Response
             
           if Status == "wait_secure":
                     order = Orders.objects.get( id = int(OrderId), status="created" )
                     order.status = "wait_secure"
                     order.save()
                     Response =  HttpResponse( json.JSONEncoder().encode({"status":True,"signature":True}) )
                     Response['Content-Type'] = 'application/json'
                     return Response
           ##TODO add system message  
           if Status == "success":
                     order = Orders.objects.get(id = int(OrderId) )
                     if order.status !="created" and order.status !="wait_secure":
                             raise TransError("Invalid order")
                     order.status="processing"
                     order.save()
                     from main.models import check_holds
                     check_holds(order)
                     DebCred =   LiqPayTrans(   phone = Phone,
                                                description = Desc,
                                                  #pib = ,
                                                currency = self.__currency,
                                                amnt = Decimal(Amount) ,
                                                user = order.user,
                                                pub_date = datetime.now(),
                                                comission = self.__comis,
                                                user_accomplished_id =  1,
                                                status = "processed",
                                                debit_credit = "in",
                                                confirm_key = Signature,
                                                order = order
                                            )
                     DebCred.sign_record(self.__private_key)
                     DebCred.save()
                     add_trans(order.transit_1 , order.sum1, self.__currency,
                               order.transit_2, order,
                               "payin", DebCred.id, False)
                     
                     #hack if privat is wrong  
                     HackComis = order.sum1 * self.__comis
                     if Comission < HackComis:
                         Comission = HackComis

                     add_trans( order.transit_2 , Comission, self.__currency,
                                order.transit_1,  order, 
                                "comission", OutOrderId, False)


                     order.status = "processed"
                     order.save()
                     notify_email(order.user, "deposit_notify", DebCred ) 
                     Response =  HttpResponse( json.JSONEncoder().encode({"status":True,"signature":True}) )
                     Response['Content-Type'] = 'application/json'
                     return Response

           if Status == "sandbox":
                     raise TransError("hacker ")
                     order = Orders.objects.get(id = int(OrderId), status = "created")
                     order.status="processing"
                     order.save()
                     check_holds(order)

                     add_trans(order.transit_1, order.sum1, self.__currency,
                               order.transit_2, order, "payin", OutOrderId, False )
                     
                     
                     #Comission = order.sum1 * self.__comis
                     add_trans( order.transit_2, Comission , self.__currency,
                                order.transit_1,  order, 
                                "comission", OutOrderId, False)
                     DebCred =   LiqPayTrans(
                                                  phone = Phone,
                                                  description = Desc, 
                                                  currency = self.__currency, 
                                                  amnt = Decimal(Amount) , 
                                                  user = order.user ,
						                          pub_date = datetime.now(),
                                                  comission = self.__comis,
                                                  user_accomplished_id =  1,
                                                  status = "processed",
                                                  debit_credit = "in",
                                                  confirm_key = Signature,
                                                  order = order
                                                  
                                            )
                     DebCred.save()
                     order.status = "processed"
                     order.save()
                     Response =  HttpResponse( json.JSONEncoder().encode({"status":True,"signature":True}) )
                     Response['Content-Type'] = 'application/json'
                     return Response
示例#4
0
    def api_callback_pay(self, Params):
           PublicKey = Params["public_key"] 
           Amount =  Params["amount"] 
           CurrencyStr = Params["currency"] 
           Desc = Params["description"]
           Type = Params["type"]
           OrderId = Params["order_id"]
           Status = Params["status"]
           OutOrderId = Params["transaction_id"]
           Phone = Params["sender_phone"]
           Signature = Params["signature"]
           Comission = Decimal(Params["receiver_commission"])
           m = hashlib.sha1(self.__private_key + 
                         Amount +
                         CurrencyStr  +
                         self.__public_key +
                         OrderId +
                         self.__type +
                         self.__description +
                         Status +
                         OutOrderId +
                         Phone
                         )
           
           signature = b64encode( m.digest() )       
           if signature != Signature: 
                    raise TransError("Invalid Signature")
             
           if Status == "failure":
                     order = Orders.objects.get( id = int(OrderId) )
                     order.status = "order_cancel"
                     order.save()
                     Response =  HttpResponse( json.JSONEncoder().encode({"status":True,"signature":True}) )
                     Response['Content-Type'] = 'application/json'
                     return Response
             
           if Status == "wait_secure":
                     order = Orders.objects.get( id = int(OrderId), status="created" )
                     order.status = "wait_secure"
                     order.save()
                     Response =  HttpResponse( json.JSONEncoder().encode({"status":True,"signature":True}) )
                     Response['Content-Type'] = 'application/json'
                     return Response
           ##TODO add system message  
           if Status == "success":
                     order = Orders.objects.get(id = int(OrderId) )
                     if order.status !="created" and order.status !="wait_secure":
                             raise TransError("Invalid order")
                     order.status="processing"
                     order.save()
 		     from main.models import check_holds
                     check_holds(order)
                     add_trans( order.transit_1 , order.sum1, self.__currency,
                                order.transit_2, order, 
                                "payin", OutOrderId, False)
                     
                     #hack if privat is wrong  
                     HackComis = order.sum1 * self.__comis
		     if Comission < HackComis:
			Comission = HackComis

                     add_trans( order.transit_2 , Comission, self.__currency,
                                order.transit_1,  order, 
                                "comission", OutOrderId, False)

                     DebCred =   LiqPayTrans(
                                                  phone = Phone,
                                                  description = Desc,
                                                  #pib = ,
                                                  currency = self.__currency, 
                                                  amnt = Decimal(Amount) , 
                                                  user = order.user ,
                                                  comission = self.__comis,
                                                  user_accomplished_id =  1,
                                                  status = "processed",
                                                  debit_credit = "in",
                                                  confirm_key = Signature,
                                                  order = order
                                                 )
                     DebCred.save()
                     order.status = "processed"
                     order.save()
                     notify_email(order.user, "deposit_notify", DebCred ) 
                     Response =  HttpResponse( json.JSONEncoder().encode({"status":True,"signature":True}) )
                     Response['Content-Type'] = 'application/json'
                     return Response

           if Status == "sandbox":
                     raise TransError("hacker ")
                     order = Orders.objects.get(id = int(OrderId), status = "created")
                     order.status="processing"
                     order.save()
                     check_holds(order)

                     add_trans(order.transit_1, order.sum1, self.__currency,
                               order.transit_2, order, "payin", OutOrderId, False )
                     
                     
                     #Comission = order.sum1 * self.__comis
                     add_trans( order.transit_2, Comission , self.__currency,
                                order.transit_1,  order, 
                                "comission", OutOrderId, False)
                     DebCred =   LiqPayTrans(
                                                  phone = Phone,
                                                  description = Desc, 
                                                  currency = self.__currency, 
                                                  amnt = Decimal(Amount) , 
                                                  user = order.user ,
                                                  comission = self.__comis,
                                                  user_accomplished_id =  1,
                                                  status = "processed",
                                                  debit_credit = "in",
                                                  confirm_key = Signature,
                                                  order = order
                                                  
                                            )
                     DebCred.save()
                     order.status = "processed"
                     order.save()
                     Response =  HttpResponse( json.JSONEncoder().encode({"status":True,"signature":True}) )
                     Response['Content-Type'] = 'application/json'
                     return Response