131 lines
4.7 KiB
PHP
Executable File
131 lines
4.7 KiB
PHP
Executable File
<?php
|
|
$nomFicAppelant = basename(__FILE__);
|
|
// -----------------------------------------------------
|
|
// 1 - recup idClient 123clients
|
|
// -----------------------------------------------------
|
|
if ( !isset($_SESSION['idClient123']) || empty($_SESSION['idClient123']) ) include ($includePathAdmin. "/req/reqRecupClient123.php");
|
|
|
|
// -----------------------------------------------------
|
|
// Recup description
|
|
// -----------------------------------------------------
|
|
$desc=$_SESSION['desc'];
|
|
|
|
// -----------------------------------------------------
|
|
// Recup profil
|
|
// -----------------------------------------------------
|
|
switch ($_SESSION['cliOpt']) {
|
|
// case 1:
|
|
// case 2:
|
|
// $comment='Profil gestionnaire';
|
|
// $idProfil=1;
|
|
// break;
|
|
|
|
// case 3:
|
|
// case 4:
|
|
// $comment='Profil webmaster';
|
|
// $idProfil=2;
|
|
// break;
|
|
|
|
// case 5:
|
|
// case 6:
|
|
// $comment='Profil expert';
|
|
// $idProfil=3;
|
|
// break;
|
|
|
|
default:
|
|
$comment='Profil gestionnaire';
|
|
$idProfil=6;
|
|
break;
|
|
}
|
|
|
|
// -----------------------------------------------------
|
|
// Retrouver le subscription ID pour le mettre en base ( pas reussi à le faire directement dans le checkout, mais marche ici )
|
|
// -----------------------------------------------------
|
|
|
|
require 'vendor/autoload.php';
|
|
|
|
// recup cles api
|
|
$niveau=1;
|
|
include ("./profils/clesStripe/stripePKSProfil.php");
|
|
|
|
|
|
// recup subscription
|
|
$stripe = new \Stripe\StripeClient($privateSecretStripe);
|
|
try {
|
|
$response= $stripe->checkout->sessions->retrieve($_SESSION['checkOutSession_id']);
|
|
if (isset($debug[2]) && $debug[2] == '1') $debugMsg .= monDebug(2, ['reponse' => $response], '');
|
|
|
|
$stripePaiement_id=$response->id;
|
|
$_SESSION['stripePaiement_id']=$stripePaiement_id;
|
|
if (isset($debug[2]) && $debug[2] == '1' ) $debugMsg .= monDebug (2, ['stripePaiement_id' => $stripePaiement_id ],'');
|
|
|
|
$stripeSubscription_id=$response->subscription;
|
|
$_SESSION['stripeSubscription_id']=$stripeSubscription_id;
|
|
if (isset($debug[2]) && $debug[2] == '1' ) $debugMsg .= monDebug (2, ['stripeSubscription_id' => $stripeSubscription_id ],'');
|
|
|
|
$custId=$response->client_reference_id;
|
|
$cust=$response->customer;
|
|
$_SESSION['custId']=$cust;
|
|
if (isset($debug[2]) && $debug[2] == '1') $debugMsg .= monDebug(2, ['cust' => $cust], '');
|
|
}
|
|
catch(Exception $e) {
|
|
$api_error = $e->getMessage();
|
|
if (isset($debug[2]) && $debug[2] == '1') { $debugMsg .= monDebug(2, ['api_error' => $api_error ], '');}
|
|
}
|
|
|
|
// -----------------------------------------------------
|
|
// Recupérer le prix
|
|
// -----------------------------------------------------
|
|
$reqSelect="SELECT prixTTC FROM `123modules` WHERE idModule=1 AND idOption=" .$_SESSION['cliOpt']. " ;";
|
|
if (isset($debug[2]) && $debug[2] == '1') { $debugMsg .= monDebug(2, ['reqSelect' => $reqSelect], 'reqUpdateProfil.php');}
|
|
$resConn=$connexion->query($reqSelect);
|
|
if ($resConn) {
|
|
while ($tabResult = $resConn->fetch(PDO::FETCH_ASSOC)) {
|
|
$prixTTC=$tabResult['prixTTC'];
|
|
}
|
|
}
|
|
|
|
// -----------------------------------------------------
|
|
// Mettre à jour la DB client
|
|
// -----------------------------------------------------
|
|
$today = date("Y-n-j");
|
|
$next = date('Y-m-d', strtotime('+1 month', strtotime($today)) );
|
|
|
|
$reqUpdate="UPDATE `123projets` SET is_payed=1, ";
|
|
$reqUpdate .= "prix='" .$prixTTC. "', ";
|
|
$reqUpdate .= "param1='" .$_SESSION['cliOpt']. "', ";
|
|
$reqUpdate .= "param2='" .$idProfil. "', ";
|
|
$reqUpdate .= "stripeSubscription_id='" .$stripeSubscription_id. "', ";
|
|
$reqUpdate .= "stripePaiement_id='" .$stripePaiement_id. "', ";
|
|
$reqUpdate .= "stripeClient_id='" .$cust. "', ";
|
|
$reqUpdate .= "statut='actif', ";
|
|
$reqUpdate .= "dateAchat='" .$today. "', ";
|
|
$reqUpdate .= "dateRenouvellement='" .$next. "', ";
|
|
$reqUpdate .= "description='" .$desc. "', ";
|
|
$reqUpdate .= "commentaire='" .$comment. "', ";
|
|
$reqUpdate .= "jsonReponse='" .$response. "' ";
|
|
$reqUpdate .= "WHERE idClient=" .$idClient123. " AND idModule=1;";
|
|
|
|
if (isset($debug[2]) && $debug[2] == '1') { $debugMsg .= monDebug(2, ['Req update profil' => $reqUpdate], 'reqUpdateProfil.php');}
|
|
$resConn=$connexion->query($reqUpdate);
|
|
if ($resConn) {
|
|
$admMsg .= 'Mise à jour du profil ok';
|
|
}
|
|
else {
|
|
$admMsg .= 'Echec de la mise à jour du profil';
|
|
}
|
|
|
|
// -----------------------------------------------------
|
|
// Version SMS free API
|
|
// -----------------------------------------------------
|
|
setlocale (LC_TIME, 'fr_FR.utf8','fra');
|
|
$msg= "Nouvel abonnement 123ventes : " .$_SESSION['nomSiteAff']. ' - ' .$desc ;
|
|
include ("smsFree.php");
|
|
if (isset($debug[2]) && $debug[2] == '1' ) echo $output;
|
|
|
|
// -----------------------------------------------------
|
|
// Make facture
|
|
// -----------------------------------------------------
|
|
$idModule=1; // pour reqUdateFacture
|
|
include ("./extensions/makeFact/chapeauMakeFacture.php");
|
|
?>
|