Advertisement
Guest User

IPNPDF

a guest
Mar 18th, 2018
29
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 5.55 KB | None | 0 0
  1. <?php namespace Listener;
  2.  
  3. require('PaypalIPN.php');
  4.  
  5. use PaypalIPN;
  6.  
  7. $ipn = new PaypalIPN();
  8.  
  9. // Use the sandbox endpoint during testing.
  10. $ipn->useSandbox();
  11. $verified = $ipn->verifyIPN();
  12. if ($verified) {
  13.     ////////////////////////////////////////////////////////////////////////////////////////
  14.     ///////////////////////////////////////TEST PDF/////////////////////////////////////////
  15.     ////////////////////////////////////////////////////////////////////////////////////////
  16.  
  17. use \setasign\Fpdi;
  18.  
  19. // require_once('fpdf/fpdf.php');
  20. // require_once('fpdi2/src/autoload.php');
  21.  
  22. require_once('fpdf181/fpdf.php');
  23. require_once('fpdf181/fpdi/autoload.php');
  24.  
  25. // initiate FPDI
  26. $pdf = new Fpdi\Fpdi();
  27. // add a page
  28. $pdf->AddPage();
  29. // set the source file
  30. $pdf->setSourceFile("templatedoc.pdf");
  31. // import page 1
  32. $tplIdx = $pdf->importPage(1);
  33. // use the imported page and place it at point 10,10 with a width of 100 mm
  34. $pdf->useImportedPage($tplIdx, 10, 10, 100);
  35.  
  36. // now write some text above the imported page
  37. $pdf->SetFont('Helvetica');
  38. $pdf->SetTextColor(255, 0, 0);
  39. $pdf->SetXY(30, 30);
  40. $pdf->Write(0, 'This is just a simple text');
  41.  
  42. // $pdf->Output();
  43.  
  44. $dir = "/pdf/";
  45. $file = 'test.pdf';
  46. $dir_file = $dir.$file;
  47. $pdf->Output($dir_file,'F');
  48.  
  49.  
  50.  
  51.     ////////////////////////////////////////////////////////////////////////////////////////
  52.     ////////////////////////////MAIL DE CONFIRMATION A L'ACHETEUR///////////////////////////
  53.     ////////////////////////////////////////////////////////////////////////////////////////
  54.  
  55. $mail_From = "From: Equipe du Gala de l'IUT de Troyes <gala.iuttroyes2018@gmail.com>\r\n";
  56. $mail_From .= "MIME-Version: 1.0\r\n";
  57. $mail_From .= "Content-Type: text/html; charset=UTF-8\r\n";
  58. $mail_To = $_POST['payer_email'];
  59. $mail_Subject = "Confirmation de paiement";
  60. $message = '<html><body>';
  61. $message .= '
  62. <table style="width: 1355px; border-color: #080707;" border="10">
  63. <tbody>
  64. <tr style="border-color: #0d0b0b;">
  65. <td style="width: 1920px; background-color: #6b6969; text-align: center;"><img class="aligncenter  wp-image-365" src="http://gala-etudiants.iut-troyes.univ-reims.fr/wp-content/uploads/2018/02/blanc-sans-fond.png" alt="" width="394" height="238" /></td>
  66. </tr>
  67. </tbody>
  68. </table>
  69. <p>&nbsp;</p>
  70. <p><span style="font-size: 20px;"><strong>Cher '.$_POST['first_name'].'&nbsp;'.$_POST['last_name'].',</strong></span></p>
  71. <p>Votre commande a bien été prise en compte et vous recevrez sous 48 heures votre billet par mail.<br />N&#39;oubliez-pas de vous munir d&#39;une carte d&#39;identité et du billet imprimé lors de votre entrée au Gala sinon nous serons obligé de vous refuser!</p>
  72. <p>Pour plus d&#39;informations concernant le Gala, n&#39;hésitez pas à vous rendre aux liens suivants ci ce n&#39;est déjà fait:</p>
  73. <ul>
  74. <li>Accès: <a href="http://gala-etudiants.iut-troyes.univ-reims.fr/acces/">http://gala-etudiants.iut-troyes.univ-reims.fr/acces/</a></li>
  75. <li>Entrée: <a href="http://gala-etudiants.iut-troyes.univ-reims.fr/entree/">http://gala-etudiants.iut-troyes.univ-reims.fr/entree/</a></li>
  76. <li>Artistes: <a href="http://gala-etudiants.iut-troyes.univ-reims.fr/artistes/">http://gala-etudiants.iut-troyes.univ-reims.fr/artistes/</a></li>
  77. </ul>
  78. <p>Si vous avez des questions, n&#39;hésitez pas à nous envoyer un mail: Cliquez <a href="mailto:gala.iuttroyes2018@gmail.com">ICI</a></p>
  79. <p>Rendez-vous le 31 mars!</p>
  80. <p>   - L&#39;Equipe de l&#39;edition 2018 du Gala de l&#39;IUT de Troyes</p>
  81. <hr />
  82. <p><strong>Reçu de Commande Numéro:&nbsp;</strong>'.$_POST['receipt_ID'].'</p>
  83. <p>&nbsp;</p>
  84. <table style="width: 408px;">
  85. <tbody>
  86. <tr>
  87. <td style="width: 267px;">Nom</td>
  88. <td style="width: 149px;">'.$_POST['last_name'].'</td>
  89. </tr>
  90. <tr>
  91. <td style="width: 267px;">Prénom</td>
  92. <td style="width: 149px;">'.$_POST['first_name'].'</td>
  93. </tr>
  94. <tr>
  95. <td style="width: 267px;">Numéro de Commande</td>
  96. <td style="width: 149px;">'.$_POST['txn_id'].'</td>
  97. </tr>
  98. <tr>
  99. <td style="width: 267px;">Produit</td>
  100. <td style="width: 149px;">'.$_POST['item_name1'].'</td>
  101. </tr>
  102. <tr>
  103. <td style="width: 267px;">Quantité </td>
  104. <td style="width: 149px;">'.$_POST['quantity'].'</td>
  105. </tr>
  106. <tr>
  107. <td style="width: 267px;"> </td>
  108. <td style="width: 149px;"> </td>
  109. </tr>
  110. <tr>
  111. <td style="width: 267px;">Total</td>
  112. <td style="width: 149px;">'.$_POST['mc_gross'].'</td>
  113. </tr>
  114. </tbody>
  115. </table>
  116. ';
  117. $message .= '</body></html>';
  118.  
  119.  
  120. mail($mail_To, $mail_Subject, $message, $mail_From);
  121.  
  122. /////////////////////////////////////////////////////////////////////////
  123. /////////////////INSCRIPTION DANS BDD DES INFOS POUR LOGS////////////////
  124. /////////////////////////////////////////////////////////////////////////
  125. $servername = "xxxx";
  126. $username = "xxxx";
  127. $password = "xxxx";
  128. $dbname = "xxxx";
  129.  
  130. // Create connection
  131. $conn = mysqli_connect($servername, $username, $password, $dbname);
  132. // Check connection
  133. if (!$conn) {
  134.     die("Connection failed: " . mysqli_connect_error());
  135. }
  136.  
  137. $sql = "INSERT INTO xxxx (nom, prenom, email, numcommande, numrecu, produit, quantite, heureprocess)
  138. VALUES (
  139. '".$_POST['last_name']."',
  140. '".$_POST['first_name']."',
  141. '".$_POST['payer_email']."',
  142. '".$_POST['txn_id']."',
  143. '".$_POST['receipt_ID']."',
  144. '".$_POST['item_name1']."',
  145. '".$_POST['quantity']."',
  146. '".$_POST['payment_date']."'
  147. )";
  148.  
  149. if (mysqli_query($conn, $sql)) {
  150.     echo "New record created successfully";
  151. } else {
  152.     echo "Error: " . $sql . "<br>" . mysqli_error($conn);
  153. }
  154.  
  155. mysqli_close($conn);
  156.  
  157. }
  158.  
  159. // Reply with an empty 200 response to indicate to paypal the IPN was received correctly.
  160. header("HTTP/1.1 200 OK");
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement