dolibarr 21.0.0-alpha
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 *
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
26if (session_id() == "") {
27 session_start();
28 if (ini_get('register_globals')) { // To solve bug in using $_SESSION
29 foreach ($_SESSION as $key => $value) {
30 if (isset($GLOBALS[$key])) {
31 unset($GLOBALS[$key]);
32 }
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 */
51if (getDolGlobalString('PAYPAL_API_SANDBOX') || GETPOST('forcesandbox', 'alpha')) { // We can force sand box with param 'forcesandbox'
52 $API_Endpoint = "https://api-3t.sandbox.paypal.com/nvp";
53 $API_Url = "https://www.sandbox.paypal.com/webscr?cmd=_express-checkout&token=";
54} else {
55 $API_Endpoint = "https://api-3t.paypal.com/nvp";
56 $API_Url = "https://www.paypal.com/cgi-bin/webscr?cmd=_express-checkout&token=";
57}
58
59// Clean parameters
60$PAYPAL_API_USER = "";
61if (getDolGlobalString('PAYPAL_API_USER')) {
62 $PAYPAL_API_USER = getDolGlobalString('PAYPAL_API_USER');
63}
64$PAYPAL_API_PASSWORD = "";
65if (getDolGlobalString('PAYPAL_API_PASSWORD')) {
66 $PAYPAL_API_PASSWORD = getDolGlobalString('PAYPAL_API_PASSWORD');
67}
68$PAYPAL_API_SIGNATURE = "";
69if (getDolGlobalString('PAYPAL_API_SIGNATURE')) {
70 $PAYPAL_API_SIGNATURE = getDolGlobalString('PAYPAL_API_SIGNATURE');
71}
72$PAYPAL_API_SANDBOX = "";
73if (getDolGlobalString('PAYPAL_API_SANDBOX')) {
74 $PAYPAL_API_SANDBOX = getDolGlobalString('PAYPAL_API_SANDBOX');
75}
76
77// Proxy
78$PROXY_HOST = getDolGlobalString('MAIN_PROXY_HOST');
79$PROXY_PORT = getDolGlobalString('MAIN_PROXY_PORT');
80$PROXY_USER = getDolGlobalString('MAIN_PROXY_USER');
81$PROXY_PASS = getDolGlobalString('MAIN_PROXY_PASS');
82$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.