Version Notes
Improved user experience for configuring the extension.
Download this release
Release Info
Developer | Angell EYE, LLC |
Extension | Angelleye_PayPal_BML_Banners |
Version | 1.0.2 |
Comparing to | |
See all releases |
Code changes from version 1.0.1 to 1.0.2
- app/code/community/Angelleye/PaypalBanner/Block/Settings.php +22 -0
- app/code/community/Angelleye/PaypalBanner/Block/System/Field/Id.php +14 -0
- app/code/community/Angelleye/PaypalBanner/Helper/Data.php +61 -1
- app/code/community/Angelleye/PaypalBanner/Model/Client.php +195 -0
- app/code/community/Angelleye/PaypalBanner/controllers/PpbsettingsController.php +123 -0
- app/code/community/Angelleye/PaypalBanner/controllers/SettingsController.php +70 -0
- app/code/community/Angelleye/PaypalBanner/etc/config.xml +39 -14
- app/code/community/Angelleye/PaypalBanner/etc/system.xml +137 -10
- app/code/community/Angelleye/PaypalBanner/sql/paypalbanner_setup/mysql4-install-0.0.1.php +10 -0
- app/design/frontend/base/default/template/paypalbanner/snippet.phtml +0 -1
- app/design/frontend/default/default/layout/paypalbanner.xml +14 -0
- app/design/frontend/default/default/template/paypalbanner/settings.phtml +103 -0
- package.xml +8 -12
app/code/community/Angelleye/PaypalBanner/Block/Settings.php
ADDED
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Angelleye_PaypalBanner_Block_Settings extends Mage_Core_Block_Template
|
4 |
+
{
|
5 |
+
/**
|
6 |
+
* Get predefined value for setting paypal name (taken from default page title)
|
7 |
+
* @return string|null
|
8 |
+
*/
|
9 |
+
public function getPaypalName()
|
10 |
+
{
|
11 |
+
return Mage::getStoreConfig('design/head/default_title');
|
12 |
+
}
|
13 |
+
|
14 |
+
/**
|
15 |
+
* Get predefined value for setting paypal email (taken from paypal standard settings)
|
16 |
+
* @return string|null
|
17 |
+
*/
|
18 |
+
public function getPaypalEmail()
|
19 |
+
{
|
20 |
+
return Mage::getStoreConfig('paypal/general/business_account');
|
21 |
+
}
|
22 |
+
}
|
app/code/community/Angelleye/PaypalBanner/Block/System/Field/Id.php
ADDED
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Angelleye_Paypalbanner_Block_System_Field_Id
|
4 |
+
extends Mage_Adminhtml_Block_System_Config_Form_Field
|
5 |
+
{
|
6 |
+
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element) {
|
7 |
+
$element->setType('hidden');
|
8 |
+
$value = is_object($element->getValue()) ? (string) $element->getValue():$element->getValue();
|
9 |
+
$success = '<div id="messages_success" style="width: 274px; display: '.( (empty($value)?'none':'block')).'"><ul class="messages"><li id="ppbanner_msg_holder_success" class="success-msg"><ul><li><span>'. $this->__('You\'re all set!') .'</span></li></ul></li></ul></div>';
|
10 |
+
$error = '<div id="messages_error" style="width: 274px;display: '.( (empty($value)?'block':'none')).'"><ul class="messages"><li id="ppbanner_msg_holder_failed" class="notice-msg"><ul><li><span>'. $this->__('You have not yet configured this module.<br /><br />Please fill in your name and email address below as it is in your PayPal account.<br /><br />Then agree to the terms and click the activate button.') .'</span></li></ul></li></ul></div>';
|
11 |
+
return $success.$error.parent::_getElementHtml($element);
|
12 |
+
}
|
13 |
+
|
14 |
+
}
|
app/code/community/Angelleye/PaypalBanner/Helper/Data.php
CHANGED
@@ -54,7 +54,7 @@ class Angelleye_PaypalBanner_Helper_Data extends Mage_Core_Helper_Abstract
|
|
54 |
$container = Mage::getStoreConfig('paypalbanner/settings/container');
|
55 |
$size = $this->getSectionConfig()->getSize();
|
56 |
|
57 |
-
$snippet = '<script type="text/javascript" data-pp-pubid="'.$id.'" data-pp-placementtype="'.$size.'">
|
58 |
(function (d, t) {
|
59 |
"use strict";
|
60 |
var s = d.getElementsByTagName(t)[0], n = d.createElement(t);
|
@@ -67,4 +67,64 @@ class Angelleye_PaypalBanner_Helper_Data extends Mage_Core_Helper_Abstract
|
|
67 |
}
|
68 |
return $snippet;
|
69 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
70 |
}
|
54 |
$container = Mage::getStoreConfig('paypalbanner/settings/container');
|
55 |
$size = $this->getSectionConfig()->getSize();
|
56 |
|
57 |
+
$snippet = '<script type="text/javascript" data-pp-pubid="'.$id.'" data-pp-placementtype="'.$size.'" data-pp-channel = "Magento Extension" data-pp-td = \'{"d":{"segments": {"cart_price": "'.$this->getCartPrice().'", "item_price":"'.$this->getItemPrice().'","page_name": "'.$this->getPageName().'"}}}\'>
|
58 |
(function (d, t) {
|
59 |
"use strict";
|
60 |
var s = d.getElementsByTagName(t)[0], n = d.createElement(t);
|
67 |
}
|
68 |
return $snippet;
|
69 |
}
|
70 |
+
|
71 |
+
/**
|
72 |
+
* Get cart total price
|
73 |
+
* @return string
|
74 |
+
*/
|
75 |
+
public function getCartPrice()
|
76 |
+
{
|
77 |
+
$price = (string)(Mage::helper('checkout/cart')->getQuote()->getGrandTotal()>0 ?
|
78 |
+
Mage::app()->getStore()->formatPrice(
|
79 |
+
Mage::helper('checkout/cart')->getQuote()->getGrandTotal(), false) : '');
|
80 |
+
|
81 |
+
if ($price[0] == '$'){
|
82 |
+
$price = substr($price, 1);
|
83 |
+
}
|
84 |
+
return $price;
|
85 |
+
}
|
86 |
+
|
87 |
+
/**
|
88 |
+
* Get item price (in case customer on product view page)
|
89 |
+
* @return string
|
90 |
+
*/
|
91 |
+
public function getItemPrice()
|
92 |
+
{
|
93 |
+
$request = Mage::app()->getRequest();
|
94 |
+
$module = $request->getModuleName();
|
95 |
+
$controller = $request->getControllerName();
|
96 |
+
$action = $request->getActionName();
|
97 |
+
if ($module.$controller.$action == 'catalogproductview'){
|
98 |
+
$prodId = $request->getParam('id');
|
99 |
+
$product = Mage::getModel('catalog/product')->load($prodId);
|
100 |
+
if ($product && $product->getPrice()){
|
101 |
+
$price = (string)Mage::app()->getStore()->formatPrice($product->getPrice(), false);
|
102 |
+
}
|
103 |
+
if ($price[0] == '$'){
|
104 |
+
$price = substr($price, 1);
|
105 |
+
}
|
106 |
+
return $price;
|
107 |
+
}
|
108 |
+
return '';
|
109 |
+
}
|
110 |
+
|
111 |
+
/**
|
112 |
+
* Get page name
|
113 |
+
* @return string
|
114 |
+
*/
|
115 |
+
public function getPageName()
|
116 |
+
{
|
117 |
+
$path = Mage::app()->getRequest()->getOriginalPathInfo();
|
118 |
+
if (empty($path) || $path == '/'){
|
119 |
+
return 'home';
|
120 |
+
} else if ($path[0] == '/' || $path[strlen($path)-1]=='/'){
|
121 |
+
if ($path[0] == '/'){
|
122 |
+
$path = substr($path, 1);
|
123 |
+
}
|
124 |
+
if ($path[strlen($path)-1]=='/'){
|
125 |
+
$path = substr($path, 0, -1);
|
126 |
+
}
|
127 |
+
}
|
128 |
+
return $path;
|
129 |
+
}
|
130 |
}
|
app/code/community/Angelleye/PaypalBanner/Model/Client.php
ADDED
@@ -0,0 +1,195 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Angelleye_PaypalBanner_Model_Client extends Mage_Core_Model_Abstract
|
3 |
+
{
|
4 |
+
/**
|
5 |
+
* API endpoint
|
6 |
+
* @var string
|
7 |
+
*/
|
8 |
+
protected $_endpoint = '';
|
9 |
+
|
10 |
+
/**
|
11 |
+
* API BN Code
|
12 |
+
* @var string
|
13 |
+
*/
|
14 |
+
protected $_bnCode = '';
|
15 |
+
|
16 |
+
/**
|
17 |
+
* API Access Key
|
18 |
+
* @var string
|
19 |
+
*/
|
20 |
+
protected $_accessKey = '';
|
21 |
+
|
22 |
+
/**
|
23 |
+
* API Secret
|
24 |
+
* @var string
|
25 |
+
*/
|
26 |
+
protected $_secret = '';
|
27 |
+
|
28 |
+
/**
|
29 |
+
* Current Timestamp
|
30 |
+
* @var string
|
31 |
+
*/
|
32 |
+
protected $_timestamp = '';
|
33 |
+
|
34 |
+
/**
|
35 |
+
* API Token
|
36 |
+
* @var string
|
37 |
+
*/
|
38 |
+
protected $_token = '';
|
39 |
+
|
40 |
+
/**
|
41 |
+
* API call results
|
42 |
+
* @var object|null
|
43 |
+
*/
|
44 |
+
protected $_responseData = null;
|
45 |
+
|
46 |
+
/**
|
47 |
+
* Payer Name
|
48 |
+
* @var string
|
49 |
+
*/
|
50 |
+
protected $_name = null;
|
51 |
+
|
52 |
+
/**
|
53 |
+
* Payer Email
|
54 |
+
* @var string
|
55 |
+
*/
|
56 |
+
protected $_email = null;
|
57 |
+
|
58 |
+
/**
|
59 |
+
* Check whether to use sandbox settings
|
60 |
+
* @var bool
|
61 |
+
*/
|
62 |
+
protected $_sandboxMode = false;
|
63 |
+
|
64 |
+
/**
|
65 |
+
* Constructor
|
66 |
+
*/
|
67 |
+
public function __construct($params)
|
68 |
+
{
|
69 |
+
list($name, $email)=$params;
|
70 |
+
$this->_name = $name;
|
71 |
+
$this->_email = $email;
|
72 |
+
parent::__construct();
|
73 |
+
}
|
74 |
+
|
75 |
+
/**
|
76 |
+
* Internal Constructor. Initialize API Client
|
77 |
+
*/
|
78 |
+
protected function _construct()
|
79 |
+
{
|
80 |
+
date_default_timezone_set('America/Chicago');
|
81 |
+
$mode = $this->_sandboxMode ? '-sandbox':'';
|
82 |
+
|
83 |
+
$this->_endpoint = Mage::getStoreConfig('paypalbanner'.$mode.'/settings/api_endpoint');
|
84 |
+
$this->_bnCode = Mage::getStoreConfig('paypalbanner'.$mode.'/settings/api_bn_code');
|
85 |
+
$this->_accessKey = Mage::getStoreConfig('paypalbanner'.$mode.'/settings/api_access_key');
|
86 |
+
$this->_secret = Mage::getStoreConfig('paypalbanner'.$mode.'/settings/api_secret');
|
87 |
+
$this->_timestamp = round(microtime(true) * 1000);
|
88 |
+
$this->_token = $token = sha1($this->_secret.$this->_timestamp);
|
89 |
+
$this->_responseData = new Varien_Object();
|
90 |
+
}
|
91 |
+
|
92 |
+
/**
|
93 |
+
* Get headers for API call
|
94 |
+
* @return array
|
95 |
+
*/
|
96 |
+
protected function _getHeaders()
|
97 |
+
{
|
98 |
+
return array(
|
99 |
+
"AUTHORIZATION: FPA ".$this->_accessKey.":".sha1($this->_secret.$this->_timestamp).":".$this->_timestamp,
|
100 |
+
"CONTENT-TYPE: application/json",
|
101 |
+
"ACCEPT: application/json"
|
102 |
+
);
|
103 |
+
}
|
104 |
+
|
105 |
+
/**
|
106 |
+
* Get params for API call
|
107 |
+
* @return array
|
108 |
+
*/
|
109 |
+
protected function _getParams()
|
110 |
+
{
|
111 |
+
return array(
|
112 |
+
'payerId' => '',
|
113 |
+
'sellerName' => $this->_name,
|
114 |
+
'emailAddress' => $this->_email,
|
115 |
+
'bnCode' => $this->_bnCode
|
116 |
+
);
|
117 |
+
}
|
118 |
+
|
119 |
+
/**
|
120 |
+
* Get params for API proxy call
|
121 |
+
* @return array
|
122 |
+
*/
|
123 |
+
protected function _getProxyParams()
|
124 |
+
{
|
125 |
+
return '?seller_name='.urlencode($this->_name).'&email_address='.urlencode($this->_email);
|
126 |
+
}
|
127 |
+
|
128 |
+
/**
|
129 |
+
* Get API response object
|
130 |
+
* @return object|null
|
131 |
+
*/
|
132 |
+
protected function _getResponse()
|
133 |
+
{
|
134 |
+
return $this->_responseData;
|
135 |
+
}
|
136 |
+
|
137 |
+
|
138 |
+
/**
|
139 |
+
* API Call.
|
140 |
+
* @return array
|
141 |
+
*/
|
142 |
+
public function call()
|
143 |
+
{
|
144 |
+
$curl = curl_init();
|
145 |
+
curl_setopt($curl, CURLOPT_VERBOSE, 1);
|
146 |
+
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE);
|
147 |
+
curl_setopt($curl, CURLOPT_TIMEOUT, 30);
|
148 |
+
curl_setopt($curl, CURLOPT_URL, $this->_endpoint);
|
149 |
+
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
|
150 |
+
curl_setopt($curl, CURLOPT_POSTFIELDS, json_encode($this->_getParams()));
|
151 |
+
curl_setopt($curl, CURLOPT_HTTPHEADER, $this->_getHeaders());
|
152 |
+
|
153 |
+
$this->_responseData = json_decode(curl_exec($curl));
|
154 |
+
return $this;
|
155 |
+
}
|
156 |
+
|
157 |
+
|
158 |
+
/**
|
159 |
+
* API Call proxy server.
|
160 |
+
* @return array
|
161 |
+
*/
|
162 |
+
public function callProxy()
|
163 |
+
{
|
164 |
+
$mode = $this->_sandboxMode ? '-sandbox':'';
|
165 |
+
$endpoint = Mage::getStoreConfig('paypalbanner'.$mode.'/settings/api_proxy_endpoint');
|
166 |
+
$endpoint .= $this->_getProxyParams();
|
167 |
+
|
168 |
+
$curl = curl_init();
|
169 |
+
curl_setopt($curl, CURLOPT_VERBOSE, 1);
|
170 |
+
curl_setopt($curl, CURLOPT_TIMEOUT, 30);
|
171 |
+
curl_setopt($curl, CURLOPT_URL, $endpoint);
|
172 |
+
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
|
173 |
+
$this->_responseData = json_decode(curl_exec($curl));
|
174 |
+
curl_close($curl);
|
175 |
+
return $this;
|
176 |
+
}
|
177 |
+
|
178 |
+
/**
|
179 |
+
* Get publisher ID from API response
|
180 |
+
* @return string|null
|
181 |
+
*/
|
182 |
+
public function extractPublisherId()
|
183 |
+
{
|
184 |
+
|
185 |
+
if ($this->_getResponse()){
|
186 |
+
if (!empty($this->_getResponse()->publisher_id)) {
|
187 |
+
return $this->_getResponse()->publisher_id;
|
188 |
+
} else {
|
189 |
+
return $this->_getResponse()->publisherId;
|
190 |
+
}
|
191 |
+
}
|
192 |
+
return null;
|
193 |
+
}
|
194 |
+
|
195 |
+
}
|
app/code/community/Angelleye/PaypalBanner/controllers/PpbsettingsController.php
ADDED
@@ -0,0 +1,123 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Angelleye_PaypalBanner_PpbsettingsController extends Mage_Adminhtml_Controller_Action
|
4 |
+
{
|
5 |
+
public function indexAction()
|
6 |
+
{
|
7 |
+
$this->loadLayout();
|
8 |
+
$this->getLayout()->getBlock('head')->setTitle($this->__('PaypalBanners - Setup Finance Portal'));
|
9 |
+
$this->renderLayout();
|
10 |
+
}
|
11 |
+
|
12 |
+
public function processAction()
|
13 |
+
{
|
14 |
+
$post = $this->getRequest()->getParams();
|
15 |
+
|
16 |
+
$email = !empty($post['paypal_email']) ? $post['paypal_email'] : '';
|
17 |
+
$name = !empty($post['paypal_name']) ? $post['paypal_name'] : '';
|
18 |
+
$terms = !empty($post['paypal_terms']) ? $post['paypal_terms'] : '';
|
19 |
+
$active = !empty($post['paypal_active']) ? $post['paypal_active'] : 0;
|
20 |
+
$container = !empty($post['paypal_container']) ? $post['paypal_container'] : '';
|
21 |
+
|
22 |
+
$messages = array();
|
23 |
+
$success = false;
|
24 |
+
$publisherId = '';
|
25 |
+
|
26 |
+
if (empty($email) || empty($name)){
|
27 |
+
$messages[] = 'Please, enter all required fields';
|
28 |
+
}
|
29 |
+
if (empty($terms)){
|
30 |
+
$messages[] = 'You have to agree with terms and conditions';
|
31 |
+
}
|
32 |
+
|
33 |
+
if (!Zend_Validate::is($email, 'EmailAddress')) {
|
34 |
+
$messages[] = 'Please, enter valid email';
|
35 |
+
}
|
36 |
+
|
37 |
+
|
38 |
+
if (empty($messages)) {
|
39 |
+
// $publisherId = Mage::getSingleton('paypalbanner/client', array($name, $email))->call()->extractPublisherId();
|
40 |
+
$publisherId = Mage::getSingleton('paypalbanner/client', array($name, $email))->callProxy()->extractPublisherId();
|
41 |
+
|
42 |
+
if (!empty($publisherId)){
|
43 |
+
$success = true;
|
44 |
+
}
|
45 |
+
}
|
46 |
+
|
47 |
+
$res = array(
|
48 |
+
'success'=>$success,
|
49 |
+
'msg'=>implode('. ', $messages),
|
50 |
+
'publisher_id'=>$publisherId
|
51 |
+
);
|
52 |
+
if ($success){
|
53 |
+
$elementId = Mage::getModel('core/config_data')
|
54 |
+
->getCollection()
|
55 |
+
->addFieldToFilter('path', 'paypalbanner/settings/id')
|
56 |
+
->getFirstItem();
|
57 |
+
|
58 |
+
if ($elementId && $elementId->getId()){
|
59 |
+
$elementId->setValue($publisherId)->save();
|
60 |
+
} else {
|
61 |
+
Mage::getModel('core/config_data')
|
62 |
+
->setScope('default')
|
63 |
+
->setScopeId(0)
|
64 |
+
->setPath('paypalbanner/settings/id')
|
65 |
+
->setValue($publisherId)
|
66 |
+
->save();
|
67 |
+
}
|
68 |
+
|
69 |
+
$elementActive = Mage::getModel('core/config_data')
|
70 |
+
->getCollection()
|
71 |
+
->addFieldToFilter('path', 'paypalbanner/settings/active')
|
72 |
+
->getFirstItem();
|
73 |
+
|
74 |
+
if ($elementActive && $elementActive->getId()){
|
75 |
+
$elementActive->setValue($active)->save();
|
76 |
+
} else {
|
77 |
+
Mage::getModel('core/config_data')
|
78 |
+
->setScope('default')
|
79 |
+
->setScopeId(0)
|
80 |
+
->setPath('paypalbanner/settings/active')
|
81 |
+
->setValue($active)
|
82 |
+
->save();
|
83 |
+
}
|
84 |
+
|
85 |
+
$elementContainer = Mage::getModel('core/config_data')
|
86 |
+
->getCollection()
|
87 |
+
->addFieldToFilter('path', 'paypalbanner/settings/container')
|
88 |
+
->getFirstItem();
|
89 |
+
|
90 |
+
if ($elementContainer && $elementContainer->getId()){
|
91 |
+
$elementContainer->setValue($container)->save();
|
92 |
+
} else {
|
93 |
+
Mage::getModel('core/config_data')
|
94 |
+
->setScope('default')
|
95 |
+
->setScopeId(0)
|
96 |
+
->setPath('paypalbanner/settings/container')
|
97 |
+
->setValue($container)
|
98 |
+
->save();
|
99 |
+
}
|
100 |
+
}
|
101 |
+
return $this->getResponse()->setBody(json_encode($res));
|
102 |
+
|
103 |
+
}
|
104 |
+
|
105 |
+
public function clearAction()
|
106 |
+
{
|
107 |
+
$elementId = Mage::getModel('core/config_data')
|
108 |
+
->getCollection()
|
109 |
+
->addFieldToFilter('path', 'paypalbanner/settings/id')
|
110 |
+
->getFirstItem();
|
111 |
+
if ($elementId && $elementId->getId()){
|
112 |
+
$elementId->delete();
|
113 |
+
}
|
114 |
+
|
115 |
+
$elementActive = Mage::getModel('core/config_data')
|
116 |
+
->getCollection()
|
117 |
+
->addFieldToFilter('path', 'paypalbanner/settings/active')
|
118 |
+
->getFirstItem();
|
119 |
+
if ($elementActive && $elementActive->getId()){
|
120 |
+
$elementActive->setValue(0)->save();
|
121 |
+
}
|
122 |
+
}
|
123 |
+
}
|
app/code/community/Angelleye/PaypalBanner/controllers/SettingsController.php
ADDED
@@ -0,0 +1,70 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Angelleye_PaypalBanner_SettingsController extends Mage_Core_Controller_Front_Action
|
4 |
+
{
|
5 |
+
public function indexAction()
|
6 |
+
{
|
7 |
+
$this->loadLayout();
|
8 |
+
$this->getLayout()->getBlock('head')->setTitle($this->__('PaypalBanners - Setup Finance Portal'));
|
9 |
+
$this->renderLayout();
|
10 |
+
}
|
11 |
+
|
12 |
+
public function processAction()
|
13 |
+
{
|
14 |
+
$post = $this->getRequest()->getParams();
|
15 |
+
|
16 |
+
$email = !empty($post['paypal_email']) ? $post['paypal_email'] : '';
|
17 |
+
$name = !empty($post['paypal_name']) ? $post['paypal_name'] : '';
|
18 |
+
$terms = !empty($post['paypal_terms']) ? $post['paypal_terms'] : '';
|
19 |
+
|
20 |
+
$messages = array();
|
21 |
+
$success = false;
|
22 |
+
$publisherId = '';
|
23 |
+
|
24 |
+
if (empty($email) || empty($name)){
|
25 |
+
$messages[] = 'Please, enter all required fields';
|
26 |
+
}
|
27 |
+
if (empty($terms)){
|
28 |
+
$messages[] = 'You have to agree with terms and conditions';
|
29 |
+
}
|
30 |
+
|
31 |
+
if (!Zend_Validate::is($email, 'EmailAddress')) {
|
32 |
+
$messages[] = 'Please, enter valid email';
|
33 |
+
}
|
34 |
+
|
35 |
+
|
36 |
+
if (empty($messages)) {
|
37 |
+
// $publisherId = Mage::getSingleton('paypalbanner/client', array($name, $email))->call()->extractPublisherId();
|
38 |
+
$publisherId = Mage::getSingleton('paypalbanner/client', array($name, $email))->callProxy()->extractPublisherId();
|
39 |
+
|
40 |
+
if (!empty($publisherId)){
|
41 |
+
$success = true;
|
42 |
+
}
|
43 |
+
}
|
44 |
+
|
45 |
+
$res = array(
|
46 |
+
'success'=>$success,
|
47 |
+
'msg'=>implode('. ', $messages),
|
48 |
+
'publisher_id'=>$publisherId
|
49 |
+
);
|
50 |
+
if ($success){
|
51 |
+
$element = Mage::getModel('core/config_data')
|
52 |
+
->getCollection()
|
53 |
+
->addFieldToFilter('path', 'paypalbanner/settings/id')
|
54 |
+
->getFirstItem();
|
55 |
+
|
56 |
+
if ($element->getId()){
|
57 |
+
$element->setValue($publisherId)->save();
|
58 |
+
} else {
|
59 |
+
Mage::getModel('core/config_data')
|
60 |
+
->setScope('default')
|
61 |
+
->setScopeId(0)
|
62 |
+
->setPath('paypalbanner/settings/id')
|
63 |
+
->setValue($publisherId)
|
64 |
+
->save();
|
65 |
+
}
|
66 |
+
}
|
67 |
+
return $this->getResponse()->setBody(json_encode($res));
|
68 |
+
|
69 |
+
}
|
70 |
+
}
|
app/code/community/Angelleye/PaypalBanner/etc/config.xml
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
<config>
|
3 |
<modules>
|
4 |
<Angelleye_PaypalBanner>
|
5 |
-
<version>1.0.
|
6 |
</Angelleye_PaypalBanner>
|
7 |
</modules>
|
8 |
<global>
|
@@ -20,11 +20,11 @@
|
|
20 |
<paypalbanner>
|
21 |
<class>Angelleye_PaypalBanner_Model</class>
|
22 |
</paypalbanner>
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
</models>
|
29 |
<events>
|
30 |
<controller_action_layout_generate_xml_before>
|
@@ -38,21 +38,46 @@
|
|
38 |
</events>
|
39 |
</global>
|
40 |
<frontend>
|
41 |
-
<
|
42 |
-
<
|
43 |
-
<
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
|
|
|
|
48 |
</frontend>
|
49 |
<default>
|
50 |
<paypalbanner>
|
51 |
<settings>
|
52 |
<container><![CDATA[<div style="width: 100%; text-align: center; padding-bottom: 7px ">{container}</div>]]></container>
|
|
|
|
|
|
|
|
|
|
|
53 |
</settings>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
54 |
</paypalbanner>
|
55 |
</default>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
56 |
<adminhtml>
|
57 |
<acl>
|
58 |
<resources>
|
@@ -63,7 +88,7 @@
|
|
63 |
<config>
|
64 |
<children>
|
65 |
<paypalbanner translate="title" module="paypalbanner">
|
66 |
-
<title>PayPal
|
67 |
</paypalbanner>
|
68 |
</children>
|
69 |
</config>
|
2 |
<config>
|
3 |
<modules>
|
4 |
<Angelleye_PaypalBanner>
|
5 |
+
<version>1.0.2</version>
|
6 |
</Angelleye_PaypalBanner>
|
7 |
</modules>
|
8 |
<global>
|
20 |
<paypalbanner>
|
21 |
<class>Angelleye_PaypalBanner_Model</class>
|
22 |
</paypalbanner>
|
23 |
+
<paypal>
|
24 |
+
<rewrite>
|
25 |
+
<config>Angelleye_PaypalBanner_Model_Config</config>
|
26 |
+
</rewrite>
|
27 |
+
</paypal>
|
28 |
</models>
|
29 |
<events>
|
30 |
<controller_action_layout_generate_xml_before>
|
38 |
</events>
|
39 |
</global>
|
40 |
<frontend>
|
41 |
+
<routers>
|
42 |
+
<paypalbanner>
|
43 |
+
<use>standard</use>
|
44 |
+
<args>
|
45 |
+
<module>Angelleye_PaypalBanner</module>
|
46 |
+
<frontName>paypalbanner</frontName>
|
47 |
+
</args>
|
48 |
+
</paypalbanner>
|
49 |
+
</routers>
|
50 |
</frontend>
|
51 |
<default>
|
52 |
<paypalbanner>
|
53 |
<settings>
|
54 |
<container><![CDATA[<div style="width: 100%; text-align: center; padding-bottom: 7px ">{container}</div>]]></container>
|
55 |
+
<api_secret></api_secret>
|
56 |
+
<api_access_key></api_access_key>
|
57 |
+
<api_bn_code>AngellEYE_PHPClass</api_bn_code>
|
58 |
+
<api_endpoint>https://api.financing.paypal.com/finapi/v1/publishers/</api_endpoint>
|
59 |
+
<api_proxy_endpoint>http://www.angelleye.com/web-services/paypal-bml/FinancingBannerEnrollment.php</api_proxy_endpoint>
|
60 |
</settings>
|
61 |
+
<settings-sandbox>
|
62 |
+
<api_secret></api_secret>
|
63 |
+
<api_access_key></api_access_key>
|
64 |
+
<api_bn_code>AngellEYE_PHPClass</api_bn_code>
|
65 |
+
<api_endpoint>https://api.financing-mint.paypal.com/finapi/v1/publishers/</api_endpoint>
|
66 |
+
<api_proxy_endpoint>http://www.angelleye.com/web-services/paypal-bml/FinancingBannerEnrollment.php</api_proxy_endpoint>
|
67 |
+
</settings-sandbox>
|
68 |
</paypalbanner>
|
69 |
</default>
|
70 |
+
<admin>
|
71 |
+
<routers>
|
72 |
+
<adminhtml>
|
73 |
+
<args>
|
74 |
+
<modules>
|
75 |
+
<Angelleye_PaypalBanner before="Mage_Adminhtml">Angelleye_PaypalBanner</Angelleye_PaypalBanner>
|
76 |
+
</modules>
|
77 |
+
</args>
|
78 |
+
</adminhtml>
|
79 |
+
</routers>
|
80 |
+
</admin>
|
81 |
<adminhtml>
|
82 |
<acl>
|
83 |
<resources>
|
88 |
<config>
|
89 |
<children>
|
90 |
<paypalbanner translate="title" module="paypalbanner">
|
91 |
+
<title>PayPal Banners Settings</title>
|
92 |
</paypalbanner>
|
93 |
</children>
|
94 |
</config>
|
app/code/community/Angelleye/PaypalBanner/etc/system.xml
CHANGED
@@ -18,32 +18,159 @@
|
|
18 |
<show_in_website>0</show_in_website>
|
19 |
<show_in_store>0</show_in_store>
|
20 |
<fields>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
21 |
<active translate="label">
|
22 |
-
<label>
|
23 |
<frontend_type>select</frontend_type>
|
24 |
<source_model>adminhtml/system_config_source_yesno</source_model>
|
25 |
-
<sort_order>
|
26 |
<show_in_default>1</show_in_default>
|
27 |
<show_in_website>0</show_in_website>
|
28 |
<show_in_store>0</show_in_store>
|
29 |
</active>
|
30 |
-
<
|
31 |
-
<label>
|
|
|
32 |
<comment><![CDATA[
|
33 |
-
|
34 |
-
|
35 |
]]></comment>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
36 |
<frontend_type>text</frontend_type>
|
37 |
-
<
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
38 |
<show_in_default>1</show_in_default>
|
39 |
<show_in_website>0</show_in_website>
|
40 |
<show_in_store>0</show_in_store>
|
41 |
-
</
|
|
|
42 |
<container translate="label,comment">
|
43 |
<label>Code Wrapper</label>
|
44 |
-
<comment><![CDATA[Place
|
45 |
<frontend_type>textarea</frontend_type>
|
46 |
-
<sort_order>
|
47 |
<show_in_default>1</show_in_default>
|
48 |
<show_in_website>0</show_in_website>
|
49 |
<show_in_store>0</show_in_store>
|
18 |
<show_in_website>0</show_in_website>
|
19 |
<show_in_store>0</show_in_store>
|
20 |
<fields>
|
21 |
+
<id translate="label,comment">
|
22 |
+
<label></label>
|
23 |
+
<frontend_type>text</frontend_type>
|
24 |
+
<frontend_model>paypalbanner/system_field_id</frontend_model>
|
25 |
+
<sort_order>1</sort_order>
|
26 |
+
<show_in_default>1</show_in_default>
|
27 |
+
<show_in_website>0</show_in_website>
|
28 |
+
<show_in_store>0</show_in_store>
|
29 |
+
</id>
|
30 |
<active translate="label">
|
31 |
+
<label>Enabled</label>
|
32 |
<frontend_type>select</frontend_type>
|
33 |
<source_model>adminhtml/system_config_source_yesno</source_model>
|
34 |
+
<sort_order>2</sort_order>
|
35 |
<show_in_default>1</show_in_default>
|
36 |
<show_in_website>0</show_in_website>
|
37 |
<show_in_store>0</show_in_store>
|
38 |
</active>
|
39 |
+
<paypal_email translate="label,comment">
|
40 |
+
<label>PayPal Email</label>
|
41 |
+
<frontend_type>text</frontend_type>
|
42 |
<comment><![CDATA[
|
43 |
+
<div style="display:none" id="advice-required-entry-paypal_email" class="validation-advice">This is a required field.</div>
|
44 |
+
<div style="display:none" id="advice-required-entry-paypal_email2" class="validation-advice">Please, enter a valid email.</div>
|
45 |
]]></comment>
|
46 |
+
<sort_order>3</sort_order>
|
47 |
+
<show_in_default>1</show_in_default>
|
48 |
+
<show_in_website>0</show_in_website>
|
49 |
+
<show_in_store>0</show_in_store>
|
50 |
+
</paypal_email>
|
51 |
+
<paypal_name translate="label,comment">
|
52 |
+
<label>PayPal Name</label>
|
53 |
<frontend_type>text</frontend_type>
|
54 |
+
<comment><![CDATA[
|
55 |
+
<div style="display:none" id="advice-required-entry-paypal_name" class="validation-advice">This is a required field.</div>
|
56 |
+
<br />
|
57 |
+
<input type="checkbox" style="margin-right: 5px" value="1" id="paypalbanner_settings_paypal_terms" name="paypal_terms" class="checkbox validation-passed">
|
58 |
+
<span>I agree to PayPal finance portal <a target="_blank" href="http://financing.paypal.com">terms and conditions</a> </span>
|
59 |
+
<div style="display: none" id="paypal_terms_validation_failed" class="validation-advice">You must agree to terms and conditions.</div>
|
60 |
+
<br />
|
61 |
+
<button class="scalable save" style="margin-top: 5px" onclick="processForm(); return false" type="button" id="paypalbanner_get_id_btn">
|
62 |
+
<span><span><span>Activate</span></span></span>
|
63 |
+
</button>
|
64 |
+
<button class="scalable delete" style="margin-top: 5px" onclick="if(confirm('Are you sure?')){clearSettings()}; return false" type="button" id="paypalbanner_clear_btn">
|
65 |
+
<span><span><span>Clear Settings</span></span></span>
|
66 |
+
</button>
|
67 |
+
<script type="text/javascript">
|
68 |
+
|
69 |
+
function processForm(){
|
70 |
+
$('advice-required-entry-paypal_name').hide();
|
71 |
+
$('advice-required-entry-paypal_email').hide();
|
72 |
+
$('advice-required-entry-paypal_email2').hide();
|
73 |
+
$('paypal_terms_validation_failed').hide();
|
74 |
+
|
75 |
+
var re = /^([a-z0-9,!\#\$%&'\*\+\/=\?\^_`\{\|\}~-]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z0-9,!\#\$%&'\*\+\/=\?\^_`\{\|\}~-]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*@([a-z0-9-]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z0-9-]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*\.(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]){2,})$/i;
|
76 |
+
|
77 |
+
if (!$('paypalbanner_settings_paypal_terms').checked
|
78 |
+
|| $('paypalbanner_settings_paypal_email').value ==''
|
79 |
+
|| $('paypalbanner_settings_paypal_name').value ==''
|
80 |
+
|| !re.test($('paypalbanner_settings_paypal_email').value)
|
81 |
+
){
|
82 |
+
if ($('paypalbanner_settings_paypal_name').value ==''){
|
83 |
+
$('advice-required-entry-paypal_name').show();
|
84 |
+
}
|
85 |
+
if ($('paypalbanner_settings_paypal_email').value ==''){
|
86 |
+
$('advice-required-entry-paypal_email').show();
|
87 |
+
} else if (!re.test($('paypalbanner_settings_paypal_email').value)) {
|
88 |
+
$('advice-required-entry-paypal_email2').show();
|
89 |
+
}
|
90 |
+
if (!$('paypalbanner_settings_paypal_terms').checked ) {
|
91 |
+
$('paypal_terms_validation_failed').show();
|
92 |
+
}
|
93 |
+
return false;
|
94 |
+
}
|
95 |
+
|
96 |
+
$('loading-mask').show();
|
97 |
+
var terms = ($('paypalbanner_settings_paypal_terms').checked?'1':'0');
|
98 |
+
var params = 'paypal_name='+$('paypalbanner_settings_paypal_name').value;
|
99 |
+
params+='&paypal_email='+$('paypalbanner_settings_paypal_email').value;
|
100 |
+
params+='&paypal_active='+$('paypalbanner_settings_active').value;
|
101 |
+
params+='&paypal_container='+ encodeURI($('paypalbanner_settings_container').value);
|
102 |
+
params+='&paypal_terms='+terms;
|
103 |
+
|
104 |
+
var request = new Ajax.Request(
|
105 |
+
'/paypalbanner/ppbsettings/process/form_key/'+FORM_KEY,
|
106 |
+
{
|
107 |
+
method:'post',
|
108 |
+
parameters:params,
|
109 |
+
onComplete: function(transport){
|
110 |
+
var response = transport.responseText.evalJSON();
|
111 |
+
if (!response.success || !response.publisher_id) {
|
112 |
+
if (response.msg && response.msg != ''){
|
113 |
+
var msg = response.msg;
|
114 |
+
} else {
|
115 |
+
var msg = 'Can not get ID for this name and email';
|
116 |
+
}
|
117 |
+
alert(msg);
|
118 |
+
} else {
|
119 |
+
$("paypalbanner_settings_id").value = response.publisher_id;
|
120 |
+
<!--$("ppbanner_msg_holder").removeClassName("notice-msg");-->
|
121 |
+
<!--$("ppbanner_msg_holder").addClassName("success-msg");-->
|
122 |
+
<!--$("ppbanner_msg_holder").update("<ul><li><span>Value is set</span>");-->
|
123 |
+
showSettingsFine();
|
124 |
+
}
|
125 |
+
$('loading-mask').hide();
|
126 |
+
}
|
127 |
+
}
|
128 |
+
);
|
129 |
+
|
130 |
+
}
|
131 |
+
|
132 |
+
function clearSettings(){
|
133 |
+
$('loading-mask').show();
|
134 |
+
var request = new Ajax.Request(
|
135 |
+
'/paypalbanner/ppbsettings/clear/form_key/'+FORM_KEY,
|
136 |
+
{
|
137 |
+
method:'post',
|
138 |
+
onComplete: function(transport){
|
139 |
+
$('paypalbanner_settings_active').value = '0';
|
140 |
+
$("paypalbanner_settings_id").value = '';
|
141 |
+
$("paypalbanner_settings_paypal_email").value = '';
|
142 |
+
$("paypalbanner_settings_paypal_name").value = '';
|
143 |
+
$("paypalbanner_settings_paypal_terms").checked = false;
|
144 |
+
$('loading-mask').hide();
|
145 |
+
showNoSettings();
|
146 |
+
}
|
147 |
+
}
|
148 |
+
);
|
149 |
+
}
|
150 |
+
|
151 |
+
function showNoSettings(){
|
152 |
+
$("messages_success").hide();
|
153 |
+
$("messages_error").show();
|
154 |
+
}
|
155 |
+
|
156 |
+
function showSettingsFine(){
|
157 |
+
$("messages_success").show();
|
158 |
+
$("messages_error").hide();
|
159 |
+
}
|
160 |
+
|
161 |
+
|
162 |
+
</script>]]></comment>
|
163 |
+
<sort_order>5</sort_order>
|
164 |
<show_in_default>1</show_in_default>
|
165 |
<show_in_website>0</show_in_website>
|
166 |
<show_in_store>0</show_in_store>
|
167 |
+
</paypal_name>
|
168 |
+
|
169 |
<container translate="label,comment">
|
170 |
<label>Code Wrapper</label>
|
171 |
+
<comment><![CDATA[Place html code with "{container}"-tag inside, which will be replaced with your banner block]]></comment>
|
172 |
<frontend_type>textarea</frontend_type>
|
173 |
+
<sort_order>6</sort_order>
|
174 |
<show_in_default>1</show_in_default>
|
175 |
<show_in_website>0</show_in_website>
|
176 |
<show_in_store>0</show_in_store>
|
app/code/community/Angelleye/PaypalBanner/sql/paypalbanner_setup/mysql4-install-0.0.1.php
ADDED
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
$installer = $this;
|
4 |
+
$installer->startSetup();
|
5 |
+
|
6 |
+
$adminSession = Mage::getSingleton('admin/session');
|
7 |
+
$adminSession->unsetAll();
|
8 |
+
$adminSession->getCookie()->delete($adminSession->getSessionName());
|
9 |
+
|
10 |
+
$installer->endSetup();
|
app/design/frontend/base/default/template/paypalbanner/snippet.phtml
DELETED
@@ -1 +0,0 @@
|
|
1 |
-
<?php echo $this->getBannerCode();?>
|
|
app/design/frontend/default/default/layout/paypalbanner.xml
ADDED
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<layout version="0.1.0">
|
3 |
+
<paypalbanner_settings_index>
|
4 |
+
<remove name="right"/>
|
5 |
+
<remove name="left"/>
|
6 |
+
<!--<remove name="head"/>-->
|
7 |
+
<reference name="root">
|
8 |
+
<action method="setTemplate"><template>page/empty.phtml</template></action>
|
9 |
+
</reference>
|
10 |
+
<reference name="content">
|
11 |
+
<block type="paypalbanner/settings" name="settings" template="paypalbanner/settings.phtml" />
|
12 |
+
</reference>
|
13 |
+
</paypalbanner_settings_index>
|
14 |
+
</layout>
|
app/design/frontend/default/default/template/paypalbanner/settings.phtml
ADDED
@@ -0,0 +1,103 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<link rel="stylesheet" type="text/css" href="/skin/adminhtml/default/default/boxes.css" media="all" />
|
2 |
+
<h3 style="border-bottom: 4px solid #dfdfdf; padding-bottom: .25em;">Please, enter following data:</h3>
|
3 |
+
<ul class="messages">
|
4 |
+
<li class="error-msg" id="error-msg-holder" style="display: none">
|
5 |
+
<ul>
|
6 |
+
<li>
|
7 |
+
<span id="error-msg-text"></span>
|
8 |
+
</li>
|
9 |
+
</ul>
|
10 |
+
</li>
|
11 |
+
</ul>
|
12 |
+
<fieldset class="config collapseable" id="paypalbanner_settings" style="">
|
13 |
+
<legend>General Settings</legend>
|
14 |
+
<table cellspacing="0" class="form-list">
|
15 |
+
<tbody>
|
16 |
+
<tr id="paypalbanner_settings_name">
|
17 |
+
<td class="label">
|
18 |
+
<label for="paypal_name">PayPal Name</label>
|
19 |
+
</td>
|
20 |
+
<td class="value">
|
21 |
+
<input id="paypal_name" name="paypal_name"class="required-entry input-text" type="text" value="<?php echo $this->getPaypalName()?>">
|
22 |
+
</td>
|
23 |
+
</tr>
|
24 |
+
<tr id="paypalbanner_settings_email">
|
25 |
+
<td class="label">
|
26 |
+
<label for="paypal_email">PayPal Email</label>
|
27 |
+
</td>
|
28 |
+
<td class="value">
|
29 |
+
<input id="paypal_email" name="paypal_email" class="input-text validate-email required-entry" type="text" value="<?php echo $this->getPaypalEmail()?>">
|
30 |
+
</td>
|
31 |
+
</tr>
|
32 |
+
<tr id="paypalbanner_settings_terms">
|
33 |
+
<td class="label"> </td>
|
34 |
+
<td class="value">
|
35 |
+
<input type="checkbox" class="checkbox" name="paypal_terms" id="paypal_terms" value="41" price="0.01">
|
36 |
+
I agree to PayPal finance portal <a href="http://financing.paypal.com" target=_blank>terms and conditions</a>.
|
37 |
+
<div style="display: none" id="paypal_terms_validation_failed" class="validation-advice">You must agree to terms and conditions.</div>
|
38 |
+
</td>
|
39 |
+
</tr>
|
40 |
+
<tr id="paypalbanner_settings_container">
|
41 |
+
<td class="label"> </td>
|
42 |
+
<td class="value">
|
43 |
+
<span>
|
44 |
+
<button style="margin-top: 5px" class="scalable" type="button" onclick="processForm(); return false" id="get_id_submit_btn">
|
45 |
+
<span><span><span>Continue!</span></span></span>
|
46 |
+
</button>
|
47 |
+
</span>
|
48 |
+
</td>
|
49 |
+
</tr>
|
50 |
+
</tbody>
|
51 |
+
</table>
|
52 |
+
</fieldset>
|
53 |
+
<div style="left: -2px; top: 0px; width: 100% ; height: 100%; display: none;" id="loading-mask">
|
54 |
+
<p id="loading_mask_loader" class="loader"><img alt="Loading..." src="/skin/adminhtml/default/default/images/ajax-loader-tr.gif"><br>Please wait...</p>
|
55 |
+
</div>
|
56 |
+
|
57 |
+
<script type="text/javascript">
|
58 |
+
//<![CDATA[
|
59 |
+
function processForm(){
|
60 |
+
var form = $('paypalbanner_settings');
|
61 |
+
var validator= new Validation(form);
|
62 |
+
if (!$('paypal_terms').checked){
|
63 |
+
$('paypal_terms_validation_failed').show();
|
64 |
+
validator.validate();
|
65 |
+
return false;
|
66 |
+
} else {
|
67 |
+
$('paypal_terms_validation_failed').hide();
|
68 |
+
}
|
69 |
+
if (validator.validate()) {
|
70 |
+
$('loading-mask').show();
|
71 |
+
var params = Form.serialize(form);
|
72 |
+
var request = new Ajax.Request(
|
73 |
+
'<?php echo $this->getUrl('paypalbanner/settings/process');?>',
|
74 |
+
{
|
75 |
+
method:'post',
|
76 |
+
parameters:params,
|
77 |
+
onComplete: function(transport){
|
78 |
+
var response = transport.responseText.evalJSON();
|
79 |
+
if (!response.success || !response.publisher_id) {
|
80 |
+
|
81 |
+
$('loading-mask').hide();
|
82 |
+
if (response.msg && response.msg != ''){
|
83 |
+
var msg = response.msg;
|
84 |
+
} else {
|
85 |
+
var msg = 'Can not get ID for this name and email';
|
86 |
+
}
|
87 |
+
$('error-msg-text').update(msg);
|
88 |
+
$('error-msg-holder').show();
|
89 |
+
} else {
|
90 |
+
window.opener.document.getElementById("paypalbanner_settings_id").value = response.publisher_id;
|
91 |
+
$('error-msg-holder').hide();
|
92 |
+
$('loading-mask').hide();
|
93 |
+
self.close();
|
94 |
+
}
|
95 |
+
$('loading-mask').hide();
|
96 |
+
}
|
97 |
+
}
|
98 |
+
);
|
99 |
+
}
|
100 |
+
}
|
101 |
+
|
102 |
+
//]]!>
|
103 |
+
</script>
|
package.xml
CHANGED
@@ -1,22 +1,18 @@
|
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>Angelleye_PayPal_BML_Banners</name>
|
4 |
-
<version>1.0.
|
5 |
<stability>stable</stability>
|
6 |
-
<license uri="http://opensource.org/licenses/osl-3.0.php">OSL</license>
|
7 |
<channel>community</channel>
|
8 |
<extends/>
|
9 |
-
<summary>Easily add PayPal Bill Me Later banners to your
|
10 |
-
<description>
|
11 |
-
|
12 |
-
If you're already using one of the eligible PayPal products you may use this module to advertise the Bill Me Later financing option on your website. Studies have shown that Bill Me Later drives a 75% lift in average order value (compared with overall order value.)
|
13 |
-

|
14 |
-
The module will give you the ability to easily add a PayPal Bill Me Later promotional banner to your home page, category pages, product detail pages, and your shopping cart. You can choose to display the banner at the top or bottom of your content area or a side bar, and you can choose from variety of banner sizes.</description>
|
15 |
-
<notes>Added missing template file.</notes>
|
16 |
<authors><author><name>Angell EYE, LLC</name><user>angelleye</user><email>andrew@angelleye.com</email></author></authors>
|
17 |
-
<date>2013-
|
18 |
-
<time>
|
19 |
-
<contents><target name="magecommunity"><dir name="Angelleye"><dir name="PaypalBanner"><dir name="Block"><file name="Banner.php" hash="c1d46299ee0f006972d9b03f09469d32"/></dir><dir name="Helper"><file name="Data.php" hash="
|
20 |
<compatible/>
|
21 |
<dependencies><required><php><min>5.1.0</min><max>6.0.0</max></php></required></dependencies>
|
22 |
</package>
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>Angelleye_PayPal_BML_Banners</name>
|
4 |
+
<version>1.0.2</version>
|
5 |
<stability>stable</stability>
|
6 |
+
<license uri="http://opensource.org/licenses/osl-3.0.php">OSL v3.0</license>
|
7 |
<channel>community</channel>
|
8 |
<extends/>
|
9 |
+
<summary>Easily add PayPal Bill Me Later financing promotional banners to your Magento site.</summary>
|
10 |
+
<description>The module will give you the ability to easily add a PayPal Bill Me Later promotional banner ads (financing offers) to your home page, category pages, product detail pages, and your shopping cart.</description>
|
11 |
+
<notes>Improved user experience for configuring the extension.</notes>
|
|
|
|
|
|
|
|
|
12 |
<authors><author><name>Angell EYE, LLC</name><user>angelleye</user><email>andrew@angelleye.com</email></author></authors>
|
13 |
+
<date>2013-11-22</date>
|
14 |
+
<time>02:25:07</time>
|
15 |
+
<contents><target name="magecommunity"><dir name="Angelleye"><dir name="PaypalBanner"><dir name="Block"><file name="Banner.php" hash="c1d46299ee0f006972d9b03f09469d32"/><file name="Settings.php" hash="0e74c0d3f55b567391317c36252cef3c"/><dir name="System"><dir name="Field"><file name="Id.php" hash="db22bc4c991021446b601863f379b723"/></dir></dir></dir><dir name="Helper"><file name="Data.php" hash="e7a3afc7b66633e46de1c5d870d7fd91"/></dir><dir name="Model"><file name="Client.php" hash="46d88b3a36986fb4aa92d0f3f836beb1"/><file name="Config.php" hash="280d4f1bdcd5793c6be4bcb7a09d3a04"/><file name="Observer.php" hash="3e598f4cd6029a405fb72c31ec977317"/><dir name="System"><dir name="Config"><file name="Position.php" hash="414a7e9017f72ca2f230742cbc8abd6b"/><file name="Size.php" hash="a75fab8643bbbb2f41b1703dd6d2487a"/></dir></dir></dir><dir name="controllers"><file name="PpbsettingsController.php" hash="53ebc7593b3deb2fbae27c6e3e0ad21b"/><file name="SettingsController.php" hash="0b9129ccb46b7f91826b3099c522dff6"/></dir><dir name="etc"><file name="config.xml" hash="cb2b8aec45482226fd08bc3f87a7229e"/><file name="system.xml" hash="2cef785dea3409a55b8a0264bf7f7054"/></dir><dir name="sql"><dir name="paypalbanner_setup"><file name="mysql4-install-0.0.1.php" hash="dfaec511268382bb65b52fe7e794fff0"/></dir></dir></dir></dir></target><target name="magedesign"><dir name="frontend"><dir name="default"><dir name="default"><dir name="layout"><file name="paypalbanner.xml" hash="78644a669cf4e6aacf858e61d399e81e"/></dir><dir name="template"><dir name="paypalbanner"><file name="settings.phtml" hash="63487b3474eb56e8ac33842dd7016886"/></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Angelleye_PaypalBanner.xml" hash="1b360ec01ee752e5958551582a941dd8"/></dir></target></contents>
|
16 |
<compatible/>
|
17 |
<dependencies><required><php><min>5.1.0</min><max>6.0.0</max></php></required></dependencies>
|
18 |
</package>
|