dolibarr  13.0.2
paypalfunctions.lib.php
Go to the documentation of this file.
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 
25 if (session_id() == "")
26 {
27  session_start();
28  if (ini_get('register_globals')) // To solve bug in using $_SESSION
29  {
30  foreach ($_SESSION as $key=>$value)
31  {
32  if (isset($GLOBALS[$key])) unset($GLOBALS[$key]);
33  }
34  }
35 }
36 
37 // ==================================
38 // PayPal Express Checkout Module
39 // ==================================
40 
41 $API_version = "56";
42 
43 /*
44  ' Define the PayPal Redirect URLs.
45  ' This is the URL that the buyer is first sent to do authorize payment with their paypal account
46  ' change the URL depending if you are testing on the sandbox or the live PayPal site
47  '
48  ' For the sandbox, the URL is https://www.sandbox.paypal.com/webscr&cmd=_express-checkout&token=
49  ' For the live site, the URL is https://www.paypal.com/webscr&cmd=_express-checkout&token=
50  */
51 if (!empty($conf->global->PAYPAL_API_SANDBOX) || GETPOST('forcesandbox', 'alpha')) // We can force sand box with param 'forcesandbox'
52 {
53  $API_Endpoint = "https://api-3t.sandbox.paypal.com/nvp";
54  $API_Url = "https://www.sandbox.paypal.com/webscr?cmd=_express-checkout&token=";
55 } else {
56  $API_Endpoint = "https://api-3t.paypal.com/nvp";
57  $API_Url = "https://www.paypal.com/cgi-bin/webscr?cmd=_express-checkout&token=";
58 }
59 
60 // Clean parameters
61 $PAYPAL_API_USER = "";
62 if (!empty($conf->global->PAYPAL_API_USER)) $PAYPAL_API_USER = $conf->global->PAYPAL_API_USER;
63 $PAYPAL_API_PASSWORD = "";
64 if (!empty($conf->global->PAYPAL_API_PASSWORD)) $PAYPAL_API_PASSWORD = $conf->global->PAYPAL_API_PASSWORD;
65 $PAYPAL_API_SIGNATURE = "";
66 if (!empty($conf->global->PAYPAL_API_SIGNATURE)) $PAYPAL_API_SIGNATURE = $conf->global->PAYPAL_API_SIGNATURE;
67 $PAYPAL_API_SANDBOX = "";
68 if (!empty($conf->global->PAYPAL_API_SANDBOX)) $PAYPAL_API_SANDBOX = $conf->global->PAYPAL_API_SANDBOX;
69 
70 // Proxy
71 $PROXY_HOST = $conf->global->MAIN_PROXY_HOST;
72 $PROXY_PORT = $conf->global->MAIN_PROXY_PORT;
73 $PROXY_USER = $conf->global->MAIN_PROXY_USER;
74 $PROXY_PASS = $conf->global->MAIN_PROXY_PASS;
75 $USE_PROXY = empty($conf->global->MAIN_PROXY_USE) ?false:true;
GETPOST($paramname, $check= 'alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.