/** * Magento * * NOTICE OF LICENSE * * This source file is subject to the Open Software License (OSL 3.0) * that is bundled with this package in the file LICENSE.txt. * It is also available through the world-wide-web at this URL: * http://opensource.org/licenses/osl-3.0.php * If you did not receive a copy of the license and are unable to * obtain it through the world-wide-web, please send an email * to license@magentocommerce.com so we can send you a copy immediately. * * @category Phoenix * @package Phoenix_Moneybookers * @copyright Copyright (c) 2009 Phoenix Medien GmbH & Co. KG (http://www.phoenix-medien.de) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ Event.observe(window, 'load', function() { initMoneybookers(); }); Moneybookers = Class.create(); Moneybookers.prototype = { initialize: function(bannerUrl, activateemailUrl, checksecretUrl, checkemailUrl){ this.bannerUrl = bannerUrl; this.activateemailUrl = activateemailUrl; this.checksecretUrl = checksecretUrl; this.checkemailUrl = checkemailUrl; this.txtBtnStatus0 = this.translate('Validate Email'); this.txtBtnStatus1 = this.translate('Activate Moneybookers Quick Checkout'); this.txtBtnStatus2 = this.translate('Validate Secret Word'); this.txtErrStatus0 = this.translate('This email address is not registered.'); this.txtErrStatus2 = this.translate('This Secret Word is incorrect. After activation Moneybookers will give you access to a new section in your Moneybookers account called "Merchant tools". Please choose a secret word (do not use your password for this) and provide it in your Moneybookers admin area and above.'); this.txtInfStatus0 = this.translate('Moneybookers is an all in one payments solution that enables a merchant to accept debit and credit card payments, bank transfers and the largest range of local payments directly on your website.') + ''; this.txtInfStatus1 = this.translate('Moneybookers Quick Checkout enables you to take direct payments from credit cards, debit cards and over 50 other local payment options in over 200 countries for customers without an existing Moneybookers eWallet.'); this.txtNotSavechanges = this.translate('Please save the configuration before continuing.'); this.txtNotStatus0 = this.translate('Email was validated by Moneybookers.'); this.txtNotStatus1 = this.translate('Activation email was sent to Moneybookers. Please be aware that the verification process to use Moneybookers Quick Checkout takes some time. You will be contacted by Moneybookers when the verification process has been completed.'); this.txtNotStatus2 = this.translate('Secret Word was validated by Moneybookers. Your installation is completed and you are ready to receive international and local payments.'); $("moneybookers_settings_moneybookers_email").setAttribute("onchange", "moneybookers.setStatus(0); moneybookers.changeUi(); document.getElementById('moneybookers_settings_customer_id').value = ''; document.getElementById('moneybookers_settings_customer_id_hidden').value = '';"); $("moneybookers_settings_customer_id").disabled = true; $("moneybookers_settings_customer_id_hidden").name = document.getElementById("moneybookers_settings_customer_id").name; $("moneybookers_settings_customer_id_hidden").value = document.getElementById("moneybookers_settings_customer_id").value; $("moneybookers_settings_secret_key").setAttribute("onchange", "moneybookers.setStatus(2); moneybookers.changeUi();"); this.changeUi(); }, translate: function(text) { try { if(Translator){ return Translator.translate(text); } } catch(e){} return text; }, button: function () { var status, response, result; status = this.getStatus(); if (status < 1) { response = this.getHttp(this.checkemailUrl + "?email=" + $("moneybookers_settings_moneybookers_email").value); result = response.split(','); if (result[0] == "OK") { $("moneybookers_settings_customer_id").value = result[1]; $("moneybookers_settings_customer_id_hidden").value = result[1]; this.setStatus(1); status = 1; alert(this.txtNotStatus0); } else { $("moneybookers_settings_customer_id").value = ""; alert(this.txtErrStatus0 + "\n("+response+")"); } } if (status == 1) { this.getHttp(this.activateemailUrl); this.setStatus(2); alert(this.txtNotStatus1); this.alertSaveChanges(); } if (status == 2) { response = this.getHttp(this.checksecretUrl + "?email=" + $("moneybookers_settings_moneybookers_email").value + "&secret=" + $("moneybookers_settings_secret_key").value + "&cust_id=" + $("moneybookers_settings_customer_id").value); if (response == "OK") { this.setStatus(3); alert(this.txtNotStatus2); this.alertSaveChanges(); } else { alert(this.txtErrStatus2 + "\n("+response+")"); } } }, alertSaveChanges: function () { $("moneybookers_multifuncbutton").style.display = "none"; alert(this.txtNotSavechanges); }, getHttp: function (url) { var response; new Ajax.Request( url, { method: "get", onComplete: function(transport) {response = transport.responseText;}, asynchronous: false }); return response; }, getInteger: function (number) { number = parseInt(number); if (isNaN(number)) return 0; return number; }, getStatus: function () { var status = this.getInteger($("moneybookers_settings_activationstatus").value); if (status == 1 && $("moneybookers_settings_customer_id").value != '' && $("moneybookers_settings_secret_key").value == '') { status = 2; this.setStatus(status); } return status; }, setStatus: function (number) { number = this.getInteger(number); if (number < 0) number = 0; else if (number > 3) number = 3; $("moneybookers_settings_activationstatus").value = number; }, changeUi: function () { var status = this.getStatus(); if (status < 1) { $("moneybookers_inf_div").update(this.txtInfStatus0); $("moneybookers_multifuncbutton_label").update(this.txtBtnStatus0); } if (status == 1) { $("moneybookers_inf_div").update(this.txtInfStatus1); $("moneybookers_multifuncbutton_label").update(this.txtBtnStatus1); } if (status < 2) { $("moneybookers_inf_div").style.display = "block"; $("moneybookers_settings_secret_key").disabled = true; } if (status == 2) { $("moneybookers_multifuncbutton_label").update(this.txtBtnStatus2); } if (status > 2) { $("moneybookers_multifuncbutton").style.display = "none"; } else { $("moneybookers_multifuncbutton").style.display = "block"; } } }