| Current Path : /home/happyrenas/old/happy-r.fr/transfere_pro/mangopay/ |
Linux webd005.cluster105.gra.hosting.ovh.net 5.15.206-ovh-vps-grsec-zfs-classid #1 SMP Fri May 15 02:41:25 UTC 2026 x86_64 |
| Current File : /home/happyrenas/old/happy-r.fr/transfere_pro/mangopay/paiement_simple_verification.php |
<?php
session_start();
error_reporting(E_ALL);
//ini_set('display_errors','On');
require_once 'MangoPay/mangoPayApi.inc';
define('MangoPayDemo_ClientId', 'philippe2015');
define('MangoPayDemo_ClientPassword', 'hK15oQKQig9N2UFEXQpCoirptU4VTeU28p0CTyiprt0fQuwFPP');
define('MangoPayDemo_ReturnURL', 'https://www.happy-r.fr/mangopay/paiement_simple_verification.php');
define('MangoPayDemo_TemporaryFolder', 'temp');
define('db_name', 'happyrenashappy');
define('db_user', 'happyrenashappy');
define('db_password', 'K4Pli74zZfv');
define('db_host', 'happyrenashappy.mysql.db');
include("../includes/ez_sql_core.php");
include("../includes/ez_sql_mysqli.php");
$db = new ezSQL_mysqli(db_user,db_password,db_name,db_host);
?>
<!doctype html>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr">
<head>
<title>Module de paiement en ligne</title>
<meta name='description' content=""/>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<link rel="icon" href="images/icone.ico"/>
<!--[if lt IE 9]>
<script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<link rel="stylesheet" href="design.css" type="text/css" media="screen" />
<script type="text/javascript" src="js/prefixfree.js"></script>
</head>
<body>
<header>
</header>
<section id="main-content">
<p id="top"></p>
<div>
<div id="bloc-paiement">
<p class="font11">
<?
$myquery = "SELECT * from client_reservation where id =".$_SESSION['reservation_id'];
$reservation = $db->get_row($myquery);
$reservation_id = $reservation->id;
$date1 = $reservation->date_debut;
$date2 = $reservation->date_fin;
$proprietaire_mail = $reservation->proprietaire_mail;
$myquery = "SELECT * from client where id =".$_SESSION['client_id'];
$client = $db->get_row($myquery);
if (!isset($_SESSION['montant'])) {die('<div style="color:red;">No payment has been started<div>');}
$mangoPayApi = new \MangoPay\MangoPayApi();
$mangoPayApi->Config->ClientId = MangoPayDemo_ClientId;
$mangoPayApi->Config->ClientPassword = MangoPayDemo_ClientPassword;
$mangoPayApi->Config->TemporaryFolder = MangoPayDemo_TemporaryFolder;
$mangoPayApi->Config->BaseUrl = 'https://api.mangopay.com';
try {
$cardRegister = $mangoPayApi->CardRegistrations->Get($_SESSION['cardRegisterId']);
$cardRegister->RegistrationData = isset($_GET['data']) ? 'data=' . $_GET['data'] : 'errorCode=' . $_GET['errorCode'];
$updatedCardRegister = $mangoPayApi->CardRegistrations->Update($cardRegister);
if ($updatedCardRegister->Status != 'VALIDATED' || !isset($updatedCardRegister->CardId))
die('<div style="color:red;">Erreur<div>');
$card = $mangoPayApi->Cards->Get($updatedCardRegister->CardId);
$wallet = new \MangoPay\Wallet();
$wallet->Owners = array( $updatedCardRegister->UserId );
$wallet->Currency = $_SESSION['currency'];
$wallet->Description = 'Paiement';
$createdWallet = $mangoPayApi->Wallets->Create($wallet);
$payIn = new \MangoPay\PayIn();
$payIn->CreditedWalletId = $createdWallet->Id;
$payIn->AuthorId = $updatedCardRegister->UserId;
$payIn->DebitedFunds = new \MangoPay\Money();
$payIn->DebitedFunds->Amount = $_SESSION['montant'];
$payIn->DebitedFunds->Currency = $_SESSION['currency'];
$payIn->Fees = new \MangoPay\Money();
$payIn->Fees->Amount = $_SESSION['commission'];
$payIn->Fees->Currency = $_SESSION['currency'];
$payIn->PaymentDetails = new \MangoPay\PayInPaymentDetailsCard();
$payIn->PaymentDetails->CardType = $card->CardType;
$payIn->ExecutionDetails = new \MangoPay\PayInExecutionDetailsDirect();
$payIn->ExecutionDetails->CardId = $card->Id;
$payIn->ExecutionDetails->SecureModeReturnURL = "https://www.happy-r.fr/mangopay/paiement_simple_verification_3ds.php";
$payIn->ExecutionDetails->ReturnURL = MangoPayDemo_ReturnURL;
$createdPayIn = $mangoPayApi->PayIns->Create($payIn);
if ($createdPayIn->Status == 'SUCCEEDED')
{
print '<div style="color:green;">'.
'Votre paiement a été validé.<br> '
.'Pay-In Id = ' . $createdPayIn->Id
. '<br> Wallet Id = ' . $createdWallet->Id
. ' <br> Transaction : '.$_SESSION['reservation_id'].'<br><br><a style="color:black" href="http://www.happy-r.fr/"> Retour au site</a> </div>';
require_once('../includes/class.phpmailer.php');
require_once('../includes/class.smtp.php');
//CLIENT
include('tpl_client.php');
$objet="Confirmation paiement";
$from = "contact@happy-r.fr";
$destinataire = "phil_aph@hotmail.com";
$reply = $from;
$mail = new PHPmailer();
$mail->SMTPDebug = 0;
$mail->CharSet = "UTF-8";
$mail->IsHTML(true);
$mail->From=$from;
$mail->AddAddress($destinataire);
$mail->AddReplyTo($reply);
$mail->Subject=$objet;
$mail->Body=$message;
if(!$mail->Send())
{echo $mail->ErrorInfo;}
else{echo '';}
unset($mail);
//PROPRIETAIRE
include('tpl_proprietaire.php');
$objet="Confirmation paiement";
$from = "contact@happy-r.fr";
$destinataire = "phil_aph@hotmail.com";
$reply = $from;
$mail = new PHPmailer();
$mail->SMTPDebug = 0;
$mail->CharSet = "UTF-8";
$mail->IsHTML(true);
$mail->From=$from;
$mail->AddAddress($destinataire);
$mail->AddReplyTo($reply);
$mail->Subject=$objet;
$mail->Body=$message;
if(!$mail->Send())
{echo $mail->ErrorInfo;}
else{echo '';}
unset($mail);
$payment_id_date = date("Y-m-d H:i:s");
$payment_id_date = date("Y-m-d", strtotime($payment_id_date));
$payment_id_montant = $_SESSION['montant']/100;
$payment_id_commission = $_SESSION['commission']/100;
$requete="UPDATE client_reservation set statut ='4', payment_id='".$createdPayIn->Id."', payment_id_date='".$payment_id_date."', payment_id_montant='".$payment_id_montant."', payment_id_commission='".$payment_id_commission."', createdWallet='".$createdWallet->Id."' where id =".$_SESSION['reservation_id'];
echo $requete;
$db->query($requete);
}
//AJOUT 3DSECURE
elseif ($createdPayIn->ExecutionDetails->SecureModeNeeded && $createdPayIn->Status!="FAILED")
{
header("Location: ".$createdPayIn->ExecutionDetails->SecureModeRedirectURL);//after the 3DS step, they will be redirected to the $createdPayIn→ExecutionDetails→SecureModeReturnURL whether the 3DS step was successfull or not
//die();
}
//FIN AJOUT 3DSECURE
else {
print '<div style="color:red;">'.
'Pay-In has been created with status: '
. $createdPayIn->Status . ' (result code: '
. $createdPayIn->ResultCode . ')'
.'</div>';
}
} catch (\MangoPay\ResponseException $e) {
print '<div style="color: red;">'
.'\MangoPay\ResponseException: Code: '
. $e->getCode() . '<br/>Message: ' . $e->getMessage()
.'<br/><br/>Details: '; print_r($e->GetErrorDetails())
.'</div>';
}
// clear data in session to protect against double processing
//session_unset();session_destroy();
//$_SESSION['passage'] = $createdPayIn->Id;
?>
</p>
</div>
</div>
</section>
<footer>
<div>
<p>
<br/><br/>
© Copyright 2014 - Happy Rentals - Tous droits réservés - Marque déposée<br/>
Happy R protège les clients des faux propriétaires ou de personnes qui usurpent l'identité de vrai propriétaire.
</p>
</div>
</footer>
</body>
<!-- SCRIPTS -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js" type="text/javascript"></script>
<script src="js/smoothscroll.js"></script>
<script type="text/javascript">
function inputFocus(input) {
if(input.value==input.defaultValue) {
input.value = '';
}
}
function inputBlur(input) {
if(input.value=='') {
input.value = input.defaultValue;
}
}
</script>
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-89044331-2', 'auto');
ga('send', 'pageview');
</script>
</html>