24/01/23 - 19h
parent
8f1f9b3206
commit
e58266a2c8
|
@ -3,13 +3,9 @@
|
||||||
<component name="ChangeListManager">
|
<component name="ChangeListManager">
|
||||||
<list default="true" id="1122d9e2-679f-46d6-8c4f-97e9ae4041b5" name="Changes" comment="21/01/23 - 12h">
|
<list default="true" id="1122d9e2-679f-46d6-8c4f-97e9ae4041b5" name="Changes" comment="21/01/23 - 12h">
|
||||||
<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$/GlobalVariable.py" beforeDir="false" afterPath="$PROJECT_DIR$/GlobalVariable.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$/data_indexees.csv" beforeDir="false" afterPath="$PROJECT_DIR$/data_indexees.csv" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/Session_Formation.py" beforeDir="false" afterPath="$PROJECT_DIR$/Session_Formation.py" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/ela_factures_mgt.py" beforeDir="false" afterPath="$PROJECT_DIR$/ela_factures_mgt.py" afterDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/ela_output_test_file_pandas_2.txt" beforeDir="false" afterPath="$PROJECT_DIR$/ela_output_test_file_pandas_2.txt" afterDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/main.py" beforeDir="false" afterPath="$PROJECT_DIR$/main.py" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/main.py" beforeDir="false" afterPath="$PROJECT_DIR$/main.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" />
|
<change beforePath="$PROJECT_DIR$/strype_payement.py" beforeDir="false" afterPath="$PROJECT_DIR$/strype_payement.py" afterDir="false" />
|
||||||
</list>
|
</list>
|
||||||
|
|
7371
Log/log_file.log
7371
Log/log_file.log
File diff suppressed because one or more lines are too long
|
@ -243,7 +243,7 @@ def Add_Update_SessionFormation(diction):
|
||||||
# Fin Controle de cohérence sur les dates
|
# Fin Controle de cohérence sur les dates
|
||||||
|
|
||||||
|
|
||||||
print(" ### query_key = ", query_key)
|
#print(" ### query_key = ", query_key)
|
||||||
coll_name = MYSY_GV.dbname['session_formation']
|
coll_name = MYSY_GV.dbname['session_formation']
|
||||||
ret_val = coll_name.find_one_and_update(
|
ret_val = coll_name.find_one_and_update(
|
||||||
query_key,
|
query_key,
|
||||||
|
@ -252,7 +252,7 @@ def Add_Update_SessionFormation(diction):
|
||||||
return_document=ReturnDocument.AFTER
|
return_document=ReturnDocument.AFTER
|
||||||
)
|
)
|
||||||
|
|
||||||
if (ret_val['_id'] is False):
|
if (ret_val['_id'] is None):
|
||||||
mycommon.myprint(
|
mycommon.myprint(
|
||||||
str(inspect.stack()[0][3]) + " Impossible d'ajouter/mettre à jour la session '"+str(diction['code_session'])+"' ")
|
str(inspect.stack()[0][3]) + " Impossible d'ajouter/mettre à jour la session '"+str(diction['code_session'])+"' ")
|
||||||
return False, "Impossible d'ajouter/mettre à jour la session '"+str(diction['code_session'])+"' "
|
return False, "Impossible d'ajouter/mettre à jour la session '"+str(diction['code_session'])+"' "
|
||||||
|
|
25
main.py
25
main.py
|
@ -2332,6 +2332,31 @@ def stop_strip_subscription():
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
"""
|
||||||
|
Cette API verifie le statut d'un payement
|
||||||
|
"""
|
||||||
|
@app.route('/myclass/api/payment_retrieve_status/', methods=['POST','GET'])
|
||||||
|
@crossdomain(origin='*')
|
||||||
|
def payment_retrieve_status():
|
||||||
|
# On recupere le corps (payload) de la requete
|
||||||
|
payload = request.form.to_dict()
|
||||||
|
print(" ### payment_retrieve_status : payload = ",payload)
|
||||||
|
localStatus, message = Stripe.payment_retrieve_status(payload)
|
||||||
|
return jsonify(status=localStatus, message=message )
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
"""
|
||||||
|
Cette API verifie l'existance ou non d'une commande vente
|
||||||
|
"""
|
||||||
|
@app.route('/myclass/api/CheckSalesOrder/', methods=['POST','GET'])
|
||||||
|
@crossdomain(origin='*')
|
||||||
|
def CheckSalesOrder():
|
||||||
|
# On recupere le corps (payload) de la requete
|
||||||
|
payload = request.form.to_dict()
|
||||||
|
print(" ### CheckSalesOrder : payload = ",payload)
|
||||||
|
localStatus, message = mycommon.CheckSalesOrder(payload)
|
||||||
|
return jsonify(status=localStatus, message=message )
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
print(" debut api")
|
print(" debut api")
|
||||||
|
|
|
@ -2746,3 +2746,56 @@ def Sedesabonner(diction):
|
||||||
exc_type, exc_obj, exc_tb = sys.exc_info()
|
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))
|
myprint(str(inspect.stack()[0][3]) + " -" + str(e) + " - ERRORRRR AT Line : " + str(exc_tb.tb_lineno))
|
||||||
return False, " Impossible de desactivier l'adresse email "
|
return False, " Impossible de desactivier l'adresse email "
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
"""
|
||||||
|
Cette fonction verifie qu'une commande existe est qu'elle est bien valide
|
||||||
|
"""
|
||||||
|
def CheckSalesOrder(diction):
|
||||||
|
|
||||||
|
try:
|
||||||
|
field_list_obligatoire = ['token', 'orderid']
|
||||||
|
|
||||||
|
for val in field_list_obligatoire:
|
||||||
|
if val not in diction:
|
||||||
|
myprint(
|
||||||
|
str(inspect.stack()[0][3]) + " - La valeur '" + val + "' n'est pas presente dans liste ")
|
||||||
|
return False, " Toutes les informations obligatoires n'ont pas été fornies"
|
||||||
|
|
||||||
|
my_orderid = ""
|
||||||
|
if ("orderid" in diction.keys()):
|
||||||
|
if diction['orderid']:
|
||||||
|
my_orderid = diction['orderid']
|
||||||
|
|
||||||
|
|
||||||
|
my_token = ""
|
||||||
|
if ("token" in diction.keys()):
|
||||||
|
if diction['token']:
|
||||||
|
my_token = diction['token']
|
||||||
|
|
||||||
|
# Recuperation du recid du partenaire
|
||||||
|
partner_recid = get_parnter_recid_from_token(str(my_token))
|
||||||
|
if partner_recid is False:
|
||||||
|
myprint(str(inspect.stack()[0][3]) + " - Impossible de recuperer le recid du partenaire")
|
||||||
|
return False, " Les informations d'identification sont invalides"
|
||||||
|
|
||||||
|
insertObject = []
|
||||||
|
|
||||||
|
salesorder = MYSY_GV.dbname['sales_order'].find_one({'client_recid':partner_recid, 'order_id':my_orderid,
|
||||||
|
'valide':'1'}, {'order_id':1, 'order_date':1, 'stripe_pi':1,
|
||||||
|
})
|
||||||
|
|
||||||
|
if (salesorder is None or salesorder['order_id'] is None):
|
||||||
|
myprint(str(inspect.stack()[0][3]) + " La commande "+str(my_orderid)+" n'existe pas")
|
||||||
|
return False, " La commande "+str(my_orderid)+" n'existe pas"
|
||||||
|
|
||||||
|
insertObject.append(JSONEncoder().encode(salesorder))
|
||||||
|
|
||||||
|
return True, insertObject
|
||||||
|
|
||||||
|
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, " Impossible de verifier l'existence de la commande "
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
"""
|
"""
|
||||||
Python 3.6 or newer required.
|
Python 3.6 or newer required.
|
||||||
"""
|
"""
|
||||||
|
import pymongo
|
||||||
import stripe
|
import stripe
|
||||||
import json
|
import json
|
||||||
import os
|
import os
|
||||||
|
@ -281,7 +282,7 @@ def confirm_suscription(diction):
|
||||||
if val not in diction:
|
if val not in diction:
|
||||||
mycommon.myprint(
|
mycommon.myprint(
|
||||||
str(inspect.stack()[0][3]) + " - La valeur '" + val + "' n'est pas presente dans liste ")
|
str(inspect.stack()[0][3]) + " - La valeur '" + val + "' n'est pas presente dans liste ")
|
||||||
return False, " Impossible de créer el moyen de payement", False
|
return False, " Impossible de créer el moyen de payement", False, False
|
||||||
|
|
||||||
|
|
||||||
stripe_payment_id = ""
|
stripe_payment_id = ""
|
||||||
|
@ -301,17 +302,61 @@ def confirm_suscription(diction):
|
||||||
if (local_ret_val['stripe_paymentmethod_id'] is None):
|
if (local_ret_val['stripe_paymentmethod_id'] is None):
|
||||||
mycommon.myprint(
|
mycommon.myprint(
|
||||||
str(inspect.stack()[0][3]) + " Impossible de finaliser le payement")
|
str(inspect.stack()[0][3]) + " Impossible de finaliser le payement")
|
||||||
return False, " Impossible de finaliser le payement ", False
|
return False, " Impossible de finaliser le payement ", False, False
|
||||||
|
|
||||||
|
# Recuperation de la dernière commande du client
|
||||||
|
cmd_ret_val = MYSY_GV.dbname['sales_order'].find(
|
||||||
|
{'client_recid': str(local_ret_val['recid']), 'valide': '1'}).sort([("_id",pymongo.DESCENDING) ])
|
||||||
|
|
||||||
print(" ### stripe_payment_id = ", stripe_payment_id, " ### stripe_paymentmethod_id = ", local_ret_val['stripe_paymentmethod_id'])
|
if(cmd_ret_val[0] is None or cmd_ret_val[0]['order_id'] is None ):
|
||||||
|
mycommon.myprint(
|
||||||
|
str(inspect.stack()[0][3]) + " Impossible de finaliser le payement")
|
||||||
|
return False, " Impossible de finaliser le payement ", False, False
|
||||||
|
|
||||||
|
cmd_order_id = cmd_ret_val[0]['order_id']
|
||||||
|
mydata_update = {'stripe_pi':stripe_payment_id}
|
||||||
|
|
||||||
|
### Mise à jour de la commande avec le payement id
|
||||||
|
local_update_val = MYSY_GV.dbname['sales_order'].find_one_and_update(
|
||||||
|
{'order_id':str(cmd_order_id)},
|
||||||
|
{"$set": mydata_update},
|
||||||
|
upsert=False,
|
||||||
|
return_document=ReturnDocument.AFTER
|
||||||
|
)
|
||||||
|
|
||||||
|
if (local_update_val['_id'] is None):
|
||||||
|
mycommon.myprint(
|
||||||
|
str(inspect.stack()[0][3]) + " Impossible de finaliser le payement 2")
|
||||||
|
return False, " Impossible de finaliser le payement (2) ", False, False
|
||||||
|
|
||||||
|
#print(" ### stripe_payment_id = ", stripe_payment_id, " ### stripe_paymentmethod_id = ", local_ret_val['stripe_paymentmethod_id'])
|
||||||
confirmation_payement = stripe.PaymentIntent.confirm(
|
confirmation_payement = stripe.PaymentIntent.confirm(
|
||||||
stripe_payment_id,
|
stripe_payment_id,
|
||||||
payment_method=str(local_ret_val['stripe_paymentmethod_id']),
|
payment_method=str(local_ret_val['stripe_paymentmethod_id']),
|
||||||
return_url="http://localhost:3009/testurl/:course/:tab",
|
return_url="http://localhost:3009/OrderConfirmation_3DS/"+str(cmd_order_id)+"/"+str(local_ret_val['pack_service'])
|
||||||
|
|
||||||
)
|
)
|
||||||
|
|
||||||
print(' #### confirmation_payement = ', confirmation_payement)
|
"""
|
||||||
|
/!\ : le client a demarré un payement.
|
||||||
|
1 - je supprimer son pack abonnement pour se premunir d'un echec au prelevement
|
||||||
|
2 - Je remettrai le bon pack lors qu'il aura confirmé
|
||||||
|
|
||||||
|
"""
|
||||||
|
### Mise à jour de la commande avec le payement id
|
||||||
|
local_update_cust = MYSY_GV.dbname['partnair_account'].find_one_and_update(
|
||||||
|
{'token': token, 'active': '1', 'locked': '0'},
|
||||||
|
{"$set": {'pack_service':'', }},
|
||||||
|
upsert=False,
|
||||||
|
return_document=ReturnDocument.AFTER
|
||||||
|
)
|
||||||
|
|
||||||
|
if (local_update_cust['_id'] is None):
|
||||||
|
mycommon.myprint(
|
||||||
|
str(inspect.stack()[0][3]) + " Impossible de finaliser le payement 3")
|
||||||
|
return False, " Impossible de finaliser le payement (3) ", False, False
|
||||||
|
|
||||||
|
#print(' #### confirmation_payement = ', confirmation_payement)
|
||||||
return True, confirmation_payement.id, confirmation_payement.status, confirmation_payement.next_action.redirect_to_url.url
|
return True, confirmation_payement.id, confirmation_payement.status, confirmation_payement.next_action.redirect_to_url.url
|
||||||
|
|
||||||
|
|
||||||
|
@ -320,6 +365,82 @@ def confirm_suscription(diction):
|
||||||
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))
|
||||||
return False, False, False, False
|
return False, False, False, False
|
||||||
|
|
||||||
|
"""
|
||||||
|
Cette fonction verifier si un payement est ok ou Ko"""
|
||||||
|
def payment_retrieve_status(diction):
|
||||||
|
try:
|
||||||
|
field_list_obligatoire = ['stripe_payment_id','token', 'packs']
|
||||||
|
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, " Impossible de verifier le payement les données obligatoires ne sont pas fournies",
|
||||||
|
|
||||||
|
|
||||||
|
stripe_payment_id = ""
|
||||||
|
if ("stripe_payment_id" in diction.keys()):
|
||||||
|
if diction['stripe_payment_id']:
|
||||||
|
stripe_payment_id = diction['stripe_payment_id']
|
||||||
|
|
||||||
|
token = ""
|
||||||
|
if ("token" in diction.keys()):
|
||||||
|
if diction['token']:
|
||||||
|
token = diction['token']
|
||||||
|
|
||||||
|
packs = ""
|
||||||
|
if ("packs" in diction.keys()):
|
||||||
|
if diction['packs']:
|
||||||
|
packs = diction['packs']
|
||||||
|
|
||||||
|
# Recuperation du payement methode du client.
|
||||||
|
local_ret_val = MYSY_GV.dbname['partnair_account'].find_one(
|
||||||
|
{'token': token, 'active': '1', 'locked': '0'})
|
||||||
|
|
||||||
|
if (local_ret_val['stripe_paymentmethod_id'] is None):
|
||||||
|
mycommon.myprint(
|
||||||
|
str(inspect.stack()[0][3]) + " Impossible de verifier le payement 'stripe_paymentmethod_id' instrouvable ")
|
||||||
|
return False, " Impossible de verifier le payement 'stripe_paymentmethod_id' instrouvable "
|
||||||
|
|
||||||
|
|
||||||
|
payement_retrive_status = stripe.PaymentIntent.retrieve(
|
||||||
|
stripe_payment_id,
|
||||||
|
)
|
||||||
|
|
||||||
|
#print(" ### payement_retrive_status = ", payement_retrive_status, )
|
||||||
|
|
||||||
|
if( payement_retrive_status is None or payement_retrive_status['status'] is None):
|
||||||
|
mycommon.myprint(
|
||||||
|
str(inspect.stack()[0][3]) + " le Payement "+str(stripe_payment_id)+" n'est pas validé")
|
||||||
|
return False, " le Payement "+str(stripe_payment_id)+" n'est pas validé"
|
||||||
|
|
||||||
|
if( payement_retrive_status['status'] and str(payement_retrive_status['status'] ).strip() == "succeeded" ):
|
||||||
|
|
||||||
|
#On reactive le pack du partner
|
||||||
|
local_coll_name = MYSY_GV.dbname['partnair_account']
|
||||||
|
|
||||||
|
now = datetime.now()
|
||||||
|
ret_val = local_coll_name.find_one_and_update({'token': token, 'active': '1', 'locked': '0', 'pack_service':''},
|
||||||
|
{"$set":
|
||||||
|
{"pack_service": str(packs),
|
||||||
|
"date_update": str(now)}
|
||||||
|
},
|
||||||
|
upsert=False,
|
||||||
|
return_document=ReturnDocument.AFTER
|
||||||
|
)
|
||||||
|
|
||||||
|
mycommon.myprint(
|
||||||
|
str(inspect.stack()[0][3]) + " le Payement "+str(stripe_payment_id)+" est validé")
|
||||||
|
return True, " le Payement "+str(stripe_payment_id)+" est validé"
|
||||||
|
|
||||||
|
mycommon.myprint(
|
||||||
|
str(inspect.stack()[0][3]) + " Impossible de connaitre le status du payement " + str(stripe_payment_id) + " ")
|
||||||
|
return False, " Impossible de connaitre le status du payement " + str(stripe_payment_id) + " "
|
||||||
|
|
||||||
|
|
||||||
|
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, False
|
||||||
|
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
Loading…
Reference in New Issue