08/07/23 - 20h
parent
ae9218fddf
commit
27b1f14139
|
@ -3,18 +3,10 @@
|
||||||
<component name="ChangeListManager">
|
<component name="ChangeListManager">
|
||||||
<list default="true" id="c6d0259a-16e1-410d-91a1-830590ee2a08" name="Changes" comment="05/07/23 - 20h">
|
<list default="true" id="c6d0259a-16e1-410d-91a1-830590ee2a08" name="Changes" comment="05/07/23 - 20h">
|
||||||
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/Attestation_Certificat.py" beforeDir="false" afterPath="$PROJECT_DIR$/Attestation_Certificat.py" afterDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/Inscription_mgt.py" beforeDir="false" afterPath="$PROJECT_DIR$/Inscription_mgt.py" afterDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/Log/log_file.log" beforeDir="false" afterPath="$PROJECT_DIR$/Log/log_file.log" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/Log/log_file.log" beforeDir="false" afterPath="$PROJECT_DIR$/Log/log_file.log" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/Session_Formation.py" beforeDir="false" afterPath="$PROJECT_DIR$/Session_Formation.py" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/main.py" beforeDir="false" afterPath="$PROJECT_DIR$/main.py" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/class_mgt.py" beforeDir="false" afterPath="$PROJECT_DIR$/class_mgt.py" afterDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/data_indexees.csv" beforeDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/ela_output_test_file_pandas_2.txt" beforeDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/ela_user_account.py" beforeDir="false" afterPath="$PROJECT_DIR$/ela_user_account.py" afterDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/email_mgt.py" beforeDir="false" afterPath="$PROJECT_DIR$/email_mgt.py" afterDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/emargement.py" beforeDir="false" afterPath="$PROJECT_DIR$/emargement.py" afterDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/partners.py" beforeDir="false" afterPath="$PROJECT_DIR$/partners.py" afterDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/prj_common.py" beforeDir="false" afterPath="$PROJECT_DIR$/prj_common.py" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/prj_common.py" beforeDir="false" afterPath="$PROJECT_DIR$/prj_common.py" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/strype_payement.py" beforeDir="false" afterPath="$PROJECT_DIR$/strype_payement.py" afterDir="false" />
|
||||||
</list>
|
</list>
|
||||||
<option name="SHOW_DIALOG" value="false" />
|
<option name="SHOW_DIALOG" value="false" />
|
||||||
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
||||||
|
|
3630
Log/log_file.log
3630
Log/log_file.log
File diff suppressed because one or more lines are too long
17
main.py
17
main.py
|
@ -310,7 +310,7 @@ mais pour que l'api fonctionne, il faut lui fournir
|
||||||
def get_class():
|
def get_class():
|
||||||
# On recupere le corps (payload) de la requete
|
# On recupere le corps (payload) de la requete
|
||||||
payload = mycommon.strip_dictionary (request.form.to_dict())
|
payload = mycommon.strip_dictionary (request.form.to_dict())
|
||||||
print(" ### payload = ",str(payload)+" IP requester = "+str(request.remote_addr))
|
print(" ### get_class : payload = ",str(payload)+" IP requester = "+str(request.remote_addr))
|
||||||
status, retval = cm.get_class(payload)
|
status, retval = cm.get_class(payload)
|
||||||
return jsonify(status=status, message=retval)
|
return jsonify(status=status, message=retval)
|
||||||
|
|
||||||
|
@ -3065,6 +3065,21 @@ def Get_Given_Code_Promo():
|
||||||
return jsonify(status=localStatus, message=message)
|
return jsonify(status=localStatus, message=message)
|
||||||
|
|
||||||
|
|
||||||
|
"""
|
||||||
|
Cette API Permet de recuperer les données
|
||||||
|
d'abonnement d'un client
|
||||||
|
"""
|
||||||
|
@app.route('/myclass/api/Strip_Get_Customer_Abonnement_Data/', methods=['POST','GET'])
|
||||||
|
@crossdomain(origin='*')
|
||||||
|
def Strip_Get_Customer_Abonnement_Data():
|
||||||
|
# On recupere le corps (payload) de la requete
|
||||||
|
payload = mycommon.strip_dictionary (request.form.to_dict())
|
||||||
|
print(" ### Strip_Get_Customer_Abonnement_Data : payload = ",payload)
|
||||||
|
localStatus, message = Stripe.Strip_Get_Customer_Abonnement_Data(payload)
|
||||||
|
return jsonify(status=localStatus, message=message)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
print(" debut api")
|
print(" debut api")
|
||||||
context = SSL.Context(SSL.SSLv23_METHOD)
|
context = SSL.Context(SSL.SSLv23_METHOD)
|
||||||
|
|
|
@ -394,6 +394,31 @@ def get_partner_data_from_recid(user_recid = ""):
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
|
"""
|
||||||
|
Recuperation des données du partner à partir du token
|
||||||
|
"""
|
||||||
|
def get_partner_data_from_token(token = ""):
|
||||||
|
try :
|
||||||
|
if len(str(token)) <= 0:
|
||||||
|
myprint(" Le token partner est vide")
|
||||||
|
return False, ""
|
||||||
|
|
||||||
|
val_tmp = MYSY_GV.dbname['partnair_account'].count_documents({'token': str(token), 'active': '1', 'locked':'0'})
|
||||||
|
if (val_tmp <= 0):
|
||||||
|
return False, ""
|
||||||
|
|
||||||
|
ret_val = MYSY_GV.dbname['partnair_account'].find_one(
|
||||||
|
{'token': str(token), 'active': '1', 'locked': '0'})
|
||||||
|
|
||||||
|
return True, ret_val
|
||||||
|
|
||||||
|
except Exception as e:
|
||||||
|
exc_type, exc_obj, exc_tb = sys.exc_info()
|
||||||
|
myprint(str(inspect.stack()[0][3]) + " -" + str(e) + " - ERRORRRR AT Line : " + str(exc_tb.tb_lineno))
|
||||||
|
return False, ""
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
'''
|
'''
|
||||||
recuperation d'email du user from token
|
recuperation d'email du user from token
|
||||||
'''
|
'''
|
||||||
|
|
|
@ -1168,7 +1168,6 @@ def strip_update_subscription_plan(diction):
|
||||||
print(" ### local_status = "+str(local_status)+" mysy_lms.Disable_MySy_LMS_Class_Of_User = "+str(local_message))
|
print(" ### local_status = "+str(local_status)+" mysy_lms.Disable_MySy_LMS_Class_Of_User = "+str(local_message))
|
||||||
return True, " ok"
|
return True, " ok"
|
||||||
|
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
exc_type, exc_obj, exc_tb = sys.exc_info()
|
exc_type, exc_obj, exc_tb = sys.exc_info()
|
||||||
mycommon.myprint(str(inspect.stack()[0][3]) + " -" + str(e) + " - ERRORRRR AT Line : " + str(exc_tb.tb_lineno))
|
mycommon.myprint(str(inspect.stack()[0][3]) + " -" + str(e) + " - ERRORRRR AT Line : " + str(exc_tb.tb_lineno))
|
||||||
|
@ -1242,3 +1241,111 @@ def webhook_received():
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
"""
|
||||||
|
Cette fonction recuperer les informations sur l'abonnement
|
||||||
|
d'un client. Par exemple,
|
||||||
|
- date de prochaine facturation
|
||||||
|
- montant de prochaine facture
|
||||||
|
"""
|
||||||
|
def Strip_Get_Customer_Abonnement_Data(diction):
|
||||||
|
try:
|
||||||
|
|
||||||
|
field_list_obligatoire = ['recid']
|
||||||
|
|
||||||
|
for val in field_list_obligatoire:
|
||||||
|
if val not in diction:
|
||||||
|
mycommon.myprint(
|
||||||
|
str(inspect.stack()[0][
|
||||||
|
3]) + " La valeur '" + val + "' n'est pas presente dans liste ")
|
||||||
|
return False, " Les informations fournies sont incorrectes"
|
||||||
|
|
||||||
|
recid = ""
|
||||||
|
if ("recid" in diction.keys()):
|
||||||
|
if diction['recid']:
|
||||||
|
recid = diction['recid']
|
||||||
|
|
||||||
|
|
||||||
|
# Recuperation du recid du partenaire
|
||||||
|
local_status, partner_data = mycommon.get_partner_data_from_recid(str(recid))
|
||||||
|
if local_status is False:
|
||||||
|
mycommon.myprint(str(inspect.stack()[0][3]) + " - Impossible de recuperer les données du partenaire")
|
||||||
|
return False, " Impossible de recuperer les données du partenaire"
|
||||||
|
|
||||||
|
if ("stripe_account_id" not in partner_data.keys()):
|
||||||
|
mycommon.myprint(str(inspect.stack()[0][3]) + " - Impossible de recuperer les données du partenaire (2)")
|
||||||
|
return False, " Impossible de recuperer les données du partenaire (2)"
|
||||||
|
|
||||||
|
|
||||||
|
stripe_account_id = partner_data["stripe_account_id"]
|
||||||
|
local_ret_val = stripe.Invoice.upcoming(
|
||||||
|
customer=stripe_account_id,
|
||||||
|
)
|
||||||
|
|
||||||
|
print(" #### local_ret_val : ", str(local_ret_val))
|
||||||
|
|
||||||
|
|
||||||
|
lines_to_invoice = local_ret_val.lines.list(limit=5)
|
||||||
|
|
||||||
|
stripe_account_id_JSON = json.loads(str(local_ret_val))
|
||||||
|
|
||||||
|
lines_to_invoice_JSON = json.loads(str(lines_to_invoice))
|
||||||
|
|
||||||
|
return_data = {}
|
||||||
|
return_data['recid'] = str(recid)
|
||||||
|
period_start = ""
|
||||||
|
period_end = ""
|
||||||
|
total = ""
|
||||||
|
|
||||||
|
if( "period_start" in stripe_account_id_JSON.keys()):
|
||||||
|
# convert the timestamp to a datetime object in the local timezone
|
||||||
|
dt_object = datetime.fromtimestamp(stripe_account_id_JSON["period_start"]).strftime("%d/%m/%Y")
|
||||||
|
return_data['period_start'] = str(dt_object)[0:10]
|
||||||
|
period_start = str(dt_object)[0:10]
|
||||||
|
|
||||||
|
if ("period_end" in stripe_account_id_JSON.keys()):
|
||||||
|
# convert the timestamp to a datetime object in the local timezone
|
||||||
|
dt_object = datetime.fromtimestamp(stripe_account_id_JSON["period_end"]).strftime("%d/%m/%Y")
|
||||||
|
return_data['period_end'] = str(dt_object)[0:10]
|
||||||
|
period_end = str(dt_object)[0:10]
|
||||||
|
|
||||||
|
if ("total" in stripe_account_id_JSON.keys()):
|
||||||
|
total_local = mycommon.tryFloat(str(stripe_account_id_JSON["total"])) / 100
|
||||||
|
return_data['total'] = str(total_local)
|
||||||
|
total = str(total_local)
|
||||||
|
|
||||||
|
return_data['main_description'] = "Facture à venir : Ceci est un aperçu de la facture qui sera émise "+str(period_end)+"." \
|
||||||
|
" Elle est susceptible d'être modifiée si l'abonnement est mis à jour."
|
||||||
|
|
||||||
|
return_data['lines'] = []
|
||||||
|
|
||||||
|
|
||||||
|
for val in lines_to_invoice_JSON['data']:
|
||||||
|
|
||||||
|
local_diction = {}
|
||||||
|
|
||||||
|
local_diction['id'] = str(val['id'])
|
||||||
|
|
||||||
|
period = val['period']
|
||||||
|
|
||||||
|
local_diction['period_end'] = str(datetime.fromtimestamp(period['end']).strftime("%d/%m/%Y-%H:%M:%S"))
|
||||||
|
local_diction['period_start'] = str(datetime.fromtimestamp(period['start']).strftime("%d/%m/%Y-%H:%M:%S"))
|
||||||
|
|
||||||
|
|
||||||
|
local_diction['unit_amount'] = str(val['price']['unit_amount'])
|
||||||
|
|
||||||
|
local_diction['quantity'] = str(val['quantity'])
|
||||||
|
|
||||||
|
local_diction['description'] = str(val['description'])
|
||||||
|
|
||||||
|
local_diction['amount'] = str(val['amount'])
|
||||||
|
return_data['lines'].append(local_diction)
|
||||||
|
|
||||||
|
|
||||||
|
RetObject = []
|
||||||
|
RetObject.append(mycommon.JSONEncoder().encode(return_data))
|
||||||
|
return True, RetObject
|
||||||
|
|
||||||
|
except Exception as e:
|
||||||
|
exc_type, exc_obj, exc_tb = sys.exc_info()
|
||||||
|
mycommon.myprint(str(inspect.stack()[0][3]) + " -" + str(e) + " - ERRORRRR AT Line : " + str(exc_tb.tb_lineno))
|
||||||
|
return False, " Impossible de recuperer les données de l'abonnement "
|
||||||
|
|
Loading…
Reference in New Issue