HEX
Server: Apache
System: Linux c119.dattaweb.com 3.10.0-1160.119.1.el7.x86_64 #1 SMP Tue Jun 4 14:43:51 UTC 2024 x86_64
User: c1190199 (57165)
PHP: 7.4.33
Disabled: mail, system, shell, exec, system_exec, shell_exec, mysql_pconnect, passthru, popen, proc_open, proc_close, proc_nice, proc_terminate, proc_get_status, escapeshellarg, escapeshellcmd, eval, dl, imap_mail, libvirt_connect, gnupg_init, unsetenv, apache_setenv, pcntl_exec, pcntl_alarm, pcntl_fork, pcntl_waitpid, pcntl_wait, pcntl_wifexited, pcntl_wifstopped, pcntl_wifsignaled, pcntl_wifcontinued, pcntl_wexitstatus, pcntl_wtermsig, pcntl_wstopsig, pcntl_signal, pcntl_signal_get_handler, pcntl_signal_dispatch, pcntl_get_last_error, pcntl_strerror, pcntl_sigprocmask, pcntl_sigwaitinfo, pcntl_sigtimedwait, pcntl_getpriority, pcntl_setpriority, pcntl_async_signals, opcache_get_status, opcache_reset, opcache_get_configuration
Upload Files
File: /home/c1190199/public_html/wp-content/themes/directory/functions/class-paypal.php
<?php
class Paypal {
	/**
	* Last error message(s)
	* @var array
	*/
	protected $_errors = array();

	/**
	* API Credentials
	* Use the correct credentials for the environment in use (Live / Sandbox)
	* @var array
	*/
	protected $_credentials = array(
		'USER' => '',
		'PWD' => '',
		'SIGNATURE' => '',
	);

	/**
	* API endpoint
	* Live - https://api-3t.paypal.com/nvp
	* Sandbox - https://api-3t.sandbox.paypal.com/nvp
	* @var string
	*/
	protected $_endPoint = '';

	/**
	* API Version
	* @var string
	*/
	protected $_version = '98.0';

	/**
	* use sandbox of live api
	* @var boolean
	*/
	protected $_sandbox = true;

	/**
	* Constructor
	*/
	public function __construct($credentials, $sandbox = true){
		$this->_credentials = $credentials;
		$this->_sandbox = $sandbox;
		if($sandbox){
			$this->_endPoint = 'https://api-3t.sandbox.paypal.com/nvp';
		} else {
			$this->_endPoint = 'https://api-3t.paypal.com/nvp';
		}
	}

	/**
	* Make API request
	*
	* @param string $method string API method to request
	* @param array $params Additional request parameters
	* @return array / boolean Response array / boolean false on failure
	*/
	public function request($method,$params = array()) {
		$this -> _errors = array();
		if( empty($method) ) { //Check if API method is not empty
			$this -> _errors = array('API method is missing');
			return false;
		}

		//Our request parameters
		$requestParams = array(
			'METHOD' => $method,
			'VERSION' => $this -> _version
		) + $this -> _credentials;

		//Building our NVP string
		$request = http_build_query($requestParams + $params);

		//cURL settings
		$curlOptions = array (
			CURLOPT_URL => $this -> _endPoint,
			CURLOPT_VERBOSE => 1,
			CURLOPT_SSL_VERIFYPEER => true,
			CURLOPT_SSL_VERIFYHOST => 2,
			CURLOPT_CAINFO => dirname(__FILE__) . '/cacert.pem', //CA cert file
			CURLOPT_RETURNTRANSFER => 1,
			CURLOPT_POST => 1,
			CURLOPT_POSTFIELDS => $request
		);

		$ch = curl_init();
		curl_setopt_array($ch,$curlOptions);

		//Sending our request - $response will hold the API response
		$response = curl_exec($ch);

		//Checking for cURL errors
		if (curl_errno($ch)) {
			$this -> _errors = curl_error($ch);
			curl_close($ch);
			return false;
			//Handle errors
		} else  {
			curl_close($ch);
			$responseArray = array();
			parse_str($response,$responseArray); // Break the NVP string to an array
			return $responseArray;
		}
	}

	public function getErrors()
	{
		return $this->_errors;
	}

	public function getEndpoint()
	{
		return $this->_endPoint;
	}

}