20/01/23 - 23h
parent
0e919151fd
commit
755524c68c
|
@ -1,7 +1,15 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ChangeListManager">
|
||||
<list default="true" id="1122d9e2-679f-46d6-8c4f-97e9ae4041b5" name="Changes" comment="19/01/23 - 20h" />
|
||||
<list default="true" id="1122d9e2-679f-46d6-8c4f-97e9ae4041b5" name="Changes" comment="19/01/23 - 20h">
|
||||
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" 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$/ela_user_account.py" beforeDir="false" afterPath="$PROJECT_DIR$/ela_user_account.py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/main.py" beforeDir="false" afterPath="$PROJECT_DIR$/main.py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/statistics.py" beforeDir="false" afterPath="$PROJECT_DIR$/statistics.py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/strype_payement.py" beforeDir="false" afterPath="$PROJECT_DIR$/strype_payement.py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/tools_cherif/tools_cherif.py" beforeDir="false" afterPath="$PROJECT_DIR$/tools_cherif/tools_cherif.py" afterDir="false" />
|
||||
</list>
|
||||
<option name="SHOW_DIALOG" value="false" />
|
||||
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
||||
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
|
||||
|
|
9906
Log/log_file.log
9906
Log/log_file.log
File diff suppressed because one or more lines are too long
|
@ -598,16 +598,14 @@ def valide_user_account(value):
|
|||
tmp = coll_name.find({'_id':ObjectId(str(value))})
|
||||
|
||||
now = datetime.now()
|
||||
ret_val = coll_name.find_one_and_update({'_id':ObjectId(str(value)), 'locked':'0'},
|
||||
{"$set":
|
||||
{'active': "1","date_update":str(now)}
|
||||
},
|
||||
return_document=ReturnDocument.AFTER
|
||||
)
|
||||
update = coll_name.find_one_and_update({'_id': ObjectId(str(value)), 'locked': '0'},
|
||||
{"$set": {'active': "1", "date_update": str(now)}},
|
||||
return_document=ReturnDocument.AFTER)
|
||||
ret_val = update
|
||||
|
||||
if( ret_val and ret_val['_id']):
|
||||
mycommon.myprint("La modif a bien ete faite ="+str(ret_val['_id']))
|
||||
"""
|
||||
remerciement_ = """
|
||||
Declenchement de l'envoie du mail de remerciement
|
||||
"""
|
||||
status = mail.send_user_thks_mail("", ret_val['email'])
|
||||
|
|
15
main.py
15
main.py
|
@ -2318,6 +2318,21 @@ def Sedesabonner():
|
|||
return jsonify(status=localStatus, message=message )
|
||||
|
||||
|
||||
"""
|
||||
Stripe Payement : Arret d'un abonnement à la fin du mois en cours
|
||||
"""
|
||||
@app.route('/myclass/api/stop_strip_subscription/', methods=['POST','GET'])
|
||||
@crossdomain(origin='*')
|
||||
def stop_strip_subscription():
|
||||
# On recupere le corps (payload) de la requete
|
||||
payload = request.form.to_dict()
|
||||
print(" ### stop_strip_subscription : payload = ",payload)
|
||||
localStatus, message = Stripe.stop_strip_subscription(payload)
|
||||
return jsonify(status=localStatus, message=message )
|
||||
|
||||
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
print(" debut api")
|
||||
context = SSL.Context(SSL.SSLv23_METHOD)
|
||||
|
|
|
@ -449,10 +449,12 @@ def GetStat_class_view_topX(diction):
|
|||
tab_valeur = []
|
||||
for result in collection.aggregate(pipe2):
|
||||
|
||||
print(" ### NAME = ", name)
|
||||
if( name in result['_id']['INTERNAL URL']):
|
||||
|
||||
print(" #### RESULT = ", result)
|
||||
tab_valeur.append(str(result['count']))
|
||||
|
||||
|
||||
ret_val['data'+str(i)] = tab_valeur
|
||||
|
||||
insertObject.append(JSONEncoder().encode(ret_val))
|
||||
|
|
|
@ -16,6 +16,7 @@ import inspect
|
|||
import sys, os
|
||||
import time
|
||||
from datetime import datetime
|
||||
from dateutil.relativedelta import relativedelta
|
||||
|
||||
# Setup Stripe python client library
|
||||
load_dotenv(find_dotenv())
|
||||
|
@ -285,13 +286,12 @@ def confirm_suscription(diction):
|
|||
if diction['stripe_payment_id']:
|
||||
stripe_payment_id = diction['stripe_payment_id']
|
||||
|
||||
|
||||
print(" ### stripe_payment_id = ", stripe_payment_id)
|
||||
confirmation_payement = stripe.PaymentIntent.confirm(
|
||||
stripe_payment_id,
|
||||
payment_method="pm_card_visa",
|
||||
)
|
||||
|
||||
#print("### confirmation_payement.data = "+str(confirmation_payement))
|
||||
return True, confirmation_payement.id, confirmation_payement.status
|
||||
|
||||
|
||||
|
@ -300,6 +300,70 @@ def confirm_suscription(diction):
|
|||
mycommon.myprint(str(inspect.stack()[0][3]) + " -" + str(e) + " - ERRORRRR AT Line : " + str(exc_tb.tb_lineno))
|
||||
return False, False, False,
|
||||
|
||||
|
||||
|
||||
"""
|
||||
Cette fonction schedul un payeement
|
||||
"""
|
||||
def Schedule_Stripe_Payement(diction):
|
||||
try:
|
||||
|
||||
field_list_obligatoire = ['token', ]
|
||||
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, " - La valeur '" + val + "' n'est pas presente dans liste "
|
||||
|
||||
|
||||
mytoken = ""
|
||||
if ("token" in diction.keys()):
|
||||
if (str(diction['token'])):
|
||||
mytoken = str(diction['token'])
|
||||
|
||||
# recuperation de la susbscription du client
|
||||
local_ret_val = MYSY_GV.dbname['partnair_account'].find_one({'token':mytoken,'active':'1', 'locked':'0'})
|
||||
|
||||
if( local_ret_val['stripe_subscription_id'] is None ):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3]) + " Impossible de trouver la suscritpion, planification annulée ")
|
||||
return False, " Impossible de trouver la suscritpion, planification annulée "
|
||||
|
||||
schedul = stripe.SubscriptionSchedule.create(
|
||||
from_subscription=str(local_ret_val['stripe_subscription_id']),
|
||||
)
|
||||
|
||||
print(" ### Schedule id = ", schedul['id'])
|
||||
|
||||
"""
|
||||
Mise à jour du partenaire avec la valeur du suscription id
|
||||
"""
|
||||
local_coll_name = MYSY_GV.dbname['partnair_account']
|
||||
|
||||
now = datetime.now()
|
||||
ret_val = local_coll_name.find_one_and_update({'token':mytoken, 'active': '1', 'locked': '0'},
|
||||
{"$set":
|
||||
{"stripe_subscription_schedule_id": str(schedul['id']),
|
||||
"date_update": str(now)}
|
||||
},
|
||||
upsert=False,
|
||||
return_document=ReturnDocument.AFTER
|
||||
)
|
||||
|
||||
if (ret_val is None or ret_val['_id'] is None):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3]) + " - planification des payement : impossible de mettre à jour le client")
|
||||
return False, False, "Planification des payement : impossible de mettre à jour le client"
|
||||
|
||||
return True, " La planification des payement a bien été activée"
|
||||
|
||||
|
||||
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 d'activer la plafinification recurrente du payement",
|
||||
|
||||
|
||||
def create_subscription(diction):
|
||||
|
||||
|
||||
|
@ -336,7 +400,30 @@ def create_subscription(diction):
|
|||
expand=['latest_invoice.payment_intent'],
|
||||
)
|
||||
|
||||
#print(" ### subscription = "+str(subscription))
|
||||
print(" ### subscription ID =", subscription['id'])
|
||||
print(" ### customer_id = ", customer_id)
|
||||
##print(" ### payment_intent = id = " + str(subscription.latest_invoice.payment_intent.id))
|
||||
|
||||
"""
|
||||
Mise à jour du partenaire avec la valeur du suscription id
|
||||
"""
|
||||
local_coll_name = MYSY_GV.dbname['partnair_account']
|
||||
|
||||
now = datetime.now()
|
||||
ret_val = local_coll_name.find_one_and_update({'stripe_account_id':customer_id, 'active':'1', 'locked':'0'},
|
||||
{"$set":
|
||||
{"stripe_subscription_id":str(subscription['id']), "date_update": str(now)}
|
||||
},
|
||||
upsert=False,
|
||||
return_document=ReturnDocument.AFTER
|
||||
)
|
||||
|
||||
if (ret_val is None or ret_val['_id'] is None):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3]) + " - Creation payement : impossible de mettre à jour le client")
|
||||
return False, False, "Creation payement : impossible de mettre à jour le client"
|
||||
|
||||
|
||||
return True, subscription.latest_invoice.payment_intent.id, subscription.latest_invoice.payment_intent.client_secret
|
||||
|
||||
|
||||
|
@ -420,6 +507,83 @@ def update_subscription():
|
|||
return jsonify(error=str(e)), 403
|
||||
|
||||
|
||||
"""
|
||||
Cette fonction arrete la prelevement d'un payement à la fin du mois en cours
|
||||
"""
|
||||
def stop_strip_subscription(diction):
|
||||
try:
|
||||
|
||||
field_list_obligatoire = ['token',]
|
||||
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 , toutes le données obligatoire ne sont pas fournies ")
|
||||
return False, " Impossible de supprimer le moyen de payement, toutes le données obligatoire ne sont pas fournies"
|
||||
|
||||
mytoken = ""
|
||||
if ("token" in diction.keys()):
|
||||
if diction['token']:
|
||||
mytoken = diction['token']
|
||||
|
||||
retval = mycommon.check_partner_token_validity("", str(mytoken))
|
||||
|
||||
if retval is False:
|
||||
mycommon.myprint(str(inspect.stack()[0][3]) + " - Le token n'est pas valide")
|
||||
return False, "Les informations d'identification ne sont pas valident"
|
||||
|
||||
# Recuperation du recid du partenaire
|
||||
partner_recid = mycommon.get_parnter_recid_from_token(str(mytoken))
|
||||
if partner_recid is False:
|
||||
mycommon.myprint(str(inspect.stack()[0][3]) + " - Impossible de recuperer le recid du partenaire")
|
||||
return False, " Les informations d'identification sont incorrectes"
|
||||
|
||||
# recuperation de la susbscription du client
|
||||
local_ret_val = MYSY_GV.dbname['partnair_account'].find_one(
|
||||
{'token': mytoken, 'active': '1', 'locked': '0'})
|
||||
|
||||
if (local_ret_val['stripe_subscription_id'] is None):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3]) + " Impossible d'annuler le payement ")
|
||||
return False, " Impossible d'annuler le payement "
|
||||
|
||||
|
||||
#a = stripe.SubscriptionSchedule.release( str(local_ret_val['stripe_subscription_id']), )
|
||||
a = stripe.Subscription.modify(
|
||||
str(local_ret_val['stripe_subscription_id']),
|
||||
cancel_at_period_end=True
|
||||
)
|
||||
|
||||
arret_abonnement = datetime.today().date() + relativedelta(months=+1)
|
||||
arrete_abonnement_formated = arret_abonnement.strftime("%d/%m/%Y")
|
||||
|
||||
#mise à jour du partenaire
|
||||
local_coll_name = MYSY_GV.dbname['partnair_account']
|
||||
|
||||
now = datetime.now()
|
||||
ret_val = local_coll_name.find_one_and_update({'token': mytoken, 'active': '1', 'locked': '0'},
|
||||
{"$set":
|
||||
{"end_date_abonnement": str(arrete_abonnement_formated),
|
||||
"date_update": str(now)}
|
||||
},
|
||||
upsert=False,
|
||||
return_document=ReturnDocument.AFTER
|
||||
)
|
||||
|
||||
if (ret_val is None or ret_val['_id'] is None):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3]) + " - Arret abonnement : impossible de mettre à jour le client")
|
||||
return False, False, "Arret abonnement : : impossible de mettre à jour le client"
|
||||
|
||||
|
||||
return True, " Votre abonement va s'arreter le "+str(arrete_abonnement_formated)
|
||||
|
||||
|
||||
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 d'annuler votre abonnement"
|
||||
|
||||
|
||||
@app.route('/webhook', methods=['POST'])
|
||||
def webhook_received():
|
||||
# You can use webhooks to receive information about asynchronous payment events.
|
||||
|
|
|
@ -24,6 +24,7 @@ def email_validation():
|
|||
coll_emails = MYSY_GV.dbname['bdd_email']
|
||||
|
||||
cpt = 0
|
||||
nb_doc = coll_emails.count_documents({'valide':'1', "checked_status": {"$ne": "1"}})
|
||||
|
||||
for val in coll_emails.find({'valide':'1', "checked_status": {"$ne": "1"}}):
|
||||
cpt = cpt + 1
|
||||
|
@ -67,7 +68,7 @@ def email_validation():
|
|||
return_document=ReturnDocument.AFTER
|
||||
)
|
||||
|
||||
print(" ### "+str(cpt)+" email traité")
|
||||
print(" ### "+str(cpt)+" email traité sur "+str(nb_doc))
|
||||
|
||||
|
||||
return retval, str(cpt)+" adresse email ont été mise à jour "
|
||||
|
|
Loading…
Reference in New Issue