| Current Path : /home/happyrenas/old/happy-r.fr/transfere_pro/mangopay/OLD/ |
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/OLD/payment.php |
<?php
session_start();
$page='paiement';
// include MangoPay SDK
require_once 'MangoPay/mangoPayApi.inc';
require_once 'config.php';
include("../config.php");
?>
<!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">
<?
if ($_SESSION['reservation_id'])
{
$myquery = "SELECT * from reservation where id =".$_SESSION['reservation_id'];
$laresa = $db->get_row($myquery);
$id_du_logement=$laresa->id_logement;
$date1=$laresa->date1;
$date2=$laresa->date2;
$id_proprietaire=$laresa->id_proprietaire;
$myquery = "SELECT * from proprietaire where id=".$id_proprietaire;
$leproprietaire = $db->get_row($myquery);
$proprietaire_mail=$leproprietaire->mail;
$myquery = "SELECT * from logement where id =".$id_du_logement;
$lelogement = $db->get_row($myquery);
$nom_logement=$lelogement->label;
$nom_logement=utf8_decode($nom_logement);
}
echo $proprietaire_mail;
//exit;
// check if payment has been initialized
if (!isset($_SESSION['amount'])) {
die('<div style="color:red;">No payment has been started<div>');
}
// create instance of MangoPayApi
$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 {
// update register card with registration data from Payline service
$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;">Cannot create virtual card. Payment has not been created.<div>');
// get created virtual card object
$card = $mangoPayApi->Cards->Get($updatedCardRegister->CardId);
// create temporary wallet for user
$wallet = new \MangoPay\Wallet();
$wallet->Owners = array( $updatedCardRegister->UserId );
$wallet->Currency = $_SESSION['currency'];
$wallet->Description = 'Temporary wallet for payment demo';
$createdWallet = $mangoPayApi->Wallets->Create($wallet);
// create pay-in CARD DIRECT
$payIn = new \MangoPay\PayIn();
$payIn->CreditedWalletId = $createdWallet->Id;
$payIn->AuthorId = $updatedCardRegister->UserId;
$payIn->DebitedFunds = new \MangoPay\Money();
$payIn->DebitedFunds->Amount = $_SESSION['amount'];
$payIn->DebitedFunds->Currency = $_SESSION['currency'];
$payIn->Fees = new \MangoPay\Money();
//$payIn->Fees->Amount = 0;
$payIn->Fees->Amount = $_SESSION['commission'];
$payIn->Fees->Currency = $_SESSION['currency'];
// payment type as CARD
$payIn->PaymentDetails = new \MangoPay\PayInPaymentDetailsCard();
$payIn->PaymentDetails->CardType = $card->CardType;
// execution type as DIRECT
$payIn->ExecutionDetails = new \MangoPay\PayInExecutionDetailsDirect();
$payIn->ExecutionDetails->CardId = $card->Id;
$payIn->ExecutionDetails->SecureModeReturnURL = "https://www.happy-r.fr/administration/templates/admin2/mp-integre-prod/3dsecure.php";
$payIn->ExecutionDetails->ReturnURL = MangoPayDemo_ReturnURL;
// create Pay-In
$createdPayIn = $mangoPayApi->PayIns->Create($payIn);
// if created Pay-in object has status SUCCEEDED it's mean that all is fine
if ($createdPayIn->Status == 'SUCCEEDED') {
print '<div style="color:green;">'.
'Votre paiement a été validé. '
//.'Pay-In Id = ' . $createdPayIn->Id
//. ', Wallet Id = ' . $createdWallet->Id
. ' (macommande: '.$_SESSION['macommande'].')</div>';
// ENVOI DU MAIL DE VALIDATION AU PROPRIETAIRE//
//////////////////
require "../includes/class.phpmailer.php";
if ($_SESSION['reservation_id'])
{
$myquery = "SELECT * from reservation where id =".$_SESSION['reservation_id'];
$laresa = $db->get_row($myquery);
$id_du_logement=$laresa->id_logement;
$date1=$laresa->date1;
$date2=$laresa->date2;
$client_mail=$laresa->mail;
$myquery = "SELECT * from logement where id =".$id_du_logement;
$lelogement = $db->get_row($myquery);
$nom_logement=$lelogement->label;
$nom_logement=utf8_decode($nom_logement);
/* AJOUT 15/02/2016*/
$myquery = "SELECT * from proprietaire where id=".$lelogement->id_proprietaire;
$leproprietaire = $db->get_row($myquery);
$proprietaire_mail=$leproprietaire->mail;
$proprietaire_nom=$leproprietaire->nom;
$proprietaire_prenom=$leproprietaire->prenom;
/* FIN AJOUT 15/02/2016*/
include('mailing_template_paiement_proprietaire.php');
$objet="Confirmation paiement ".$nom_logement." du ".date("j-m-Y", strtotime($date1))." au ".date("j-m-Y", strtotime($date2));
$from="contact@happy-r.fr";
$to_1=$proprietaire_mail;
$reply=$nom_du_mail;
$mail = new PHPmailer();
$mail->IsHTML(true);
$mail->From=$from;
$mail->AddAddress($to_1);
$mail->AddBCC("resa@happy-r.fr");
$mail->AddReplyTo($reply);
$mail->Subject=$objet;
$mail->Body=$message;
if(!$mail->Send())
{echo $mail->ErrorInfo;}
else{echo '';}
unset($mail);
}
if ($_SESSION['reservation_id'])
{
// ENVOI DU MAIL DE VALIDATION AU CLIENT//
//////////////////
$lien=$nom_de_domaine."/administration/templates/admin2/contrat.php?reservation_id=".$_SESSION['reservation_id'];
$signature = $_SESSION['proprietaire_prenom']." ".$_SESSION['proprietaire_nom'];
$myquery = "SELECT * from reservation where id =".$_SESSION['reservation_id'];
$laresa = $db->get_row($myquery);
$id_du_logement=$laresa->id_logement;
$date1=$laresa->date1;
$date2=$laresa->date2;
$client_mail=$laresa->mail;
$myquery = "SELECT * from logement where id =".$id_du_logement;
$lelogement = $db->get_row($myquery);
$nom_logement=$lelogement->label;
$nom_logement=utf8_decode($nom_logement);
/* AJOUT 15/02/2016*/
$myquery = "SELECT * from proprietaire where id=".$lelogement->id_proprietaire;
$leproprietaire = $db->get_row($myquery);
$proprietaire_mail=$leproprietaire->mail;
$proprietaire_nom=$leproprietaire->nom;
$proprietaire_prenom=$leproprietaire->prenom;
/* FIN AJOUT 15/02/2016*/
include('mailing_template_paiement_client.php');
$objet="Confirmation paiement ".$nom_logement." du ".date("j-m-Y", strtotime($date1))." au ".date("j-m-Y", strtotime($date2));
$from="contact@happy-r.fr";
$to_1=$client_mail;
$reply=$nom_du_mail;
$mail = new PHPmailer();
$mail->IsHTML(true);
$mail->From=$from;
$mail->AddAddress($to_1);
$mail->AddBCC("resa@happy-r.fr");
$mail->AddReplyTo($reply);
$mail->Subject=$objet;
$mail->Body=$message;
if(!$mail->Send())
{echo $mail->ErrorInfo;}
else{echo '';}
unset($mail);
}
// MISE A JOUR BDD
if ($_SESSION['reservation_id'])
{
$requete="UPDATE reservation set statut ='4', paymentid='".$createdPayIn->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 {
// if created Pay-in object has status different than SUCCEEDED
// that occurred error and display error message
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
$proprietaire_mail = $_SESSION['proprietaire_mail'];
$client_mail = $_SESSION['client_mail'];
$proprietaire_prenom = $_SESSION['proprietaire_prenom'];
$proprietaire_nom = $_SESSION['proprietaire_nom'];
$reservation_id = $_SESSION['reservation_id'];
$macommande = $_SESSION['macommande'];
$_SESSION = array();
$_SESSION['proprietaire_mail'] = $proprietaire_mail;
$_SESSION['client_mail'] = $client_mail;
$_SESSION['proprietaire_prenom'] = $proprietaire_prenom;
$_SESSION['proprietaire_nom'] = $proprietaire_nom;
$_SESSION['reservation_id'] = $reservation_id;
$_SESSION['macommande'] = $macommande;
$_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>
</html>