config.php 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. <?php
  2. /* Copyright (C) 2017 Alexandre Spangaro <aspangaro@open-dsi.fr>
  3. * Copyright (C) 2017 Saasprov <saasprov@gmail.com>
  4. * Copyright (C) 2017 Ferran Marcet <fmarcet@2byte.es.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 <https://www.gnu.org/licenses/>.
  18. *
  19. * Set Stripe environment: set the ApiKey and AppInfo
  20. */
  21. /**
  22. * \file htdocs/stripe/config.php
  23. * \ingroup Stripe
  24. * \brief Page to move config in api
  25. */
  26. require_once DOL_DOCUMENT_ROOT.'/includes/stripe/stripe-php/init.php';
  27. require_once DOL_DOCUMENT_ROOT.'/includes/stripe/stripe-php/lib/Stripe.php';
  28. //global $stripe;
  29. global $conf;
  30. global $stripearrayofkeysbyenv;
  31. $stripearrayofkeysbyenv = array(
  32. 0=>array(
  33. "secret_key" => empty($conf->global->STRIPE_TEST_SECRET_KEY) ? '' : $conf->global->STRIPE_TEST_SECRET_KEY,
  34. "publishable_key" => empty($conf->global->STRIPE_TEST_PUBLISHABLE_KEY) ? '' : $conf->global->STRIPE_TEST_PUBLISHABLE_KEY
  35. ),
  36. 1=>array(
  37. "secret_key" => empty($conf->global->STRIPE_LIVE_SECRET_KEY) ? '' : $conf->global->STRIPE_LIVE_SECRET_KEY,
  38. "publishable_key" => empty($conf->global->STRIPE_LIVE_PUBLISHABLE_KEY) ? '' : $conf->global->STRIPE_LIVE_PUBLISHABLE_KEY
  39. )
  40. );
  41. $stripearrayofkeys = array();
  42. if (empty($conf->global->STRIPE_LIVE) || GETPOST('forcesandbox', 'alpha')) {
  43. $stripearrayofkeys = $stripearrayofkeysbyenv[0]; // Test
  44. } else {
  45. $stripearrayofkeys = $stripearrayofkeysbyenv[1]; // Live
  46. }
  47. \Stripe\Stripe::setApiKey($stripearrayofkeys['secret_key']);
  48. \Stripe\Stripe::setAppInfo("Dolibarr Stripe", DOL_VERSION, "https://www.dolibarr.org"); // add dolibarr version
  49. \Stripe\Stripe::setApiVersion(empty($conf->global->STRIPE_FORCE_VERSION) ? "2020-08-27" : $conf->global->STRIPE_FORCE_VERSION); // force version API