paymentko.php 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. <?php
  2. /* Copyright (C) 2001-2002 Rodolphe Quiedeville <rodolphe@quiedeville.org>
  3. * Copyright (C) 2006-2009 Laurent Destailleur <eldy@users.sourceforge.net>
  4. * Copyright (C) 2012 Regis Houssin <regis.houssin@capnetworks.com>
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation; either version 3 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  18. */
  19. /**
  20. * \file htdocs/public/paypal/paymentko.php
  21. * \ingroup paypal
  22. * \brief File to show page after a failed payment.
  23. * This page is called by paypal with url provided to payal competed with parameter TOKEN=xxx
  24. * This token can be used to get more informations.
  25. * \author Laurent Destailleur
  26. */
  27. define("NOLOGIN",1); // This means this output page does not require to be logged.
  28. define("NOCSRFCHECK",1); // We accept to go on this page from external web site.
  29. // For MultiCompany module
  30. $entity=(! empty($_GET['entity']) ? (int) $_GET['entity'] : (! empty($_POST['entity']) ? (int) $_POST['entity'] : 1));
  31. if (is_int($entity))
  32. {
  33. define("DOLENTITY", $entity);
  34. }
  35. require '../../main.inc.php';
  36. require_once DOL_DOCUMENT_ROOT.'/paypal/lib/paypal.lib.php';
  37. require_once DOL_DOCUMENT_ROOT.'/paypal/lib/paypalfunctions.lib.php';
  38. require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
  39. // Security check
  40. if (empty($conf->paypal->enabled)) accessforbidden('',1,1,1);
  41. $langs->load("main");
  42. $langs->load("other");
  43. $langs->load("dict");
  44. $langs->load("bills");
  45. $langs->load("companies");
  46. $langs->load("paybox");
  47. $langs->load("paypal");
  48. /*
  49. * Actions
  50. */
  51. /*
  52. * View
  53. */
  54. dol_syslog("Callback url when a PayPal payment was canceled. query_string=".(empty($_SERVER["QUERY_STRING"])?'':$_SERVER["QUERY_STRING"])." script_uri=".(empty($_SERVER["SCRIPT_URI"])?'':$_SERVER["SCRIPT_URI"]), LOG_DEBUG, 0, '_paypal');
  55. $tracepost = "";
  56. foreach($_POST as $k => $v) $tracepost .= "{$k} - {$v}\n";
  57. dol_syslog("POST=".$tracepost, LOG_DEBUG, 0, '_paypal');
  58. // Send an email
  59. if (! empty($conf->global->MEMBER_PAYONLINE_SENDEMAIL) && preg_match('/MEM=/',$fulltag))
  60. {
  61. $sendto=$conf->global->MEMBER_PAYONLINE_SENDEMAIL;
  62. $from=$conf->global->MAILING_EMAIL_FROM;
  63. require_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php';
  64. $mailfile = new CMailFile(
  65. 'New subscription payed',
  66. $sendto,
  67. $from,
  68. 'New subscription payed '.$fulltag
  69. );
  70. $result=$mailfile->sendfile();
  71. if ($result)
  72. {
  73. dol_syslog("EMail sent to ".$sendto, LOG_DEBUG, 0, '_paypal');
  74. }
  75. else
  76. {
  77. dol_syslog("Failed to send EMail to ".$sendto, LOG_ERR, 0, '_paypal');
  78. }
  79. }
  80. llxHeaderPaypal($langs->trans("PaymentForm"));
  81. // Show ko message
  82. print '<span id="dolpaymentspan"></span>'."\n";
  83. print '<div id="dolpaymentdiv" align="center">'."\n";
  84. print $langs->trans("YourPaymentHasNotBeenRecorded")."<br>";
  85. $PAYPALTOKEN=GETPOST('TOKEN');
  86. if (empty($PAYPALTOKEN)) $PAYPALTOKEN=GETPOST('token');
  87. $PAYPALFULLTAG=GETPOST('FULLTAG');
  88. if (empty($PAYPALFULLTAG)) $PAYPALFULLTAG=GETPOST('fulltag');
  89. if (! empty($conf->global->PAYPAL_MESSAGE_KO)) print $conf->global->PAYPAL_MESSAGE_KO;
  90. print "\n</div>\n";
  91. html_print_paypal_footer($mysoc,$langs);
  92. llxFooterPaypal();
  93. $db->close();
  94. ?>