23/01/23 - 19h

master
cherif 2023-01-23 19:58:04 +01:00
parent 9fe2e113e8
commit 8f1f9b3206
10 changed files with 9666 additions and 71 deletions

View File

@ -3,9 +3,15 @@
<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$/Session_Formation.py" beforeDir="false" afterPath="$PROJECT_DIR$/Session_Formation.py" afterDir="false" /> <change beforePath="$PROJECT_DIR$/data_indexees.csv" beforeDir="false" afterPath="$PROJECT_DIR$/data_indexees.csv" afterDir="false" />
<change beforePath="$PROJECT_DIR$/class_mgt.py" beforeDir="false" afterPath="$PROJECT_DIR$/class_mgt.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$/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$/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" />

View File

@ -189,7 +189,6 @@ INVOICE_FTP_DIRECTORY = "https://sftp.iexercice.com/mysy_invoices/"
if (MYSY_ENV == "PROD"): if (MYSY_ENV == "PROD"):
INVOICE_FTP_LOCAL_STORAGE_DIRECTORY = "/var/www/html/sftp_iexercice/mysy_invoices/" INVOICE_FTP_LOCAL_STORAGE_DIRECTORY = "/var/www/html/sftp_iexercice/mysy_invoices/"
elif (MYSY_ENV == "DEV"): elif (MYSY_ENV == "DEV"):
INVOICE_FTP_LOCAL_STORAGE_DIRECTORY = "/var/www/html/sftp_iexercice/mysy_invoices_dev/" INVOICE_FTP_LOCAL_STORAGE_DIRECTORY = "/var/www/html/sftp_iexercice/mysy_invoices_dev/"
@ -238,4 +237,32 @@ TEMPORARY_DIRECTORY = "./temp_direct"
""" """
Nombre maximum de participants importable par csv Nombre maximum de participants importable par csv
""" """
MAX_PARTICIPANT_BY_CSV = 50 MAX_PARTICIPANT_BY_CSV = 50
"""
Stripe : Nom des produits et prix et la clé de config
"""
if (MYSY_ENV == "PROD"):
STRIPE_GOLD_PRICE_ID = "price_1MT0hIAbmaEugrFTBZxxyUdB"
STRIPE_STANDARD_PRICE_ID = "price_1MT0icAbmaEugrFTvtvpMZbG"
STRIPE_TEST_PRICE_ID = "price_1MT0f0AbmaEugrFTJjdZZXG7"
STRIPE_CONFIG_KEY_PUB = "pk_live_51LUUfAAbmaEugrFTyfNe4Dj0vbxc5qXQqNs0rztjAKy8oSlc5EEQyJGjA8Z5kXmP2gvUMcYLUBYCIyWWzLCw59RY00PtGInkVf"
STRIPE_CONFIG_API_KEY = "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"
elif (MYSY_ENV == "DEV"):
STRIPE_GOLD_PRICE_ID = "price_1MT3FmAbmaEugrFTZ5vyJRcZ"
STRIPE_STANDARD_PRICE_ID = "price_1MT3FLAbmaEugrFTDgw7MVgb"
STRIPE_TEST_PRICE_ID = "price_1MT3FLAbmaEugrFTDgw7MVgb"
STRIPE_CONFIG_KEY_PUB = "pk_test_51LUUfAAbmaEugrFTI25uZBD3IFjbtaL6jUfRV83diDf7nco8worna4NGKhMHbPP71WCwT5EHFRdDNatxPrJWwgZ300kgH5EO4p"
STRIPE_CONFIG_API_KEY = "sk_test_51LUUfAAbmaEugrFTrWsfcBWZtbBh9r3HCa2sgeyikG808LjSk3bAdFhV6KxgRZ3vFxooa6RE0c5zBkTuOUrKkyjy00BrsIXAPs"
elif (MYSY_ENV == "REC"):
STRIPE_GOLD_PRICE_ID = "price_1MT3FmAbmaEugrFTZ5vyJRcZ"
STRIPE_STANDARD_PRICE_ID = "price_1MT3FLAbmaEugrFTDgw7MVgb"
STRIPE_TEST_PRICE_ID = "price_1MT3FLAbmaEugrFTDgw7MVgb"
STRIPE_CONFIG_KEY_PUB = "pk_test_51LUUfAAbmaEugrFTI25uZBD3IFjbtaL6jUfRV83diDf7nco8worna4NGKhMHbPP71WCwT5EHFRdDNatxPrJWwgZ300kgH5EO4p"
STRIPE_CONFIG_API_KEY = "sk_test_51LUUfAAbmaEugrFTrWsfcBWZtbBh9r3HCa2sgeyikG808LjSk3bAdFhV6KxgRZ3vFxooa6RE0c5zBkTuOUrKkyjy00BrsIXAPs"

File diff suppressed because one or more lines are too long

View File

@ -1,3 +1,4 @@
,index,mots,occurence,moyenne,id_formation,source_field ,index,mots,occurence,moyenne,id_formation,source_field
0,0,gestion,1,0.5,CODE_10009,title 0,0,prise,1,0.33,GAF_10006,title
1,1,stres,1,0.5,CODE_10009,title 1,1,public,1,0.33,GAF_10006,title
2,2,parole,1,0.33,GAF_10006,title

1 index mots occurence moyenne id_formation source_field
2 0 0 gestion prise 1 0.5 0.33 CODE_10009 GAF_10006 title
3 1 1 stres public 1 0.5 0.33 CODE_10009 GAF_10006 title
4 2 2 parole 1 0.33 GAF_10006 title

View File

@ -430,18 +430,18 @@ def get_payement_mode(diction):
#print("### recherche mod de payement stripe_account_id = "+str(stripe_account_id) ) #print("### recherche mod de payement stripe_account_id = "+str(stripe_account_id) )
localStatus, payment_cards = Stripe.get_customer_payement_cards(tmp_diction) localStatus, payment_cards, nb_carte = Stripe.get_customer_payement_cards(tmp_diction)
if( localStatus and nb_carte != "0" ):
RetObject_stripe.append(payment_cards[0])
RetObject_stripe.append(payment_cards[0]) return True, RetObject_stripe, nb_carte
return True, RetObject_stripe
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))
return False, " Impossible de recuperer les mode de payement" return False, " Impossible de recuperer les mode de payement", "0"
""" """

View File

@ -1,3 +1,3 @@
mots occurence moyenne id_formation source_field Empty DataFrame
0 gestion 1 0.5 CODE_10009 title Columns: [mots, occurence, moyenne, id_formation, source_field]
1 stres 1 0.5 CODE_10009 title Index: []

10
main.py
View File

@ -1393,8 +1393,8 @@ def get_payement_mode():
# On recupere le corps (payload) de la requete # On recupere le corps (payload) de la requete
payload = request.form.to_dict() payload = request.form.to_dict()
print(" ### payload = ", payload) print(" ### payload = ", payload)
status, result = invoice.get_payement_mode(payload) status, result, nb_carte = invoice.get_payement_mode(payload)
return jsonify(status=status, message=result) return jsonify(status=status, message=result, nb_carte=nb_carte)
""" """
Cette API recupere les données et crée la commande Cette API recupere les données et crée la commande
@ -1756,9 +1756,9 @@ Stripe Payement : Confirmation d'un payement
def strip_confirm_payment(): def strip_confirm_payment():
# On recupere le corps (payload) de la requete # On recupere le corps (payload) de la requete
payload = request.form.to_dict() payload = request.form.to_dict()
print(" ### create_payment_card : payload = ",payload) print(" ### strip_confirm_payment : payload = ",payload)
localStatus, payement_id, payement_status= Stripe.confirm_suscription(payload) localStatus, payement_id, payement_status, secure_url = Stripe.confirm_suscription(payload)
return jsonify(status=localStatus, payement_id=payement_id, payement_status=payement_status ) return jsonify(status=localStatus, payement_id=payement_id, payement_status=payement_status, secure_url=secure_url )
""" """

View File

@ -674,7 +674,7 @@ def update_partner_account(diction):
if tmp[0]['stripe_account_id']: if tmp[0]['stripe_account_id']:
partnair_stripe_id = tmp[0]['stripe_account_id'] partnair_stripe_id = tmp[0]['stripe_account_id']
if ( partnair_stripe_id is False or len(partnair_stripe_id) < 5): if ( partnair_stripe_id is None or len(partnair_stripe_id) < 5):
print('### le partenaire = ' + str(tmp[0]['nom']) + " n'as pas de compte Stripe. on va le créer") print('### le partenaire = ' + str(tmp[0]['nom']) + " n'as pas de compte Stripe. on va le créer")
""" """
Creation du compte de payement Stripe Creation du compte de payement Stripe

View File

@ -2074,17 +2074,10 @@ def Partner_Get_pack_nbTraining(partner_recid):
#print("tmp = " + str(tmp[0])) #print("tmp = " + str(tmp[0]))
if(tmp and tmp[0] ): if(tmp and tmp[0] and tmp[0]['pack_service'] and tmp[0]['nb_formation']):
partner_pack = tmp[0]['pack_service'] partner_pack = tmp[0]['pack_service']
partner_pack = str(partner_pack).lower() partner_pack_nb_formation = tmp[0]['nb_formation']
#print(" partner_pack = "+partner_pack)
coll_pack = MYSY_GV.dbname['pack']
tmp_pack = coll_pack.find({'code_pack':str(partner_pack)})
#print("tmp_pack = "+str(tmp_pack[0]))
if( tmp_pack and tmp_pack[0]):
partner_pack_nb_formation = tmp_pack[0]['nb_formation']
else:
return False, partner_pack, partner_pack_nb_formation
else: else:
return False, partner_pack, partner_pack_nb_formation return False, partner_pack, partner_pack_nb_formation
@ -2522,21 +2515,65 @@ def GetAttendeeDetail_perSession(diction):
if (str(local_Insc_retval['certification_send_date'])): if (str(local_Insc_retval['certification_send_date'])):
my_retrun_dict['certification_send_date'] = str(local_Insc_retval['certification_send_date'])[0:10] my_retrun_dict['certification_send_date'] = str(local_Insc_retval['certification_send_date'])[0:10]
local_adresse = ""
if ("adresse" in local_Insc_retval.keys()):
local_adresse = local_Insc_retval['adresse']
my_retrun_dict['adresse'] = local_adresse
my_retrun_dict['adresse'] = local_Insc_retval['adresse'] local_nom = ""
my_retrun_dict['nom'] = local_Insc_retval['nom'] if ("nom" in local_Insc_retval.keys()):
my_retrun_dict['prenom'] = local_Insc_retval['prenom'] local_nom = local_Insc_retval['nom']
my_retrun_dict['employeur'] = local_Insc_retval['employeur'] my_retrun_dict['nom'] = local_nom
my_retrun_dict['telephone'] = local_Insc_retval['telephone']
my_retrun_dict['email'] = local_Insc_retval['email'] local_prenom = ""
my_retrun_dict['modefinancement'] = local_Insc_retval['modefinancement'] if ("prenom" in local_Insc_retval.keys()):
my_retrun_dict['opco'] = local_Insc_retval['opco'] local_prenom = local_Insc_retval['prenom']
my_retrun_dict['class_internal_url'] = local_Insc_retval['class_internal_url'] my_retrun_dict['prenom'] = local_prenom
my_retrun_dict['status'] = local_Insc_retval['status']
my_retrun_dict['price'] = local_Insc_retval['price'] local_employeur = ""
my_retrun_dict['inscription_validation_date'] = local_Insc_retval['inscription_validation_date'] if ("employeur" in local_Insc_retval.keys()):
local_employeur = local_Insc_retval['employeur']
my_retrun_dict['employeur'] = local_employeur
local_telephone = ""
if ("telephone" in local_Insc_retval.keys()):
local_telephone = local_Insc_retval['telephone']
my_retrun_dict['telephone'] = local_telephone
local_email = ""
if ("email" in local_Insc_retval.keys()):
local_email = local_Insc_retval['email']
my_retrun_dict['email'] = local_email
local_modefinancement = ""
if ("modefinancement" in local_Insc_retval.keys()):
local_modefinancement = local_Insc_retval['modefinancement']
my_retrun_dict['modefinancement'] = local_modefinancement
local_opco = ""
if ("opco" in local_Insc_retval.keys()):
local_opco = local_Insc_retval['opco']
my_retrun_dict['opco'] = local_opco
local_class_internal_url = ""
if ("class_internal_url" in local_Insc_retval.keys()):
local_class_internal_url = local_Insc_retval['class_internal_url']
my_retrun_dict['class_internal_url'] = local_class_internal_url
local_status = ""
if ("status" in local_Insc_retval.keys()):
local_status = local_Insc_retval['status']
my_retrun_dict['status'] = local_status
local_price = ""
if ("price" in local_Insc_retval.keys()):
local_price = local_Insc_retval['price']
my_retrun_dict['price'] = local_price
local_inscription_validation_date = ""
if ("inscription_validation_date" in local_Insc_retval.keys()):
local_inscription_validation_date = local_Insc_retval['inscription_validation_date']
my_retrun_dict['inscription_validation_date'] = local_inscription_validation_date
if ("eval_eval" in local_Insc_retval.keys()): if ("eval_eval" in local_Insc_retval.keys()):
if (str(local_Insc_retval['eval_eval'])): if (str(local_Insc_retval['eval_eval'])):

View File

@ -29,7 +29,7 @@ stripe.set_app_info(
url='https://github.com/stripe-samples/subscription-use-cases/fixed-price') url='https://github.com/stripe-samples/subscription-use-cases/fixed-price')
stripe.api_version = '2020-08-27' stripe.api_version = '2020-08-27'
stripe.api_key = "sk_test_51LUUfAAbmaEugrFTrWsfcBWZtbBh9r3HCa2sgeyikG808LjSk3bAdFhV6KxgRZ3vFxooa6RE0c5zBkTuOUrKkyjy00BrsIXAPs" stripe.api_key = MYSY_GV.STRIPE_CONFIG_API_KEY
#static_dir = str(os.path.abspath(os.path.join(__file__, "..", os.getenv("STATIC_DIR")))) #static_dir = str(os.path.abspath(os.path.join(__file__, "..", os.getenv("STATIC_DIR"))))
static_dir = "./" static_dir = "./"
@ -57,7 +57,7 @@ def get_config():
) )
return jsonify( return jsonify(
publishableKey="pk_test_51LUUfAAbmaEugrFTI25uZBD3IFjbtaL6jUfRV83diDf7nco8worna4NGKhMHbPP71WCwT5EHFRdDNatxPrJWwgZ300kgH5EO4p", publishableKey= MYSY_GV.STRIPE_CONFIG_KEY_PUB,
prices=prices.data, prices=prices.data,
) )
@ -143,7 +143,9 @@ def get_customer_payement_cards(diction):
#print(" ### customer_payments = "+str(customer_payments.data)) #print(" ### customer_payments = "+str(customer_payments.data))
RetObject = [] RetObject = []
nb_carte = 0
for val in customer_payments.data : for val in customer_payments.data :
nb_carte = nb_carte + 1
my_card = {} my_card = {}
my_card['nom_carte'] = str(val.billing_details.name) my_card['nom_carte'] = str(val.billing_details.name)
my_card['brand'] = str(val.card.brand) my_card['brand'] = str(val.card.brand)
@ -159,11 +161,11 @@ def get_customer_payement_cards(diction):
print(" ### RetObject = "+str( RetObject )) print(" ### RetObject = "+str( RetObject ))
return True, RetObject return True, RetObject, str(nb_carte)
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))
return False, False return False, False, False
""" """
Creation d'une carte de payement Creation d'une carte de payement
@ -274,12 +276,12 @@ Cette fonction confirme un abonnement
""" """
def confirm_suscription(diction): def confirm_suscription(diction):
try: try:
field_list_obligatoire = ['stripe_payment_id',] field_list_obligatoire = ['stripe_payment_id','token']
for val in field_list_obligatoire: for val in field_list_obligatoire:
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" return False, " Impossible de créer el moyen de payement", False
stripe_payment_id = "" stripe_payment_id = ""
@ -287,19 +289,36 @@ def confirm_suscription(diction):
if diction['stripe_payment_id']: if diction['stripe_payment_id']:
stripe_payment_id = diction['stripe_payment_id'] stripe_payment_id = diction['stripe_payment_id']
print(" ### stripe_payment_id = ", stripe_payment_id) token = ""
if ("token" in diction.keys()):
if diction['token']:
token = diction['token']
# 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 finaliser le payement")
return False, " Impossible de finaliser le payement ", 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="pm_card_visa", payment_method=str(local_ret_val['stripe_paymentmethod_id']),
return_url="http://localhost:3009/testurl/:course/:tab",
) )
return True, confirmation_payement.id, confirmation_payement.status print(' #### confirmation_payement = ', confirmation_payement)
return True, confirmation_payement.id, confirmation_payement.status, confirmation_payement.next_action.redirect_to_url.url
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))
return False, False, False, return False, False, False, False
@ -366,26 +385,55 @@ def Schedule_Stripe_Payement(diction):
def create_subscription(diction): def create_subscription(diction):
# Simulating authenticated user. Lookup the logged in user in your
# database, and set customer_id to the Stripe Customer ID of that user.
customer_id = ""
if ("customerid" in diction.keys()):
if diction['customerid']:
customer_id = diction['customerid']
# Extract the price ID from environment variables given the name
# of the price passed from the front end.
#
# `price_id` is the an ID of a Price object on your account.
# This was populated using Price's `lookup_key` in the /config endpoint
price_id = ""
if ("priceid" in diction.keys()):
if diction['priceid']:
price_id = diction['priceid']
try: try:
field_list_obligatoire = ['customerid', 'pack', 'qty']
for val in field_list_obligatoire:
if val not in diction:
mycommon.myprint(str(inspect.stack()[0][3]) + " - Impossible de créer la souscription La valeur '" + val + "' n'est pas presente dans liste ")
return False, " Impossible de créer le souscription. Toutes les données obligatoires ne sont pas fournies"
# Simulating authenticated user. Lookup the logged in user in your
# database, and set customer_id to the Stripe Customer ID of that user.
customer_id = ""
if ("customerid" in diction.keys()):
if diction['customerid']:
customer_id = diction['customerid']
pack = ""
if ("pack" in diction.keys()):
if diction['pack']:
pack = diction['pack']
price_id = ""
if( str(pack).lower() == "gold"):
price_id = MYSY_GV.STRIPE_GOLD_PRICE_ID
elif( str(pack).lower() == "standard"):
price_id = MYSY_GV.STRIPE_STANDARD_PRICE_ID
elif (str(pack).lower() == "test"):
price_id = MYSY_GV.STRIPE_TEST_PRICE_ID
qty = ""
if ("qty" in diction.keys()):
if diction['qty']:
qty = diction['qty']
local_status, new_int = mycommon.IsInt(qty)
if ( local_status is False ):
mycommon.myprint(str(inspect.stack()[0][
3]) + " - Impossible de realiser le souscription. La quantité n'est pas correcte")
return False, " - Impossible de realiser le souscription. La quantité n'est pas correcte"
# Extract the price ID from environment variables given the name
# of the price passed from the front end.
#
print(" ### price_id = ", price_id)
# Create the subscription. Note we're using # Create the subscription. Note we're using
# expand here so that the API will return the Subscription's related # expand here so that the API will return the Subscription's related
# latest invoice, and that latest invoice's payment_intent # latest invoice, and that latest invoice's payment_intent
@ -396,6 +444,7 @@ def create_subscription(diction):
customer=customer_id, customer=customer_id,
items=[{ items=[{
'price': price_id, 'price': price_id,
'quantity': qty,
}], }],
payment_behavior='default_incomplete', payment_behavior='default_incomplete',
expand=['latest_invoice.payment_intent'], expand=['latest_invoice.payment_intent'],