dolibarr/htdocs/stripe/config.php

56 lines
2.3 KiB
PHP
Raw Normal View History

2017-04-18 05:44:08 +02:00
<?php
2019-01-28 21:39:22 +01:00
/* Copyright (C) 2017 Alexandre Spangaro <aspangaro@open-dsi.fr>
2017-04-22 06:58:44 +02:00
* Copyright (C) 2017 Saasprov <saasprov@gmail.com>
2017-09-21 12:06:43 +02:00
* Copyright (C) 2017 Ferran Marcet <fmarcet@2byte.es.com>
2017-04-18 05:44:08 +02:00
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
2019-09-23 21:55:30 +02:00
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
* Set Stripe environment: set the ApiKey and AppInfo
2017-04-18 05:44:08 +02:00
*/
2017-04-22 06:58:44 +02:00
/**
* \file htdocs/stripe/config.php
2017-04-22 06:58:44 +02:00
* \ingroup Stripe
* \brief Page to move config in api
*/
2017-04-18 05:44:08 +02:00
2020-03-13 03:07:28 +01:00
require_once DOL_DOCUMENT_ROOT.'/includes/stripe/stripe-php/init.php';
require_once DOL_DOCUMENT_ROOT.'/includes/stripe/stripe-php/lib/Stripe.php';
2017-04-18 05:44:08 +02:00
//global $stripe;
2017-05-14 05:26:19 +02:00
global $conf;
2018-05-17 16:07:44 +02:00
global $stripearrayofkeysbyenv;
2017-05-14 05:26:19 +02:00
2018-05-17 16:07:44 +02:00
$stripearrayofkeysbyenv = array(
0=>array(
2020-10-30 04:13:31 +01:00
"secret_key" => empty($conf->global->STRIPE_TEST_SECRET_KEY) ? '' : $conf->global->STRIPE_TEST_SECRET_KEY,
"publishable_key" => empty($conf->global->STRIPE_TEST_PUBLISHABLE_KEY) ? '' : $conf->global->STRIPE_TEST_PUBLISHABLE_KEY
2018-05-17 16:07:44 +02:00
),
1=>array(
2020-10-30 04:13:31 +01:00
"secret_key" => empty($conf->global->STRIPE_LIVE_SECRET_KEY) ? '' : $conf->global->STRIPE_LIVE_SECRET_KEY,
"publishable_key" => empty($conf->global->STRIPE_LIVE_PUBLISHABLE_KEY) ? '' : $conf->global->STRIPE_LIVE_PUBLISHABLE_KEY
2018-05-17 16:07:44 +02:00
)
);
2017-05-08 06:52:30 +02:00
$stripearrayofkeys = array();
2021-02-26 21:17:52 +01:00
if (empty($conf->global->STRIPE_LIVE) || GETPOST('forcesandbox', 'alpha')) {
$stripearrayofkeys = $stripearrayofkeysbyenv[0]; // Test
2020-05-21 15:05:19 +02:00
} else {
$stripearrayofkeys = $stripearrayofkeysbyenv[1]; // Live
2017-05-08 06:52:30 +02:00
}
2017-04-18 05:44:08 +02:00
\Stripe\Stripe::setApiKey($stripearrayofkeys['secret_key']);
\Stripe\Stripe::setAppInfo("Dolibarr Stripe", DOL_VERSION, "https://www.dolibarr.org"); // add dolibarr version
2020-10-17 11:16:30 +02:00
\Stripe\Stripe::setApiVersion(empty($conf->global->STRIPE_FORCE_VERSION) ? "2020-08-27" : $conf->global->STRIPE_FORCE_VERSION); // force version API