For seeing that page, you have to follow the payment process, but you can cancel the payment once you’re in the bank portal, it will redirect you to the page where the mails are sent.
]]><?php
session_start();
$nom = isset($_SESSION['nom']) ? $_SESSION['nom'] : '';
require_once('Mercanet.php');
// Initialisation de la classe Mercanet avec passage en parametre de la cle secrete
$paymentResponse = new Mercanet('002001000000001_KEY1');
$paymentResponse->setResponse($_POST);
?>
<?php $mts_options = get_option(MTS_THEME_NAME); ?>
<?php get_header(); ?>
<div id="page" class="single">
<div class="container">
<article class="<?php mts_article_class(); ?>">
<div id="content_box" class="panel">
<?php
if($paymentResponse->isValid() && $paymentResponse->isSuccessful()){
// Traitement pour les paiements valides
echo "paiement reussi ";
$emailTo = '[email protected]';
$subject = 'Paiement de la facture';
/*$sendCopy = trim($_POST['sendCopy']);*/
$body = "paiement accepté $nom";
$headers .= "Content-Type: text/plain; charset=UTF-8\n";
$headers .= "Content-Transfer-Encoding: 8bit\n";
}
else{
// Traitement pour les paiements en echec
echo "paiement en echec ";
$emailTo = '[email protected]';
$subject = 'Paiement de la facture';
/*$sendCopy = trim($_POST['sendCopy']);*/
$body = "paiement echec $nom";
$headers .= "Content-Type: text/plain; charset=UTF-8\n";
$headers .= "Content-Transfer-Encoding: 8bit\n";
}
if (is_page() && $nom != '') {
wp_mail($emailTo, $subject, $body, $headers);
}
?>
</div>
</article>
</div>
</div>
<?php get_footer();
session_destroy();
?>
Hopefully, this should send a single email only.
]]>The $nom variable verification is simple and smart, I searched too complicated solution.
Anyway, I had to unset the is_page() in the if, the $nom != ” is enought to block the twice sending.
Thanks a lot !
]]>