def handle(self, *args, **options): from sdk.liqpay import liqpay for DebCred in LiqPayTrans.objects.filter(status='processing', debit_credit='in'): order = DebCred.order OrderId = order.id d = liqpay("ru", "UAH") Dict = d.api("payment/status", {"version": "2", "order_id": str(OrderId)}) print Dict if Dict["status"] == "success": if order.status != "processing": DebCred.status = 'canceled' DebCred.save() continue order.status = "processing2" order.save() OutOrderId = Dict["liqpay_order_id"] from main.models import check_holds check_holds(order) add_trans(order.transit_1, order.sum1, d.currency, order.transit_2, order, "payin", OutOrderId, False) #hack if privat is wrong Comission = Decimal(Dict["receiver_commission"]) Phone = Dict['sender_phone'] Desc = Dict['description'] Signature = Dict['liqpay_order_id'] Amount = Dict['amount'] add_trans(order.transit_2, Comission, d.currency, order.transit_1, order, "comission", OutOrderId, False) DebCred.status = 'processed' DebCred.save() order.status = "processed" order.save() #notify_email(order.user, "deposit_notify", DebCred ) else: DebCred.status = 'canceled' DebCred.save()
def liqpay_call_back_url(Req, OrderId): pay_call_back = liqpay("ru", "UAH") rlog_req = OutRequest(raw_text=str(Req), from_ip=get_client_ip(Req)) rlog_req.save() return pay_call_back.api_callback_pay(Req.REQUEST)
def confirm_withdraw_liqpay(Req, S): Transfer = LiqPayTrans.objects.get(user = Req.user, status = "created", confirm_key = S) liqpay_class = liqpay("ru", Transfer.currency.title) FreqKey = "orders" + str(Req.user.id) if not check_freq(FreqKey, 3) : Response = HttpResponse('{"status":false}') Response['Content-Type'] = 'application/json' return Response ##add trans may be there AccountTo = Accounts.objects.get(user = Req.user, currency = Transfer.currency) ## if not by reference, but by users TradePair = liqpay_class.get_traid_pair() order = Orders( user = Req.user, currency1 = Transfer.currency, currency2 = Transfer.currency, sum1_history = Transfer.amnt, sum2_history = Transfer.amnt, sum1 = Transfer.amnt, sum2 = Transfer.amnt, transit_1 = AccountTo, transit_2 = TradePair.transit_from , trade_pair = TradePair, status = "created" ) order.save() add_trans(AccountTo, Transfer.amnt, Transfer.currency, TradePair.transit_from, order, "withdraw", S, True) order.status = "processing" order.save() Transfer.order = order Transfer.status = "processing" Transfer.save() t = loader.get_template("ajax_simple_msg.html") Dict = {} Dict["title"] = settings.withdraw_ok Dict["simple_msg"] = settings.withdraw_msg_ok caching().delete("balance_" + str(Req.user.id) ) return tmpl_context(Req, t, Dict)
def confirm_withdraw_liqpay(Req, S): Transfer = LiqPayTrans.objects.get(user=Req.user, status="created", confirm_key=S) liqpay_class = liqpay("ru", Transfer.currency.title) FreqKey = "orders" + str(Req.user.id) if not check_freq(FreqKey, 3): Response = HttpResponse('{"status":false}') Response['Content-Type'] = 'application/json' return Response ##add trans may be there AccountTo = get_account(user=Req.user, currency=Transfer.currency) ## if not by reference, but by users TradePair = liqpay_class.get_traid_pair() 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() add_trans(AccountTo.acc(), Transfer.amnt, Transfer.currency, TradePair.transit_from, order, "withdraw", S, False) order.status = "processing" order.save() Transfer.order = order Transfer.status = "processing" Transfer.save() t = loader.get_template("ajax_simple_msg.html") Dict = {} Dict["title"] = settings.withdraw_ok Dict["simple_msg"] = settings.withdraw_msg_ok caching().delete("balance_" + str(Req.user.id)) return tmpl_context(Req, t, Dict)
def liqpay_deposit(Req, Amnt): amnt = Decimal(Amnt) if amnt < 100: raise TransError("pay_requirments") pay_invoice = liqpay("ru", "UAH") return HttpResponse(pay_invoice.generate_button(Amnt))
def liqpay_start_pay(Req, Amnt): pay_invoice = liqpay("ru", "UAH") if not Req.user.is_authenticated(): return denied(Req) else: return pay_invoice.generate_pay_request(Req.user, Amnt)