Commit 82d50450 by Javier

Función para cambiar método de pago

parent ef5ce199
...@@ -108,6 +108,16 @@ def _create_did(phone_number: str): ...@@ -108,6 +108,16 @@ def _create_did(phone_number: str):
if not re.match(succesful, result.decode('utf-8')): if not re.match(succesful, result.decode('utf-8')):
raise MagnusCommandError(result.decode('utf-8')) raise MagnusCommandError(result.decode('utf-8'))
def _update_payment(phone_number : str, postpay : bool = False, credit : float = 0.0):
with mariadb.connect(**DB_CREDENTIALS) as cnx:
with cnx.cursor() as cursor:
cursor.execute(
"UPDATE mbilling.pkg_user SET typepaid=?, creditlimit=? WHERE username=?",
(postpay, credit if postpay else 0, phone_number)
)
cnx.commit()
def create_user(phone_number: str, name: str, surname: str, password: str = None, pbx: str = None, plan_id: int = 1, offer_id: int = 0) -> str: def create_user(phone_number: str, name: str, surname: str, password: str = None, pbx: str = None, plan_id: int = 1, offer_id: int = 0) -> str:
"""Genera un nuevo usuario en Magnus Billing con una cuenta SIP, un DID para llamadas nacionales\ """Genera un nuevo usuario en Magnus Billing con una cuenta SIP, un DID para llamadas nacionales\
...@@ -138,14 +148,8 @@ def create_user(phone_number: str, name: str, surname: str, password: str = None ...@@ -138,14 +148,8 @@ def create_user(phone_number: str, name: str, surname: str, password: str = None
_create_user(phone_number.strip(), password, name, surname, plan_id, offer_id) _create_user(phone_number.strip(), password, name, surname, plan_id, offer_id)
_create_sip(phone_number, password, pbx) _create_sip(phone_number, password, pbx)
_create_did(phone_number) _create_did(phone_number)
_update_payment(phone_number,offer_id != 0, 30.00)
with mariadb.connect(**DB_CREDENTIALS) as cnx:
with cnx.cursor() as cursor:
cursor.execute(
"UPDATE mbilling.pkg_user SET typepaid=1, creditlimit=30 WHERE username=?",
(phone_number,)
)
cnx.commit()
return password return password
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment