Beispiel #1
0
def liqpay_transfer_withdraw(Req, CurrencyTitle, Amnt):

    amnt = Decimal(Amnt)
    if amnt < 10:
        raise TransError("pay_requirments")
    if CurrencyTitle != "UAH":
        raise TransError("pay_requirments")

    Dict = {}
    CurrencyIn = Currency.objects.get(title=CurrencyTitle)

    Account = Accounts.objects.get(user=Req.user, currency=CurrencyIn)
    if Account.reference is None or len(Account.reference) == 0:
        Account.reference = generate_key(settings.BANK_KEY_SALT)
        Account.save()

    Dict["amnt"] = str(Amnt)
    Dict["currency"] = "UAH"
    try:
        Last = LiqPayTrans.objects.filter(user=Req.user, status="processed").order_by("-id")[0]
        Dict["phone"] = Last.phone
    except:
        pass

    t = loader.get_template("ajax_form.html")
    Dict["action"] = "/finance/liqpay_transfer_withdraw_submit"
    Dict["action_title"] = settings.withdraw_transfer
    Dict["common_help_text"] = settings.liqpay_attention_be_aware
    Form = LiqPayTransferForm(initial=Dict, user=Req.user)

    Dict["form"] = Form.as_p()
    return tmpl_context(Req, t, Dict)
Beispiel #2
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)
Beispiel #3
0
def liqpay_transfer_withdraw(Req, CurrencyTitle, Amnt):
    amnt = Decimal(Amnt)
    if amnt < 10:
        raise TransError("pay_requirments")
    if CurrencyTitle != "UAH":
        raise TransError("pay_requirments")

    Dict = {}
    CurrencyIn = Currency.objects.get(title=CurrencyTitle)

    Account = get_account(user=Req.user, currency=CurrencyIn)
    Acc = Account.acc()
    if Acc.reference is None or len(Acc.reference) == 0:
        Account.reference = generate_key(settings.BANK_KEY_SALT)
        Account.save()

    Dict["amnt"] = str(Amnt)
    Dict["currency"] = "UAH"
    try:
        Last = LiqPayTrans.objects.filter(user=Req.user, status="processed").order_by('-id')[0]
        Dict["phone"] = Last.phone
    except:
        pass

    t = loader.get_template("ajax_form.html")
    Dict["action"] = "/finance/liqpay_transfer_withdraw_submit"
    Dict["action_title"] = settings.withdraw_transfer
    Dict["common_help_text"] = settings.liqpay_attention_be_aware
    Form = LiqPayTransferForm(initial=Dict, user=Req.user)

    Dict["form"] = Form.as_p()
    return tmpl_context(Req, t, Dict)
Beispiel #4
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),
                  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)