check and start payment added
This commit is contained in:
@@ -0,0 +1,2 @@
|
||||
CD %CD%
|
||||
py -3.9 payment_start.py
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,3 @@
|
||||
import kassa.new
|
||||
|
||||
kassa.new.run_get_check()
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -39,9 +39,7 @@ class Atol:
|
||||
|
||||
def set_sell(self, reciept, is_refund):
|
||||
func = '/sell' if is_refund == 0 else '/sell_refund'
|
||||
print(reciept)
|
||||
s = self.get_request('post', self.group_id+func, reciept)
|
||||
print(s)
|
||||
return s
|
||||
|
||||
def get_reciepts(self, uuid):
|
||||
|
||||
Binary file not shown.
+4
-2
@@ -1,3 +1,4 @@
|
||||
from ast import Dict
|
||||
from sqlalchemy.orm import Session
|
||||
import kassa.schemas as schemas
|
||||
import kassa.models as models
|
||||
@@ -25,6 +26,7 @@ def create_doc(db: Session, doc: schemas.Doc, external_id: str = None):
|
||||
|
||||
def create_error(db: Session, error: schemas.Error, external_id: str = None):
|
||||
err = error
|
||||
|
||||
err['external_id'] = external_id
|
||||
err_query = db.query(models.Error).filter(
|
||||
models.Error.external_id == external_id)
|
||||
@@ -32,7 +34,7 @@ def create_error(db: Session, error: schemas.Error, external_id: str = None):
|
||||
|
||||
err_query.update(values=err)
|
||||
else:
|
||||
err_query = models.Error(**err, synchronize_session=False)
|
||||
err_query = models.Error(**err)
|
||||
db.add(err_query)
|
||||
db.commit()
|
||||
|
||||
@@ -43,7 +45,7 @@ def create_payload(db: Session, payload: schemas.Payload, external_id: str = Non
|
||||
payload_query = db.query(models.Payload).filter(
|
||||
models.Payload.external_id == external_id)
|
||||
if payload_query.first():
|
||||
payload_query.update(pay, synchronize_session=False)
|
||||
payload_query.update(pay)
|
||||
|
||||
else:
|
||||
pay['external_id'] = external_id
|
||||
|
||||
+1
-1
@@ -46,7 +46,7 @@ class Doc(Base):
|
||||
|
||||
class Atol(Base):
|
||||
__tablename__ = 'atol_receipts'
|
||||
uuid = Column('uuid', String(length=128), primary_key=True)
|
||||
uuid = Column('uuid', String(length=128), primary_key=True, nullable= True)
|
||||
timestamp = Column('timestamp', String(length=128))
|
||||
external_id = Column('external_id', String(length=128))
|
||||
status = Column('status', String(length=128))
|
||||
|
||||
+50
-9
@@ -1,4 +1,6 @@
|
||||
from ast import While
|
||||
from lib2to3.pgen2 import token
|
||||
from re import A
|
||||
from time import sleep
|
||||
from typing import Dict, List, Tuple
|
||||
from sqlalchemy.ext.declarative import declarative_base
|
||||
@@ -10,6 +12,7 @@ from sqlalchemy.sql.sqltypes import DateTime
|
||||
from sqlalchemy import desc, cast, case, func
|
||||
import kassa.schemas as schemas
|
||||
import kassa.models as models
|
||||
from kassa.cruds import doc
|
||||
from kassa.databases import SessionLocal
|
||||
from kassa.atol import Atol
|
||||
import datetime
|
||||
@@ -258,10 +261,11 @@ def get_sell(data: query):
|
||||
|
||||
|
||||
def get_client(phone: str):
|
||||
return {
|
||||
'phone': phone
|
||||
}
|
||||
|
||||
if phone:
|
||||
return {
|
||||
'phone': phone
|
||||
}
|
||||
return { 'email': 'test@test.ru'}
|
||||
|
||||
def get_vat(vat: str):
|
||||
return {'type': vat}
|
||||
@@ -291,16 +295,38 @@ def clear_dict(d):
|
||||
return r
|
||||
|
||||
def add_doc(sell: schemas.Sell, is_refund, token):
|
||||
|
||||
atol_model = Atol(token)
|
||||
session = SessionLocal()
|
||||
a = atol_model.set_sell(clear_dict(sell.dict()), is_refund)
|
||||
check = models.Atol(schemas.AtolSell(**a))
|
||||
check.external_id = sell.external_id
|
||||
ext_id = sell.external_id
|
||||
err = a.pop('error', None)
|
||||
if err:
|
||||
print(err)
|
||||
return doc.create_error(session, error = schemas.Error(**err), external_id = ext_id )
|
||||
|
||||
a["external_id"]= sell.external_id
|
||||
check = models.Atol(**a)
|
||||
session.add(check)
|
||||
session.commit()
|
||||
return a
|
||||
|
||||
|
||||
def get_check(db: Session, uuid: str, external_id: str, token: str):
|
||||
atol_model = Atol(token)
|
||||
a = atol_model.get_reciepts(uuid)
|
||||
err = a.pop('error', None)
|
||||
if err:
|
||||
print(err)
|
||||
return doc.create_error(db, error = schemas.Error(**err), external_id = external_id )
|
||||
doc.create_doc(db, a, external_id)
|
||||
return a
|
||||
|
||||
|
||||
def get_atol_wo_doc(db: Session):
|
||||
return db.query(models.Atol.uuid, models.Atol.external_id).\
|
||||
where(models.Atol.external_id.notin_(models.Doc.external_id)).\
|
||||
all()
|
||||
|
||||
def get_main_payment():
|
||||
server = 'Sanctuary'
|
||||
user = 'sa'
|
||||
@@ -334,5 +360,20 @@ def main():
|
||||
if payment == False:
|
||||
break
|
||||
sleep(1)
|
||||
add_doc(sell=payment, is_refund=is_refund, token = token)
|
||||
break
|
||||
doc = add_doc(sell=payment, is_refund=is_refund, token = token)
|
||||
print(doc)
|
||||
|
||||
def run_get_check():
|
||||
session = SessionLocal()
|
||||
atols = get_atol_wo_doc(session)
|
||||
while len(atols)>0:
|
||||
server = 'Sanctuary'
|
||||
user = 'sa'
|
||||
password = '159357'
|
||||
db_dicts_name = 'fz54'
|
||||
db = Session(autocommit=False, autoflush=False, bind=db.engine)
|
||||
db_dicts = DBEngine(server, db_dicts_name, user, password)
|
||||
token = get_token(db, db_dicts)
|
||||
uuid, ext_id = atols.pop()
|
||||
check = get_check(session, uuid, ext_id, token)
|
||||
print(check)
|
||||
@@ -212,6 +212,7 @@ class AtolSell(BaseModel):
|
||||
timestamp: str
|
||||
status: Optional[str] = None
|
||||
error: Error = None
|
||||
external_id: Optional[str] = None
|
||||
class Config:
|
||||
orm_mode = True
|
||||
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,3 @@
|
||||
import kassa.new
|
||||
|
||||
kassa.new.main()
|
||||
@@ -0,0 +1,2 @@
|
||||
CD %CD%
|
||||
py -3.9 main.py
|
||||
Reference in New Issue
Block a user