name = 'paypal';
$this->tab = 'Payment';
$this->version = '1.6';
$this->currencies = true;
$this->currencies_mode = 'radio';
parent::__construct();
$this->page = basename(__FILE__, '.php');
$this->displayName = $this->l('PayPal');
$this->description = $this->l('Accepts payments by PayPal');
$this->confirmUninstall = $this->l('Are you sure you want to delete your details ?');
if (Configuration::get('PAYPAL_BUSINESS') == 'paypal@prestashop.com')
$this->warning = $this->l('You are currently using the default PayPal email address, you need to use your own email address');
if ($_SERVER['SERVER_NAME'] == 'localhost')
$this->warning = $this->l('Your are in localhost, PayPal we can\'t validate order');
}
public function getPaypalUrl()
{
return Configuration::get('PAYPAL_SANDBOX') ? 'https://www.sandbox.paypal.com/cgi-bin/webscr' : 'https://www.paypal.com/cgi-bin/webscr';
}
public function install()
{
if (!parent::install()
OR !Configuration::updateValue('PAYPAL_BUSINESS', 'paypal@prestashop.com')
OR !Configuration::updateValue('PAYPAL_SANDBOX', 1)
OR !$this->registerHook('payment')
OR !$this->registerHook('paymentReturn'))
return false;
return true;
}
public function uninstall()
{
if (!Configuration::deleteByName('PAYPAL_BUSINESS')
OR !Configuration::deleteByName('PAYPAL_SANDBOX')
OR !parent::uninstall())
return false;
return true;
}
public function getContent()
{
$this->_html = '
Paypal
';
if (isset($_POST['submitPaypal']))
{
if (empty($_POST['business']))
$this->_postErrors[] = $this->l('Paypal business e-mail address is required.');
elseif (!Validate::isEmail($_POST['business']))
$this->_postErrors[] = $this->l('Paypal business must be an e-mail address.');
if (!isset($_POST['sandbox']))
$_POST['sandbox'] = 1;
if (!sizeof($this->_postErrors))
{
Configuration::updateValue('PAYPAL_BUSINESS', strval($_POST['business']));
Configuration::updateValue('PAYPAL_SANDBOX', intval($_POST['sandbox']));
Configuration::updateValue('PAYPAL_HEADER', strval($_POST['header']));
$this->displayConf();
}
else
$this->displayErrors();
}
$this->displayPayPal();
$this->displayFormSettings();
return $this->_html;
}
public function displayConf()
{
$this->_html .= '
'.$this->l('Settings updated').'
';
}
public function displayErrors()
{
$nbErrors = sizeof($this->_postErrors);
$this->_html .= '
';
foreach ($this->_postErrors AS $error)
$this->_html .= '
'.$error.'
';
$this->_html .= '
';
}
public function displayPayPal()
{
$this->_html .= '
'.$this->l('Opening your PayPal account').'
'.$this->l('By opening your PayPal account by clicking on the following image you are helping us significantly to improve the PrestaShop software:').'
'.$this->l('This module allows you to accept payments by PayPal.').'
'.$this->l('If the client chooses this payment mode, your PayPal account will be automatically credited.').'
'.$this->l('You need to configure your PayPal account first before using this module.').'