* @copyright 2007-2011 PrestaShop SA * @version Release: $Revision: 7801 $ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) * International Registered Trademark & Property of PrestaShop SA */ if (!defined('_CAN_LOAD_FILES_')) exit; class MoneyBookers extends PaymentModule { const LEFT_COLUMN = 0; const RIGHT_COLUMN = 1; const DISABLE = -1; public function __construct() { $this->name = 'moneybookers'; $this->tab = 'payments_gateways'; $this->version = '1.5'; 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 ?'); if (Configuration::get('MB_PAY_TO_EMAIL') == 'testmerchant@moneybookers.com') $this->warning = $this->l('You are currently using the default Moneybookers e-mail address, please use your own e-mail address.'); /* MoneyBookers payment methods */ $this->_internationalPaymentMethods = array( 0 => array('file' => 'amex', 'name' => 'American Express', 'code' => 'AMX'), 1 => array('file' => 'diners', 'name' => 'Diners', 'code' => 'DIN'), 2 => array('file' => 'jcb', 'name' => 'JCB', 'code' => 'JCB'), 3 => array('file' => 'maestro', 'name' => 'Maestro', 'code' => 'MAE'), 4 => array('file' => 'mastercard', 'name' => 'Mastercard', 'code' => 'MSC'), 5 => array('file' => 'visa', 'name' => 'Visa', 'code' => 'VSA'), 6 => array('file' => 'visadebit', 'name' => 'Visa Debit', 'code' => 'VSD'), 7 => array('file' => 'ewallet', 'name' => 'Moneybookers eWallet', 'code' => 'WLT')); $this->_localPaymentMethods = array( 0 => array('file' => '4b', 'name' => '4B', 'code' => 'MSC'), 1 => array('file' => 'cartasi', 'name' => 'Cartasi', 'code' => 'CSI'), 2 => array('file' => 'cartebleue', 'name' => 'Carte bleue', 'code' => 'GCB'), 3 => array('file' => 'dankort', 'name' => 'Dankort' , 'code' => 'DNK'), 4 => array('file' => 'ec', 'name' => 'EC', 'code' => 'ELV'), 5 => array('file' => 'enets', 'name' => 'eNets', 'code' => 'ENT'), 6 => array('file' => 'epay', 'name' => 'ePay', 'code' => 'EPY'), 7 => array('file' => 'eps', 'name' => 'EPS', 'code' => 'NPY'), 8 => array('file' => 'euro6000', 'name' => 'Euro 6000', 'code' => 'MSC'), 9 => array('file' => 'giropay', 'name' => 'Giropay', 'code' => 'GIR'), 10 => array('file' => 'ideal', 'name' => 'iDeal', 'code' => 'IDL'), 11 => array('file' => 'instantbanktransfer', 'name' => 'Instant Bank Transfer', 'code' => 'PWY'), 12 => array('file' => 'laser', 'name' => 'Laser', 'code' => 'LSR'), 13 => array('file' => 'nordea', 'name' => 'Nordea', 'code' => 'EBT,SO2'), 14 => array('file' => 'p24', 'name' => 'P24', 'code' => ''), 15 => array('file' => 'pekao', 'name' => 'Pekao', 'code' => 'PWY18'), 16 => array('file' => 'poli', 'name' => 'Poli', 'code' => 'PLI'), 17 => array('file' => 'postepay', 'name' => 'PostePay', 'code' => 'PSP'), 18 => array('file' => 'sofort', 'name' => 'Sofort', 'code' => 'SFT'), 19 => array('file' => 'solo', 'name' => 'Solo', 'code' => 'SLO'), 20 => array('file' => 'unionpay', 'name' => 'UnionPay', 'code' => ''), 21 => array('file' => 'visaelectron', 'name' => 'Visa Electron', 'code' => 'VSE')); /* MoneyBookers countries (for iso 3 letters compatibility) */ $this->_country = array('AF' => 'AFG', 'AL' => 'ALB', 'DZ' => 'DZA', 'AS' => 'ASM', 'AD' => 'AND', 'AO' => 'AGO', 'AI' => 'AIA', 'AQ' => 'ATA', 'AG' => 'ATG', 'AR' => 'ARG', 'AM' => 'ARM', 'AW' => 'ABW', 'AU' => 'AUS', 'AT' => 'AUT', 'AZ' => 'AZE', 'BS' => 'BHS', 'BH' => 'BHR', 'BD' => 'BGD', 'BB' => 'BRB', 'BY' => 'BLR', 'BE' => 'BEL', 'BZ' => 'BLZ', 'BJ' => 'BEN', 'BM' => 'BMU', 'BT' => 'BTN', 'BO' => 'BOL', 'BA' => 'BIH', 'BW' => 'BWA', 'BV' => 'BVT', 'BR' => 'BRA', 'IO' => 'IOT', 'BN' => 'BRN', 'BG' => 'BGR', 'BF' => 'BFA', 'BI' => 'BDI', 'KH' => 'KHM', 'CM' => 'CMR', 'CA' => 'CAN', 'CV' => 'CPV', 'KY' => 'CYM', 'CF' => 'CAF', 'TD' => 'TCD', 'CL' => 'CHL', 'CN' => 'CHN', 'CX' => 'CXR', 'CC' => 'CCK', 'CO' => 'COL', 'KM' => 'COM', 'CG' => 'COG', 'CK' => 'COK', 'CR' => 'CRI', 'CI' => 'CIV', 'HR' => 'HRV', 'CU' => 'CUB', 'CY' => 'CYP', 'CZ' => 'CZE', 'DK' => 'DNK', 'DJ' => 'DJI', 'DM' => 'DMA', 'DO' => 'DOM', 'TP' => 'TMP', 'EC' => 'ECU', 'EG' => 'EGY', 'SV' => 'SLV', 'GQ' => 'GNQ', 'ER' => 'ERI', 'EE' => 'EST', 'ET' => 'ETH', 'FK' => 'FLK', 'FO' => 'FRO', 'FJ' => 'FJI', 'FI' => 'FIN', 'FR' => 'FRA', 'FX' => 'FXX', 'GF' => 'GUF', 'PF' => 'PYF', 'TF' => 'ATF', 'GA' => 'GAB', 'GM' => 'GMB', 'GE' => 'GEO', 'DE' => 'DEU', 'GH' => 'GHA', 'GI' => 'GIB', 'GR' => 'GRC', 'GL' => 'GRL', 'GD' => 'GRD', 'GP' => 'GLP', 'GU' => 'GUM', 'GT' => 'GTM', 'GN' => 'GIN', 'GW' => 'GNB', 'GY' => 'GUY', 'HT' => 'HTI', 'HM' => 'HMD', 'HN' => 'HND', 'HK' => 'HKG', 'HU' => 'HUN', 'IS' => 'ISL', 'IN' => 'IND', 'ID' => 'IDN', 'IR' => 'IRN', 'IQ' => 'IRQ', 'IE' => 'IRL', 'IL' => 'ISR', 'IT' => 'ITA', 'JM' => 'JAM', 'JP' => 'JPN', 'JO' => 'JOR', 'KZ' => 'KAZ', 'KE' => 'KEN', 'KI' => 'KIR', 'KP' => 'PRK', 'KR' => 'KOR', 'KW' => 'KWT', 'KG' => 'KGZ', 'LA' => 'LAO', 'LV' => 'LVA', 'LB' => 'LBN', 'LS' => 'LSO', 'LR' => 'LBR', 'LY' => 'LBY', 'LI' => 'LIE', 'LT' => 'LTU', 'LU' => 'LUX', 'MO' => 'MAC', 'MK' => 'MKD', 'MG' => 'MDG', 'MW' => 'MWI', 'MY' => 'MYS', 'MV' => 'MDV', 'ML' => 'MLI', 'MT' => 'MLT', 'MH' => 'MHL', 'MQ' => 'MTQ', 'MR' => 'MRT', 'MU' => 'MUS', 'YT' => 'MYT', 'MX' => 'MEX', 'FM' => 'FSM', 'MD' => 'MDA', 'MC' => 'MCO', 'MN' => 'MNG', 'MS' => 'MSR', 'MA' => 'MAR', 'MZ' => 'MOZ', 'MM' => 'MMR', 'NA' => 'NAM', 'NR' => 'NRU', 'NP' => 'NPL', 'NL' => 'NLD', 'AN' => 'ANT', 'NC' => 'NCL', 'NZ' => 'NZL', 'NI' => 'NIC', 'NE' => 'NER', 'NG' => 'NGA', 'NU' => 'NIU', 'NF' => 'NFK', 'MP' => 'MNP', 'NO' => 'NOR', 'OM' => 'OMN', 'PK' => 'PAK', 'PW' => 'PLW', 'PA' => 'PAN', 'PG' => 'PNG', 'PY' => 'PRY', 'PE' => 'PER', 'PH' => 'PHL', 'PN' => 'PCN', 'PL' => 'POL', 'PT' => 'PRT', 'PR' => 'PRI', 'QA' => 'QAT', 'RE' => 'REU', 'RO' => 'ROM', 'RU' => 'RUS', 'RW' => 'RWA', 'KN' => 'KNA', 'LC' => 'LCA', 'VC' => 'VCT', 'WS' => 'WSM', 'SM' => 'SMR', 'ST' => 'STP', 'SA' => 'SAU', 'SN' => 'SEN', 'SC' => 'SYC', 'SL' => 'SLE', 'SG' => 'SGP', 'SK' => 'SVK', 'SI' => 'SVN', 'SB' => 'SLB', 'SO' => 'SOM', 'ZA' => 'ZAF', 'GS' => 'SGS', 'ES' => 'ESP', 'LK' => 'LKA', 'SH' => 'SHN', 'PM' => 'SPM', 'SD' => 'SDN', 'SR' => 'SUR', 'SJ' => 'SJM', 'SZ' => 'SWZ', 'SE' => 'SWE', 'CH' => 'CHE', 'SY' => 'SYR', 'TW' => 'TWN', 'TJ' => 'TJK', 'TZ' => 'TZA', 'TH' => 'THA', 'TG' => 'TGO', 'TK' => 'TKL', 'TO' => 'TON', 'TT' => 'TTO', 'TN' => 'TUN', 'TR' => 'TUR', 'TM' => 'TKM', 'TC' => 'TCA', 'TV' => 'TUV', 'UG' => 'UGA', 'UA' => 'UKR', 'AE' => 'ARE', 'GB' => 'GBR', 'US' => 'USA', 'UM' => 'UMI', 'UY' => 'URY', 'UZ' => 'UZB', 'VU' => 'VUT', 'VA' => 'VAT', 'VE' => 'VEN', 'VN' => 'VNM', 'VG' => 'VGB', 'VI' => 'VIR', 'WF' => 'WLF', 'EH' => 'ESH', 'YE' => 'YEM', 'YU' => 'YUG', 'ZR' => 'ZAR', 'ZM' => 'ZMB', 'ZW' => 'ZWE'); } 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_CANCEL_URL', (Configuration::get('PS_SSL_ENABLED') ? 'https' : 'http').'://'.$_SERVER['HTTP_HOST'].__PS_BASE_URI__); Configuration::updateValue('MB_ID_LOGO', 1); Configuration::updateValue('MB_ID_LOGO_WALLET', 1); Configuration::updateValue('MB_PARAMETERS', 0); Configuration::updateValue('MB_DISPLAY_MODE', 1); return true; } public function uninstall() { if (!parent::uninstall()) return false; /* Clean configuration table */ Configuration::deleteByName('MB_PAY_TO_EMAIL'); 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'); Configuration::deleteByName('MB_PARAMETERS'); Configuration::deleteByName('MB_DISPLAY_MODE'); return true; } /* ** Fetch a distant content trying to use all the available function ** if one of theme doesn't exist of failed */ private function _fetchWebContent($url, $timeout = 5, $contextOptions = array()) { $context = NULL; $defaultContextOptions = array( 'http' => array( 'user_agent' => $_SERVER['HTTP_USER_AGENT'], 'max_redirects' => 10, 'timeout' => $timeout, 'header' => array( 'Accept-language: en', 'Cookie: foo=bar'))); if (is_callable('curl_init') && ($ch = curl_init())) { curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout); $content = curl_exec($ch); curl_close($ch); } else { // Check availability of the context options if (!is_array($contextOptions) || !count($contextOptions)) $contextOptions = $defaultContextOptions; // Create a stream context $context = stream_context_create($contextOptions); if (($fp = @fopen($url, $mode, false, $context))) { $content = fgets($fp, 4096); fclose($fp); } else if (!($content = @file_get_contents($url, false, $context))) if (($fp = @fsockopen($url, 80, $errnom, $errstr, $timeout))) { preg_match('@^(?:http://)?([^/]+)@i', $url, $matches); $host = $matches[1]; $out = "GET / HTTP/1.1\r\n"; $out .= "Host: ".$host."\r\n"; $out .= "Connection: Close\r\n\r\n"; fwrite($fp, $out); $fetched = ''; while (!feof($fp)) $fetched .= fgets($fp, 1024); if (strlen($fetched)) $content = $fetched; fclose($fp); } } if (!$content) throw new Exception($this->l('Unable to fetch content')); return $content; } public function getContent() { global $cookie; $errors = array(); $output = '
'.
$this->l('Take advantage of the special fees offered by Moneybookers to PrestaShop merchants !').'
'.
$this->l('Moneybookers, controlled by Skrill Holdings, is one of the biggest online payment systems in Europe, and proposes more than 100 payment options and 41 currencies in more than 200 countries and territories. More than 80,000 merchants already use this solution among which eBay.com, Skype and Thomas Cook.').'
'.
$this->l('With more than 17 million users and more than 15,000 new accounts created per day, Moneybookers also offers one of the biggest electronic wallet in the world. Your customers can also pay by using their e-mail and password thanks to the e-Wallet solution.').'
'.
$this->l('Moneybookers changes its name and becomes Skrill!').'