dolibarr 21.0.0-beta
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 * Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
5 * Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <https://www.gnu.org/licenses/>.
19 */
20
27if (session_id() == "") {
28 session_start();
29 if (ini_get('register_globals')) { // To solve bug in using $_SESSION
30 foreach ($_SESSION as $key => $value) {
31 if (isset($GLOBALS[$key])) {
32 unset($GLOBALS[$key]);
33 }
34 }
35 }
36}
37
38// ==================================
39// PayPal Express Checkout Module
40// ==================================
41
42$API_version = "56";
43
44/*
45 ' Define the PayPal Redirect URLs.
46 ' This is the URL that the buyer is first sent to do authorize payment with their paypal account
47 ' change the URL depending if you are testing on the sandbox or the live PayPal site
48 '
49 ' For the sandbox, the URL is https://www.sandbox.paypal.com/webscr&cmd=_express-checkout&token=
50 ' For the live site, the URL is https://www.paypal.com/webscr&cmd=_express-checkout&token=
51 */
52if (getDolGlobalString('PAYPAL_API_SANDBOX') || GETPOST('forcesandbox', 'alpha')) { // We can force sand box with param 'forcesandbox'
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 = getDolGlobalString('PAYPAL_API_USER');
62$PAYPAL_API_PASSWORD = getDolGlobalString('PAYPAL_API_PASSWORD');
63$PAYPAL_API_SIGNATURE = getDolGlobalString('PAYPAL_API_SIGNATURE');
64$PAYPAL_API_SANDBOX = getDolGlobalString('PAYPAL_API_SANDBOX');
65
66// Proxy
67$PROXY_HOST = getDolGlobalString('MAIN_PROXY_HOST');
68$PROXY_PORT = getDolGlobalString('MAIN_PROXY_PORT');
69$PROXY_USER = getDolGlobalString('MAIN_PROXY_USER');
70$PROXY_PASS = getDolGlobalString('MAIN_PROXY_PASS');
71$USE_PROXY = getDolGlobalBool('MAIN_PROXY_USE');
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
getDolGlobalBool($key, $default=false)
Return a Dolibarr global constant boolean value.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.