def bank_transfer_withdraw_submit(Req): Form = BankTransferForm(Req.POST, user=Req.user) Dict = {} if Form.is_valid(): # Save Key = generate_key("bank_withdraw") transfer = BankTransfers( ref="", okpo=Form.cleaned_data["okpo"], mfo=Form.cleaned_data["mfo"], debit_credit="out", account=Form.cleaned_data["account"], description=Form.cleaned_data["description"], currency=Form.currency_instance, amnt=Form.cleaned_data["amnt"], user=Req.user, comission="0.00", confirm_key=Key ) transfer.save() #if settings.DEBUG is False: send_mail(_(u'Подтверждение вывода ' + settings.BASE_HOST), confirm_bank_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_bank Dict["form"] = Form.as_p() Dict["common_help_text"] = settings.attention_be_aware Dict["action"] = "/finance/bank_transfer_withdraw_submit" Dict["action_title"] = settings.withdraw_transfer return tmpl_context(Req, t, Dict)
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)
def notify_admin_withdraw(Text): try: send_mail(u'Вывода ' + settings.BASE_HOST, Text, [settings.ADMIN_COPY], fail_silently=False) except: pass
def emoney_transfer_withdraw_secure(Req, Form, provider): Key = generate_key("p2p_ahuihui") Wallet = Form.cleaned_data["wallet"] Wallet = Wallet.replace(" ", "") Transfer = TransOut( wallet=Wallet, currency=Form.currency_instance, amnt=Form.cleaned_data["amnt"], user=Req.user, pub_date=datetime.datetime.now(), confirm_key=Key, provider=provider ) FreqKey = "orders" + str(Req.user.id) if not check_freq(FreqKey, 3): Response = HttpResponse('{"status":false}') Response['Content-Type'] = 'application/json' return Response Transfer.save() AccountTo = get_account(user=Req.user, currency=Transfer.currency) ## if not by reference, but by users trade_pair_title = provider + "_" + Form.currency_instance.title.lower() TradePair = TradePairs.objects.get(url_title=trade_pair_title) order = Orders(user=Req.user, price=Decimal("1"), currency1=Transfer.currency, currency2=Transfer.currency, sum1_history=Transfer.amnt, sum2_history=Transfer.amnt, sum1=Transfer.amnt, sum2=Transfer.amnt, transit_1=AccountTo.acc(), transit_2=TradePair.transit_from, trade_pair=TradePair, status="created" ) order.save() # TODO add process exception in withdraw p2p add_trans(AccountTo.acc(), Transfer.amnt, Transfer.currency, TradePair.transit_from, order, "withdraw", Key, False) order.status = "processing" order.save() Transfer.order = order Transfer.save() #if settings.DEBUG is False: send_mail(_(u'Подтверждение вывода ') + settings.BASE_HOST, confirm_emoney_withdraw_email(Form.cleaned_data, Key), [Req.user.email], fail_silently=False)
def regis_new_user(Req, Form): (new_user, rand_key) = store_registration(Form.cleaned_data['username'], Form.cleaned_data['email'], Form.cleaned_data['password1'], Form.cleaned_data.get('reference', False), Req.session.get('reference_from', False) ) Req.session['auth_user_computered'] = True Email = Form.cleaned_data["email"] #if settings.DEBUG is False: send_mail(_(u'Регистрация на бирже ' + settings.BASE_HOST), register_new_user_mail(new_user, rand_key), [Email, settings.ADMIN_COPY], fail_silently=False)
def crypto_currency_withdraw_submit(Req): Dict = {"use_f2a": False} if Req.session.has_key("use_f2a"): Dict["use_f2a"] = Req.session["use_f2a"] Form = CurrencyTransferForm(data=Req.POST, user=Req.user) getcontext().prec = settings.TRANS_PREC if Form.is_valid(): # Save Key = generate_key("currency_withdraw") Amnt = Decimal(Form.cleaned_data["amnt"]) - Form.comission transfer = CryptoTransfers(account=Form.cleaned_data["wallet"], currency=Form.currency_instance, amnt=Amnt, pub_date=datetime.datetime.now(), comission=Form.comission, user=Req.user, confirm_key=Key, debit_credit="out") transfer.save() #if settings.DEBUG is False: send_mail(_(u'Подтверждение вывода ') + settings.BASE_HOST, confirm_crypto_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["form"] = Form.as_p() CurrencyIn = Currency.objects.get(title=Form.cleaned_data["currency"]) Dict["currency"] = Form.cleaned_data["currency"] TradePair = TradePairs.objects.get(currency_on=CurrencyIn, currency_from=CurrencyIn) Dict["common_help_text"] = settings.attention_be_aware_crypto % ( str(TradePair.min_trade_base) ) Dict["action"] = "/finance/crypto_currency_withdraw_submit" Dict["action_title"] = settings.withdraw_transfer Dict["pin_load"] = not Dict["use_f2a"] return tmpl_context(Req, t, Dict)
def p2p_transfer_withdraw_common_operation(Req, Form): Key = generate_key("p2p_ahuihui") CardNumber = Form.cleaned_data["CardNumber"] CardNumber = CardNumber.replace(" ", "") Amnt = Form.cleaned_data["amnt"] NewAmnt = get_comisP2P(CardNumber, Decimal(Amnt)) Transfer = None FreqKey = "orders" + str(Req.user.id) if not check_freq(FreqKey, 3): Response = HttpResponse('{"status":false}') Response['Content-Type'] = 'application/json' return Response if NewAmnt < 0: Transfer = CardP2PTransfers( debit_credit="out", CardName=Form.cleaned_data["CardName"], CardNumber=CardNumber, currency=Form.currency_instance, amnt=Amnt, pub_date=datetime.datetime.now(), user=Req.user, confirm_key=Key, status="processing2") Transfer.sign_record(settings.COMMON_SALT) if NewAmnt > 0: Transfer = CardP2PTransfers( debit_credit="out", CardName=Form.cleaned_data["CardName"], CardNumber=CardNumber, currency=Form.currency_instance, amnt=Amnt, pub_date=datetime.datetime.now(), user=Req.user, confirm_key=Key, status="auto" ) Transfer.sign_record(settings.COMMON_SALT) AccountTo = get_account(user=Req.user, currency=Transfer.currency) ## if not by reference, but by users TradePair = TradePairs.objects.get(url_title="p2p_transfers") order = Orders(user=Req.user, price=Decimal("1"), currency1=Transfer.currency, currency2=Transfer.currency, sum1_history=Transfer.amnt, sum2_history=Transfer.amnt, sum1=Transfer.amnt, sum2=Transfer.amnt, transit_1=AccountTo.acc(), transit_2=TradePair.transit_from, trade_pair=TradePair, status="created" ) order.save() # TODO add process exception in withdraw p2p add_trans(AccountTo.acc(), Transfer.amnt, Transfer.currency, TradePair.transit_from, order, "withdraw", Key, False) order.status = "processing" order.save() Transfer.order = order Transfer.save() notify_admin_withdraw(withdraw_p2p_auto(Transfer)) send_mail(_(u'Подтверждение вывода ') + settings.BASE_HOST, confirm_p2p_withdraw_email_common(Form.cleaned_data, Key), [Req.user.email], fail_silently=False)