paypalfunctions.lib.php 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. <?php
  2. /* Copyright (C) 2010-2011 Laurent Destailleur <eldy@users.sourceforge.org>
  3. * Copyright (C) 2011 Regis Houssin <regis.houssin@inodbox.com>
  4. *
  5. * This program is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation; either version 3 of the License, or
  8. * (at your option) any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with this program. If not, see <https://www.gnu.org/licenses/>.
  17. */
  18. /**
  19. * \file htdocs/paypal/lib/paypalfunctions.lib.php
  20. * \ingroup paypal
  21. * \brief Page with Paypal init var.
  22. */
  23. if (session_id() == "") {
  24. session_start();
  25. if (ini_get('register_globals')) { // To solve bug in using $_SESSION
  26. foreach ($_SESSION as $key => $value) {
  27. if (isset($GLOBALS[$key])) {
  28. unset($GLOBALS[$key]);
  29. }
  30. }
  31. }
  32. }
  33. // ==================================
  34. // PayPal Express Checkout Module
  35. // ==================================
  36. $API_version = "56";
  37. /*
  38. ' Define the PayPal Redirect URLs.
  39. ' This is the URL that the buyer is first sent to do authorize payment with their paypal account
  40. ' change the URL depending if you are testing on the sandbox or the live PayPal site
  41. '
  42. ' For the sandbox, the URL is https://www.sandbox.paypal.com/webscr&cmd=_express-checkout&token=
  43. ' For the live site, the URL is https://www.paypal.com/webscr&cmd=_express-checkout&token=
  44. */
  45. if (!empty($conf->global->PAYPAL_API_SANDBOX) || GETPOST('forcesandbox', 'alpha')) { // We can force sand box with param 'forcesandbox'
  46. $API_Endpoint = "https://api-3t.sandbox.paypal.com/nvp";
  47. $API_Url = "https://www.sandbox.paypal.com/webscr?cmd=_express-checkout&token=";
  48. } else {
  49. $API_Endpoint = "https://api-3t.paypal.com/nvp";
  50. $API_Url = "https://www.paypal.com/cgi-bin/webscr?cmd=_express-checkout&token=";
  51. }
  52. // Clean parameters
  53. $PAYPAL_API_USER = "";
  54. if (!empty($conf->global->PAYPAL_API_USER)) {
  55. $PAYPAL_API_USER = $conf->global->PAYPAL_API_USER;
  56. }
  57. $PAYPAL_API_PASSWORD = "";
  58. if (!empty($conf->global->PAYPAL_API_PASSWORD)) {
  59. $PAYPAL_API_PASSWORD = $conf->global->PAYPAL_API_PASSWORD;
  60. }
  61. $PAYPAL_API_SIGNATURE = "";
  62. if (!empty($conf->global->PAYPAL_API_SIGNATURE)) {
  63. $PAYPAL_API_SIGNATURE = $conf->global->PAYPAL_API_SIGNATURE;
  64. }
  65. $PAYPAL_API_SANDBOX = "";
  66. if (!empty($conf->global->PAYPAL_API_SANDBOX)) {
  67. $PAYPAL_API_SANDBOX = $conf->global->PAYPAL_API_SANDBOX;
  68. }
  69. // Proxy
  70. $PROXY_HOST = $conf->global->MAIN_PROXY_HOST;
  71. $PROXY_PORT = $conf->global->MAIN_PROXY_PORT;
  72. $PROXY_USER = $conf->global->MAIN_PROXY_USER;
  73. $PROXY_PASS = $conf->global->MAIN_PROXY_PASS;
  74. $USE_PROXY = empty($conf->global->MAIN_PROXY_USE) ?false:true;