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