def handle(self, *args, **options): from sdk.p24 import p24 # for item in P24TransIn.objects.filter(status='processing'): # TradePair = TradePairs.objects.get(url_title = "p24") for i in [113720]: D = get_p24() item = Orders.objects.get(id=i) Res = D.check_payment(item.id, True) if item.status == "processing": #item.order.status='processing' #item.save() if Res == 1: process_p24_in(item.id, D.description, D.comis) item.status = 'processed' if Res == 0: cancel_p24_in(item.id) item.status = 'canceled'
def handle(self, *args, **options): from sdk.p24 import p24 TradePair = TradePairs.objects.get(url_title = "p24") D = p24() for item in Orders.objects.filter(trade_pair = TradePair, status="wait_secure"): Res = D.check_payment(item.id, True) item.status = "processing2" item.save() if Res == 1 : process_p24_in(item.id, D.description, D.comis ) if Res == 0: cancel_p24_in(item.id) for item in Orders.objects.filter(trade_pair = TradePair, status="processing"): Res = D.check_payment(item.id, True) item.status = "processing2" item.save() if Res == 1: process_p24_in(item.id, D.description, D.comis ) if Res == 0: cancel_p24_in(item.id )
def api_callback_pay(self, Params, OrderId): Payment = Params["payment"] signature = self.signature(Payment) Signature = Params["signature"] if signature != Signature: raise TransError("Invalid Signature") for Val in Payment.split("&"): [Name, Value] = Val.split("=") if Name == "state": Status = Value break if Status == "fail": 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": Response = HttpResponse(json.JSONEncoder().encode({ "status": True, "signature": True })) Response['Content-Type'] = 'application/json' return Response ##TODO add system message if Status == "ok": process_p24_in(int(OrderId), self.description, self.comis) Response = HttpResponse(json.JSONEncoder().encode({ "status": True, "signature": True })) Response['Content-Type'] = 'application/json' return Response if Status == "test": order = Orders.objects.get(id=int(OrderId), status="created") order.status = "processing" order.save() 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 = P24TransIn(description=self.description, currency=self.__currency, amnt=order.sum1, user=order.user, comission=Comission, 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
def api_callback_pay(self, Params, OrderId): Payment = Params["payment"] signature = self.signature(Payment) Signature = Params["signature"] #if signature != Signature: #raise TransError("Invalid Signature") for Val in Payment.split("&"): [Name, Value] = Val.split("=") if Name == "state": Status = Value break if Status == "fail": 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": Response = HttpResponse(json.JSONEncoder().encode({"status": True, "signature": True})) Response['Content-Type'] = 'application/json' return Response ##TODO add system message if Status == "ok": process_p24_in(int(OrderId), self.description, self.comis, self.__password) Response = HttpResponse(json.JSONEncoder().encode({"status": True, "signature": True})) Response['Content-Type'] = 'application/json' return Response if Status == "test": order = Orders.objects.get(id=int(OrderId), status="created") order.status = "processing" order.save() 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 = P24TransIn( description=self.description, currency=self.__currency, amnt=order.sum1, user=order.user, comission=Comission, 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