name = 'moneybookers';
$this->tab = 'Payment';
$this->version = '1.0';
parent::__construct();
$this->page = basename(__FILE__, '.php');
$this->displayName = $this->l('Moneybookers');
$this->description = $this->l('Accepts payments by Moneybookers');
$this->confirmUninstall = $this->l('Are you sure you want to delete your details ?');
}
public function install()
{
if (!parent::install() OR !$this->registerHook('payment') OR !$this->registerHook('paymentReturn'))
return false;
Configuration::updateValue('MB_HIDE_LOGIN', 1);
Configuration::updateValue('MB_PAY_TO_EMAIL', Configuration::get('PS_SHOP_EMAIL'));
Configuration::updateValue('MB_RETURN_URL', 'http://'.$_SERVER['HTTP_HOST'].__PS_BASE_URI__.'history.php');
Configuration::updateValue('MB_CANCEL_URL', 'http://'.$_SERVER['HTTP_HOST'].__PS_BASE_URI__);
Configuration::updateValue('MB_ID_LOGO', 1);
Configuration::updateValue('MB_ID_LOGO_WALLET', 1);
return true;
}
public function uninstall()
{
if (!parent::uninstall())
return false;
/* Clean configuration table */
Configuration::deleteByName('MB_PAY_TO_EMAIL');
Configuration::deleteByName('MB_RETURN_URL');
Configuration::deleteByName('MB_CANCEL_URL');
Configuration::deleteByName('MB_HIDE_LOGIN');
Configuration::deleteByName('MB_SECRET_WORD');
Configuration::deleteByName('MB_ID_LOGO');
Configuration::deleteByName('MB_ID_LOGO_WALLET');
return true;
}
public function getContent()
{
global $cookie;
$output = '
Moneybookers

';
$errors = array();
/* Update configuration variables */
if (isset($_POST['submitMoneyBookers']))
{
if (!isset($_POST['mb_hide_login']))
$_POST['mb_hide_login'] = 0;
Configuration::updateValue('MB_PAY_TO_EMAIL', $_POST['mb_pay_to_email']);
Configuration::updateValue('MB_RETURN_URL', $_POST['mb_return_url']);
Configuration::updateValue('MB_CANCEL_URL', $_POST['mb_cancel_url']);
Configuration::updateValue('MB_HIDE_LOGIN', intval($_POST['mb_hide_login']));
Configuration::updateValue('MB_SECRET_WORD', $_POST['mb_secret_word']);
Configuration::updateValue('MB_ID_LOGO', $_POST['mb_id_logo']);
Configuration::updateValue('MB_ID_LOGO_WALLET', $_POST['mb_id_logo_wallet']);
/* Check account validity */
$fp = fopen('http://moneybookers.prestashop.com/email_check.php?email='.$_POST['mb_pay_to_email'].'&url=http://'.$_SERVER['HTTP_HOST'].__PS_BASE_URI__, 'r');
if (!$fp)
$errors[] = $this->l('Impossible to contact activation server, please try later');
else
{
$response = trim(strtolower(fgets($fp, 4096)));
if (!strstr('ok', $response))
$errors[] = $this->l('Account validation failed, your email might be wrong');
else
{
$fp2 = fopen('http://moneybookers.prestashop.com/email_check.php?email='.$_POST['mb_pay_to_email'].'&url=http://'.$_SERVER['HTTP_HOST'].__PS_BASE_URI__.'&sw=1&secret_word='.md5($_POST['mb_secret_word']), 'r');
if (!$fp2)
$errors[] = $this->l('Impossible to contact activation server, please try later');
else
{
$response2 = trim(strtolower(fgets($fp2, 4096)));
if (strstr('velocity_check_exceeded', $response2))
$errors[] = $this->l('Secret word validation failed, execeeded max tries (3 per hour)');
elseif (!strstr('ok', $response2))
$errors[] = $this->l('Secret word validation failed, your secret word might be wrong');
else
$conf = true;
}
}
}
}
/* Display errors */
if (sizeof($errors))
{
$output .= '';
foreach ($errors AS $error)
$output .= '- '.$error.'
';
$output .= '
';
}
/* Display conf */
if (isset($conf))
{
$output .= '
- '.$this->l('Activation successfull, secret word OK').'
';
}
$lang = new Language(intval($cookie->id_lang));
$iso_img = $lang->iso_code;
if ($lang->iso_code != 'fr' AND $lang->iso_code != 'en')
$iso_img = 'en';
$manual_links = array(
'en' => 'http://www.prestashop.com/partner/Activation_Manual_Prestashop_EN.pdf',
'es' => 'http://www.prestashop.com/partner/Manual%20de%20Activacion%20Prestashop_ES.pdf',
'fr' => 'http://www.prestashop.com/partner/Manuel_Activation_Prestashop_FR.pdf');
$iso_manual = $lang->iso_code;
if (!array_key_exists($lang->iso_code, $manual_links))
$iso_manual = 'en';
/* Display settings form */
$output .= '
'.$this->l('Opening your Moneybookers account').'
'.$this->l('Open your Moneybookers account:').'

'.$this->l('This module allows you to accept payments by Moneybookers.').'
'.$this->l('About Moneybookers').'
'.
$this->l('Moneybookers is one of Europe\'s largest online payments systems and among the world\'s leading eWallet providers, with over 11 million account holders. The simple eWallet enables any customer to conveniently and securely pay online without revealing personal financial data, as well as to send and receive money transfers cost-effectively by simply using an email address.').'
'.
$this->l('Moneybookers. worldwide payment network offers businesses access to over 80 local payment options in over 200 countries with just one integration. Already more than 60,000 merchants use Moneybookers. payments service, including global partners such as eBay, Skype and Thomas Cook').'
'.$this->l('Moneybookers was founded in 2001 in London and is regulated by the Financial Services Authority of the United Kingdom.').'
';
return $output;
}
public function hookPayment($params)
{
$flag = false;
$allowedCurrencies = $this->getCurrency();
foreach ($allowedCurrencies AS $allowedCurrency)
if ($allowedCurrency['id_currency'] == $params['cart']->id_currency)
{
$flag = true;
break;
}
if (!$flag)
{
/* Uncomment the line below if you'd like to display an error message, rather than not showing the Moneybookers module */
// return $this->display(__FILE__, 'moneybookers-currency-error.tpl');
}
else
/* Display the MoneyBookers iframe */
return $this->display(__FILE__, 'moneybookers.tpl');
}
public function hookPaymentReturn($params)
{
return $this->display(__FILE__, 'confirmation.tpl');
}
}
?>