Version Notes
Plugin UFFICIALE per integrare Magento con il sistema di pagamento online Banca Sella.
Download this release
Release Info
Developer | EasyNolo Spa |
Extension | EASYNOLOBANCASELLAPRO |
Version | 1.4.0.0 |
Comparing to | |
See all releases |
Version 1.4.0.0
- app/code/community/EasyNolo/BancaSellaPro/Block/Confirm3d.php +17 -0
- app/code/community/EasyNolo/BancaSellaPro/Block/Form.php +104 -0
- app/code/community/EasyNolo/BancaSellaPro/Block/Newroot.php +9 -0
- app/code/community/EasyNolo/BancaSellaPro/Block/Redirect.php +42 -0
- app/code/community/EasyNolo/BancaSellaPro/Block/Tokenization/Newtoken.php +100 -0
- app/code/community/EasyNolo/BancaSellaPro/Block/Utility/Text.php +21 -0
- app/code/community/EasyNolo/BancaSellaPro/Exception.php +10 -0
- app/code/community/EasyNolo/BancaSellaPro/Helper/Baseclient.php +49 -0
- app/code/community/EasyNolo/BancaSellaPro/Helper/Crypt.php +286 -0
- app/code/community/EasyNolo/BancaSellaPro/Helper/Data.php +151 -0
- app/code/community/EasyNolo/BancaSellaPro/Helper/Recurringprofile.php +266 -0
- app/code/community/EasyNolo/BancaSellaPro/Helper/S2s.php +128 -0
- app/code/community/EasyNolo/BancaSellaPro/Model/Gestpay.php +693 -0
- app/code/community/EasyNolo/BancaSellaPro/Model/Observer.php +57 -0
- app/code/community/EasyNolo/BancaSellaPro/Model/Resource/Token.php +17 -0
- app/code/community/EasyNolo/BancaSellaPro/Model/Resource/Token/Collection.php +24 -0
- app/code/community/EasyNolo/BancaSellaPro/Model/Sales/Recurring/Profile.php +22 -0
- app/code/community/EasyNolo/BancaSellaPro/Model/System/Config/Source/Currency.php +34 -0
- app/code/community/EasyNolo/BancaSellaPro/Model/System/Config/Source/Language.php +28 -0
- app/code/community/EasyNolo/BancaSellaPro/Model/System/Config/Source/PaymentAction.php +23 -0
- app/code/community/EasyNolo/BancaSellaPro/Model/Token.php +96 -0
- app/code/community/EasyNolo/BancaSellaPro/Model/Webservice/Abstract.php +20 -0
- app/code/community/EasyNolo/BancaSellaPro/Model/Webservice/Wscryptdecrypt.php +213 -0
- app/code/community/EasyNolo/BancaSellaPro/Model/Webservice/Wss2s.php +187 -0
- app/code/community/EasyNolo/BancaSellaPro/controllers/GestpayController.php +228 -0
- app/code/community/EasyNolo/BancaSellaPro/controllers/JsonController.php +66 -0
- app/code/community/EasyNolo/BancaSellaPro/controllers/TokenizationController.php +134 -0
- app/code/community/EasyNolo/BancaSellaPro/etc/config.xml +155 -0
- app/code/community/EasyNolo/BancaSellaPro/etc/jstranslator.xml +26 -0
- app/code/community/EasyNolo/BancaSellaPro/etc/system.xml +210 -0
- app/code/community/EasyNolo/BancaSellaPro/sql/easynolo_bancasellapro_setup/install-1.3.0.php +60 -0
- app/code/community/EasyNolo/BancaSellaPro/sql/easynolo_bancasellapro_setup/upgrade-1.3.0-1.3.1.php +15 -0
- app/design/frontend/base/default/layout/easynolo_bancasellapro.xml +115 -0
- app/design/frontend/base/default/template/easynolo/bancasellapro/checkout/onepage.phtml +43 -0
- app/design/frontend/base/default/template/easynolo/bancasellapro/checkout/onepage1-6.phtml +43 -0
- app/design/frontend/base/default/template/easynolo/bancasellapro/gestpay/confirm3d.phtml +18 -0
- app/design/frontend/base/default/template/easynolo/bancasellapro/gestpay/form.phtml +129 -0
- app/design/frontend/base/default/template/easynolo/bancasellapro/gestpay/form_onepagecheckout.phtml +116 -0
- app/design/frontend/base/default/template/easynolo/bancasellapro/gestpay/newtoken.phtml +98 -0
- app/design/frontend/base/default/template/easynolo/bancasellapro/gestpay/redirect.phtml +17 -0
- app/design/frontend/base/default/template/easynolo/bancasellapro/page/redirect.phtml +22 -0
- app/design/frontend/enterprise/default/layout/easynolo_bancasellapro.xml +71 -0
- app/design/frontend/enterprise/default/template/easynolo/bancasellapro/checkout/onepage.phtml +42 -0
- app/etc/modules/EasyNolo_BancaSellaPro.xml +9 -0
- app/etc/modules/EasyNolo_BancaSellaPro.xml.Onepage.txt +13 -0
- app/locale/en_US/EasyNolo_BancaSellaPro.csv +7 -0
- app/locale/it_IT/EasyNolo_BancaSellaPro.csv +7 -0
- js/bancasellapro/gestpayform.js +464 -0
- js/bancasellapro/gestpayform_onepagecheckout.js +592 -0
- js/bancasellapro/newtoken.js +115 -0
- package.xml +18 -0
- skin/frontend/base/default/images/easynolo_bancasella/wait.gif +0 -0
app/code/community/EasyNolo/BancaSellaPro/Block/Confirm3d.php
ADDED
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @category EasyNolo
|
4 |
+
* @package EasyNolo_BancaSellaPro
|
5 |
+
* @author Easy Nolo <ecommerce@sella.it>
|
6 |
+
*/
|
7 |
+
class EasyNolo_BancaSellaPro_Block_Confirm3d extends Mage_Core_Block_Template {
|
8 |
+
|
9 |
+
public function getPARes(){
|
10 |
+
return $this->getRequest()->get('PaRes');
|
11 |
+
}
|
12 |
+
|
13 |
+
public function getCartUrl(){
|
14 |
+
return Mage::getUrl('checkout/cart',array('_secure' => Mage::app()->getStore()->isCurrentlySecure()));
|
15 |
+
}
|
16 |
+
|
17 |
+
}
|
app/code/community/EasyNolo/BancaSellaPro/Block/Form.php
ADDED
@@ -0,0 +1,104 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @category EasyNolo
|
4 |
+
* @package EasyNolo_BancaSellaPro
|
5 |
+
* @author Easy Nolo <ecommerce@sella.it>
|
6 |
+
*/
|
7 |
+
|
8 |
+
class EasyNolo_BancaSellaPro_Block_Form extends Mage_Payment_Block_Form
|
9 |
+
{
|
10 |
+
protected $_isRecurringProfile = null;
|
11 |
+
|
12 |
+
protected function _construct()
|
13 |
+
{
|
14 |
+
parent::_construct();
|
15 |
+
|
16 |
+
if(Mage::app()->getRequest()->getRouteName()=='opc'){
|
17 |
+
$this->setTemplate('easynolo/bancasellapro/gestpay/form_onepagecheckout.phtml');
|
18 |
+
}else{
|
19 |
+
$this->setTemplate('easynolo/bancasellapro/gestpay/form.phtml');
|
20 |
+
}
|
21 |
+
}
|
22 |
+
|
23 |
+
/**
|
24 |
+
* Metodo che verifica se la richiesta è di tipo ajax
|
25 |
+
* @return bool
|
26 |
+
*/
|
27 |
+
public function isAjaxRequest(){
|
28 |
+
return $this->getRequest()->isXmlHttpRequest();
|
29 |
+
}
|
30 |
+
|
31 |
+
/**
|
32 |
+
* Metodo che restituisce l'url dove reindirizzare l'utente dopo la verifica 3dsecure
|
33 |
+
* @return string
|
34 |
+
*/
|
35 |
+
public function getPage3d(){
|
36 |
+
return Mage::getUrl('bancasellapro/gestpay/confirm3d',
|
37 |
+
array('_secure' => Mage::app()->getStore()->isCurrentlySecure()));
|
38 |
+
}
|
39 |
+
|
40 |
+
public function getSuccessRedirect(){
|
41 |
+
return Mage::getUrl('bancasellapro/gestpay/result',array('_secure' => Mage::app()->getStore()->isCurrentlySecure()));
|
42 |
+
}
|
43 |
+
|
44 |
+
/**
|
45 |
+
* metodo che restituisce l'url dove effettuare la verifica 3dsecure
|
46 |
+
* @return string
|
47 |
+
*/
|
48 |
+
public function getAuthPage(){
|
49 |
+
$helper = Mage::helper('easynolo_bancasellapro');
|
50 |
+
return $helper->getAuthPage();
|
51 |
+
}
|
52 |
+
|
53 |
+
/**
|
54 |
+
* Retrieve credit card expire years
|
55 |
+
*
|
56 |
+
* @return array
|
57 |
+
*/
|
58 |
+
public function getCcYears()
|
59 |
+
{
|
60 |
+
$years = $this->getData('cc_years');
|
61 |
+
if (is_null($years)) {
|
62 |
+
$years = Mage::helper('easynolo_bancasellapro')->getYears();
|
63 |
+
$this->setData('cc_years', $years);
|
64 |
+
}
|
65 |
+
return $years;
|
66 |
+
}
|
67 |
+
|
68 |
+
/**
|
69 |
+
* Retrieve credit card expire months
|
70 |
+
*
|
71 |
+
* @return array
|
72 |
+
*/
|
73 |
+
public function getCcMonths()
|
74 |
+
{
|
75 |
+
$months = $this->getData('cc_months');
|
76 |
+
if (is_null($months)) {
|
77 |
+
|
78 |
+
$months = Mage::helper('easynolo_bancasellapro')->getMonths();
|
79 |
+
$this->setData('cc_months', $months);
|
80 |
+
}
|
81 |
+
return $months;
|
82 |
+
}
|
83 |
+
|
84 |
+
/**
|
85 |
+
* Check if iframe is enable on backend
|
86 |
+
* @return boolean
|
87 |
+
*/
|
88 |
+
public function isIframeEnable(){
|
89 |
+
return $this->getMethod()->isIframeEnable();
|
90 |
+
}
|
91 |
+
|
92 |
+
public function isRecurringProfile()
|
93 |
+
{
|
94 |
+
if($this->_isRecurringProfile ==null){
|
95 |
+
|
96 |
+
$quote= Mage::getModel('checkout/cart')->getQuote();
|
97 |
+
|
98 |
+
$helper = Mage::helper('easynolo_bancasellapro/recurringprofile');
|
99 |
+
$this->_isRecurringProfile = $helper->isRecurringProfile($quote);
|
100 |
+
}
|
101 |
+
return $this->_isRecurringProfile;
|
102 |
+
}
|
103 |
+
|
104 |
+
}
|
app/code/community/EasyNolo/BancaSellaPro/Block/Newroot.php
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @category EasyNolo
|
4 |
+
* @package EasyNolo_BancaSellaPro
|
5 |
+
* @author Easy Nolo <ecommerce@sella.it>
|
6 |
+
*/
|
7 |
+
class EasyNolo_BancaSellaPro_Block_Newroot extends Mage_Page_Block_Html {
|
8 |
+
|
9 |
+
}
|
app/code/community/EasyNolo/BancaSellaPro/Block/Redirect.php
ADDED
@@ -0,0 +1,42 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @category EasyNolo
|
4 |
+
* @package EasyNolo_BancaSellaPro
|
5 |
+
* @author Easy Nolo <ecommerce@sella.it>
|
6 |
+
*/
|
7 |
+
|
8 |
+
class EasyNolo_BancaSellaPro_Block_Redirect extends Mage_Page_Block_Redirect
|
9 |
+
{
|
10 |
+
|
11 |
+
public function getOrder()
|
12 |
+
{
|
13 |
+
return Mage::registry('current_order');
|
14 |
+
}
|
15 |
+
|
16 |
+
/**
|
17 |
+
* Get target URL
|
18 |
+
*
|
19 |
+
* @return string
|
20 |
+
*/
|
21 |
+
public function getTargetURL ()
|
22 |
+
{
|
23 |
+
if(!$this->getCalculateTargetUrl()){
|
24 |
+
$helper = Mage::helper('easynolo_bancasellapro');
|
25 |
+
$this->setCalculateTargetUrl( $helper->getRedirectUrlToPayment($this->getOrder()));
|
26 |
+
}
|
27 |
+
return $this->getCalculateTargetUrl();
|
28 |
+
|
29 |
+
}
|
30 |
+
|
31 |
+
|
32 |
+
public function getMethod ()
|
33 |
+
{
|
34 |
+
return 'GET';
|
35 |
+
}
|
36 |
+
|
37 |
+
public function getMessage ()
|
38 |
+
{
|
39 |
+
return $this->__('You will be redirected to Banca Sella in a few seconds.');
|
40 |
+
}
|
41 |
+
|
42 |
+
}
|
app/code/community/EasyNolo/BancaSellaPro/Block/Tokenization/Newtoken.php
ADDED
@@ -0,0 +1,100 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Class Newtoken.php
|
4 |
+
* @category EasyNolo
|
5 |
+
* @package EasyNolo_BancaSellaPro
|
6 |
+
* @author Easy Nolo <ecommerce@sella.it>
|
7 |
+
*/
|
8 |
+
|
9 |
+
class EasyNolo_BancaSellaPro_Block_Tokenization_Newtoken extends Mage_Core_Block_Template
|
10 |
+
{
|
11 |
+
|
12 |
+
protected $_method, $_order;
|
13 |
+
|
14 |
+
/**
|
15 |
+
* Retrieve credit card expire years
|
16 |
+
*
|
17 |
+
* @return array
|
18 |
+
*/
|
19 |
+
public function getCcYears()
|
20 |
+
{
|
21 |
+
$years = $this->getData('cc_years');
|
22 |
+
if (is_null($years)) {
|
23 |
+
$years = Mage::helper('easynolo_bancasellapro')->getYears();
|
24 |
+
$this->setData('cc_years', $years);
|
25 |
+
}
|
26 |
+
return $years;
|
27 |
+
}
|
28 |
+
|
29 |
+
/**
|
30 |
+
* Retrieve credit card expire months
|
31 |
+
*
|
32 |
+
* @return array
|
33 |
+
*/
|
34 |
+
public function getCcMonths()
|
35 |
+
{
|
36 |
+
$months = $this->getData('cc_months');
|
37 |
+
if (is_null($months)) {
|
38 |
+
|
39 |
+
$months = Mage::helper('easynolo_bancasellapro')->getMonths();
|
40 |
+
$this->setData('cc_months', $months);
|
41 |
+
}
|
42 |
+
return $months;
|
43 |
+
}
|
44 |
+
|
45 |
+
protected function _construct()
|
46 |
+
{
|
47 |
+
parent::_construct();
|
48 |
+
|
49 |
+
$profile = Mage::registry('current_recurring_profile');
|
50 |
+
|
51 |
+
/** @var EasyNolo_BancaSellaPro_Helper_Recurringprofile $recurringHelper */
|
52 |
+
$recurringHelper = Mage::helper('easynolo_bancasellapro/recurringprofile');
|
53 |
+
|
54 |
+
/** @var EasyNolo_BancaSellaPro_Model_Gestpay $method */
|
55 |
+
$method = Mage::helper('payment')->getMethodInstance($profile->getMethodCode());
|
56 |
+
|
57 |
+
$order = $method->createOrderToNewToken($profile);
|
58 |
+
|
59 |
+
$this->_order = $order;
|
60 |
+
|
61 |
+
Mage::register('easynolo_current_order', $order);
|
62 |
+
|
63 |
+
}
|
64 |
+
|
65 |
+
public function getMethodCode(){
|
66 |
+
$profile = Mage::registry('current_recurring_profile');
|
67 |
+
return $profile->getMethodCode();
|
68 |
+
}
|
69 |
+
|
70 |
+
/**
|
71 |
+
* Return an instance of Bancasella payment method
|
72 |
+
* @return false|Mage_Payment_Model_Method_Abstract
|
73 |
+
*/
|
74 |
+
public function getMethod(){
|
75 |
+
if($this->_method==null){
|
76 |
+
$profile = Mage::registry('current_recurring_profile');
|
77 |
+
$this->_method = Mage::helper('payment')->getMethodInstance($profile->getMethodCode());
|
78 |
+
}
|
79 |
+
return $this->_method;
|
80 |
+
}
|
81 |
+
|
82 |
+
public function getEncryptString(){
|
83 |
+
/** @var EasyNolo_BancaSellaPro_Helper_Crypt $helper */
|
84 |
+
$helper =Mage::helper('easynolo_bancasellapro/crypt');
|
85 |
+
return $helper->getEncryptStringByOrderWitTokenRequest($this->_order);
|
86 |
+
}
|
87 |
+
|
88 |
+
public function getSuccessRedirect(){
|
89 |
+
return Mage::getUrl('bancasellapro/tokenization/result',array('_secure' => Mage::app()->getStore()->isCurrentlySecure()));
|
90 |
+
}
|
91 |
+
|
92 |
+
public function getDisableProfileRedirect(){
|
93 |
+
return Mage::getUrl('bancasellapro/tokenization/disable',
|
94 |
+
array(
|
95 |
+
'_secure' => Mage::app()->getStore()->isCurrentlySecure(),
|
96 |
+
'profile'=> Mage::registry('current_recurring_profile')->getId()
|
97 |
+
));
|
98 |
+
}
|
99 |
+
|
100 |
+
}
|
app/code/community/EasyNolo/BancaSellaPro/Block/Utility/Text.php
ADDED
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @category EasyNolo
|
4 |
+
* @package EasyNolo_BancaSellaPro
|
5 |
+
* @author Easy Nolo <ecommerce@sella.it>
|
6 |
+
*/
|
7 |
+
class EasyNolo_BancaSellaPro_Block_Utility_Text extends Mage_Core_Block_Abstract{
|
8 |
+
|
9 |
+
protected function _toHtml()
|
10 |
+
{
|
11 |
+
/** @var EasyNolo_BancaSellaPro_Helper_Data $helper */
|
12 |
+
$helper = Mage::helper('easynolo_bancasellapro');
|
13 |
+
$text = $helper->getGestPayJs();
|
14 |
+
$script = '';
|
15 |
+
if($text){
|
16 |
+
$script = '<script type="text/javascript" src="'.$text.'"></script>';
|
17 |
+
}
|
18 |
+
return $script;
|
19 |
+
}
|
20 |
+
|
21 |
+
}
|
app/code/community/EasyNolo/BancaSellaPro/Exception.php
ADDED
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @category EasyNolo
|
4 |
+
* @package EasyNolo_BancaSellaPro
|
5 |
+
* @author Easy Nolo <ecommerce@sella.it>
|
6 |
+
*/
|
7 |
+
|
8 |
+
class EasyNolo_BancaSellaPro_Exception extends Zend_Exception{
|
9 |
+
|
10 |
+
}
|
app/code/community/EasyNolo/BancaSellaPro/Helper/Baseclient.php
ADDED
@@ -0,0 +1,49 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Class Baseclient.php
|
4 |
+
* @category EasyNolo_BancaSellaPro
|
5 |
+
* @package EasyNolo
|
6 |
+
* @author Easy Nolo <ecommerce@sella.it>
|
7 |
+
*/
|
8 |
+
|
9 |
+
class EasyNolo_BancaSellaPro_Helper_Baseclient extends Mage_Core_Helper_Abstract{
|
10 |
+
|
11 |
+
protected $_webserviceClassName = null;
|
12 |
+
|
13 |
+
/**
|
14 |
+
* Inizializza il client basandosi sul webservice passato in input
|
15 |
+
* @param $webService
|
16 |
+
*
|
17 |
+
* @return bool|Zend_Soap_Client
|
18 |
+
*/
|
19 |
+
protected function _initClient($webService){
|
20 |
+
if (!extension_loaded('soap')) {
|
21 |
+
Mage::logException(Mage::exception('EasyNolo_BancaSellaPro','PHP SOAP extension is required.'));
|
22 |
+
$_helper= Mage::helper('easynolo_bancasellapro');
|
23 |
+
$_helper->log('Non è stato possibile creare il client per il webserver');
|
24 |
+
return false;
|
25 |
+
}
|
26 |
+
|
27 |
+
$url = $webService->getWSUrl();
|
28 |
+
$client = new Zend_Soap_Client(
|
29 |
+
$url, array(
|
30 |
+
'compression' => SOAP_COMPRESSION_ACCEPT,
|
31 |
+
'soap_version' => SOAP_1_2,));
|
32 |
+
return $client;
|
33 |
+
}
|
34 |
+
|
35 |
+
public function getInitWebservice(){
|
36 |
+
if($this->_webserviceClassName == null){
|
37 |
+
$exception = Mage::exception('EasyNolo_BancaSellaPro','Helper '.__CLASS__.' didn\'t set webserviceClassName');
|
38 |
+
Mage::logException($exception);
|
39 |
+
|
40 |
+
throw $exception;
|
41 |
+
}
|
42 |
+
|
43 |
+
$webService = Mage::getModel($this->_webserviceClassName);
|
44 |
+
$gestPay=Mage::getModel('easynolo_bancasellapro/gestpay');
|
45 |
+
$webService->setBaseUrl($gestPay->getBaseWSDLUrlSella());
|
46 |
+
|
47 |
+
return $webService;
|
48 |
+
}
|
49 |
+
}
|
app/code/community/EasyNolo/BancaSellaPro/Helper/Crypt.php
ADDED
@@ -0,0 +1,286 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @category EasyNolo
|
4 |
+
* @package EasyNolo_BancaSellaPro
|
5 |
+
* @author Easy Nolo <ecommerce@sella.it>
|
6 |
+
*/
|
7 |
+
|
8 |
+
class EasyNolo_BancaSellaPro_Helper_Crypt extends EasyNolo_BancaSellaPro_Helper_Baseclient{
|
9 |
+
|
10 |
+
protected $_webserviceClassName ='easynolo_bancasellapro/webservice_wscryptdecrypt';
|
11 |
+
/**
|
12 |
+
* Effettua l'encypt dei dati memorizzati nel webserice
|
13 |
+
* @param $webService contiene le info da criptare
|
14 |
+
*
|
15 |
+
* @return string stringa criptata
|
16 |
+
*/
|
17 |
+
protected function getEncryptString($webService){
|
18 |
+
|
19 |
+
$client = $this->_initClient($webService);
|
20 |
+
if(!$client){
|
21 |
+
return false;
|
22 |
+
}
|
23 |
+
|
24 |
+
$param = $webService->getParamToEncrypt();
|
25 |
+
|
26 |
+
$result = $client->Encrypt($param);
|
27 |
+
|
28 |
+
$webService->setResponseEncrypt($result);
|
29 |
+
|
30 |
+
$_helper= Mage::helper('easynolo_bancasellapro');
|
31 |
+
|
32 |
+
$_helper->log('Encrypt string: ' .$webService->getCryptDecryptString());
|
33 |
+
|
34 |
+
return $webService->getCryptDecryptString();
|
35 |
+
|
36 |
+
}
|
37 |
+
|
38 |
+
/**
|
39 |
+
* Funzione che dall'ordine restituisce la stringa criptata delle sue info
|
40 |
+
* @param $order ordine da criptare
|
41 |
+
*
|
42 |
+
* @return mixed stringa criptate
|
43 |
+
*/
|
44 |
+
public function getEncryptStringByOrder ($order){
|
45 |
+
$method = $order->getPayment()->getMethodInstance();
|
46 |
+
/** @var $webService EasyNolo_BancaSellaPro_Model_Webservice_Wscryptdecrypt */
|
47 |
+
$webService = Mage::getModel('easynolo_bancasellapro/webservice_wscryptdecrypt');
|
48 |
+
$webService->setOrder($order);
|
49 |
+
$webService->setBaseUrl($method->getBaseWSDLUrlSella());
|
50 |
+
|
51 |
+
return $this->getEncryptString($webService);
|
52 |
+
|
53 |
+
}
|
54 |
+
|
55 |
+
public function getEncryptStringByOrderWitTokenRequest ($order){
|
56 |
+
$method = $order->getPayment()->getMethodInstance();
|
57 |
+
/** @var $webService EasyNolo_BancaSellaPro_Model_Webservice_Wscryptdecrypt */
|
58 |
+
$webService = Mage::getModel('easynolo_bancasellapro/webservice_wscryptdecrypt');
|
59 |
+
$webService->setOrder($order);
|
60 |
+
$webService->setRecurringProfile(true);
|
61 |
+
$webService->setBaseUrl($method->getBaseWSDLUrlSella());
|
62 |
+
|
63 |
+
return $this->getEncryptString($webService);
|
64 |
+
|
65 |
+
}
|
66 |
+
|
67 |
+
/**
|
68 |
+
* @param $method EasyNolo_BancaSellaPro_Model_Gestpay
|
69 |
+
*
|
70 |
+
* @return string
|
71 |
+
*/
|
72 |
+
public function getEncryptStringBeforeOrder ($method){
|
73 |
+
/** @var EasyNolo_BancaSellaPro_Model_Webservice_Wscryptdecrypt $webService */
|
74 |
+
$webService = Mage::getModel('easynolo_bancasellapro/webservice_wscryptdecrypt');
|
75 |
+
|
76 |
+
$webService->setInfoBeforeOrder($method);
|
77 |
+
$webService->setBaseUrl($method->getBaseWSDLUrlSella());
|
78 |
+
|
79 |
+
return $this->getEncryptString($webService);
|
80 |
+
|
81 |
+
}
|
82 |
+
|
83 |
+
|
84 |
+
/**
|
85 |
+
* funzione che si occupa di decriptare i dati ricevuti da gestpay
|
86 |
+
* @param $webService
|
87 |
+
*
|
88 |
+
* @return mixed
|
89 |
+
*/
|
90 |
+
public function decriptPaymentRequest($webService){
|
91 |
+
|
92 |
+
$client = $this->_initClient($webService);
|
93 |
+
if(!$client){
|
94 |
+
return false;
|
95 |
+
}
|
96 |
+
|
97 |
+
$param = $webService->getParamToDecrypt();
|
98 |
+
|
99 |
+
$result = $client->Decrypt($param);
|
100 |
+
|
101 |
+
$webService->setResponseDecrypt($result);
|
102 |
+
|
103 |
+
return $webService;
|
104 |
+
|
105 |
+
}
|
106 |
+
|
107 |
+
public function isPaymentOk($a , $b ){
|
108 |
+
$_helper= Mage::helper('easynolo_bancasellapro');
|
109 |
+
|
110 |
+
$webService =$this->getInitWebservice();
|
111 |
+
|
112 |
+
$webService->setDecryptParam($a , $b);
|
113 |
+
|
114 |
+
$result = $this->decriptPaymentRequest ($webService);
|
115 |
+
|
116 |
+
if(!$result){
|
117 |
+
return false;
|
118 |
+
}
|
119 |
+
|
120 |
+
$orderId = $webService->getShopTransactionID();
|
121 |
+
/** @var Mage_Sales_Model_Order $order */
|
122 |
+
|
123 |
+
$order = Mage::getModel('sales/order')->loadByIncrementId($orderId);
|
124 |
+
//salvo lo store per effettuare il redirect a completamento della verifica
|
125 |
+
Mage::register('easynolo_bancasellapro_store_maked_order',$order->getStore());
|
126 |
+
Mage::register('easynolo_bancasellapro_order',$order);
|
127 |
+
|
128 |
+
if($order->getId()){
|
129 |
+
if($webService->getFastResultPayment()){
|
130 |
+
$_helper->log('Il web service ha dato esito positivo al pagamento');
|
131 |
+
|
132 |
+
//controllo se la richiesta s2s è già stata elaborata
|
133 |
+
if(!$_helper->isElaborateS2S($order)){
|
134 |
+
$_helper->log('La transazione non è ancora stata inviata sul s2s');
|
135 |
+
|
136 |
+
//in questo punto l'utente ha completato l'ordine ma aspettiamo la chiamata s2s per confermare lo stato
|
137 |
+
if($order->getId()){
|
138 |
+
$message = $this->__("Authorizing amount of %s is pending approval on gateway.", $order->getBaseCurrency()->formatTxt($order->getBaseGrandTotal()));
|
139 |
+
$order->setState(Mage_Sales_Model_Order::STATE_PENDING_PAYMENT, true, $message);
|
140 |
+
$order->save();
|
141 |
+
}
|
142 |
+
}else{
|
143 |
+
$_helper->log('La tranzazione è gia stata salvata, non cambio lo stato');
|
144 |
+
}
|
145 |
+
|
146 |
+
if( $order->getStatus() != Mage_Sales_Model_Order::STATUS_FRAUD){
|
147 |
+
$_helper->log('Invio email di conferma creazione ordine all\'utente');
|
148 |
+
$order->sendNewOrderEmail();
|
149 |
+
}
|
150 |
+
return true;
|
151 |
+
}else{
|
152 |
+
$_helper->log('Il web service ha restituito KO');
|
153 |
+
$message = $this->__('Payment transaction not authorized: %s.', $result->getErrorDescription());
|
154 |
+
//in questo punto l'ordine è stato annullato dall'utente
|
155 |
+
if($order->getId()){
|
156 |
+
$method= $order->getPayment()->getMethodInstance();
|
157 |
+
$order->cancel();
|
158 |
+
$order->setState($method->getOrderStatusKoUser(), true, $message);
|
159 |
+
$order->save();
|
160 |
+
}
|
161 |
+
|
162 |
+
return $message;
|
163 |
+
}
|
164 |
+
}else{
|
165 |
+
$message = $this->__("There was an error processing your order. Please contact us or try again later.");
|
166 |
+
$_helper->log('L\'ordine restituito da bancasella non esiste. Increment id= '.$orderId);
|
167 |
+
return $message;
|
168 |
+
}
|
169 |
+
}
|
170 |
+
|
171 |
+
public function getInitWebservice(){
|
172 |
+
$webService = Mage::getModel('easynolo_bancasellapro/webservice_wscryptdecrypt');
|
173 |
+
$gestPay=Mage::getModel('easynolo_bancasellapro/gestpay');
|
174 |
+
$webService->setBaseUrl($gestPay->getBaseWSDLUrlSella());
|
175 |
+
|
176 |
+
return $webService;
|
177 |
+
}
|
178 |
+
|
179 |
+
public function setStatusOrderByS2SRequest($order, $webservice){
|
180 |
+
$order = Mage::getModel('sales/order')->load($order->getId());
|
181 |
+
$payment = $order->getPayment();
|
182 |
+
$method = $payment->getMethodInstance();
|
183 |
+
$_helper= Mage::helper('easynolo_bancasellapro');
|
184 |
+
$_helper->log('Controllo l\'ordine in base alle risposte della S2S');
|
185 |
+
if($method->getConfigData('order_status_fraud_gestpay')){
|
186 |
+
$_helper->log('Controllo frode');
|
187 |
+
|
188 |
+
$message=false;
|
189 |
+
$total= $method->getTotalByOrder($order);
|
190 |
+
$_helper->log('controllo il totale dell\'ordine : ' .$webservice->getAmount(). ' = '.round($total, 2));
|
191 |
+
if (round($webservice->getAmount(), 2) != round($total, 2)){
|
192 |
+
// il totatle dell'ordine non corrisponde al totale della transazione
|
193 |
+
$message = $this->__('Transaction amount differs from order grand total.');
|
194 |
+
}
|
195 |
+
|
196 |
+
if ($webservice->getAlertCode()!=''){
|
197 |
+
$_helper->log('controllo alert della transazione : ' .$webservice->getAlertCode());
|
198 |
+
$message = $webservice->getAlertDescription();
|
199 |
+
}
|
200 |
+
|
201 |
+
if($message){
|
202 |
+
$_helper->log('rilevata possibile frode: '.$message);
|
203 |
+
$payment->setTransactionAdditionalInfo(array( Mage_Sales_Model_Order_Payment_Transaction::RAW_DETAILS=>$webservice->getData()),"");
|
204 |
+
$payment->setTransactionId($webservice->getShopTransactionId())
|
205 |
+
->setCurrencyCode($order->getBaseCurrencyCode())
|
206 |
+
->setIsTransactionClosed(0)
|
207 |
+
->setPreparedMessage($message)
|
208 |
+
->registerPaymentReviewAction(Mage_Sales_Model_Order_Payment::REVIEW_ACTION_UPDATE, false);
|
209 |
+
$order->setState(Mage_Sales_Model_Order::STATE_PAYMENT_REVIEW, Mage_Sales_Model_Order::STATUS_FRAUD, $message);
|
210 |
+
$order->save();
|
211 |
+
return false;
|
212 |
+
}
|
213 |
+
}
|
214 |
+
|
215 |
+
switch ($webservice->getTransactionResult()){
|
216 |
+
case EasyNolo_BancaSellaPro_Model_Webservice_Wscryptdecrypt::TRANSACTION_RESULT_PENDING :
|
217 |
+
$message = $this->__("Authorizing amount of %s is pending approval on gateway.", $order->getBaseCurrency()->formatTxt($order->getBaseGrandTotal()));
|
218 |
+
$order->setState(Mage_Sales_Model_Order::STATE_PENDING_PAYMENT, true, $message);
|
219 |
+
$_helper->log('Pagamento effettuato con bonifico bancario, verificare a mano la transazione');
|
220 |
+
$order->addStatusHistoryComment($this->__('Payment was using bank transfer. Please verify the order status on GestPay.'));
|
221 |
+
break;
|
222 |
+
case EasyNolo_BancaSellaPro_Model_Webservice_Wscryptdecrypt::TRANSACTION_RESULT_OK :
|
223 |
+
$_helper->log('Pagamento effettuato correttamente. Cambio stato all\'ordine e salvo l\'id della transazione');
|
224 |
+
$message = $this->__("Authorization approved on gateway. GestPay Transaction ID: %s", $webservice->getBankTransactionID());
|
225 |
+
if($paymentMethod = $webservice->getPaymentMethod()){
|
226 |
+
$message .= " (".$paymentMethod.")";
|
227 |
+
}
|
228 |
+
|
229 |
+
$order->addStatusHistoryComment($message);
|
230 |
+
|
231 |
+
// create the authorization transaction
|
232 |
+
$payment->setAdditionalData(serialize($webservice->getData()));
|
233 |
+
$payment->setTransactionAdditionalInfo(array(Mage_Sales_Model_Order_Payment_Transaction::RAW_DETAILS => $webservice->getData()), "");
|
234 |
+
$payment->setTransactionId($webservice->getShopTransactionId());
|
235 |
+
$payment->setCurrencyCode($order->getBaseCurrencyCode());
|
236 |
+
$payment->setIsTransactionClosed(0);
|
237 |
+
$payment->registerAuthorizationNotification($webservice->getAmount());
|
238 |
+
$order = $payment->getOrder();
|
239 |
+
$order->save();
|
240 |
+
|
241 |
+
// reload the order and the related payment entities
|
242 |
+
$order = Mage::getModel('sales/order')->load($order->getId());
|
243 |
+
$payment = $order->getPayment();
|
244 |
+
|
245 |
+
// perform the capture
|
246 |
+
$setOrderAsPaid = true;
|
247 |
+
if($method->getConfigPaymentAction() == Mage_Payment_Model_Method_Abstract::ACTION_AUTHORIZE_CAPTURE) {
|
248 |
+
if($method->getConfigData('use_s2s_api')){
|
249 |
+
try{
|
250 |
+
$payment->capture();
|
251 |
+
$order->save();
|
252 |
+
}catch(Exception $e){
|
253 |
+
$setOrderAsPaid = false;
|
254 |
+
$message = $this->__("Failed capture online: %", $e->getMessage());
|
255 |
+
$order->setState(Mage_Sales_Model_Order::STATE_PAYMENT_REVIEW, Mage_Sales_Model_Order::STATE_PAYMENT_REVIEW, $message);
|
256 |
+
}
|
257 |
+
}
|
258 |
+
|
259 |
+
if($setOrderAsPaid == true){
|
260 |
+
$payment->registerCaptureNotification($order->getBaseGrandTotal());
|
261 |
+
}
|
262 |
+
}
|
263 |
+
|
264 |
+
if($setOrderAsPaid == true){
|
265 |
+
$order->setState($method->getOrderStatusOkGestPay(), true);
|
266 |
+
}
|
267 |
+
|
268 |
+
break;
|
269 |
+
case EasyNolo_BancaSellaPro_Model_Webservice_Wscryptdecrypt::TRANSACTION_RESULT_KO :
|
270 |
+
$_helper->log('Pagamento non andato a buon fine. Cambio stato all\'ordine e salvo l\'id della transazione');
|
271 |
+
$message = $this->__("Authorizing amount of %s is pending approval on gateway.", $order->getBaseCurrency()->formatTxt($order->getBaseGrandTotal()));
|
272 |
+
$order->cancel();
|
273 |
+
$order->setState($method->getOrderStatusKoGestPay(), true, $message);
|
274 |
+
$message = $this->__("Payment attempt has been declined. GestPay Transaction ID: %s", $webservice->getBankTransactionID());
|
275 |
+
if($paymentMethod = $webservice->getPaymentMethod()){
|
276 |
+
$message .= " (".$paymentMethod.")";
|
277 |
+
}
|
278 |
+
|
279 |
+
$order->addStatusHistoryComment($message);
|
280 |
+
break;
|
281 |
+
}
|
282 |
+
|
283 |
+
$order->save();
|
284 |
+
$_helper->log('Dopo l\'elaborazione della s2s l\'ordine con id: '.$order->getId().' ha state: '.$order->getState().' e status: '.$order->getStatus());
|
285 |
+
}
|
286 |
+
}
|
app/code/community/EasyNolo/BancaSellaPro/Helper/Data.php
ADDED
@@ -0,0 +1,151 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @category EasyNolo
|
4 |
+
* @package EasyNolo_BancaSellaPro
|
5 |
+
* @author Easy Nolo <ecommerce@sella.it>
|
6 |
+
*/
|
7 |
+
|
8 |
+
class EasyNolo_BancaSellaPro_Helper_Data extends Mage_Core_Helper_Abstract {
|
9 |
+
|
10 |
+
/**
|
11 |
+
* metodo per effettuare il log del modulo
|
12 |
+
* @param $msg
|
13 |
+
*/
|
14 |
+
public function log($msg) {
|
15 |
+
Mage::log($msg, null, 'EasyNolo_BancaSellaPro.log', Mage::getStoreConfig('payment/gestpaypro/log'));
|
16 |
+
}
|
17 |
+
|
18 |
+
/**
|
19 |
+
* Metodo che restituisce l'url sul quale effettuare il pagamento
|
20 |
+
* @param Mage_Sales_Model_Order $order
|
21 |
+
*
|
22 |
+
* @return bool|string
|
23 |
+
*/
|
24 |
+
function getRedirectUrlToPayment(Mage_Sales_Model_Order $order){
|
25 |
+
|
26 |
+
//recupero la stringa criptata in base ai dati dell'ordine
|
27 |
+
$crypt = Mage::helper('easynolo_bancasellapro/crypt');
|
28 |
+
$stringEncrypt = $crypt->getEncryptStringByOrder($order);
|
29 |
+
|
30 |
+
$method = $order->getPayment()->getMethodInstance();
|
31 |
+
|
32 |
+
if($method instanceof EasyNolo_BancaSellaPro_Model_Gestpay){
|
33 |
+
$url = $method->getRedirectPagePaymentUrl();
|
34 |
+
return $this->createUrl($url , array('a'=>$method->getMerchantId(), 'b'=> $stringEncrypt));
|
35 |
+
}
|
36 |
+
return false;
|
37 |
+
}
|
38 |
+
|
39 |
+
function createUrl($url, $param){
|
40 |
+
$paramether= '';
|
41 |
+
if(count($param)){
|
42 |
+
$paramether= '?';
|
43 |
+
foreach($param as $name => $value)
|
44 |
+
{
|
45 |
+
$paramether.=$name.'='.$value.'&';
|
46 |
+
}
|
47 |
+
}
|
48 |
+
$this->log('Url per il pagamento: '.$url.$paramether);
|
49 |
+
return $url.$paramether;
|
50 |
+
}
|
51 |
+
|
52 |
+
|
53 |
+
/**
|
54 |
+
* Recupera l'url del javascript per usare l'iframe
|
55 |
+
* @return string
|
56 |
+
*/
|
57 |
+
function getGestPayJs(){
|
58 |
+
$method = Mage::getModel('easynolo_bancasellapro/gestpay');
|
59 |
+
$url = null;
|
60 |
+
if($method->isIframeEnable()){
|
61 |
+
$url = $method->getIframeUrl();
|
62 |
+
}
|
63 |
+
return $url;
|
64 |
+
}
|
65 |
+
|
66 |
+
|
67 |
+
/**
|
68 |
+
* Recupera l'url dove effettuare la verifica del 3ds
|
69 |
+
* @return string
|
70 |
+
*/
|
71 |
+
function getAuthPage(){
|
72 |
+
/** @var EasyNolo_BancaSellaPro_Model_Gestpay $method */
|
73 |
+
$method = Mage::getModel('easynolo_bancasellapro/gestpay');
|
74 |
+
$url = $method->getAuthPage();
|
75 |
+
return $url;
|
76 |
+
}
|
77 |
+
|
78 |
+
/**
|
79 |
+
* Metodo che verifica se la transazione è stata elaborata dal una richiesta server to server
|
80 |
+
* @param $order
|
81 |
+
*
|
82 |
+
* @return bool
|
83 |
+
*/
|
84 |
+
public function isElaborateS2S($order){
|
85 |
+
$state = $order->getState();
|
86 |
+
if ($state == Mage_Sales_Model_Order::STATE_NEW)
|
87 |
+
return false;
|
88 |
+
return true;
|
89 |
+
|
90 |
+
}
|
91 |
+
|
92 |
+
/**
|
93 |
+
* Metodo che restituisce un array associativo con anno in due cifre e anno in 4 cifre
|
94 |
+
* @return array
|
95 |
+
*/
|
96 |
+
public function getYears(){
|
97 |
+
$years = array();
|
98 |
+
$firstTwo = date("y");
|
99 |
+
$firstFour = date("Y");
|
100 |
+
$years[0]=$this->__('Year');
|
101 |
+
for ($index=0; $index <= 10; $index++) {
|
102 |
+
$years[$firstTwo + $index] = $firstFour+ $index;
|
103 |
+
}
|
104 |
+
return $years;
|
105 |
+
}
|
106 |
+
|
107 |
+
/**
|
108 |
+
* Metodo che restituisce un array associativo con mese in due cifre e descrizione mese (numero - nome mese)
|
109 |
+
* @return array
|
110 |
+
*/
|
111 |
+
public function getMonths()
|
112 |
+
{
|
113 |
+
$data = Mage::app()->getLocale()->getTranslationList('month');
|
114 |
+
$return = array();
|
115 |
+
$return['0'] = $this->__('Month');
|
116 |
+
foreach ($data as $key => $value) {
|
117 |
+
$monthNum = ($key < 10) ? '0'.$key : ''.$key;
|
118 |
+
$return[$monthNum] = $monthNum . ' - ' . $value;
|
119 |
+
}
|
120 |
+
return $return;
|
121 |
+
}
|
122 |
+
|
123 |
+
public function isIWDOpcEnable(){
|
124 |
+
$children = Mage::getConfig()->getNode('modules')->children();
|
125 |
+
$modulesArray = (array)$children;
|
126 |
+
//controllo se ci sono dipendenze nel modulo bancasella
|
127 |
+
if(isset($modulesArray['EasyNolo_BancaSellaPro']->depends)){
|
128 |
+
$depens = $modulesArray['EasyNolo_BancaSellaPro']->depends->children();
|
129 |
+
$dependsArray = (array)$depens;
|
130 |
+
//se presente la dipendenza da IWD devo aggiornare la finestra per il pagamento con iframe
|
131 |
+
if(isset($dependsArray['IWD_Opc'])){
|
132 |
+
return true;
|
133 |
+
}
|
134 |
+
}
|
135 |
+
return false;
|
136 |
+
}
|
137 |
+
|
138 |
+
/**
|
139 |
+
* Metodo per aggiungere l'ordine alla sessione del checkout
|
140 |
+
* @param Mage_Sales_Model_Order $order
|
141 |
+
*/
|
142 |
+
public function addOrderToSession(Mage_Sales_Model_Order $order){
|
143 |
+
|
144 |
+
if($order->getId()){
|
145 |
+
$session = Mage::getSingleton('checkout/session');
|
146 |
+
$session->setLastOrderId($order->getId())
|
147 |
+
->setLastRealOrderId($order->getIncrementId());
|
148 |
+
}
|
149 |
+
|
150 |
+
}
|
151 |
+
}
|
app/code/community/EasyNolo/BancaSellaPro/Helper/Recurringprofile.php
ADDED
@@ -0,0 +1,266 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @category EasyNolo
|
4 |
+
* @package EasyNolo_BancaSellaPro
|
5 |
+
* @author Easy Nolo <ecommerce@sella.it>
|
6 |
+
*/
|
7 |
+
|
8 |
+
class EasyNolo_BancaSellaPro_Helper_Recurringprofile extends EasyNolo_BancaSellaPro_Helper_Baseclient {
|
9 |
+
|
10 |
+
protected $_webserviceClassName ='easynolo_bancasellapro/webservice_wss2s';
|
11 |
+
|
12 |
+
const STATUS_REFUND_TOTAL = 'refund_bancasella';
|
13 |
+
|
14 |
+
|
15 |
+
/**
|
16 |
+
* Method to check if an order is for a recurring payment and if yes, save the token
|
17 |
+
* @param Mage_Sales_Model_Order $order
|
18 |
+
* @param $webservice
|
19 |
+
*/
|
20 |
+
public function checkAndSaveToken( Mage_Sales_Model_Order $order, $webservice){
|
21 |
+
|
22 |
+
$profileId = $this->getProfileIdByOrder($order);
|
23 |
+
|
24 |
+
if(false !== $profileId){
|
25 |
+
//find a recurring profile
|
26 |
+
/** @var Mage_Sales_Model_Recurring_Profile $profile */
|
27 |
+
$profile = Mage::getModel('sales/recurring_profile')->load($profileId);
|
28 |
+
|
29 |
+
//controllo se il profile è in attesa
|
30 |
+
if($profile->getState()==Mage_Sales_Model_Recurring_Profile::STATE_PENDING){
|
31 |
+
|
32 |
+
switch ($webservice->getTransactionResult()){
|
33 |
+
case EasyNolo_BancaSellaPro_Model_Webservice_Wscryptdecrypt::TRANSACTION_RESULT_OK :
|
34 |
+
//se imposto il bank transactionId l'utente puo accedere alla pagina per vedere il profilo ricorrente,
|
35 |
+
//ma la richiesta dei dettagli deve essere disabilitata perché bancasella non utilizza il banktransactionId,
|
36 |
+
//in alternativa potremmo impostare l'id del profilo
|
37 |
+
$profile->setReferenceId($webservice->getBankTransactionId());
|
38 |
+
$profile->setReferenceId($profile->getId());
|
39 |
+
$profile->setState(Mage_Sales_Model_Recurring_Profile::STATE_ACTIVE);
|
40 |
+
|
41 |
+
/** @var EasyNolo_Bancasellapro_Model_Token $tokenInfo */
|
42 |
+
$tokenInfo = Mage::getModel('easynolo_bancasellapro/token');
|
43 |
+
$tokenInfo->setProfile($profile)
|
44 |
+
->setTokenInfo(
|
45 |
+
$webservice->getToken(),
|
46 |
+
$webservice->getTokenExpiryMonth(),
|
47 |
+
$webservice->getTokenExpiryYear());
|
48 |
+
$tokenInfo->save();
|
49 |
+
break;
|
50 |
+
case EasyNolo_BancaSellaPro_Model_Webservice_Wscryptdecrypt::TRANSACTION_RESULT_KO :
|
51 |
+
$profile->setState(Mage_Sales_Model_Recurring_Profile::STATE_CANCELED);
|
52 |
+
break;
|
53 |
+
}
|
54 |
+
$profile->save();
|
55 |
+
}
|
56 |
+
}
|
57 |
+
}
|
58 |
+
|
59 |
+
/**
|
60 |
+
* Method to getting back the profile id by order
|
61 |
+
* @param Mage_Sales_Model_Order $order
|
62 |
+
* @return string|false id of the profile or false otherwise
|
63 |
+
*/
|
64 |
+
public function getProfileIdByOrder($order){
|
65 |
+
|
66 |
+
$bind = array(':order_id' => $order->getId());
|
67 |
+
|
68 |
+
$adapter = Mage::getSingleton('core/resource')->getConnection('core_read');
|
69 |
+
$tableName = Mage::getSingleton('core/resource')->getTableName('sales/recurring_profile_order');
|
70 |
+
|
71 |
+
$select = $adapter->select()
|
72 |
+
->from(array('main_table' => $tableName),'profile_id')
|
73 |
+
->where('order_id=:order_id');
|
74 |
+
|
75 |
+
return $adapter->fetchOne($select, $bind);
|
76 |
+
}
|
77 |
+
|
78 |
+
public function getOrdersIdsByProfile($profile){
|
79 |
+
|
80 |
+
$bind = array('profile_id'=> $profile->getId());
|
81 |
+
|
82 |
+
$adapter = Mage::getSingleton('core/resource')->getConnection('core_read');
|
83 |
+
$tableName = Mage::getSingleton('core/resource')->getTableName('sales/recurring_profile_order');
|
84 |
+
|
85 |
+
$select= $adapter->select()
|
86 |
+
->from(array('main_table'=> $tableName),'order_id')
|
87 |
+
->where('profile_id=:profile_id');
|
88 |
+
|
89 |
+
return $adapter->fetchCol($select,$bind);
|
90 |
+
|
91 |
+
}
|
92 |
+
|
93 |
+
/**
|
94 |
+
* Method to check if an order has a recurring progile item
|
95 |
+
* @param Mage_Sales_Model_Order|Mage_Sales_Model_Quote $orderOrQuote
|
96 |
+
*
|
97 |
+
* @return bool
|
98 |
+
*/
|
99 |
+
public function isRecurringProfile($orderOrQuote){
|
100 |
+
//recupero tutti gli item visibili è controllo se l'ordine è di un recurring payment
|
101 |
+
foreach ($orderOrQuote->getAllVisibleItems() as $item) {
|
102 |
+
if ($item->getProduct()->getIsRecurring())
|
103 |
+
return true;
|
104 |
+
//è presente una limitazione per i recurring profile, ovvero ci puo essere solo un item nel carrello.
|
105 |
+
//Quindi non serve controllarli tutti
|
106 |
+
return false;
|
107 |
+
}
|
108 |
+
return false;
|
109 |
+
}
|
110 |
+
|
111 |
+
/**
|
112 |
+
* Method to extract the recurring profile array by quote
|
113 |
+
* @param Mage_Sales_Model_Quote $quote
|
114 |
+
* @return array
|
115 |
+
*/
|
116 |
+
public function getRecurringProfileByQuote($quote){
|
117 |
+
//recupero tutti gli item visibili è controllo se l'ordine è di un recurring payment
|
118 |
+
foreach ($quote->getAllVisibleItems() as $item) {
|
119 |
+
if ($item->getProduct()->getIsRecurring()){
|
120 |
+
$option = $item->getOptionByCode(Mage_Payment_Model_Recurring_Profile::PRODUCT_OPTIONS_KEY);
|
121 |
+
if( $option == null ){
|
122 |
+
//su magento 1.7 si chiama in un altro mdoo
|
123 |
+
$option = $item->getOptionByCode('info_buyRequest');
|
124 |
+
}
|
125 |
+
//recupero le opzioni del l'item epr il recurring profile
|
126 |
+
$recurringItem =$option->getItem();
|
127 |
+
$recurringProfile = $item->getProduct()->getRecurringProfile();
|
128 |
+
//nel recurring profile non ci sta il prezzo dell'item, lo aggiungiamo noi per un eventuale analisi del profilo
|
129 |
+
$recurringProfile['billing_amount']=$recurringItem->getPrice();//$item->getProduct()->getPrice();
|
130 |
+
|
131 |
+
$recurringProfile['shipping_amount'] = $recurringItem->getShippingAmount();//$quote->getShippingAddress()->getShippingAmount();
|
132 |
+
$recurringProfile['tax_amount'] = $recurringItem->getTaxAmount();//$quote->getShippingAddress()->getTaxAmount();
|
133 |
+
return $recurringProfile;
|
134 |
+
}
|
135 |
+
}
|
136 |
+
return array();
|
137 |
+
}
|
138 |
+
|
139 |
+
public function payOrderOfProfile($order, $profile){
|
140 |
+
$_helper= Mage::helper('easynolo_bancasellapro');
|
141 |
+
$_helper->log('richiesto pagamento con token per profile id: '.$profile->getId().' e id ordine:'. $order->getId());
|
142 |
+
|
143 |
+
$token= Mage::getModel('easynolo_bancasellapro/token')
|
144 |
+
->getCollection()
|
145 |
+
->addProfileToFilter($profile)
|
146 |
+
->addValidDateFilter()
|
147 |
+
->getFirstItem();
|
148 |
+
|
149 |
+
if($token->getId()){
|
150 |
+
//inizializza il webservice
|
151 |
+
$webservice = $this->getInitWebservice();
|
152 |
+
//imposta l'ordine
|
153 |
+
$webservice->setOrder($order);
|
154 |
+
//imposta il token
|
155 |
+
$webservice->setToken($token);
|
156 |
+
//effettua la chiamata
|
157 |
+
$result = $this->executePaymentS2S($webservice);
|
158 |
+
|
159 |
+
if(strcmp($result->getErrorCode(),'8006')==0){
|
160 |
+
$_helper->log('Attenzione: per poter effettuare i pagamenti è necessario che l\'esercente disabiliti "Verify by visa" e "mastercard secure" sull\'account bancasella');
|
161 |
+
Mage::logException(Mage::exception('EasyNolo_BancaSellaPro','Account bancasella non correttamente configurato. Le opzioni .'));
|
162 |
+
$profile->setState(Mage_Sales_Model_Recurring_Profile::STATE_SUSPENDED);
|
163 |
+
$profile->save();
|
164 |
+
}else{
|
165 |
+
$_helper->log('Analizzo il pagamento tramite token');
|
166 |
+
//analizza il risultato
|
167 |
+
$helperDecript = Mage::helper('easynolo_bancasellapro/crypt');
|
168 |
+
$helperDecript->setStatusOrderByS2SRequest($order,$webservice);
|
169 |
+
$method= $order->getPayment()->getMethodInstance();
|
170 |
+
if( $order->getStatus()==$method->getOrderStatusOkGestPay()){
|
171 |
+
$_helper->log('Invio email di conferma creazione ordine all\'utente');
|
172 |
+
$order->sendNewOrderEmail();
|
173 |
+
}else{
|
174 |
+
$_helper->log('Problema con il pagamento, lo stato dell\'ordine non corrisponde a quello configurato per "pagamento eseguito correttamente".');
|
175 |
+
}
|
176 |
+
$profile->setUpdatedAt(Mage::getSingleton('core/date')->gmtDate());
|
177 |
+
|
178 |
+
$profile->save();
|
179 |
+
return true;
|
180 |
+
}
|
181 |
+
|
182 |
+
}else{
|
183 |
+
|
184 |
+
$_helper->log('Non è stato trovato un token valido, sospendo il profilo ricorrente');
|
185 |
+
//imposto lo stato a scaduto
|
186 |
+
$profile->setState(Mage_Sales_Model_Recurring_Profile::STATE_SUSPENDED);
|
187 |
+
$profile->save();
|
188 |
+
}
|
189 |
+
return false;
|
190 |
+
}
|
191 |
+
|
192 |
+
|
193 |
+
protected function executePaymentS2S($webService){
|
194 |
+
$client = $this->_initClient($webService);
|
195 |
+
if(!$client){
|
196 |
+
return false;
|
197 |
+
}
|
198 |
+
|
199 |
+
$param = $webService->getParamToCallPagamS2S();
|
200 |
+
|
201 |
+
$result = $client->callPagamS2S($param);
|
202 |
+
|
203 |
+
$webService->setResponseCallPagamS2S($result);
|
204 |
+
return $webService;
|
205 |
+
}
|
206 |
+
|
207 |
+
|
208 |
+
/**
|
209 |
+
* Method to calculate next recurring date
|
210 |
+
* @param $unit
|
211 |
+
* @param $periodFrequency
|
212 |
+
* @param $lastUpdated
|
213 |
+
* @return int|null
|
214 |
+
*/
|
215 |
+
public function getNexDateByUnitAndFrequency($unit, $periodFrequency, $lastUpdated){
|
216 |
+
/** @var EasyNolo_BancaSellaPro_Helper_Data $_helper */
|
217 |
+
$_helper = Mage::helper('easynolo_bancasellapro');
|
218 |
+
$checkDate = null;
|
219 |
+
|
220 |
+
if(!is_int($lastUpdated)){
|
221 |
+
$lastUpdated= strtotime($lastUpdated);
|
222 |
+
}
|
223 |
+
//per ognuno dei metodi bisogna effettuare il pagamento se scade oggi
|
224 |
+
switch ($unit){
|
225 |
+
case Mage_Payment_Model_Recurring_Profile::PERIOD_UNIT_DAY :
|
226 |
+
$checkDate = strtotime('+'.$periodFrequency.' day', $lastUpdated);
|
227 |
+
$_helper->log('Tipo di periodo "giornaliero", prossima data: '. date ( DATE_RFC2822, $checkDate));
|
228 |
+
break;
|
229 |
+
case Mage_Payment_Model_Recurring_Profile::PERIOD_UNIT_WEEK :
|
230 |
+
$checkDate = strtotime('+'.$periodFrequency.' week', $lastUpdated);
|
231 |
+
$_helper->log('Tipo di periodo "settimanale", prossima data: '. date ( DATE_RFC2822, $checkDate));
|
232 |
+
break;
|
233 |
+
case Mage_Payment_Model_Recurring_Profile::PERIOD_UNIT_SEMI_MONTH : //two weeks
|
234 |
+
$twoWeek = $periodFrequency*2;
|
235 |
+
$checkDate = strtotime('+'.$twoWeek.' week', $lastUpdated);
|
236 |
+
$_helper->log('Tipo di periodo "due settimane", prossima data: '. date ( DATE_RFC2822, $checkDate));
|
237 |
+
break;
|
238 |
+
case Mage_Payment_Model_Recurring_Profile::PERIOD_UNIT_MONTH :
|
239 |
+
$checkDate = strtotime('+'.$periodFrequency.' month', $lastUpdated);
|
240 |
+
$_helper->log('Tipo di periodo "mensile", prossima data: '. date ( DATE_RFC2822, $checkDate));
|
241 |
+
break;
|
242 |
+
case Mage_Payment_Model_Recurring_Profile::PERIOD_UNIT_YEAR :
|
243 |
+
$checkDate = strtotime('+'.$periodFrequency.' year', $lastUpdated);
|
244 |
+
$_helper->log('Tipo di periodo "annuale", prossima data: '. date ( DATE_RFC2822, $checkDate));
|
245 |
+
break;
|
246 |
+
}
|
247 |
+
return $checkDate;
|
248 |
+
}
|
249 |
+
|
250 |
+
/**
|
251 |
+
* Methot to calculate the last date of the period
|
252 |
+
* @param $unit
|
253 |
+
* @param $periodFrequency
|
254 |
+
* @param $maxcycles
|
255 |
+
* @param $lastUpdated
|
256 |
+
* @return int|null
|
257 |
+
*/
|
258 |
+
public function getLastDateByUnitAndFrequency($unit, $periodFrequency, $maxcycles, $lastUpdated){
|
259 |
+
if($maxcycles){
|
260 |
+
return $this->getNexDateByUnitAndFrequency($unit,$periodFrequency*$maxcycles,$lastUpdated);
|
261 |
+
}
|
262 |
+
return null;
|
263 |
+
}
|
264 |
+
|
265 |
+
|
266 |
+
}
|
app/code/community/EasyNolo/BancaSellaPro/Helper/S2s.php
ADDED
@@ -0,0 +1,128 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @category Bitbull
|
4 |
+
* @package Bitbull_BancaSellaPro
|
5 |
+
* @author Mirko Cesaro <mirko.cesaro@bitbull.it>
|
6 |
+
*/
|
7 |
+
|
8 |
+
class EasyNolo_BancaSellaPro_Helper_S2s extends EasyNolo_BancaSellaPro_Helper_Baseclient {
|
9 |
+
|
10 |
+
protected $_webserviceClassName ='easynolo_bancasellapro/webservice_wss2s';
|
11 |
+
|
12 |
+
const STATUS_REFUND_TOTAL = 'refund_bancasella';
|
13 |
+
|
14 |
+
|
15 |
+
public function capturePayment($payment,$amount){
|
16 |
+
$order = $payment->getOrder();
|
17 |
+
$_helper= Mage::helper('easynolo_bancasellapro');
|
18 |
+
$_helper->log('richiesto capture per ordine '. $order->getIncrementId());
|
19 |
+
//inizializza il webservice
|
20 |
+
$webservice = $this->getInitWebservice();
|
21 |
+
//imposta l'ordine
|
22 |
+
$webservice->setOrder($order);
|
23 |
+
$result = $this->executeCaptureS2S($webservice,$amount);
|
24 |
+
if ($result->getTransactionResult() == "KO") {
|
25 |
+
$payment->setIsTransactionPending(true);
|
26 |
+
$message = $this->__('Capture amount of %s online failed: %s', $order->getBaseCurrency()->formatTxt($amount), $result->getErrorDescription());
|
27 |
+
$order->addStatusHistoryComment($message, false);
|
28 |
+
Mage::throwException($message);
|
29 |
+
}
|
30 |
+
|
31 |
+
return $this;
|
32 |
+
}
|
33 |
+
|
34 |
+
public function refundPayment($payment,$amount){
|
35 |
+
$order = $payment->getOrder();
|
36 |
+
$_helper= Mage::helper('easynolo_bancasellapro');
|
37 |
+
$_helper->log('richiesto refund per ordine '. $order->getIncrementId());
|
38 |
+
//inizializza il webservice
|
39 |
+
$webservice = $this->getInitWebservice();
|
40 |
+
//imposta l'ordine
|
41 |
+
$webservice->setOrder($order);
|
42 |
+
$result = $this->executeRefundS2S($webservice,$amount);
|
43 |
+
if($result->getTransactionResult() == "KO") {
|
44 |
+
$payment->setIsTransactionPending(true);
|
45 |
+
$message = $this->__('Refund amount of %s online failed: %s', $order->getBaseCurrency()->formatTxt($amount), $result->getErrorDescription());
|
46 |
+
$order->addStatusHistoryComment($message, false);
|
47 |
+
Mage::throwException($message);
|
48 |
+
}
|
49 |
+
|
50 |
+
return $this;
|
51 |
+
}
|
52 |
+
|
53 |
+
public function voidPayment($payment){
|
54 |
+
$order = $payment->getOrder();
|
55 |
+
$_helper= Mage::helper('easynolo_bancasellapro');
|
56 |
+
$_helper->log('richiesto annullamento per ordine '. $order->getIncrementId());
|
57 |
+
//inizializza il webservice
|
58 |
+
$webservice = $this->getInitWebservice();
|
59 |
+
//imposta l'ordine
|
60 |
+
$webservice->setOrder($order);
|
61 |
+
$result = $this->executeVoidS2S($webservice);
|
62 |
+
if($result->getTransactionResult() == "KO"){
|
63 |
+
$payment->setIsTransactionPending(true);
|
64 |
+
$message = $this->__('Void amount of %s online failed: %s', $order->getBaseCurrency()->formatTxt($amount), $result->getErrorDescription());
|
65 |
+
$order->addStatusHistoryComment($message, false);
|
66 |
+
Mage::throwException($message);
|
67 |
+
}
|
68 |
+
|
69 |
+
return $this;
|
70 |
+
}
|
71 |
+
|
72 |
+
protected function executeCaptureS2S($webService,$amount){
|
73 |
+
$client = $this->_initClient($webService);
|
74 |
+
if(!$client){
|
75 |
+
return false;
|
76 |
+
}
|
77 |
+
|
78 |
+
$param = $webService->getParamToCallCaptureS2S($amount);
|
79 |
+
|
80 |
+
$result = $client->callSettleS2S($param);
|
81 |
+
|
82 |
+
$webService->setResponseCallSettleS2S($result);
|
83 |
+
return $webService;
|
84 |
+
}
|
85 |
+
|
86 |
+
protected function executeRefundS2S($webService,$amount){
|
87 |
+
$client = $this->_initClient($webService);
|
88 |
+
if(!$client){
|
89 |
+
return false;
|
90 |
+
}
|
91 |
+
|
92 |
+
$param = $webService->getParamToCallPagamS2S($amount);
|
93 |
+
|
94 |
+
$result = $client->callRefundS2S($param);
|
95 |
+
|
96 |
+
$webService->setResponseCallRefundS2S($result);
|
97 |
+
return $webService;
|
98 |
+
}
|
99 |
+
|
100 |
+
protected function executeVoidS2S($webService){
|
101 |
+
$client = $this->_initClient($webService);
|
102 |
+
if(!$client){
|
103 |
+
return false;
|
104 |
+
}
|
105 |
+
|
106 |
+
$param = $webService->getParamToCallPagamS2S(0);
|
107 |
+
|
108 |
+
$result = $client->callDeleteS2S($param);
|
109 |
+
|
110 |
+
$webService->setResponseCallDeleteS2S($result);
|
111 |
+
return $webService;
|
112 |
+
}
|
113 |
+
|
114 |
+
public function acceptPayment(Mage_Payment_Model_Info $payment){
|
115 |
+
|
116 |
+
/* implementato per gestire accept su payment review a backend, in caso di capture non andato a buon fine*/
|
117 |
+
return true;
|
118 |
+
|
119 |
+
}
|
120 |
+
public function denyPayment(Mage_Payment_Model_Info $payment)
|
121 |
+
{
|
122 |
+
return true;
|
123 |
+
}
|
124 |
+
|
125 |
+
|
126 |
+
|
127 |
+
|
128 |
+
}
|
app/code/community/EasyNolo/BancaSellaPro/Model/Gestpay.php
ADDED
@@ -0,0 +1,693 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* @category EasyNolo
|
5 |
+
* @package EasyNolo_BancaSellaPro
|
6 |
+
* @author Easy Nolo <ecommerce@sella.it>
|
7 |
+
*/
|
8 |
+
class EasyNolo_BancaSellaPro_Model_Gestpay extends Mage_Payment_Model_Method_Abstract
|
9 |
+
implements Mage_Payment_Model_Recurring_Profile_MethodInterface
|
10 |
+
{
|
11 |
+
|
12 |
+
const RELATIVE_IFRAME_URL = '/pagam/JavaScript/js_GestPay.js';
|
13 |
+
|
14 |
+
//url per i pagamenti reali
|
15 |
+
const REAL_PAYMENT_URL = 'https://ecomm.sella.it';
|
16 |
+
const REAL_PAYMENT_URL_WSDL = 'https://ecomms2s.sella.it';
|
17 |
+
|
18 |
+
const TEST_PAYMENT_URL = 'https://testecomm.sella.it';
|
19 |
+
|
20 |
+
const PAGE_REDIRECT_TO_PAYMENT = '/pagam/pagam.aspx';
|
21 |
+
|
22 |
+
const METHOD_CODE = "gestpaypro";
|
23 |
+
|
24 |
+
//pagamento minimo consentito
|
25 |
+
const MINIMUM_AMOUNT = 0.01;
|
26 |
+
|
27 |
+
const PAYMENT_INFO_TOKEN = 'easynolo_bancasellapro_payment_token';
|
28 |
+
|
29 |
+
|
30 |
+
protected $_code = EasyNolo_BancaSellaPro_Model_Gestpay::METHOD_CODE;
|
31 |
+
protected $_formBlockType = 'easynolo_bancasellapro/form';
|
32 |
+
|
33 |
+
|
34 |
+
protected $_order;
|
35 |
+
|
36 |
+
/**
|
37 |
+
* Availability options
|
38 |
+
*/
|
39 |
+
protected $_isGateway = true;
|
40 |
+
protected $_canAuthorize = true;
|
41 |
+
protected $_canCapture = true;
|
42 |
+
protected $_canCapturePartial = true;
|
43 |
+
protected $_canRefund = true;
|
44 |
+
protected $_canVoid = true;
|
45 |
+
protected $_canUseInternal = false;
|
46 |
+
protected $_canUseCheckout = true;
|
47 |
+
protected $_canUseForMultishipping = false;
|
48 |
+
protected $_isInitializeNeeded = true;
|
49 |
+
|
50 |
+
public function canManageRecurringProfiles()
|
51 |
+
{
|
52 |
+
//solo se è abilitata la tokenizzazione posso gestire i recurring profiles
|
53 |
+
return parent::canManageRecurringProfiles() && $this->getConfigData('tokenization');
|
54 |
+
}
|
55 |
+
|
56 |
+
public function getCheckout()
|
57 |
+
{
|
58 |
+
if (empty($this->_checkout)) {
|
59 |
+
$this->_checkout = Mage::getSingleton('checkout/session');
|
60 |
+
}
|
61 |
+
return $this->_checkout;
|
62 |
+
}
|
63 |
+
|
64 |
+
/**
|
65 |
+
* Restituisce l'url quando il pagamento va a buon fine
|
66 |
+
* @return string
|
67 |
+
*/
|
68 |
+
protected function getSuccessURL()
|
69 |
+
{
|
70 |
+
return Mage::getUrl('easynolo_bancasellapro/gestpay/success', array('_secure' => Mage::app()->getStore()->isCurrentlySecure()));
|
71 |
+
}
|
72 |
+
|
73 |
+
/**
|
74 |
+
* Metodo che restituisce l'url dove reindirizzare l'utente dopo la verifica 3dsecure
|
75 |
+
* @return string
|
76 |
+
*/
|
77 |
+
public function getPage3d()
|
78 |
+
{
|
79 |
+
return Mage::getUrl('easynolo_bancasellapro/gestpay/confirm3d', array('_secure' => Mage::app()->getStore()->isCurrentlySecure()));
|
80 |
+
}
|
81 |
+
|
82 |
+
|
83 |
+
/**
|
84 |
+
* Restituisce l'url dove effettuare il redirect sul sito di bancasella
|
85 |
+
* @return string
|
86 |
+
*/
|
87 |
+
public function getOrderPlaceRedirectUrl()
|
88 |
+
{
|
89 |
+
return Mage::getUrl('easynolo_bancasellapro/gestpay/redirect', array('_secure' => true));
|
90 |
+
}
|
91 |
+
|
92 |
+
|
93 |
+
/**
|
94 |
+
* metodo che riserva un id ordine e lo restituisce
|
95 |
+
* @return mixed identificativo dell'ordine
|
96 |
+
*/
|
97 |
+
public function getFutureOrderId()
|
98 |
+
{
|
99 |
+
$info = $this->getInfoInstance();
|
100 |
+
$orderId = $info->getQuote()->getReservedOrderId();
|
101 |
+
if ($orderId) {
|
102 |
+
$order = Mage::getModel('sales/order')->loadByIncrementId($orderId);
|
103 |
+
if ($order->getId()) {
|
104 |
+
//esiste gia un ordine con questo increment id, quindi ne creo un altro
|
105 |
+
$info->getQuote()->reserveOrderId()->save();
|
106 |
+
}
|
107 |
+
} else {
|
108 |
+
$info->getQuote()->reserveOrderId()->save();
|
109 |
+
}
|
110 |
+
return $info->getQuote()->getReservedOrderId();
|
111 |
+
}
|
112 |
+
|
113 |
+
/**
|
114 |
+
* Metodo che restituisce il quote tramite l'istanza info del metodo di pagamento
|
115 |
+
* @return mixed
|
116 |
+
*/
|
117 |
+
public function getQuote()
|
118 |
+
{
|
119 |
+
$info = $this->getInfoInstance();
|
120 |
+
return $info->getQuote();
|
121 |
+
}
|
122 |
+
|
123 |
+
/**
|
124 |
+
* Metodo che restituisce il merchant id impostato nello store
|
125 |
+
* @return mixed
|
126 |
+
*/
|
127 |
+
public function getMerchantId()
|
128 |
+
{
|
129 |
+
return $this->getConfigData('merchant_id');
|
130 |
+
}
|
131 |
+
|
132 |
+
public function getOrderStatusKoUser()
|
133 |
+
{
|
134 |
+
return $this->getConfigData('order_status_ko_user');
|
135 |
+
}
|
136 |
+
|
137 |
+
public function getOrderStatusOkGestPay()
|
138 |
+
{
|
139 |
+
return $this->getConfigData('order_status_ok_gestpay');
|
140 |
+
}
|
141 |
+
|
142 |
+
public function getOrderStatusKoGestPay()
|
143 |
+
{
|
144 |
+
return $this->getConfigData('order_status_ko_gestpay');
|
145 |
+
}
|
146 |
+
|
147 |
+
/**
|
148 |
+
* Metodo che restituisce la moneta impostata nello store
|
149 |
+
* @return mixed
|
150 |
+
*/
|
151 |
+
public function getCurrency()
|
152 |
+
{
|
153 |
+
return $this->getConfigData('currency');
|
154 |
+
}
|
155 |
+
|
156 |
+
/**
|
157 |
+
* Metodo che restituisce la lingua impostata nello store
|
158 |
+
* @return mixed
|
159 |
+
*/
|
160 |
+
public function getLanguage()
|
161 |
+
{
|
162 |
+
return $this->getConfigData('language');
|
163 |
+
}
|
164 |
+
|
165 |
+
/**
|
166 |
+
* Metodo che restitiusce url per il pagaemento su gestpay
|
167 |
+
* @return string
|
168 |
+
*/
|
169 |
+
public function getGestpayUrl()
|
170 |
+
{
|
171 |
+
$domain = $this->getBaseUrlSella();
|
172 |
+
return $domain . "/gestpay/pagam.asp";
|
173 |
+
}
|
174 |
+
|
175 |
+
/**
|
176 |
+
* Restituisce l'url dove effettuare il redirect per il pagamento sul sito di bancasella
|
177 |
+
* @return string
|
178 |
+
*/
|
179 |
+
public function getRedirectPagePaymentUrl()
|
180 |
+
{
|
181 |
+
$domain = $this->getBaseUrlSella();
|
182 |
+
return $domain . self::PAGE_REDIRECT_TO_PAYMENT;
|
183 |
+
}
|
184 |
+
|
185 |
+
/**
|
186 |
+
* Metodo che restituisce l'url dove effettuare la verifica 3dsecure
|
187 |
+
* @return string
|
188 |
+
*/
|
189 |
+
public function getAuthPage()
|
190 |
+
{
|
191 |
+
$url = $this->getBaseUrlSella();
|
192 |
+
return $url . '/pagam/pagam3d.aspx';
|
193 |
+
}
|
194 |
+
|
195 |
+
/**
|
196 |
+
* Restituisce l'url di bancasella a seconda se la modalità di sviluppo è attiva oppure no
|
197 |
+
* @return string
|
198 |
+
*/
|
199 |
+
public function getBaseUrlSella()
|
200 |
+
{
|
201 |
+
$url = self::REAL_PAYMENT_URL;
|
202 |
+
if ($this->getConfigData('debug'))
|
203 |
+
$url = self::TEST_PAYMENT_URL;
|
204 |
+
return $url;
|
205 |
+
}
|
206 |
+
|
207 |
+
/**
|
208 |
+
* Restituisce l'url del wsdl di bancasella a seconda se la modalità di sviluppo è attiva oppure no
|
209 |
+
* @return string
|
210 |
+
*/
|
211 |
+
public function getBaseWSDLUrlSella()
|
212 |
+
{
|
213 |
+
$url = self::REAL_PAYMENT_URL_WSDL;
|
214 |
+
if ($this->getConfigData('debug'))
|
215 |
+
$url = self::TEST_PAYMENT_URL;
|
216 |
+
return $url;
|
217 |
+
}
|
218 |
+
|
219 |
+
/**
|
220 |
+
* Restituisce l'url per l'iframe
|
221 |
+
* @return string
|
222 |
+
*/
|
223 |
+
public function getIframeUrl()
|
224 |
+
{
|
225 |
+
return $this->getBaseUrlSella() . self::RELATIVE_IFRAME_URL;
|
226 |
+
}
|
227 |
+
|
228 |
+
/**
|
229 |
+
* Metodo che indica se la soluzione con iframe è abilitata
|
230 |
+
* @return bool true se abilitato, false altrimenti
|
231 |
+
*/
|
232 |
+
public function isIframeEnable()
|
233 |
+
{
|
234 |
+
$enableIframe = $this->getConfigData('iframe');
|
235 |
+
if ($enableIframe) {
|
236 |
+
return true;
|
237 |
+
}
|
238 |
+
return false;
|
239 |
+
|
240 |
+
}
|
241 |
+
|
242 |
+
/**
|
243 |
+
* Metodo che si occupa di associare l'encrypted string al pagamento solo se è prensente la dipendenza da IWD_Opc (one page checkout)
|
244 |
+
* @param mixed $data
|
245 |
+
* @return Mage_Payment_Model_Info|void
|
246 |
+
*/
|
247 |
+
public function assignData($data)
|
248 |
+
{
|
249 |
+
if ($this->isIframeEnable()) {
|
250 |
+
$children = Mage::getConfig()->getNode('modules')->children();
|
251 |
+
$modulesArray = (array)$children;
|
252 |
+
//controllo se ci sono dipendenze nel modulo bancasella
|
253 |
+
if (isset($modulesArray['EasyNolo_BancaSellaPro']->depends)) {
|
254 |
+
$depens = $modulesArray['EasyNolo_BancaSellaPro']->depends->children();
|
255 |
+
$dependsArray = (array)$depens;
|
256 |
+
//se presente la dipendenza da IWD devo aggiornare la finestra per il pagamento con iframe
|
257 |
+
if (isset($dependsArray['IWD_Opc'])) {
|
258 |
+
//calcolare l encrypt e lo associa al metodo di pagamento solo in questa richiesta
|
259 |
+
$helper = Mage::helper('easynolo_bancasellapro/crypt');
|
260 |
+
$encryptString = $helper->getEncryptStringBeforeOrder($this);
|
261 |
+
$this->setEncryptString($encryptString);
|
262 |
+
Mage::helper('easynolo_bancasellapro')->log('Salvo l encrypt string per ricreare l\'iframe => ' . $encryptString);
|
263 |
+
}
|
264 |
+
}
|
265 |
+
}
|
266 |
+
}
|
267 |
+
|
268 |
+
/**
|
269 |
+
* Metodo che restituisce il totale dell'ordine da passare al a bancasella
|
270 |
+
* @param $order
|
271 |
+
* @return float
|
272 |
+
*/
|
273 |
+
public function getTotalByOrder($order)
|
274 |
+
{
|
275 |
+
//recupero la currency di default
|
276 |
+
$defaultCurrency = $this->getConfigData(
|
277 |
+
'currency',
|
278 |
+
Mage::app()->getWebsite(true)->getDefaultGroup()->getDefaultStoreId()
|
279 |
+
);
|
280 |
+
//e quella dello store attuale
|
281 |
+
$storeCurrency = $this->getConfigData('currency');
|
282 |
+
|
283 |
+
/** @var $order Mage_Sales_Model_Order */
|
284 |
+
//se sono diverse
|
285 |
+
if ($defaultCurrency != $storeCurrency) {
|
286 |
+
//si deve utilizzare la valuta dello store
|
287 |
+
return $order->getGrandTotal();
|
288 |
+
} else {
|
289 |
+
//se sono uguali o hanno la stessa configurazione oppure è stato scelto solo di usare il pagamento di default
|
290 |
+
|
291 |
+
//quindi restituisco il base grand total
|
292 |
+
return $order->getBaseGrandTotal();
|
293 |
+
}
|
294 |
+
|
295 |
+
}
|
296 |
+
|
297 |
+
/**
|
298 |
+
* Validate data
|
299 |
+
*
|
300 |
+
* @param Mage_Payment_Model_Recurring_Profile $profile
|
301 |
+
* @throws Mage_Core_Exception
|
302 |
+
*/
|
303 |
+
public function validateRecurringProfile(Mage_Payment_Model_Recurring_Profile $profile)
|
304 |
+
{
|
305 |
+
//metodo per validare il profilo ricorrente
|
306 |
+
//non è necessario farlo perché bancasella non ha i pagamenti ricorrenti, e i totali vendono controllati nel metodo chiamante
|
307 |
+
return true;
|
308 |
+
}
|
309 |
+
|
310 |
+
/**
|
311 |
+
* Submit to the gateway
|
312 |
+
*
|
313 |
+
* @param Mage_Payment_Model_Recurring_Profile $profile
|
314 |
+
* @param Mage_Payment_Model_Info $paymentInfo
|
315 |
+
*/
|
316 |
+
public function submitRecurringProfile(
|
317 |
+
Mage_Payment_Model_Recurring_Profile $profile,
|
318 |
+
Mage_Payment_Model_Info $paymentInfo
|
319 |
+
)
|
320 |
+
{
|
321 |
+
|
322 |
+
/** @var EasyNolo_Bancasellapro_Model_Token $token */
|
323 |
+
$token = Mage::getModel('easynolo_bancasellapro/token')
|
324 |
+
->getCollection()
|
325 |
+
->addProfileToFilter($profile)
|
326 |
+
//questo non serve perché se il token non è valido va sospeso il profilo, mentre se non esistono token (neanche scaduti)
|
327 |
+
//è un informazione rilevante perché indica che non è stato fatto il primo pagamento
|
328 |
+
//->addValidDateFilter()
|
329 |
+
->getFirstItem();
|
330 |
+
|
331 |
+
if (!$token->getId()) {
|
332 |
+
//primo pagamento, non possiamo fare niente, dobbiamo creare l'orine e il token per i futuri pagamenti
|
333 |
+
$profile->setState(Mage_Sales_Model_Recurring_Profile::STATE_PENDING);
|
334 |
+
|
335 |
+
$productItemInfo = $this->_getProductItemInfoToInitialPayment($profile);
|
336 |
+
|
337 |
+
//creo l'ordine impostando l'increment id riservato
|
338 |
+
/** @var Mage_Sales_Model_Order $order */
|
339 |
+
$order = $profile->createOrder($productItemInfo);
|
340 |
+
$order->setIncrementId($this->getFutureOrderId());
|
341 |
+
|
342 |
+
//imposto lo stato new per sicurezza, in quanto è presente un controllo che indica che la chiamata s2s non
|
343 |
+
//è stata fatta se lo stato è new
|
344 |
+
$order->setState(
|
345 |
+
Mage_Sales_Model_Order::STATE_NEW,
|
346 |
+
true,
|
347 |
+
Mage::helper('easynolo_bancasellapro')->__('First payment to obtain the credit card token.')
|
348 |
+
);
|
349 |
+
|
350 |
+
$order->save();
|
351 |
+
//il pagamento dell'ordine avviene dal browser dell'utente
|
352 |
+
|
353 |
+
//aggiungo l'ordine al profile
|
354 |
+
$profile->addOrderRelation($order->getId());
|
355 |
+
|
356 |
+
//in questo caso non serve fare il save, perché il metodo è stato chiamato dal submit generale del profile
|
357 |
+
} else {
|
358 |
+
//se il token esiste allora questo è un pagamento che viene fatto dal server
|
359 |
+
//controllo ed eseguo il pagamento
|
360 |
+
$this->_checkAndExecutePayment($profile);
|
361 |
+
}
|
362 |
+
}
|
363 |
+
|
364 |
+
|
365 |
+
/**
|
366 |
+
* Method to check and execute the payment for the profile
|
367 |
+
* @param $recurringProfile
|
368 |
+
*/
|
369 |
+
protected function _checkAndExecutePayment($recurringProfile)
|
370 |
+
{
|
371 |
+
$_helper = Mage::helper('easynolo_bancasellapro');
|
372 |
+
$helperRecurringPayment = Mage::helper('easynolo_bancasellapro/recurringprofile');
|
373 |
+
|
374 |
+
/** @var $recurringProfile Mage_Sales_Model_Recurring_Profile */
|
375 |
+
$_helper->log('----------------------------------------');
|
376 |
+
$_helper->log('controllo profile con id: ' . $recurringProfile->getId());
|
377 |
+
|
378 |
+
$lastUpdated = $recurringProfile->getUpdatedAt();
|
379 |
+
$startDate = $recurringProfile->getStartDatetime();
|
380 |
+
$periodFrequency = $recurringProfile->getPeriodFrequency();
|
381 |
+
$checkDate = null;
|
382 |
+
$_helper->log('Ultimo aggiornamento: ' . date(DATE_RFC2822, strtotime($lastUpdated)));
|
383 |
+
|
384 |
+
$productItemInfo = null;
|
385 |
+
$now = strtotime(Varien_Date::now(true));
|
386 |
+
|
387 |
+
$_helper->log('Controllo l\'ultima data della trial ');
|
388 |
+
|
389 |
+
//recupero l'ultima data per la trial
|
390 |
+
$lastTrialDate = $helperRecurringPayment->getLastDateByUnitAndFrequency($recurringProfile->getTrialPeriodUnit(), $recurringProfile->getTrialPeriodFrequency(), $recurringProfile->getTrialPeriodMaxCycles(), $startDate);
|
391 |
+
|
392 |
+
//se è presente una data di scadenza e non è stata superata oppure non esiste scadenza allora
|
393 |
+
if ($lastTrialDate != null && $now <= $lastTrialDate) {
|
394 |
+
$_helper->log('Controllo la prossima data per la trial ');
|
395 |
+
|
396 |
+
//recupero la prossima data di ricorrenza della trial
|
397 |
+
$trialDate = $helperRecurringPayment->getNexDateByUnitAndFrequency($recurringProfile->getPeriodUnit(), $periodFrequency, $lastUpdated);
|
398 |
+
//se la data corrisponde o è inferiore alla data attuale
|
399 |
+
|
400 |
+
if ($now >= $trialDate) {
|
401 |
+
$_helper->log('creo l\'item per effettuare il pagamento trial');
|
402 |
+
|
403 |
+
//effettuo il pagamento di una trial
|
404 |
+
$productItemInfo = $this->_getProductItemInfoToTrialPayment($recurringProfile);
|
405 |
+
|
406 |
+
}
|
407 |
+
} else if ($lastTrialDate == null || $now > $lastTrialDate) {
|
408 |
+
|
409 |
+
//se presente un periodo di prova allora bisogna calcolare la data di scadenza dalla fine del periodo di prova invece di startdate
|
410 |
+
if ($lastTrialDate != null) {
|
411 |
+
//sostituiamo start date con l'ultima data della trial
|
412 |
+
$startDate = $lastTrialDate;
|
413 |
+
}
|
414 |
+
$_helper->log('Controllo l\'ultima data per il pagamento regolare');
|
415 |
+
|
416 |
+
//recupero la data di scadenza del profilo
|
417 |
+
$lastRegularDate = $helperRecurringPayment->getLastDateByUnitAndFrequency($recurringProfile->getPeriodUnit(), $recurringProfile->getPeriodFrequency(), $recurringProfile->getPeriodMaxCycles(), $startDate);
|
418 |
+
|
419 |
+
//se la data è ancora valida oppure non è presente
|
420 |
+
if ($lastRegularDate == null || $now <= $lastRegularDate) {
|
421 |
+
$_helper->log('Controllo la prossima data per il pagamento regolare');
|
422 |
+
|
423 |
+
//recupero la prossima data di scadenza del profilo
|
424 |
+
$checkDate = $helperRecurringPayment->getNexDateByUnitAndFrequency($recurringProfile->getPeriodUnit(), $periodFrequency, $lastUpdated);
|
425 |
+
|
426 |
+
if ($now >= $checkDate) {
|
427 |
+
$_helper->log('creo l\'item per effettuare il pagamento regolare');
|
428 |
+
|
429 |
+
//creo il prodotto per la trial
|
430 |
+
$productItemInfo = $this->_getProductItemInfoToReguralPayment($recurringProfile);
|
431 |
+
} else {
|
432 |
+
// il pagamento non avverra ora non è ancora il momento
|
433 |
+
$_helper->log('Il profilo non deve essere ancora pagato');
|
434 |
+
}
|
435 |
+
} else if ($now > $lastRegularDate) {
|
436 |
+
$_helper->log('Il profilo è scaduto, aggiorno lo stato');
|
437 |
+
|
438 |
+
//imposto lo stato a scaduto
|
439 |
+
$recurringProfile->setState(Mage_Sales_Model_Recurring_Profile::STATE_EXPIRED);
|
440 |
+
$recurringProfile->save();
|
441 |
+
}
|
442 |
+
}
|
443 |
+
|
444 |
+
//se è stato creato un prodotto
|
445 |
+
if ($productItemInfo != null) {
|
446 |
+
try {
|
447 |
+
//effettuo la creazione dell'ordine e il pagamento
|
448 |
+
$this->createOrderAndExecutePayment($recurringProfile, $productItemInfo);
|
449 |
+
} catch (Exception $e) {
|
450 |
+
Mage::logException($e);
|
451 |
+
$_helper = Mage::helper('easynolo_bancasellapro');
|
452 |
+
$_helper->log('Non è stato possibile creare ed eseguire il pagamento per il profilo: ' . $recurringProfile->getId() . '. Controllare exception.log');
|
453 |
+
}
|
454 |
+
}
|
455 |
+
}
|
456 |
+
|
457 |
+
/**
|
458 |
+
* Method to execute a payment for a recurring profile using a productInfo
|
459 |
+
* @param $recurringProfile
|
460 |
+
* @param $productItemInfo
|
461 |
+
*/
|
462 |
+
protected function createOrderAndExecutePayment($recurringProfile, $productItemInfo)
|
463 |
+
{
|
464 |
+
$order = $recurringProfile->createOrder($productItemInfo);
|
465 |
+
$order->save();
|
466 |
+
|
467 |
+
$recurringProfile->addOrderRelation($order->getId());
|
468 |
+
|
469 |
+
//effettuo il pagamento dell'ordine per il profilo
|
470 |
+
Mage::helper('easynolo_bancasellapro/recurringprofile')->payOrderOfProfile($order, $recurringProfile);
|
471 |
+
}
|
472 |
+
|
473 |
+
|
474 |
+
/**
|
475 |
+
* Check whether can get recurring profile details
|
476 |
+
*
|
477 |
+
* @return bool
|
478 |
+
*/
|
479 |
+
public function canGetRecurringProfileDetails()
|
480 |
+
{
|
481 |
+
//bancasella non puo dirci nulla perhcé non gestisce i pagamenti ricorrenti
|
482 |
+
return false;
|
483 |
+
}
|
484 |
+
|
485 |
+
/**
|
486 |
+
* Update data
|
487 |
+
*
|
488 |
+
* @param Mage_Payment_Model_Recurring_Profile $profile
|
489 |
+
*/
|
490 |
+
public function updateRecurringProfile(Mage_Payment_Model_Recurring_Profile $profile)
|
491 |
+
{
|
492 |
+
//metodo per aggiornare il profilo ricorrente, forse possiamo usarlo per rinnovare il token...
|
493 |
+
Mage::log(__METHOD__ . '; Profile #' . $profile->getId(), null, 'Recurring.log', true);
|
494 |
+
}
|
495 |
+
|
496 |
+
/**
|
497 |
+
* Manage status
|
498 |
+
*
|
499 |
+
* @param Mage_Payment_Model_Recurring_Profile $profile
|
500 |
+
*/
|
501 |
+
public function updateRecurringProfileStatus(Mage_Payment_Model_Recurring_Profile $profile)
|
502 |
+
{
|
503 |
+
//non c'e bisogno di gestire questo perché bancasella non permette di aggiornare gli stati (non ha pagamenti ricorrenti)
|
504 |
+
Mage::helper('easynolo_bancasellapro')->log('Richiesto ' . __METHOD__ . ' per il profilo' . $profile->getId());
|
505 |
+
|
506 |
+
if ($profile->hasNewState()) {
|
507 |
+
switch ($profile->getNewState()) {
|
508 |
+
case Mage_Sales_Model_Recurring_Profile::STATE_CANCELED:
|
509 |
+
Mage::helper('easynolo_bancasellapro')->log('Richiesta cancellazione del profilo: ' . $profile->getId());
|
510 |
+
break;
|
511 |
+
case Mage_Sales_Model_Recurring_Profile::STATE_SUSPENDED:
|
512 |
+
Mage::helper('easynolo_bancasellapro')->log('Richiesta sospensione del profilo: ' . $profile->getId());
|
513 |
+
break;
|
514 |
+
case Mage_Sales_Model_Recurring_Profile::STATE_ACTIVE:
|
515 |
+
Mage::helper('easynolo_bancasellapro')->log('Richiesta attivazione del profilo: ' . $profile->getId());
|
516 |
+
if ($profile->getState() == Mage_Sales_Model_Recurring_Profile::STATE_PENDING) {
|
517 |
+
$helper = Mage::helper('easynolo_bancasellapro');
|
518 |
+
Mage::throwException($helper->__('Unable to update the reccuring profile status for activation.'));
|
519 |
+
}
|
520 |
+
$token = Mage::getModel('easynolo_bancasellapro/token')->getFirstValidTokenForProfile($profile);
|
521 |
+
if (!$token->getId()) {
|
522 |
+
|
523 |
+
Mage::helper('easynolo_bancasellapro')->log('Creare un nuovo token, il precedente è scaduto: ' . $profile->getId());
|
524 |
+
|
525 |
+
Mage::app()->getFrontController()->getResponse()->setRedirect(
|
526 |
+
Mage::getUrl('easynolo_bancasellapro/tokenization/newtoken', array('profile' => $profile->getId()))
|
527 |
+
);
|
528 |
+
|
529 |
+
Mage::app()->getResponse()->sendResponse();
|
530 |
+
exit;
|
531 |
+
|
532 |
+
}
|
533 |
+
break;
|
534 |
+
}
|
535 |
+
}
|
536 |
+
}
|
537 |
+
|
538 |
+
/**
|
539 |
+
* Metodo per creare un itemInfo per il pagamento iniziale del recurring payment
|
540 |
+
* @param Mage_Payment_Model_Recurring_Profile $profile
|
541 |
+
* @return Varien_Object
|
542 |
+
*/
|
543 |
+
protected function _getProductItemInfoToInitialPayment(Mage_Payment_Model_Recurring_Profile $profile)
|
544 |
+
{
|
545 |
+
$productItemInfo = new Varien_Object;
|
546 |
+
//il pagamento iniziale non puo essere a zero
|
547 |
+
$firstCost = $profile->getTrialBillingAmount() > 0 ? $profile->getTrialBillingAmount() : $profile->getBillingAmount();
|
548 |
+
$init = $profile->getInitAmount() + $firstCost;
|
549 |
+
$productItemInfo->setPaymentType(Mage_Sales_Model_Recurring_Profile::PAYMENT_TYPE_INITIAL);
|
550 |
+
$productItemInfo->setPrice($init);
|
551 |
+
$productItemInfo->setShippingAmount($profile->getShippingAmount());//impostiamo il prezzo della spedizione
|
552 |
+
$productItemInfo->setTaxAmount($profile->getTaxAmount());//impostiamo il prezzo delle tasse
|
553 |
+
|
554 |
+
return $productItemInfo;
|
555 |
+
}
|
556 |
+
|
557 |
+
|
558 |
+
protected function _getProductItemInfoToNewTokenPayment(Mage_Payment_Model_Recurring_Profile $profile)
|
559 |
+
{
|
560 |
+
$productItemInfo = new Varien_Object;
|
561 |
+
//impostiamo il prezzo iniziale al minimo pagabile con bancasella.
|
562 |
+
$init = self::MINIMUM_AMOUNT;
|
563 |
+
$productItemInfo->setPaymentType(Mage_Sales_Model_Recurring_Profile::PAYMENT_TYPE_INITIAL);
|
564 |
+
$productItemInfo->setPrice($init);
|
565 |
+
$productItemInfo->setShippingAmount(0);//impostiamo il prezzo della spedizione
|
566 |
+
$productItemInfo->setTaxAmount(0);//impostiamo il prezzo delle tasse
|
567 |
+
|
568 |
+
return $productItemInfo;
|
569 |
+
}
|
570 |
+
|
571 |
+
/**
|
572 |
+
* Method to create ad iteminfo to regular recurring payment
|
573 |
+
* @param Mage_Payment_Model_Recurring_Profile $profile
|
574 |
+
* @return Varien_Object
|
575 |
+
*/
|
576 |
+
protected function _getProductItemInfoToReguralPayment(Mage_Payment_Model_Recurring_Profile $profile)
|
577 |
+
{
|
578 |
+
|
579 |
+
$productItemInfo = new Varien_Object;
|
580 |
+
|
581 |
+
$productItemInfo->setPaymentType(Mage_Sales_Model_Recurring_Profile::PAYMENT_TYPE_REGULAR);
|
582 |
+
$productItemInfo->setPrice($profile->getBillingAmount());
|
583 |
+
$productItemInfo->setShippingAmount($profile->getShippingAmount());//impostiamo il prezzo della spedizione
|
584 |
+
$productItemInfo->setTaxAmount($profile->getTaxAmount());//impostiamo il prezzo delle tasse
|
585 |
+
|
586 |
+
return $productItemInfo;
|
587 |
+
|
588 |
+
}
|
589 |
+
|
590 |
+
/**
|
591 |
+
* Method to create ad iteminfo to regular recurring payment
|
592 |
+
* @param Mage_Payment_Model_Recurring_Profile $profile
|
593 |
+
* @return Varien_Object
|
594 |
+
*/
|
595 |
+
protected function _getProductItemInfoToTrialPayment(Mage_Payment_Model_Recurring_Profile $profile)
|
596 |
+
{
|
597 |
+
|
598 |
+
$productItemInfo = new Varien_Object;
|
599 |
+
|
600 |
+
$productItemInfo->setPaymentType(Mage_Sales_Model_Recurring_Profile::PAYMENT_TYPE_TRIAL);
|
601 |
+
$productItemInfo->setPrice($profile->getTrialBillingAmount());
|
602 |
+
$productItemInfo->setShippingAmount($profile->getShippingAmount());//impostiamo il prezzo della spedizione
|
603 |
+
$productItemInfo->setTaxAmount($profile->getTaxAmount());//impostiamo il prezzo delle tasse
|
604 |
+
|
605 |
+
return $productItemInfo;
|
606 |
+
|
607 |
+
}
|
608 |
+
|
609 |
+
|
610 |
+
public function createOrderToNewToken($profile)
|
611 |
+
{
|
612 |
+
$profile->setState(Mage_Sales_Model_Recurring_Profile::STATE_PENDING);
|
613 |
+
|
614 |
+
//creo un ordine per pagare un item regolare e ricreare il token
|
615 |
+
$productItemInfo = $this->_getProductItemInfoToReguralPayment($profile);
|
616 |
+
|
617 |
+
//creo l'ordine impostando l'increment id riservato
|
618 |
+
/** @var Mage_Sales_Model_Order $order */
|
619 |
+
$order = $profile->createOrder($productItemInfo);
|
620 |
+
|
621 |
+
//imposto lo stato new per sicurezza, in quanto è presente un controllo che indica che la chiamata s2s non
|
622 |
+
//è stata fatta se lo stato è new
|
623 |
+
$order->setState(
|
624 |
+
Mage_Sales_Model_Order::STATE_NEW,
|
625 |
+
true,
|
626 |
+
Mage::helper('easynolo_bancasellapro')->__('First payment to obtain the credit card token.')
|
627 |
+
);
|
628 |
+
|
629 |
+
$order->save();
|
630 |
+
//il pagamento dell'ordine avviene dal browser dell'utente
|
631 |
+
|
632 |
+
//aggiungo l'ordine al profile
|
633 |
+
$profile->addOrderRelation($order->getId());
|
634 |
+
|
635 |
+
$profile->save();
|
636 |
+
|
637 |
+
return $order;
|
638 |
+
}
|
639 |
+
|
640 |
+
/**
|
641 |
+
* Fetch details
|
642 |
+
*
|
643 |
+
* @param string $referenceId
|
644 |
+
* @param Varien_Object $result
|
645 |
+
*/
|
646 |
+
public function getRecurringProfileDetails($referenceId, Varien_Object $result)
|
647 |
+
{
|
648 |
+
//metodo chiamato su update del profilo ricorrente
|
649 |
+
//l'update è stato disabilitato ma essendo una funziona abstract ha bisogno di essere definita
|
650 |
+
}
|
651 |
+
|
652 |
+
public function capture(Varien_Object $payment, $amount)
|
653 |
+
{
|
654 |
+
$helper = Mage::helper('easynolo_bancasellapro/s2s');
|
655 |
+
$helper->capturePayment($payment, $amount);
|
656 |
+
return $this;
|
657 |
+
}
|
658 |
+
|
659 |
+
public function refund(Varien_Object $payment, $amount)
|
660 |
+
{
|
661 |
+
$helper = Mage::helper('easynolo_bancasellapro/s2s');
|
662 |
+
$helper->refundPayment($payment, $amount);
|
663 |
+
return $this;
|
664 |
+
}
|
665 |
+
|
666 |
+
public function void(Varien_Object $payment)
|
667 |
+
{
|
668 |
+
$helper = Mage::helper('easynolo_bancasellapro/s2s');
|
669 |
+
$helper->voidPayment($payment);
|
670 |
+
return $this;
|
671 |
+
}
|
672 |
+
|
673 |
+
/**
|
674 |
+
* @param Mage_Sales_Model_Quote|null $quote
|
675 |
+
* @return bool|void
|
676 |
+
*/
|
677 |
+
public function isAvailable($quote = null)
|
678 |
+
{
|
679 |
+
$result = parent::isAvailable($quote);
|
680 |
+
if ($result && $quote && $quote->getGrandTotal() < self::MINIMUM_AMOUNT) {
|
681 |
+
return false;
|
682 |
+
}
|
683 |
+
|
684 |
+
if ($result && !extension_loaded('soap')) {
|
685 |
+
Mage::logException(Mage::exception('EasyNolo_BancaSellaPro', 'PHP SOAP extension is required.'));
|
686 |
+
$_helper = Mage::helper('easynolo_bancasellapro');
|
687 |
+
$_helper->log('Non è stato possibile creare il client per il webserver');
|
688 |
+
return false;
|
689 |
+
}
|
690 |
+
|
691 |
+
return $result;
|
692 |
+
}
|
693 |
+
}
|
app/code/community/EasyNolo/BancaSellaPro/Model/Observer.php
ADDED
@@ -0,0 +1,57 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @category EasyNolo
|
4 |
+
* @package EasyNolo_BancaSellaPro
|
5 |
+
* @author Easy Nolo <ecommerce@sella.it>
|
6 |
+
*/
|
7 |
+
|
8 |
+
class EasyNolo_BancaSellaPro_Model_Observer extends Mage_Core_Model_Abstract{
|
9 |
+
|
10 |
+
/**
|
11 |
+
* Metodo richiamato quando viene richiesto il salvataggio del metodo di pagamento con il modulo IWD_Opc
|
12 |
+
* @param $observer
|
13 |
+
*/
|
14 |
+
public function addDataToResultSavePaymentIWD($observer){
|
15 |
+
|
16 |
+
$sendParam = $observer->getResult();
|
17 |
+
$json = $sendParam->getJson();
|
18 |
+
|
19 |
+
if($encryptString = $observer->getMethod()->getEncryptString()){
|
20 |
+
//se il metodo ha l'encryptString allora lo salvo nel result
|
21 |
+
$json['encrypt_string'] = $encryptString;
|
22 |
+
}
|
23 |
+
|
24 |
+
$observer->getResult()->setJson($json);
|
25 |
+
}
|
26 |
+
|
27 |
+
/**
|
28 |
+
* Metodo che si occupa dell'esecuzione dei pagamenti per i profili ricorrenti
|
29 |
+
*/
|
30 |
+
public function chargeRecurringProfiles(){
|
31 |
+
|
32 |
+
//recuperare tutte i profili attivi da eseguire
|
33 |
+
$recurringProfieles = Mage::getModel('sales/recurring_profile')
|
34 |
+
->getCollection()
|
35 |
+
->addFieldToFilter('method_code', EasyNolo_BancaSellaPro_Model_Gestpay::METHOD_CODE)
|
36 |
+
->addFieldToFilter('state', Mage_Sales_Model_Recurring_Profile::STATE_ACTIVE)
|
37 |
+
->addFieldToFilter('start_datetime',array('lteq' => Varien_Date::now(true)));
|
38 |
+
|
39 |
+
/** @var EasyNolo_BancaSellaPro_Helper_Data $_helper */
|
40 |
+
$_helper = Mage::helper('easynolo_bancasellapro');
|
41 |
+
$_helper->log('Cron per il pagamento dei reccuring profile. Ci sono '.count($recurringProfieles).' profili da analizzare');
|
42 |
+
|
43 |
+
foreach($recurringProfieles as $recurringProfile){
|
44 |
+
|
45 |
+
//metodo per deserializzare i dati all'interno del profilo
|
46 |
+
$recurringProfieles->getResource()->unserializeFields($recurringProfile);
|
47 |
+
|
48 |
+
//recupero il metodo di pagamento, è certo che è gestpay perché è uno dei criteri della query sopra
|
49 |
+
$methodInstance = Mage::helper('payment')->getMethodInstance($recurringProfile->getMethodCode());
|
50 |
+
$info = Mage::getModel('payment/info');
|
51 |
+
|
52 |
+
$methodInstance->submitRecurringProfile($recurringProfile, $info);
|
53 |
+
|
54 |
+
}
|
55 |
+
}
|
56 |
+
|
57 |
+
}
|
app/code/community/EasyNolo/BancaSellaPro/Model/Resource/Token.php
ADDED
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Class Token.php
|
4 |
+
* @category EasyNolo_BancaSellaPro
|
5 |
+
* @package EasyNolo
|
6 |
+
* @author Easy Nolo <ecommerce@sella.it>
|
7 |
+
*/
|
8 |
+
|
9 |
+
class EasyNolo_BancaSellaPro_Model_Resource_Token extends Mage_Core_Model_Resource_Db_Abstract {
|
10 |
+
|
11 |
+
protected function _construct()
|
12 |
+
{
|
13 |
+
$this->_init('easynolo_bancasellapro/token', 'entity_id');
|
14 |
+
$this->_idFieldName='entity_id';
|
15 |
+
}
|
16 |
+
|
17 |
+
}
|
app/code/community/EasyNolo/BancaSellaPro/Model/Resource/Token/Collection.php
ADDED
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Class Collection.php
|
4 |
+
* @category EasyNolo_BancaSellaPro
|
5 |
+
* @package EasyNolo
|
6 |
+
* @author Easy Nolo <ecommerce@sella.it>
|
7 |
+
*/
|
8 |
+
|
9 |
+
class EasyNolo_BancaSellaPro_Model_Resource_Token_Collection extends Mage_Core_Model_Resource_Db_Collection_Abstract
|
10 |
+
{
|
11 |
+
protected function _construct()
|
12 |
+
{
|
13 |
+
$this->_init('easynolo_bancasellapro/token');
|
14 |
+
}
|
15 |
+
|
16 |
+
|
17 |
+
public function addProfileToFilter(Mage_Payment_Model_Recurring_Profile $profile){
|
18 |
+
return $this->addFieldToFilter('profile_id',array('eq'=>$profile->getId()));
|
19 |
+
}
|
20 |
+
|
21 |
+
public function addValidDateFilter(){
|
22 |
+
return $this->addFieldToFilter('expiry_date',array('gteq' => Varien_Date::now(true)));
|
23 |
+
}
|
24 |
+
}
|
app/code/community/EasyNolo/BancaSellaPro/Model/Sales/Recurring/Profile.php
ADDED
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Class Profile.php
|
4 |
+
* @category EasyNolo
|
5 |
+
* @package EasyNolo_BancaSellaPro
|
6 |
+
* @author Easy Nolo <ecommerce@sella.it>
|
7 |
+
*/
|
8 |
+
|
9 |
+
class EasyNolo_BancaSellaPro_Model_Sales_Recurring_Profile extends Mage_Sales_Model_Recurring_Profile{
|
10 |
+
|
11 |
+
|
12 |
+
public function setNearestStartDatetime(Zend_Date $minAllowed = null)
|
13 |
+
{
|
14 |
+
$date = $minAllowed;
|
15 |
+
//Aggiungiamo il controllo sul method code per non aggiornare la data d'inizio con bancasellapro
|
16 |
+
if (!$date || ( $date->getTimestamp() < time() && $this->getMethodCode() != EasyNolo_BancaSellaPro_Model_Gestpay::METHOD_CODE) ) {
|
17 |
+
$date = new Zend_Date(time());
|
18 |
+
}
|
19 |
+
$this->setStartDatetime($date->toString(Varien_Date::DATETIME_INTERNAL_FORMAT));
|
20 |
+
return $this;
|
21 |
+
}
|
22 |
+
}
|
app/code/community/EasyNolo/BancaSellaPro/Model/System/Config/Source/Currency.php
ADDED
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @category EasyNolo
|
4 |
+
* @package EasyNolo_BancaSellaPro
|
5 |
+
* @author Easy Nolo <ecommerce@sella.it>
|
6 |
+
*/
|
7 |
+
|
8 |
+
class EasyNolo_BancaSellaPro_Model_System_Config_Source_Currency
|
9 |
+
{
|
10 |
+
|
11 |
+
/**
|
12 |
+
* Options getter
|
13 |
+
*
|
14 |
+
* @return array
|
15 |
+
*/
|
16 |
+
public function toOptionArray()
|
17 |
+
{
|
18 |
+
return array(
|
19 |
+
array('value' => 1, 'label'=>'USD Dollari Usa'),
|
20 |
+
array('value' => 2, 'label'=>'GBP Sterlina Gran Bretagna'),
|
21 |
+
array('value' => 3, 'label'=>'CHF Franco Svizzero'),
|
22 |
+
array('value' => 7, 'label'=>'DKK Corone Danesi'),
|
23 |
+
array('value' => 8, 'label'=>'NOK Corona Norvegese'),
|
24 |
+
array('value' => 9, 'label'=>'SEK Corona Svedese'),
|
25 |
+
array('value' => 12, 'label'=>'CAD Dollari Canadesi'),
|
26 |
+
array('value' => 18, 'label'=>'ITL Lira Italiana'),
|
27 |
+
array('value' => 71, 'label'=>'JPY Yen Giapponese'),
|
28 |
+
array('value' => 103, 'label'=>'HKD Dollaro Hong Kong'),
|
29 |
+
array('value' => 234, 'label'=>'BRL Real'),
|
30 |
+
array('value' => 242, 'label'=>'EUR Euro'),
|
31 |
+
);
|
32 |
+
}
|
33 |
+
|
34 |
+
}
|
app/code/community/EasyNolo/BancaSellaPro/Model/System/Config/Source/Language.php
ADDED
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @category EasyNolo
|
4 |
+
* @package EasyNolo_BancaSellaPro
|
5 |
+
* @author Easy Nolo <ecommerce@sella.it>
|
6 |
+
*/
|
7 |
+
|
8 |
+
class EasyNolo_BancaSellaPro_Model_System_Config_Source_Language
|
9 |
+
{
|
10 |
+
|
11 |
+
/**
|
12 |
+
* Options getter
|
13 |
+
*
|
14 |
+
* @return array
|
15 |
+
*/
|
16 |
+
public function toOptionArray()
|
17 |
+
{
|
18 |
+
return array(
|
19 |
+
array('value' => 0, 'label'=>'--NOT ENABLED--'),
|
20 |
+
array('value' => 1, 'label'=>'Italian'),
|
21 |
+
array('value' => 2, 'label'=>'English'),
|
22 |
+
array('value' => 3, 'label'=>'Spanish'),
|
23 |
+
array('value' => 4, 'label'=>'French'),
|
24 |
+
array('value' => 5, 'label'=>'German'),
|
25 |
+
);
|
26 |
+
}
|
27 |
+
|
28 |
+
}
|
app/code/community/EasyNolo/BancaSellaPro/Model/System/Config/Source/PaymentAction.php
ADDED
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @category EasyNolo
|
4 |
+
* @package EasyNolo_BancaSellaPro
|
5 |
+
* @author Easy Nolo <ecommerce@sella.it>
|
6 |
+
*/
|
7 |
+
|
8 |
+
class EasyNolo_BancaSellaPro_Model_System_Config_Source_PaymentAction
|
9 |
+
{
|
10 |
+
public function toOptionArray()
|
11 |
+
{
|
12 |
+
return array(
|
13 |
+
array(
|
14 |
+
'value' => Mage_Paygate_Model_Authorizenet::ACTION_AUTHORIZE,
|
15 |
+
'label' => Mage::helper('easynolo_bancasellapro')->__('Authorize Only')
|
16 |
+
),
|
17 |
+
array(
|
18 |
+
'value' => Mage_Paygate_Model_Authorizenet::ACTION_AUTHORIZE_CAPTURE,
|
19 |
+
'label' => Mage::helper('easynolo_bancasellapro')->__('Authorize and Capture')
|
20 |
+
)
|
21 |
+
);
|
22 |
+
}
|
23 |
+
}
|
app/code/community/EasyNolo/BancaSellaPro/Model/Token.php
ADDED
@@ -0,0 +1,96 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Class Token.php
|
4 |
+
*
|
5 |
+
* @method string getToken()
|
6 |
+
* @method EasyNolo_BancaSellaPro_Model_Token setToken(string)
|
7 |
+
* @method string getExpiryDate()
|
8 |
+
* @method EasyNolo_BancaSellaPro_Model_Token setExpiryDate(string)
|
9 |
+
* @method int getOrderId()
|
10 |
+
* @method EasyNolo_BancaSellaPro_Model_Token setOrderId(int)
|
11 |
+
* @method int getProfileId()
|
12 |
+
* @method EasyNolo_BancaSellaPro_Model_Token setProfileId(int)
|
13 |
+
* @method int getCustomerId()
|
14 |
+
* @method EasyNolo_BancaSellaPro_Model_Token setCustomerId(int)
|
15 |
+
*
|
16 |
+
* @category EasyNolo_Bancasellapro
|
17 |
+
* @package EasyNolo
|
18 |
+
* @author Easy Nolo <ecommerce@sella.it>
|
19 |
+
*/
|
20 |
+
|
21 |
+
class EasyNolo_BancaSellaPro_Model_Token extends Mage_Core_Model_Abstract{
|
22 |
+
|
23 |
+
public function _construct()
|
24 |
+
{
|
25 |
+
$this->_init('easynolo_bancasellapro/token');
|
26 |
+
}
|
27 |
+
|
28 |
+
/**
|
29 |
+
* Set the plofile inside the model
|
30 |
+
* @param Mage_Payment_Model_Recurring_Profile $profile
|
31 |
+
* @return $this
|
32 |
+
*/
|
33 |
+
public function setProfile($profile){
|
34 |
+
$this->setProfileId($profile->getId());
|
35 |
+
$this->setCustomerId($profile->getCustomerId());
|
36 |
+
return $this;
|
37 |
+
}
|
38 |
+
|
39 |
+
/**
|
40 |
+
* Set the token information inside the model
|
41 |
+
* @param string $token string with 16 characters
|
42 |
+
* @param string $expiryMonth month in 2 digits
|
43 |
+
* @param string $expiryYear year in 2 digits
|
44 |
+
* @return $this
|
45 |
+
*/
|
46 |
+
public function setTokenInfo($token, $expiryMonth, $expiryYear){
|
47 |
+
$date = Mage::getModel('core/date');
|
48 |
+
|
49 |
+
$stringDate = "20$expiryYear-$expiryMonth-01";
|
50 |
+
$expiryDate = $date->date('Y-m-t',$stringDate);
|
51 |
+
$this->setExpiryDate($expiryDate);
|
52 |
+
$this->setToken($token);
|
53 |
+
|
54 |
+
return $this;
|
55 |
+
|
56 |
+
}
|
57 |
+
|
58 |
+
/**
|
59 |
+
* Method to check if the token is expiry
|
60 |
+
* @return bool
|
61 |
+
*/
|
62 |
+
public function isExpiry()
|
63 |
+
{
|
64 |
+
$now = strtotime(Varien_Date::now());
|
65 |
+
if($now > strtotime($this->getExpiryDate())){
|
66 |
+
return true;
|
67 |
+
}
|
68 |
+
return false;
|
69 |
+
}
|
70 |
+
|
71 |
+
/**
|
72 |
+
* Method that return a valid token for the sended profile
|
73 |
+
* @param Mage_Payment_Model_Recurring_Profile $profile
|
74 |
+
* @return $this
|
75 |
+
*/
|
76 |
+
public function getFirstValidTokenForProfile( Mage_Payment_Model_Recurring_Profile$profile)
|
77 |
+
{
|
78 |
+
return $this->getCollection()
|
79 |
+
->addProfileToFilter($profile)
|
80 |
+
->addValidDateFilter()
|
81 |
+
->getFirstItem();
|
82 |
+
}
|
83 |
+
|
84 |
+
/**
|
85 |
+
* Return the first token for the sended profile
|
86 |
+
* @param Mage_Payment_Model_Recurring_Profile $profile
|
87 |
+
* @return $this
|
88 |
+
*/
|
89 |
+
public function getFirstTokenForProfile(Mage_Payment_Model_Recurring_Profile $profile)
|
90 |
+
{
|
91 |
+
return $this->getCollection()
|
92 |
+
->addProfileToFilter($profile)
|
93 |
+
->getFirstItem();
|
94 |
+
}
|
95 |
+
|
96 |
+
}
|
app/code/community/EasyNolo/BancaSellaPro/Model/Webservice/Abstract.php
ADDED
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @category EasyNolo
|
4 |
+
* @package EasyNolo_BancaSellaPro
|
5 |
+
* @author Easy Nolo <ecommerce@sella.it>
|
6 |
+
*/
|
7 |
+
abstract class EasyNolo_BancaSellaPro_Model_Webservice_Abstract extends Mage_Core_Model_Abstract{
|
8 |
+
|
9 |
+
protected $url_home;
|
10 |
+
|
11 |
+
/**
|
12 |
+
* metodo che imposta l'url dell'webservice
|
13 |
+
* @param $url
|
14 |
+
*/
|
15 |
+
public function setBaseUrl($url){
|
16 |
+
$this->url_home = $url;
|
17 |
+
}
|
18 |
+
|
19 |
+
abstract public function getWSUrl();
|
20 |
+
}
|
app/code/community/EasyNolo/BancaSellaPro/Model/Webservice/Wscryptdecrypt.php
ADDED
@@ -0,0 +1,213 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @category EasyNolo
|
4 |
+
* @package EasyNolo_BancaSellaPro
|
5 |
+
* @author Easy Nolo <ecommerce@sella.it>
|
6 |
+
*/
|
7 |
+
class EasyNolo_BancaSellaPro_Model_Webservice_Wscryptdecrypt extends EasyNolo_BancaSellaPro_Model_Webservice_Abstract{
|
8 |
+
|
9 |
+
const PATH_WS_CRYPT_DECRIPT = '/gestpay/gestpayws/WSCryptDecrypt.asmx?WSDL';
|
10 |
+
|
11 |
+
const TRANSACTION_RESULT_OK = 'OK';
|
12 |
+
const TRANSACTION_RESULT_KO = 'KO';
|
13 |
+
const TRANSACTION_RESULT_PENDING = 'XX';
|
14 |
+
|
15 |
+
public function getWSUrl(){
|
16 |
+
return $this->url_home . self::PATH_WS_CRYPT_DECRIPT;
|
17 |
+
}
|
18 |
+
|
19 |
+
/**
|
20 |
+
* metodo che imposta i dati dell'ordine all'interno
|
21 |
+
* @param Mage_Sales_Model_Order $order
|
22 |
+
*/
|
23 |
+
public function setOrder(Mage_Sales_Model_Order $order){
|
24 |
+
|
25 |
+
/**@var $gestpay EasyNolo_BancaSellaPro_Model_Gestpay */
|
26 |
+
$gestpay = $order->getPayment()->getMethodInstance();
|
27 |
+
$total = $gestpay->getTotalByOrder($order);
|
28 |
+
|
29 |
+
if($gestpay instanceof EasyNolo_BancaSellaPro_Model_Gestpay){
|
30 |
+
|
31 |
+
$this->setData('shopLogin', $gestpay->getMerchantId() );
|
32 |
+
$this->setData('shopTransactionId', $order->getIncrementId() );
|
33 |
+
$this->setData('uicCode', $gestpay->getCurrency() );
|
34 |
+
$this->setData('languageId', $gestpay->getLanguage() );
|
35 |
+
$this->setData('amount', round($total, 2) );
|
36 |
+
}
|
37 |
+
|
38 |
+
}
|
39 |
+
|
40 |
+
public function setInfoBeforeOrder(EasyNolo_BancaSellaPro_Model_Gestpay $method){
|
41 |
+
|
42 |
+
$quote = $method->getQuote();
|
43 |
+
$total = $method->getTotalByOrder($quote);
|
44 |
+
$orderId = $method->getFutureOrderId();
|
45 |
+
|
46 |
+
$this->setData('shopLogin', $method->getMerchantId() );
|
47 |
+
//se è un pagamento ricorrente e il metodo puo gestire i profili ricorrenti
|
48 |
+
if(
|
49 |
+
$method->canManageRecurringProfiles() &&
|
50 |
+
Mage::helper('easynolo_bancasellapro/recurringprofile')->isRecurringProfile($quote)
|
51 |
+
){
|
52 |
+
$recurringProfile = Mage::helper('easynolo_bancasellapro/recurringprofile')->getRecurringProfileByQuote($quote);
|
53 |
+
//il primo pagamento deve essere fatto calcolando l'init amount piu il costo della trial/billing_amount
|
54 |
+
|
55 |
+
if(isset($recurringProfile['trial_billing_amount']) && $recurringProfile['trial_billing_amount'] > 0){
|
56 |
+
$amount = $recurringProfile['trial_billing_amount'];
|
57 |
+
}else{
|
58 |
+
$amount = $recurringProfile['billing_amount'];
|
59 |
+
}
|
60 |
+
|
61 |
+
if (isset($recurringProfile['init_amount'])){
|
62 |
+
$amount += $recurringProfile['init_amount'];
|
63 |
+
}
|
64 |
+
|
65 |
+
if(isset($recurringProfile['shipping_amount'])){
|
66 |
+
$amount+= $recurringProfile['shipping_amount'];
|
67 |
+
}
|
68 |
+
if(isset($recurringProfile['tax_amount'])){
|
69 |
+
$amount+=$recurringProfile['tax_amount'];
|
70 |
+
}
|
71 |
+
|
72 |
+
$this->setData('amount', $amount);
|
73 |
+
|
74 |
+
$this->setRecurringProfile(true);
|
75 |
+
}else{
|
76 |
+
|
77 |
+
$this->setData('amount', round($total, 2) );
|
78 |
+
}
|
79 |
+
$this->setData('shopTransactionId',$orderId );
|
80 |
+
$this->setData('uicCode', $method->getCurrency() );
|
81 |
+
$this->setData('languageId', $method->getLanguage() );
|
82 |
+
|
83 |
+
}
|
84 |
+
|
85 |
+
|
86 |
+
/**
|
87 |
+
* metodo che restituisce i parametri per creare la stringa criptata per effettuare una richiesta di pagamento a bancasella
|
88 |
+
* @return array
|
89 |
+
*/
|
90 |
+
public function getParamToEncrypt(){
|
91 |
+
$_helper= Mage::helper('easynolo_bancasellapro');
|
92 |
+
$_helper->log('Imposto i parametri da inviare all\'encrypt');
|
93 |
+
|
94 |
+
$param = array();
|
95 |
+
$param['shopLogin'] = $this->getData('shopLogin');
|
96 |
+
$param['shopTransactionId'] = $this->getData('shopTransactionId');
|
97 |
+
$param['uicCode'] = $this->getData('uicCode');
|
98 |
+
|
99 |
+
//se il pagamento è ricorrente, deve essere richiesto anche il token
|
100 |
+
if($this->hasRecurringProfile() && $this->getRecurringProfile()==true){
|
101 |
+
$param['requestToken'] = 'MASKEDPAN';
|
102 |
+
}
|
103 |
+
|
104 |
+
if($this->getData('languageId')!=0){
|
105 |
+
$param['languageId'] = $this->getData('languageId');
|
106 |
+
}
|
107 |
+
$param['amount'] = $this->getData('amount');
|
108 |
+
|
109 |
+
$_helper->log($param);
|
110 |
+
|
111 |
+
return $param;
|
112 |
+
}
|
113 |
+
|
114 |
+
/**
|
115 |
+
* Metodo che restituisce i dati da inviare per decriptare un pagamento
|
116 |
+
* @return array
|
117 |
+
*/
|
118 |
+
public function getParamToDecrypt(){
|
119 |
+
$_helper= Mage::helper('easynolo_bancasellapro');
|
120 |
+
$_helper->log('Imposto i parametri da inviare al decrypt');
|
121 |
+
|
122 |
+
$param = array();
|
123 |
+
$param['shopLogin'] = $this->getParamA();
|
124 |
+
$param['CryptedString'] = $this->getParamB();
|
125 |
+
|
126 |
+
$_helper->log($param);
|
127 |
+
|
128 |
+
return $param;
|
129 |
+
}
|
130 |
+
|
131 |
+
/**
|
132 |
+
* metodo che importa i risultati dell'encrypt
|
133 |
+
* @param $result
|
134 |
+
*/
|
135 |
+
public function setResponseEncrypt($result){
|
136 |
+
|
137 |
+
$realResult = simplexml_load_string($result->EncryptResult->any);
|
138 |
+
|
139 |
+
$this->setTransactionType((string)$realResult->TransactionType);
|
140 |
+
$this->setTransactionResult((string)$realResult->TransactionResult);
|
141 |
+
$this->setErrorCode((string)$realResult->ErrorCode);
|
142 |
+
$this->setErrorDescription((string)$realResult->ErrorDescription);
|
143 |
+
|
144 |
+
if($this->getTransactionResult() == 'OK')
|
145 |
+
{
|
146 |
+
$this->setCryptDecryptString((string)$realResult->CryptDecryptString);
|
147 |
+
}
|
148 |
+
else
|
149 |
+
{
|
150 |
+
Mage::throwException($this->getErrorDescription());
|
151 |
+
}
|
152 |
+
}
|
153 |
+
/**
|
154 |
+
* metodo che importa i risultati del decrypt
|
155 |
+
* @param $result
|
156 |
+
*/
|
157 |
+
public function setResponseDecrypt($result){
|
158 |
+
|
159 |
+
$_helper= Mage::helper('easynolo_bancasellapro');
|
160 |
+
$_helper->log('Salvo i parametri decriptati');
|
161 |
+
|
162 |
+
$realResult = simplexml_load_string($result->DecryptResult->any);
|
163 |
+
|
164 |
+
$this->setTransactionType((string)$realResult->TransactionType);
|
165 |
+
$this->setTransactionResult((string)$realResult->TransactionResult);
|
166 |
+
$this->setErrorCode((string)$realResult->ErrorCode);
|
167 |
+
$this->setErrorDescription((string)$realResult->ErrorDescription);
|
168 |
+
|
169 |
+
|
170 |
+
$this->setShopTransactionID((string)$realResult->ShopTransactionID);
|
171 |
+
$this->setBankTransactionID((string)$realResult->BankTransactionID);
|
172 |
+
$this->setAuthorizationCode((string)$realResult->AuthorizationCode);
|
173 |
+
$this->setCurrency((string)$realResult->Currency);
|
174 |
+
$this->setAmount((string)$realResult->Amount);
|
175 |
+
$this->setCountry((string)$realResult->Country);
|
176 |
+
$this->setCustomInfo((string)$realResult->CustomInfo);
|
177 |
+
$this->setBuyerName((string)$realResult->Buyer->BuyerName);
|
178 |
+
$this->setBuyerEmail((string)$realResult->Buyer->BuyerEmail);
|
179 |
+
$this->setTDLevel((string)$realResult->TDLevel);
|
180 |
+
$this->setAlertCode((string)$realResult->AlertCode);
|
181 |
+
|
182 |
+
$this->setAlertDescription((string)$realResult->AlertDescription);
|
183 |
+
$this->setVbVRisp((string)$realResult->VbVRisp);
|
184 |
+
$this->setVbVBuyer((string)$realResult->VbVBuyer);
|
185 |
+
$this->setVbVFlag((string)$realResult->VbVFlag);
|
186 |
+
$this->setTransactionKey((string)$realResult->TransactionKey);
|
187 |
+
$this->setPaymentMethod((string)$realResult->PaymentMethod);
|
188 |
+
|
189 |
+
//token
|
190 |
+
$this->setToken((string)$realResult->TOKEN);
|
191 |
+
$this->setTokenExpiryMonth((string)$realResult->TokenExpiryMonth);
|
192 |
+
$this->setTokenExpiryYear((string)$realResult->TokenExpiryYear);
|
193 |
+
|
194 |
+
$_helper->log($this->getData());
|
195 |
+
|
196 |
+
}
|
197 |
+
|
198 |
+
public function setDecryptParam($a , $b){
|
199 |
+
$this->setParamA($a);
|
200 |
+
$this->setParamB($b);
|
201 |
+
}
|
202 |
+
|
203 |
+
|
204 |
+
/**
|
205 |
+
* Metodo per sapere in modo veloce se il pagamento è stato effettuato
|
206 |
+
* @return bool true se lo stato è pagato oppure in attesa di bonifico, false altrimenti
|
207 |
+
*/
|
208 |
+
public function getFastResultPayment(){
|
209 |
+
if(!$this->getTransactionResult() || $this->getTransactionResult() == 'KO')
|
210 |
+
return false;
|
211 |
+
return true;
|
212 |
+
}
|
213 |
+
}
|
app/code/community/EasyNolo/BancaSellaPro/Model/Webservice/Wss2s.php
ADDED
@@ -0,0 +1,187 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Class Wss2s.php
|
4 |
+
* @category EasyNolo
|
5 |
+
* @package EasyNolo_BancaSellaPro
|
6 |
+
* @author Easy Nolo <ecommerce@sella.it>
|
7 |
+
*/
|
8 |
+
class EasyNolo_BancaSellaPro_Model_Webservice_Wss2s extends EasyNolo_BancaSellaPro_Model_Webservice_Abstract{
|
9 |
+
|
10 |
+
const PATH_WS_CRYPT_DECRIPT = '/gestpay/gestpayws/WSS2S.asmx?WSDL';
|
11 |
+
|
12 |
+
public function getWSUrl(){
|
13 |
+
return $this->url_home . self::PATH_WS_CRYPT_DECRIPT;
|
14 |
+
}
|
15 |
+
|
16 |
+
|
17 |
+
/**
|
18 |
+
* metodo che imposta i dati dell'ordine all'interno
|
19 |
+
* @param Mage_Sales_Model_Order $order
|
20 |
+
*/
|
21 |
+
public function setOrder(Mage_Sales_Model_Order $order){
|
22 |
+
|
23 |
+
/**@var $gestpay EasyNolo_BancaSella_Model_Gestpay */
|
24 |
+
$gestpay = $order->getPayment()->getMethodInstance();
|
25 |
+
$total = $gestpay->getTotalByOrder($order);
|
26 |
+
$payment = $order->getPayment();
|
27 |
+
$bankId = false;
|
28 |
+
$add = unserialize($payment->getAdditionalData());
|
29 |
+
if($add){
|
30 |
+
$bankId= $add['bank_transaction_id'];
|
31 |
+
}
|
32 |
+
|
33 |
+
if($gestpay instanceof EasyNolo_BancaSellaPro_Model_Gestpay){
|
34 |
+
|
35 |
+
$this->setData('shopLogin', $gestpay->getMerchantId() );
|
36 |
+
$this->setData('shopTransactionId', $order->getIncrementId() );
|
37 |
+
$this->setData('bankTransactionId',$bankId);
|
38 |
+
$this->setData('uicCode', $gestpay->getCurrency() );
|
39 |
+
$this->setData('languageId', $gestpay->getLanguage() );
|
40 |
+
$this->setData('amount', round($total, 2) );
|
41 |
+
|
42 |
+
}
|
43 |
+
|
44 |
+
}
|
45 |
+
|
46 |
+
public function setToken(EasyNolo_BancaSellaPro_Model_Token $token){
|
47 |
+
$this->setData('tokenValue',$token->getToken());
|
48 |
+
}
|
49 |
+
|
50 |
+
/**
|
51 |
+
* metodo che restituisce i parametri per creare la stringa criptata per effettuare una richiesta di pagamento a bancasella
|
52 |
+
* @return array
|
53 |
+
*/
|
54 |
+
public function getParamToCallPagamS2S($amount){
|
55 |
+
$_helper= Mage::helper('easynolo_bancasellapro');
|
56 |
+
$_helper->log('Imposto i parametri da inviare all\'encrypt per effettuare il pagamento con token');
|
57 |
+
|
58 |
+
$param = array();
|
59 |
+
$param['shopLogin'] = $this->getData('shopLogin');
|
60 |
+
$param['shopTransactionId'] = $this->getData('shopTransactionId');
|
61 |
+
$param['uicCode'] = $this->getData('uicCode');
|
62 |
+
if($this->getData('bankTransactionId')){
|
63 |
+
$param['bankTransactionId'] = $this->getData('bankTransactionId');
|
64 |
+
}
|
65 |
+
if($this->getData('languageId')!=0){
|
66 |
+
$param['languageId'] = $this->getData('languageId');
|
67 |
+
}
|
68 |
+
$param['amount'] = $amount;
|
69 |
+
$param['tokenValue'] = $this->getData('tokenValue');
|
70 |
+
|
71 |
+
$_helper->log($param);
|
72 |
+
|
73 |
+
return $param;
|
74 |
+
}
|
75 |
+
public function getParamToCallCaptureS2S($amount){
|
76 |
+
$_helper= Mage::helper('easynolo_bancasellapro');
|
77 |
+
$_helper->log('Imposto i parametri da inviare all\'encrypt per effettuare il pagamento con token');
|
78 |
+
|
79 |
+
$param = array();
|
80 |
+
$param['shopLogin'] = $this->getData('shopLogin');
|
81 |
+
$param['shopTransID'] = $this->getData('shopTransactionId');
|
82 |
+
$param['uicCode'] = $this->getData('uicCode');
|
83 |
+
if($this->getData('bankTransactionId')){
|
84 |
+
$param['bankTransID'] = $this->getData('bankTransactionId');
|
85 |
+
}
|
86 |
+
if($this->getData('languageId')!=0){
|
87 |
+
$param['languageId'] = $this->getData('languageId');
|
88 |
+
}
|
89 |
+
$param['amount'] = $amount;
|
90 |
+
//$param['tokenValue'] = $this->getData('tokenValue');
|
91 |
+
|
92 |
+
$_helper->log($param);
|
93 |
+
|
94 |
+
return $param;
|
95 |
+
}
|
96 |
+
/**
|
97 |
+
* metodo che importa i risultati del decrypt
|
98 |
+
* @param $result
|
99 |
+
*/
|
100 |
+
public function setResponseCallPagamS2S($result){
|
101 |
+
|
102 |
+
$_helper= Mage::helper('easynolo_bancasellapro');
|
103 |
+
$_helper->log('Salvo i parametri decriptati');
|
104 |
+
|
105 |
+
$this->_getRealResult($result,'callPagamS2SResult');
|
106 |
+
|
107 |
+
}
|
108 |
+
|
109 |
+
/**
|
110 |
+
* metodo che importa i risultati del decrypt
|
111 |
+
* @param $result
|
112 |
+
*/
|
113 |
+
public function setResponseCallSettleS2S($result){
|
114 |
+
|
115 |
+
$_helper= Mage::helper('easynolo_bancasellapro');
|
116 |
+
$_helper->log('Salvo i parametri decriptati');
|
117 |
+
|
118 |
+
$this->_getRealResult($result,'callSettleS2SResult');
|
119 |
+
|
120 |
+
}
|
121 |
+
|
122 |
+
/**
|
123 |
+
* metodo che importa i risultati del decrypt
|
124 |
+
* @param $result
|
125 |
+
*/
|
126 |
+
public function setResponseCallRefundS2S($result){
|
127 |
+
|
128 |
+
$_helper= Mage::helper('easynolo_bancasellapro');
|
129 |
+
$_helper->log('Salvo i parametri decriptati');
|
130 |
+
|
131 |
+
$this->_getRealResult($result,'callRefundS2SResult');
|
132 |
+
|
133 |
+
}
|
134 |
+
|
135 |
+
/**
|
136 |
+
* metodo che importa i risultati del decrypt
|
137 |
+
* @param $result
|
138 |
+
*/
|
139 |
+
public function setResponseCallDeleteS2S($result){
|
140 |
+
|
141 |
+
$_helper= Mage::helper('easynolo_bancasellapro');
|
142 |
+
$_helper->log('Salvo i parametri decriptati');
|
143 |
+
|
144 |
+
$this->_getRealResult($result,'callDeleteS2SResult');
|
145 |
+
|
146 |
+
|
147 |
+
|
148 |
+
|
149 |
+
}
|
150 |
+
protected function _getRealResult($result,$method){
|
151 |
+
$_helper= Mage::helper('easynolo_bancasellapro');
|
152 |
+
$_helper->log('Salvo i parametri decriptati - '.$method);
|
153 |
+
|
154 |
+
$realResult = simplexml_load_string($result->$method->any);
|
155 |
+
$this->setTransactionType((string)$realResult->TransactionType);
|
156 |
+
$this->setTransactionResult((string)$realResult->TransactionResult);
|
157 |
+
$this->setErrorCode((string)$realResult->ErrorCode);
|
158 |
+
$this->setErrorDescription((string)$realResult->ErrorDescription);
|
159 |
+
|
160 |
+
|
161 |
+
$this->setShopTransactionID((string)$realResult->ShopTransactionID);
|
162 |
+
$this->setBankTransactionID((string)$realResult->BankTransactionID);
|
163 |
+
$this->setAuthorizationCode((string)$realResult->AuthorizationCode);
|
164 |
+
$this->setCurrency((string)$realResult->Currency);
|
165 |
+
$this->setAmount((string)$realResult->Amount);
|
166 |
+
$this->setCountry((string)$realResult->Country);
|
167 |
+
$this->setCustomInfo((string)$realResult->CustomInfo);
|
168 |
+
$this->setBuyerName((string)$realResult->Buyer->BuyerName);
|
169 |
+
$this->setBuyerEmail((string)$realResult->Buyer->BuyerEmail);
|
170 |
+
$this->setTDLevel((string)$realResult->TDLevel);
|
171 |
+
$this->setAlertCode((string)$realResult->AlertCode);
|
172 |
+
|
173 |
+
$this->setAlertDescription((string)$realResult->AlertDescription);
|
174 |
+
$this->setVbVRisp((string)$realResult->VbVRisp);
|
175 |
+
$this->setVbVBuyer((string)$realResult->VbVBuyer);
|
176 |
+
$this->setVbVFlag((string)$realResult->VbVFlag);
|
177 |
+
$this->setTransactionKey((string)$realResult->TransactionKey);
|
178 |
+
$this->setPaymentMethod((string)$realResult->PaymentMethod);
|
179 |
+
|
180 |
+
//token
|
181 |
+
$this->setData('token',(string)$realResult->TOKEN);
|
182 |
+
$this->setTokenExpiryMonth((string)$realResult->TokenExpiryMonth);
|
183 |
+
$this->setTokenExpiryYear((string)$realResult->TokenExpiryYear);
|
184 |
+
$_helper->log($this->getData());
|
185 |
+
return $this;
|
186 |
+
}
|
187 |
+
}
|
app/code/community/EasyNolo/BancaSellaPro/controllers/GestpayController.php
ADDED
@@ -0,0 +1,228 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @category EasyNolo
|
4 |
+
* @package EasyNolo_BancaSellaPro
|
5 |
+
* @author Easy Nolo <ecommerce@sella.it>
|
6 |
+
*/
|
7 |
+
class EasyNolo_BancaSellaPro_GestpayController extends Mage_Core_Controller_Front_Action {
|
8 |
+
|
9 |
+
private $_order,$_profile;
|
10 |
+
|
11 |
+
public function getOrder()
|
12 |
+
{
|
13 |
+
if ($this->_order == null) {
|
14 |
+
$session = Mage::getSingleton('checkout/session');
|
15 |
+
$this->_order = Mage::getModel('sales/order');
|
16 |
+
$this->_order->loadByIncrementId($session->getLastRealOrderId());
|
17 |
+
}
|
18 |
+
return $this->_order;
|
19 |
+
}
|
20 |
+
|
21 |
+
public function getRecurringProfiles(){
|
22 |
+
if ($this->_profile == null) {
|
23 |
+
$profileIds = Mage::getSingleton('checkout/session')->getLastRecurringProfileIds();
|
24 |
+
if ($profileIds && is_array($profileIds)) {
|
25 |
+
$collection = Mage::getModel('sales/recurring_profile')->getCollection()
|
26 |
+
->addFieldToFilter('profile_id', array('in' => $profileIds))
|
27 |
+
;
|
28 |
+
$profiles = array();
|
29 |
+
foreach ($collection as $profile) {
|
30 |
+
$profiles[] = $profile;
|
31 |
+
}
|
32 |
+
if ($profiles) {
|
33 |
+
$this->_profile = $profiles;
|
34 |
+
}
|
35 |
+
}
|
36 |
+
}
|
37 |
+
return $this->_profile;
|
38 |
+
|
39 |
+
}
|
40 |
+
|
41 |
+
|
42 |
+
public function redirectAction(){
|
43 |
+
$order = $this->getOrder();
|
44 |
+
|
45 |
+
if (!$order->getId()) {
|
46 |
+
$this->norouteAction();
|
47 |
+
return;
|
48 |
+
}
|
49 |
+
|
50 |
+
$order->addStatusHistoryComment($this->__('User correctly redirected to Banca Sella for completion of payment.'));
|
51 |
+
$order->save();
|
52 |
+
|
53 |
+
/** @var EasyNolo_BancaSellaPro_Helper_Data $_helper */
|
54 |
+
$_helper= Mage::helper('easynolo_bancasellapro');
|
55 |
+
$_helper->log('Reindirizzamento utente sul sito di bancasella dopo aver effettuato l\'ordine con id='.$order->getId());
|
56 |
+
|
57 |
+
|
58 |
+
Mage::register('current_order', $order);
|
59 |
+
|
60 |
+
try{
|
61 |
+
|
62 |
+
$this->loadLayout();
|
63 |
+
$this->renderLayout();
|
64 |
+
|
65 |
+
}catch (Exception $e){
|
66 |
+
$_helper->log($e->getMessage());
|
67 |
+
$session = Mage::getSingleton('checkout/session');
|
68 |
+
$session->addError($this->__('Payment has been declined. Please try again.'));
|
69 |
+
$this->_redirect('checkout/cart');
|
70 |
+
return;
|
71 |
+
}
|
72 |
+
|
73 |
+
}
|
74 |
+
|
75 |
+
public function resultAction(){
|
76 |
+
|
77 |
+
$a = $this->getRequest()->getParam('a',false);
|
78 |
+
$b = $this->getRequest()->getParam('b',false);
|
79 |
+
|
80 |
+
$_helper= Mage::helper('easynolo_bancasellapro');
|
81 |
+
|
82 |
+
|
83 |
+
if(!$a || !$b){
|
84 |
+
$_helper->log('Accesso alla pagina per il risultato del pagamento non consentito, mancano i parametri di input');
|
85 |
+
$this->norouteAction();
|
86 |
+
return;
|
87 |
+
}
|
88 |
+
|
89 |
+
Mage::register('bancasella_param_a', $a);
|
90 |
+
Mage::register('bancasella_param_b', $b);
|
91 |
+
|
92 |
+
/** @var EasyNolo_BancaSellaPro_Helper_Crypt $helper */
|
93 |
+
$helper= Mage::helper('easynolo_bancasellapro/crypt');
|
94 |
+
|
95 |
+
$checkoutSession = Mage::getSingleton('checkout/session');
|
96 |
+
$paymentCheckResult = $helper->isPaymentOk( $a , $b );
|
97 |
+
if($paymentCheckResult === true){
|
98 |
+
$_helper->log('L\'utente ha completato correttamente l\'inserimento dei dati su bancasella');
|
99 |
+
// reset quote on checkout session
|
100 |
+
if ($lastQuoteId = $checkoutSession->getLastQuoteId()){
|
101 |
+
$quote = Mage::getModel('sales/quote')->load($lastQuoteId);
|
102 |
+
if ($quoteId = $quote->getId()) {
|
103 |
+
$quote->setIsActive(false)->save();
|
104 |
+
$checkoutSession->setQuoteId(null);
|
105 |
+
}
|
106 |
+
}
|
107 |
+
|
108 |
+
$redirect ='checkout/onepage/success';// '*/*/success';
|
109 |
+
}
|
110 |
+
else{
|
111 |
+
$_helper->log('L\'utente ha annullato il pagamento, oppure qualche dato non corrisponde');
|
112 |
+
// set order quote to active
|
113 |
+
if ($lastQuoteId = $checkoutSession->getLastQuoteId()){
|
114 |
+
$quote = Mage::getModel('sales/quote')->load($lastQuoteId);
|
115 |
+
if ($quoteId = $quote->getId()) {
|
116 |
+
$quote->setIsActive(true);
|
117 |
+
$quote->setReservedOrderId(null);
|
118 |
+
$quote->save();
|
119 |
+
$checkoutSession->setQuoteId($quoteId);
|
120 |
+
}
|
121 |
+
}
|
122 |
+
|
123 |
+
$checkoutSession->addError($paymentCheckResult);
|
124 |
+
$redirect = 'checkout/cart';
|
125 |
+
}
|
126 |
+
|
127 |
+
//se è impostato lo store allora reindirizzo l'utente allo store corretto
|
128 |
+
$store= Mage::registry('easynolo_bancasellapro_store_maked_order');
|
129 |
+
if($store && $store->getId()){
|
130 |
+
$this->redirectInCorrectStore( $store, $redirect );
|
131 |
+
}else{
|
132 |
+
$this->_redirect($redirect);
|
133 |
+
}
|
134 |
+
|
135 |
+
return $this;
|
136 |
+
}
|
137 |
+
|
138 |
+
public function s2sAction(){
|
139 |
+
$a = $this->getRequest()->getParam('a',false);
|
140 |
+
$b = $this->getRequest()->getParam('b',false);
|
141 |
+
/** @var EasyNolo_BancaSellaPro_Helper_Data $_helper */
|
142 |
+
|
143 |
+
$_helper= Mage::helper('easynolo_bancasellapro');
|
144 |
+
|
145 |
+
if(!$a || !$b){
|
146 |
+
$_helper->log('Richiesta S2S, mancano i parametri di input');
|
147 |
+
$this->norouteAction();
|
148 |
+
return;
|
149 |
+
}
|
150 |
+
|
151 |
+
Mage::register('bancasella_param_a', $a);
|
152 |
+
Mage::register('bancasella_param_b', $b);
|
153 |
+
|
154 |
+
/** @var EasyNolo_BancaSellaPro_Helper_Crypt $helper */
|
155 |
+
$helper= Mage::helper('easynolo_bancasellapro/crypt');
|
156 |
+
|
157 |
+
$webservice = $helper->getInitWebservice();
|
158 |
+
|
159 |
+
$webservice->setDecryptParam($a , $b);
|
160 |
+
$helper->decriptPaymentRequest ($webservice);
|
161 |
+
|
162 |
+
$orderId = $webservice->getShopTransactionID();
|
163 |
+
$order = Mage::getModel('sales/order')->loadByIncrementId($orderId);
|
164 |
+
|
165 |
+
if($order->getId()){
|
166 |
+
$_helper->log('Imposto lo stato dell\'ordine in base al decrypt');
|
167 |
+
$helper->setStatusOrderByS2SRequest($order,$webservice);
|
168 |
+
Mage::helper('easynolo_bancasellapro/recurringprofile')->checkAndSaveToken($order,$webservice);
|
169 |
+
}else{
|
170 |
+
$_helper->log('La richiesta effettuata non ha un corrispettivo ordine. Id ordine= '.$webservice->getShopTransactionID());
|
171 |
+
}
|
172 |
+
|
173 |
+
//restiutisco una pagina vuota per notifica a GestPay
|
174 |
+
$this->getResponse()->setBody('<html></html>');
|
175 |
+
return;
|
176 |
+
}
|
177 |
+
|
178 |
+
|
179 |
+
public function successAction(){
|
180 |
+
$order = $this->getOrder();
|
181 |
+
if (!$order->getId()) {
|
182 |
+
$this->_redirect('checkout/cart');
|
183 |
+
return;
|
184 |
+
}
|
185 |
+
|
186 |
+
$session = Mage::getSingleton('checkout/session');
|
187 |
+
$session->clear();
|
188 |
+
|
189 |
+
$this->loadLayout();
|
190 |
+
$this->_initLayoutMessages('checkout/session');
|
191 |
+
Mage::dispatchEvent('easynolo_bancasellapro_gestpay_success_action', array('order_ids' => array($order->getId())));
|
192 |
+
$this->renderLayout();
|
193 |
+
}
|
194 |
+
|
195 |
+
|
196 |
+
public function confirm3dAction(){
|
197 |
+
$_helper= Mage::helper('easynolo_bancasellapro');
|
198 |
+
$_helper->log('Richiamata azione conferma 3dsecure');
|
199 |
+
$_helper->log($_REQUEST);
|
200 |
+
|
201 |
+
$order = $this->getOrder();
|
202 |
+
if($order->getId()){
|
203 |
+
$order->addStatusHistoryComment($this->__('User is redirecting to issuing bank for 3d authentification.'));
|
204 |
+
$order->save();
|
205 |
+
}
|
206 |
+
|
207 |
+
$this->loadLayout();
|
208 |
+
$this->renderLayout();
|
209 |
+
}
|
210 |
+
|
211 |
+
protected function redirectInCorrectStore($store, $path, $arguments = array())
|
212 |
+
{
|
213 |
+
$params = array_merge(
|
214 |
+
$arguments,
|
215 |
+
array(
|
216 |
+
'_use_rewrite' => false,
|
217 |
+
'_store' => $store,
|
218 |
+
'_store_to_url' => true,
|
219 |
+
'_secure' => $store->isCurrentlySecure()
|
220 |
+
) );
|
221 |
+
$url = Mage::getUrl($path,$params);
|
222 |
+
|
223 |
+
$this->getResponse()->setRedirect($url);
|
224 |
+
return;
|
225 |
+
}
|
226 |
+
|
227 |
+
|
228 |
+
}
|
app/code/community/EasyNolo/BancaSellaPro/controllers/JsonController.php
ADDED
@@ -0,0 +1,66 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @category EasyNolo
|
4 |
+
* @package EasyNolo_BancaSellaPro
|
5 |
+
* @author Easy Nolo <ecommerce@sella.it>
|
6 |
+
*/
|
7 |
+
|
8 |
+
require_once (Mage::getModuleDir('controllers','IWD_Opc').DS.'JsonController.php');
|
9 |
+
|
10 |
+
class EasyNolo_BancaSellaPro_JsonController extends IWD_Opc_JsonController {
|
11 |
+
|
12 |
+
public function savePaymentAction()
|
13 |
+
{
|
14 |
+
if ($this->_expireAjax()) {
|
15 |
+
return;
|
16 |
+
}
|
17 |
+
|
18 |
+
try {
|
19 |
+
|
20 |
+
// set payment to quote
|
21 |
+
$result = array();
|
22 |
+
$data = $this->getRequest()->getPost('payment', array());
|
23 |
+
$result = $this->getOnepage()->savePayment($data);
|
24 |
+
|
25 |
+
// get section and redirect data
|
26 |
+
$redirectUrl = $this->getOnepage()->getQuote()->getPayment()->getCheckoutRedirectUrl();
|
27 |
+
if (empty($result['error']) && !$redirectUrl) {
|
28 |
+
|
29 |
+
$this->loadLayout('checkout_onepage_review');
|
30 |
+
|
31 |
+
$result['review'] = $this->_getReviewHtml();
|
32 |
+
|
33 |
+
}
|
34 |
+
if ($redirectUrl) {
|
35 |
+
$result['redirect'] = $redirectUrl;
|
36 |
+
}
|
37 |
+
|
38 |
+
// Modifiche per funzionamento con bancasella pro
|
39 |
+
$result = new Varien_Object(array(
|
40 |
+
'json' => $result,
|
41 |
+
));
|
42 |
+
|
43 |
+
Mage::dispatchEvent('iwd_opc_before_send_result_save_payment', array(
|
44 |
+
'method' => $this->getOnepage()->getQuote()->getPayment()->getMethodInstance(),
|
45 |
+
'result' => $result
|
46 |
+
));
|
47 |
+
|
48 |
+
$result = $result->getJson();
|
49 |
+
//fine modifche funzionamento con bancasellapro
|
50 |
+
|
51 |
+
} catch (Mage_Payment_Exception $e) {
|
52 |
+
if ($e->getFields()) {
|
53 |
+
$result['fields'] = $e->getFields();
|
54 |
+
}
|
55 |
+
$result['error'] = $e->getMessage();
|
56 |
+
} catch (Mage_Core_Exception $e) {
|
57 |
+
$result['error'] = $e->getMessage();
|
58 |
+
} catch (Exception $e) {
|
59 |
+
Mage::logException($e);
|
60 |
+
$result['error'] = $this->__('Unable to set Payment Method.');
|
61 |
+
}
|
62 |
+
|
63 |
+
$this->getResponse()->setHeader('Content-type','application/json', true);
|
64 |
+
$this->getResponse()->setBody(Mage::helper('core')->jsonEncode($result));
|
65 |
+
}
|
66 |
+
}
|
app/code/community/EasyNolo/BancaSellaPro/controllers/TokenizationController.php
ADDED
@@ -0,0 +1,134 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Class Tokenization.php
|
4 |
+
* @category EasyNolo_BancaSellaPro
|
5 |
+
* @package EasyNolo
|
6 |
+
* @author Easy Nolo <ecommerce@sella.it>
|
7 |
+
*/
|
8 |
+
|
9 |
+
class EasyNolo_BancaSellaPro_TokenizationController extends Mage_Core_Controller_Front_Action {
|
10 |
+
|
11 |
+
/**
|
12 |
+
*
|
13 |
+
* @var Mage_Customer_Model_Session
|
14 |
+
*/
|
15 |
+
protected $_session = null;
|
16 |
+
|
17 |
+
/**
|
18 |
+
* Make sure customer is logged in and put it into registry
|
19 |
+
*/
|
20 |
+
public function preDispatch()
|
21 |
+
{
|
22 |
+
parent::preDispatch();
|
23 |
+
if (!$this->getRequest()->isDispatched()) {
|
24 |
+
return;
|
25 |
+
}
|
26 |
+
$this->_session = Mage::getSingleton('customer/session');
|
27 |
+
if (!$this->_session->authenticate($this)) {
|
28 |
+
$this->setFlag('', 'no-dispatch', true);
|
29 |
+
}
|
30 |
+
Mage::register('current_customer', $this->_session->getCustomer());
|
31 |
+
}
|
32 |
+
|
33 |
+
protected function _initProfile()
|
34 |
+
{
|
35 |
+
/** @var Mage_Sales_Model_Recurring_Profile $profile */
|
36 |
+
$profile = Mage::getModel('sales/recurring_profile')->load($this->getRequest()->getParam('profile'));
|
37 |
+
//se non esiste il profilo, non è dell'utente corrente oppure non è il metodo gestito dal modulo allora lancio eccezione
|
38 |
+
if (!$profile->getId() || $profile->getCustomerId()!= $this->_session->getCustomerId() || $profile->getMethodCode()!= EasyNolo_BancaSellaPro_Model_Gestpay::METHOD_CODE ) {
|
39 |
+
Mage::throwException($this->__('Specified profile does not exist.'));
|
40 |
+
}
|
41 |
+
|
42 |
+
Mage::register('current_recurring_profile', $profile);
|
43 |
+
return $profile;
|
44 |
+
}
|
45 |
+
|
46 |
+
public function newTokenAction(){
|
47 |
+
|
48 |
+
$profile = null;
|
49 |
+
try {
|
50 |
+
$profile = $this->_initProfile();
|
51 |
+
|
52 |
+
if(Mage_Sales_Model_Recurring_Profile::STATE_SUSPENDED != $profile->getState())
|
53 |
+
{
|
54 |
+
//se il profilo non è sospeso effettuo il redirect alla pagina dei recurring payment senza dare altri messaggi
|
55 |
+
$this->_redirect('sales/recurring_profile');
|
56 |
+
return;
|
57 |
+
}
|
58 |
+
$this->loadLayout();
|
59 |
+
$this->renderLayout();
|
60 |
+
|
61 |
+
} catch (Mage_Core_Exception $e) {
|
62 |
+
$this->_session->addError($e->getMessage());
|
63 |
+
$this->_redirect('sales/recurring_profile');
|
64 |
+
|
65 |
+
} catch (Exception $e) {
|
66 |
+
$this->_session->addError($this->__('Failed to update the profile.'));
|
67 |
+
Mage::logException($e);
|
68 |
+
$this->_redirect('sales/recurring_profile');
|
69 |
+
|
70 |
+
}
|
71 |
+
|
72 |
+
}
|
73 |
+
|
74 |
+
public function disableAction()
|
75 |
+
{
|
76 |
+
$profile = null;
|
77 |
+
try {
|
78 |
+
$profile = $this->_initProfile();
|
79 |
+
$profile->setState(Mage_Sales_Model_Recurring_Profile::STATE_SUSPENDED);
|
80 |
+
$profile->save();
|
81 |
+
$this->_redirect('sales/recurring_profile/view',
|
82 |
+
array(
|
83 |
+
'profile'=> $profile->getId()
|
84 |
+
)
|
85 |
+
);
|
86 |
+
}
|
87 |
+
catch(Exception $e){
|
88 |
+
$this->_session->addError($this->__('Failed to update the profile.'));
|
89 |
+
Mage::logException($e);
|
90 |
+
$this->_redirect('sales/recurring_profile');
|
91 |
+
}
|
92 |
+
|
93 |
+
}
|
94 |
+
|
95 |
+
|
96 |
+
public function resultAction(){
|
97 |
+
$a = $this->getRequest()->getParam('a',false);
|
98 |
+
$b = $this->getRequest()->getParam('b',false);
|
99 |
+
|
100 |
+
$_helper= Mage::helper('easynolo_bancasellapro');
|
101 |
+
|
102 |
+
|
103 |
+
if(!$a || !$b){
|
104 |
+
$_helper->log('Accesso alla pagina per il risultato del pagamento non consentito, mancano i parametri di input');
|
105 |
+
$this->norouteAction();
|
106 |
+
return;
|
107 |
+
}
|
108 |
+
|
109 |
+
Mage::register('bancasella_param_a', $a);
|
110 |
+
Mage::register('bancasella_param_b', $b);
|
111 |
+
|
112 |
+
/** @var EasyNolo_BancaSellaPro_Helper_Crypt $helper */
|
113 |
+
$helper= Mage::helper('easynolo_bancasellapro/crypt');
|
114 |
+
|
115 |
+
if( $helper->isPaymentOk( $a , $b )){
|
116 |
+
$_helper->log('L\'utente ha completato correttamente l\'inserimento dei dati su bancasella');
|
117 |
+
$this->_session->addSuccess($this->__('Richiesto aggiornamento del token effettuata con successo'));
|
118 |
+
$redirect ='sales/recurring_profile/view';// '*/*/success';
|
119 |
+
}
|
120 |
+
else{
|
121 |
+
$_helper->log('L\'utente ha annullato il pagamento, oppure qualche dato non corrisponde');
|
122 |
+
$this->_session->addError($this->__('Richiesto aggiornamento del token non effettuata'));
|
123 |
+
$redirect = '*/*/disable';
|
124 |
+
|
125 |
+
}
|
126 |
+
|
127 |
+
$profile = Mage::helper('easynolo_bancasellapro/recurringprofile')->getProfileIdByOrder(Mage::registry('easynolo_bancasellapro_order'));
|
128 |
+
$this->_redirect($redirect,array('profile'=>$profile));
|
129 |
+
|
130 |
+
return;
|
131 |
+
|
132 |
+
}
|
133 |
+
|
134 |
+
}
|
app/code/community/EasyNolo/BancaSellaPro/etc/config.xml
ADDED
@@ -0,0 +1,155 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<modules>
|
4 |
+
<EasyNolo_BancaSellaPro>
|
5 |
+
<version>1.4.0</version>
|
6 |
+
</EasyNolo_BancaSellaPro>
|
7 |
+
</modules>
|
8 |
+
<global>
|
9 |
+
<blocks>
|
10 |
+
<easynolo_bancasellapro>
|
11 |
+
<class>EasyNolo_BancaSellaPro_Block</class>
|
12 |
+
</easynolo_bancasellapro>
|
13 |
+
</blocks>
|
14 |
+
<helpers>
|
15 |
+
<easynolo_bancasellapro>
|
16 |
+
<class>EasyNolo_BancaSellaPro_Helper</class>
|
17 |
+
</easynolo_bancasellapro>
|
18 |
+
</helpers>
|
19 |
+
<models>
|
20 |
+
<easynolo_bancasellapro>
|
21 |
+
<class>EasyNolo_BancaSellaPro_Model</class>
|
22 |
+
<resourceModel>easynolo_bancasellapro_resource</resourceModel>
|
23 |
+
</easynolo_bancasellapro>
|
24 |
+
|
25 |
+
<easynolo_bancasellapro_resource>
|
26 |
+
<class>EasyNolo_BancaSellaPro_Model_Resource</class>
|
27 |
+
<entities>
|
28 |
+
<token>
|
29 |
+
<table>easynolo_bancasellapro_token</table>
|
30 |
+
</token>
|
31 |
+
</entities>
|
32 |
+
</easynolo_bancasellapro_resource>
|
33 |
+
<sales>
|
34 |
+
<rewrite>
|
35 |
+
<recurring_profile>EasyNolo_BancaSellaPro_Model_Sales_Recurring_Profile</recurring_profile>
|
36 |
+
</rewrite>
|
37 |
+
</sales>
|
38 |
+
</models>
|
39 |
+
<!--To show the order in pending payment state before bancasella send a s2s request-->
|
40 |
+
<sales>
|
41 |
+
<order>
|
42 |
+
<states>
|
43 |
+
<pending_payment translate="label">
|
44 |
+
<label>Pending Payment</label>
|
45 |
+
<statuses>
|
46 |
+
<pending_payment default="1"/>
|
47 |
+
</statuses>
|
48 |
+
<visible_on_front>1</visible_on_front>
|
49 |
+
</pending_payment>
|
50 |
+
</states>
|
51 |
+
</order>
|
52 |
+
</sales>
|
53 |
+
<resources>
|
54 |
+
<easynolo_bancasellapro_setup>
|
55 |
+
<setup>
|
56 |
+
<module>EasyNolo_BancaSellaPro</module>
|
57 |
+
</setup>
|
58 |
+
</easynolo_bancasellapro_setup>
|
59 |
+
</resources>
|
60 |
+
</global>
|
61 |
+
|
62 |
+
<phpunit>
|
63 |
+
<suite>
|
64 |
+
<modules>
|
65 |
+
<EasyNolo_BancaSellaPro />
|
66 |
+
</modules>
|
67 |
+
</suite>
|
68 |
+
</phpunit>
|
69 |
+
|
70 |
+
<frontend>
|
71 |
+
<routers>
|
72 |
+
<easynolo_bancasellapro>
|
73 |
+
<use>standard</use>
|
74 |
+
<args>
|
75 |
+
<module>EasyNolo_BancaSellaPro</module>
|
76 |
+
<frontName>bancasellapro</frontName>
|
77 |
+
</args>
|
78 |
+
</easynolo_bancasellapro>
|
79 |
+
<opc>
|
80 |
+
<args>
|
81 |
+
<modules>
|
82 |
+
<easynolo_bancasellapro before="IWD_Opc">EasyNolo_BancaSellaPro</easynolo_bancasellapro>
|
83 |
+
</modules>
|
84 |
+
</args>
|
85 |
+
</opc>
|
86 |
+
</routers>
|
87 |
+
<layout>
|
88 |
+
<updates>
|
89 |
+
<easynolo_bancasellapro>
|
90 |
+
<file>easynolo_bancasellapro.xml</file>
|
91 |
+
</easynolo_bancasellapro>
|
92 |
+
</updates>
|
93 |
+
</layout>
|
94 |
+
<events>
|
95 |
+
<easynolo_bancasellapro_gestpay_success_action>
|
96 |
+
<observers>
|
97 |
+
<googleanalytics_order_success>
|
98 |
+
<class>googleanalytics/observer</class>
|
99 |
+
<method>setGoogleAnalyticsOnOrderSuccessPageView</method>
|
100 |
+
</googleanalytics_order_success>
|
101 |
+
</observers>
|
102 |
+
</easynolo_bancasellapro_gestpay_success_action>
|
103 |
+
<iwd_opc_before_send_result_save_payment>
|
104 |
+
<observers>
|
105 |
+
<easynolo_bancasellapro_add_result>
|
106 |
+
<class>easynolo_bancasellapro/observer</class>
|
107 |
+
<method>addDataToResultSavePaymentIWD</method>
|
108 |
+
</easynolo_bancasellapro_add_result>
|
109 |
+
</observers>
|
110 |
+
</iwd_opc_before_send_result_save_payment>
|
111 |
+
</events>
|
112 |
+
<translate>
|
113 |
+
<modules>
|
114 |
+
<easynolo_bancasellapro>
|
115 |
+
<files>
|
116 |
+
<default>EasyNolo_BancaSellaPro.csv</default>
|
117 |
+
</files>
|
118 |
+
</easynolo_bancasellapro>
|
119 |
+
</modules>
|
120 |
+
</translate>
|
121 |
+
</frontend>
|
122 |
+
<crontab>
|
123 |
+
<jobs>
|
124 |
+
<easynolo_bancasellapro_recurring_profile_charge>
|
125 |
+
<schedule>
|
126 |
+
<cron_expr>0 * * * *</cron_expr>
|
127 |
+
</schedule>
|
128 |
+
<run>
|
129 |
+
<model>easynolo_bancasellapro/observer::chargeRecurringProfiles</model>
|
130 |
+
</run>
|
131 |
+
</easynolo_bancasellapro_recurring_profile_charge>
|
132 |
+
</jobs>
|
133 |
+
</crontab>
|
134 |
+
<default>
|
135 |
+
<payment>
|
136 |
+
<gestpaypro>
|
137 |
+
<active>0</active>
|
138 |
+
<model>easynolo_bancasellapro/gestpay</model>
|
139 |
+
<debug>0</debug>
|
140 |
+
<log>0</log>
|
141 |
+
<order_status_ko_user>canceled</order_status_ko_user>
|
142 |
+
<order_status_ko_gestpay>holded</order_status_ko_gestpay>
|
143 |
+
<order_status_ok_gestpay>processing</order_status_ok_gestpay>
|
144 |
+
<order_status_fraud_gestpay>1</order_status_fraud_gestpay>
|
145 |
+
<title>Banca Sella GestPay Pro</title>
|
146 |
+
<description>You will be redirected to Banca Sella payment website</description>
|
147 |
+
<iframe>0</iframe>
|
148 |
+
<tokenization>0</tokenization>
|
149 |
+
<allowspecific>0</allowspecific>
|
150 |
+
<language>0</language>
|
151 |
+
<currency>242</currency>
|
152 |
+
</gestpaypro>
|
153 |
+
</payment>
|
154 |
+
</default>
|
155 |
+
</config>
|
app/code/community/EasyNolo/BancaSellaPro/etc/jstranslator.xml
ADDED
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<jstranslator>
|
3 |
+
<!-- gestpayform_onepagecheckout.js -->
|
4 |
+
<payment-wait translate="message" module="easynolo_bancasellapro">
|
5 |
+
<message>You are waiting the completion of payment</message>
|
6 |
+
</payment-wait>
|
7 |
+
<wait-message translate="message" module="easynolo_bancasellapro">
|
8 |
+
<message>Please wait...</message>
|
9 |
+
</wait-message>
|
10 |
+
<redirect-title translate="message" module="easynolo_bancasellapro">
|
11 |
+
<message>Payment authorization error</message>
|
12 |
+
</redirect-title>
|
13 |
+
<redirect-message translate="message" module="easynolo_bancasellapro">
|
14 |
+
<message>Complete payment on Banca Sella website</message>
|
15 |
+
</redirect-message>
|
16 |
+
<confirm translate="message" module="easynolo_bancasellapro">
|
17 |
+
<message>Send Credit Card Data</message>
|
18 |
+
</confirm>
|
19 |
+
<fixed-text translate="message" module="easynolo_bancasellapro">
|
20 |
+
<message>Please correct the highlighted fields</message>
|
21 |
+
</fixed-text>
|
22 |
+
<tredsecure-text translate="message" module="easynolo_bancasellapro">
|
23 |
+
<message>3D secure</message>
|
24 |
+
</tredsecure-text>
|
25 |
+
<!-- end gestpayform_onepagecheckout.js -->
|
26 |
+
</jstranslator>
|
app/code/community/EasyNolo/BancaSellaPro/etc/system.xml
ADDED
@@ -0,0 +1,210 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<sections>
|
4 |
+
<payment>
|
5 |
+
<groups>
|
6 |
+
<gestpaypro translate="label" module="easynolo_bancasellapro">
|
7 |
+
<label>EasyNolo Banca Sella GestPay Pro</label>
|
8 |
+
<frontend_type>text</frontend_type>
|
9 |
+
<sort_order>50</sort_order>
|
10 |
+
<show_in_default>1</show_in_default>
|
11 |
+
<show_in_website>1</show_in_website>
|
12 |
+
<show_in_store>1</show_in_store>
|
13 |
+
<fields>
|
14 |
+
<active translate="label">
|
15 |
+
<label>Enabled</label>
|
16 |
+
<frontend_type>select</frontend_type>
|
17 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
18 |
+
<sort_order>1</sort_order>
|
19 |
+
<show_in_default>1</show_in_default>
|
20 |
+
<show_in_website>1</show_in_website>
|
21 |
+
<show_in_store>0</show_in_store>
|
22 |
+
</active>
|
23 |
+
<title translate="label">
|
24 |
+
<label>Title</label>
|
25 |
+
<frontend_type>text</frontend_type>
|
26 |
+
<sort_order>2</sort_order>
|
27 |
+
<show_in_default>1</show_in_default>
|
28 |
+
<show_in_website>1</show_in_website>
|
29 |
+
<show_in_store>1</show_in_store>
|
30 |
+
</title>
|
31 |
+
<description translate="label">
|
32 |
+
<label>Description</label>
|
33 |
+
<frontend_type>textarea</frontend_type>
|
34 |
+
<sort_order>3</sort_order>
|
35 |
+
<show_in_default>1</show_in_default>
|
36 |
+
<show_in_website>1</show_in_website>
|
37 |
+
<show_in_store>1</show_in_store>
|
38 |
+
</description>
|
39 |
+
<merchant_id translate="label">
|
40 |
+
<label>Shop Login</label>
|
41 |
+
<sort_order>4</sort_order>
|
42 |
+
<frontend_type>text</frontend_type>
|
43 |
+
<show_in_default>1</show_in_default>
|
44 |
+
<show_in_website>1</show_in_website>
|
45 |
+
<show_in_store>0</show_in_store>
|
46 |
+
</merchant_id>
|
47 |
+
<debug translate="label">
|
48 |
+
<label>Test Environment</label>
|
49 |
+
<frontend_type>select</frontend_type>
|
50 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
51 |
+
<comment>
|
52 |
+
<![CDATA[If enabled please insert a test shop login; so the payments will be send to https://testecomm.sella.it]]>
|
53 |
+
</comment>
|
54 |
+
<sort_order>5</sort_order>
|
55 |
+
<show_in_default>1</show_in_default>
|
56 |
+
<show_in_website>1</show_in_website>
|
57 |
+
<show_in_store>0</show_in_store>
|
58 |
+
</debug>
|
59 |
+
<payment_action translate="label">
|
60 |
+
<label>Payment Action</label>
|
61 |
+
<frontend_type>select</frontend_type>
|
62 |
+
<source_model>easynolo_bancasellapro/system_config_source_paymentAction</source_model>
|
63 |
+
<sort_order>6</sort_order>
|
64 |
+
<show_in_default>1</show_in_default>
|
65 |
+
<show_in_website>1</show_in_website>
|
66 |
+
<show_in_store>0</show_in_store>
|
67 |
+
</payment_action>
|
68 |
+
<use_s2s_api>
|
69 |
+
<label>Use S2S Sales API for Capture, Void, Refund actions</label>
|
70 |
+
<frontend_type>select</frontend_type>
|
71 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
72 |
+
<comment>
|
73 |
+
<![CDATA[If enabled, this operations will be performed natively through Magento Invoicing system.]]>
|
74 |
+
</comment>
|
75 |
+
<sort_order>7</sort_order>
|
76 |
+
<show_in_default>1</show_in_default>
|
77 |
+
<show_in_website>1</show_in_website>
|
78 |
+
<show_in_store>0</show_in_store>
|
79 |
+
</use_s2s_api>
|
80 |
+
<iframe translate="label">
|
81 |
+
<label>Enable iFrame Payment Page</label>
|
82 |
+
<comment>
|
83 |
+
<![CDATA[If enabled the payment process will be performed witouth redirection to the Banca Sella payment website.<br/><b>Please note:</b> available only if configured on GestPay backend as well.]]>
|
84 |
+
</comment>
|
85 |
+
<frontend_type>select</frontend_type>
|
86 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
87 |
+
<sort_order>8</sort_order>
|
88 |
+
<show_in_default>1</show_in_default>
|
89 |
+
<show_in_website>1</show_in_website>
|
90 |
+
<show_in_store>0</show_in_store>
|
91 |
+
</iframe>
|
92 |
+
<tokenization translate="label">
|
93 |
+
<label>Enable Tokenization</label>
|
94 |
+
<frontend_type>select</frontend_type>
|
95 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
96 |
+
<comment>
|
97 |
+
<![CDATA[Available only for Magento built-in Recurring Profile Payments.<br/><b>Please note:</b> available only if configured on GestPay backend as well.]]>
|
98 |
+
</comment>
|
99 |
+
<sort_order>9</sort_order>
|
100 |
+
<show_in_default>1</show_in_default>
|
101 |
+
<show_in_website>0</show_in_website>
|
102 |
+
<show_in_store>0</show_in_store>
|
103 |
+
<depends><iframe>1</iframe></depends>
|
104 |
+
</tokenization>
|
105 |
+
<language translate="label">
|
106 |
+
<label>Gateway Language</label>
|
107 |
+
<frontend_type>select</frontend_type>
|
108 |
+
<comment>
|
109 |
+
<![CDATA[<b>Please note:</b> available only if configured on GestPay backend as well.]]>
|
110 |
+
</comment>
|
111 |
+
<sort_order>10</sort_order>
|
112 |
+
<source_model>easynolo_bancasellapro/system_config_source_language</source_model>
|
113 |
+
<show_in_default>1</show_in_default>
|
114 |
+
<show_in_website>1</show_in_website>
|
115 |
+
<show_in_store>1</show_in_store>
|
116 |
+
</language>
|
117 |
+
<currency translate="label">
|
118 |
+
<label>Gateway Currency</label>
|
119 |
+
<frontend_type>select</frontend_type>
|
120 |
+
<sort_order>11</sort_order>
|
121 |
+
<source_model>easynolo_bancasellapro/system_config_source_currency</source_model>
|
122 |
+
<show_in_default>1</show_in_default>
|
123 |
+
<show_in_website>1</show_in_website>
|
124 |
+
<show_in_store>0</show_in_store>
|
125 |
+
</currency>
|
126 |
+
<order_status_ko_user translate="label">
|
127 |
+
<label>Status of order canceled by customer</label>
|
128 |
+
<frontend_type>select</frontend_type>
|
129 |
+
<source_model>adminhtml/system_config_source_order_status</source_model>
|
130 |
+
<sort_order>12</sort_order>
|
131 |
+
<show_in_default>1</show_in_default>
|
132 |
+
<show_in_website>1</show_in_website>
|
133 |
+
<show_in_store>0</show_in_store>
|
134 |
+
</order_status_ko_user>
|
135 |
+
<order_status_ko_gestpay translate="label">
|
136 |
+
<label>Status of order canceled by Banca Sella</label>
|
137 |
+
<frontend_type>select</frontend_type>
|
138 |
+
<source_model>adminhtml/system_config_source_order_status</source_model>
|
139 |
+
<sort_order>13</sort_order>
|
140 |
+
<show_in_default>1</show_in_default>
|
141 |
+
<show_in_website>1</show_in_website>
|
142 |
+
<show_in_store>0</show_in_store>
|
143 |
+
</order_status_ko_gestpay>
|
144 |
+
<order_status_ok_gestpay translate="label">
|
145 |
+
<label>Status of order confirmed by Banca Sella</label>
|
146 |
+
<frontend_type>select</frontend_type>
|
147 |
+
<source_model>adminhtml/system_config_source_order_status</source_model>
|
148 |
+
<sort_order>14</sort_order>
|
149 |
+
<show_in_default>1</show_in_default>
|
150 |
+
<show_in_website>1</show_in_website>
|
151 |
+
<show_in_store>0</show_in_store>
|
152 |
+
</order_status_ok_gestpay>
|
153 |
+
<order_status_fraud_gestpay translate="label">
|
154 |
+
<label>Enable Anti-Fraud Check</label>
|
155 |
+
<frontend_type>select</frontend_type>
|
156 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
157 |
+
<comment>
|
158 |
+
<![CDATA[If the payment match the anti-fraud rules, the related order state will be switched to "Review Payment" and order status to "Fraud"]]>
|
159 |
+
</comment>
|
160 |
+
<sort_order>15</sort_order>
|
161 |
+
<show_in_default>1</show_in_default>
|
162 |
+
<show_in_website>1</show_in_website>
|
163 |
+
<show_in_store>0</show_in_store>
|
164 |
+
</order_status_fraud_gestpay>
|
165 |
+
<allowspecific translate="label">
|
166 |
+
<label>Payment from Applicable Countries</label>
|
167 |
+
<frontend_type>select</frontend_type>
|
168 |
+
<sort_order>16</sort_order>
|
169 |
+
<source_model>adminhtml/system_config_source_payment_allspecificcountries</source_model>
|
170 |
+
<show_in_default>1</show_in_default>
|
171 |
+
<show_in_website>1</show_in_website>
|
172 |
+
<show_in_store>0</show_in_store>
|
173 |
+
</allowspecific>
|
174 |
+
<specificcountry translate="label">
|
175 |
+
<label>Payment from Specific Countries</label>
|
176 |
+
<frontend_type>multiselect</frontend_type>
|
177 |
+
<sort_order>17</sort_order>
|
178 |
+
<source_model>adminhtml/system_config_source_country</source_model>
|
179 |
+
<show_in_default>1</show_in_default>
|
180 |
+
<show_in_website>1</show_in_website>
|
181 |
+
<show_in_store>0</show_in_store>
|
182 |
+
<depends><allowspecific>1</allowspecific></depends>
|
183 |
+
</specificcountry>
|
184 |
+
<sort_order translate="label">
|
185 |
+
<label>Sort Order</label>
|
186 |
+
<frontend_type>text</frontend_type>
|
187 |
+
<sort_order>18</sort_order>
|
188 |
+
<show_in_default>1</show_in_default>
|
189 |
+
<show_in_website>1</show_in_website>
|
190 |
+
<show_in_store>1</show_in_store>
|
191 |
+
<frontend_class>validate-number</frontend_class>
|
192 |
+
</sort_order>
|
193 |
+
<log translate="label">
|
194 |
+
<label>Enable Log</label>
|
195 |
+
<frontend_type>select</frontend_type>
|
196 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
197 |
+
<comment>
|
198 |
+
<![CDATA[Logging from Mage::log(). File is located in {{base_dir}}/var/log/<i>EasyNolo_BancaSellaPro.log</i>]]>
|
199 |
+
</comment>
|
200 |
+
<sort_order>19</sort_order>
|
201 |
+
<show_in_default>1</show_in_default>
|
202 |
+
<show_in_website>1</show_in_website>
|
203 |
+
<show_in_store>0</show_in_store>
|
204 |
+
</log>
|
205 |
+
</fields>
|
206 |
+
</gestpaypro>
|
207 |
+
</groups>
|
208 |
+
</payment>
|
209 |
+
</sections>
|
210 |
+
</config>
|
app/code/community/EasyNolo/BancaSellaPro/sql/easynolo_bancasellapro_setup/install-1.3.0.php
ADDED
@@ -0,0 +1,60 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @author Easy Nolo <ecommerce@sella.it>
|
4 |
+
*/
|
5 |
+
|
6 |
+
/** @var Mage_Core_Model_Resource_Setup $installer */
|
7 |
+
|
8 |
+
$installer = $this;
|
9 |
+
$connection = $installer->getConnection();
|
10 |
+
|
11 |
+
$installer->startSetup();
|
12 |
+
|
13 |
+
$tableName = $installer->getTable('easynolo_bancasellapro/token');
|
14 |
+
|
15 |
+
if (!$connection->isTableExists($tableName)) {
|
16 |
+
$table= $connection->newTable($tableName)
|
17 |
+
->addColumn('entity_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
|
18 |
+
'identity' => true,
|
19 |
+
'unsigned' => true,
|
20 |
+
'nullable' => false,
|
21 |
+
'primary' => true,
|
22 |
+
), 'ID')
|
23 |
+
->addColumn('profile_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
|
24 |
+
'unsigned' => true,
|
25 |
+
'nullable' => false,
|
26 |
+
'default' => '0',
|
27 |
+
), 'Profile Id')
|
28 |
+
->addColumn('customer_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
|
29 |
+
'unsigned' => true,
|
30 |
+
), 'Customer ID')
|
31 |
+
->addColumn('token',Varien_Db_Ddl_Table::TYPE_TEXT,16,array(
|
32 |
+
'nullable' => false,
|
33 |
+
),'Token per effettuare i pagamenti con Bancasella')
|
34 |
+
->addColumn('expiry_date', Varien_Db_Ddl_Table::TYPE_DATE, null, array(
|
35 |
+
'nullable' => false,
|
36 |
+
), 'Data di scadenza del token')
|
37 |
+
->addForeignKey(
|
38 |
+
$installer->getFkName(
|
39 |
+
'easynolo_bancasellapro/token',
|
40 |
+
'profile_id',
|
41 |
+
'sales/recurring_profile',
|
42 |
+
'profile_id'
|
43 |
+
),
|
44 |
+
'profile_id', $installer->getTable('sales/recurring_profile'), 'profile_id',
|
45 |
+
Varien_Db_Ddl_Table::ACTION_CASCADE, Varien_Db_Ddl_Table::ACTION_CASCADE)
|
46 |
+
->addForeignKey(
|
47 |
+
$installer->getFkName(
|
48 |
+
'easynolo_bancasellapro/token',
|
49 |
+
'customer_id',
|
50 |
+
'customer/entity',
|
51 |
+
'entity_id'
|
52 |
+
),
|
53 |
+
'customer_id', $installer->getTable('customer/entity'), 'entity_id',
|
54 |
+
Varien_Db_Ddl_Table::ACTION_CASCADE, Varien_Db_Ddl_Table::ACTION_CASCADE)
|
55 |
+
;
|
56 |
+
|
57 |
+
$connection->createTable($table);
|
58 |
+
}
|
59 |
+
|
60 |
+
$installer->endSetup();
|
app/code/community/EasyNolo/BancaSellaPro/sql/easynolo_bancasellapro_setup/upgrade-1.3.0-1.3.1.php
ADDED
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @author Easy Nolo <ecommerce@sella.it>
|
4 |
+
*/
|
5 |
+
|
6 |
+
$installer = $this;
|
7 |
+
$installer->startSetup();
|
8 |
+
$_helper=Mage::helper('easynolo_bancasellapro/recurringprofile');
|
9 |
+
|
10 |
+
$status = Mage::getModel('sales/order_status');
|
11 |
+
$status->setStatus($_helper::STATUS_REFUND_TOTAL);
|
12 |
+
$status->setLabel('Rimborso pagamento iniziale');
|
13 |
+
$status->save();
|
14 |
+
|
15 |
+
$installer->endSetup();
|
app/design/frontend/base/default/layout/easynolo_bancasellapro.xml
ADDED
@@ -0,0 +1,115 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<layout>
|
3 |
+
|
4 |
+
<easynolo_bancasellapro_gestpay_redirect>
|
5 |
+
<label>Redirect...</label>
|
6 |
+
|
7 |
+
<block type="easynolo_bancasellapro/newroot" name="root" output="toHtml" template="easynolo/bancasellapro/page/redirect.phtml">
|
8 |
+
|
9 |
+
<block type="core/text_list" name="content" as="content" translate="label">
|
10 |
+
<label>Main Content Area</label>
|
11 |
+
<block type="easynolo_bancasellapro/redirect" name="bancasella_gestpay_redirect" template="easynolo/bancasellapro/gestpay/redirect.phtml"></block>
|
12 |
+
</block>
|
13 |
+
|
14 |
+
</block>
|
15 |
+
|
16 |
+
</easynolo_bancasellapro_gestpay_redirect>
|
17 |
+
|
18 |
+
<easynolo_bancasellapro_gestpay_success translate="label">
|
19 |
+
<label>Checkout Success</label>
|
20 |
+
<reference name="root">
|
21 |
+
<action method="setTemplate"><template>page/2columns-right.phtml</template></action>
|
22 |
+
</reference>
|
23 |
+
<reference name="content">
|
24 |
+
<block type="checkout/onepage_success" name="checkout.success" template="checkout/success.phtml"/>
|
25 |
+
</reference>
|
26 |
+
</easynolo_bancasellapro_gestpay_success>
|
27 |
+
|
28 |
+
|
29 |
+
|
30 |
+
<easynolo_bancasellapro_gestpay_confirm3d>
|
31 |
+
<block type="easynolo_bancasellapro/newroot" name="root" output="toHtml" template="easynolo/bancasellapro/page/redirect.phtml">
|
32 |
+
<block type="core/text_list" name="content" as="content" translate="label">
|
33 |
+
<block type="easynolo_bancasellapro/confirm3d" name="bancasellagestpay_confirm"
|
34 |
+
template="easynolo/bancasellapro/gestpay/confirm3d.phtml" />
|
35 |
+
</block>
|
36 |
+
</block>
|
37 |
+
|
38 |
+
</easynolo_bancasellapro_gestpay_confirm3d>
|
39 |
+
|
40 |
+
<checkout_onepage_index>
|
41 |
+
<reference name="head">
|
42 |
+
|
43 |
+
<block type="easynolo_bancasellapro/utility_text" name="gestpay.iframe.external"/>
|
44 |
+
<action method="addJs"><script>prototype/window.js</script></action>
|
45 |
+
<action method="addItem"><type>js_css</type><name>prototype/windows/themes/default.css</name></action>
|
46 |
+
<action method="addCss"><name>lib/prototype/windows/themes/magento.css</name></action>
|
47 |
+
</reference>
|
48 |
+
<reference name="checkout.onepage">
|
49 |
+
<action method="setTemplate">
|
50 |
+
<template>easynolo/bancasellapro/checkout/onepage.phtml</template>
|
51 |
+
</action>
|
52 |
+
</reference>
|
53 |
+
</checkout_onepage_index>
|
54 |
+
|
55 |
+
<!--WARNING: if you use a magento version 1.6 you must to use this comment handle instead of precedent handle-->
|
56 |
+
<!--<checkout_onepage_index>-->
|
57 |
+
<!--<reference name="head">-->
|
58 |
+
|
59 |
+
<!--<block type="easynolo_bancasellapro/utility_text" name="gestpay.iframe.external"/>-->
|
60 |
+
<!--<action method="addJs"><script>prototype/window.js</script></action>-->
|
61 |
+
<!--<action method="addItem"><type>js_css</type><name>prototype/windows/themes/default.css</name></action>-->
|
62 |
+
<!--<action method="addItem"><type>js_css</type><name>prototype/windows/themes/magento.css</name></action>-->
|
63 |
+
|
64 |
+
<!--</reference>-->
|
65 |
+
<!--<reference name="checkout.onepage">-->
|
66 |
+
<!--<action method="setTemplate">-->
|
67 |
+
<!--<template>easynolo/bancasellapro/checkout/onepage1-6.phtml</template>-->
|
68 |
+
<!--</action>-->
|
69 |
+
<!--</reference>-->
|
70 |
+
<!--</checkout_onepage_index>-->
|
71 |
+
|
72 |
+
<opc_index_index>
|
73 |
+
<reference name="head">
|
74 |
+
<block type="easynolo_bancasellapro/utility_text" name="gestpay.iframe.external"/>
|
75 |
+
<action method="addJs"><script>prototype/window.js</script></action>
|
76 |
+
<action method="addItem"><type>js_css</type><name>prototype/windows/themes/default.css</name></action>
|
77 |
+
<action method="addCss"><name>lib/prototype/windows/themes/magento.css</name></action>
|
78 |
+
<action method="addItem"><type>skin_js</type><name>js/easynolo_bancasella/gestpayform_onepagecheckout.js</name></action>
|
79 |
+
</reference>
|
80 |
+
</opc_index_index>
|
81 |
+
|
82 |
+
<!--WARNING: if you use a magento version 1.6 you must to use this comment handle instead of precedent handle-->
|
83 |
+
<!--<opc_index_index>-->
|
84 |
+
<!--<reference name="head">-->
|
85 |
+
<!--<block type="easynolo_bancasellapro/utility_text" name="gestpay.iframe.external"/>-->
|
86 |
+
<!--<action method="addJs"><script>prototype/window.js</script></action>-->
|
87 |
+
<!--<action method="addItem"><type>js_css</type><name>prototype/windows/themes/default.css</name></action>-->
|
88 |
+
<!--<action method="addItem"><type>js_css</type><name>prototype/windows/themes/magento.css</name></action>-->
|
89 |
+
<!--<action method="addItem"><type>skin_js</type><name>js/easynolo_bancasella/gestpayform_onepagecheckout.js</name></action>-->
|
90 |
+
<!--</reference>-->
|
91 |
+
<!--</opc_index_index>-->
|
92 |
+
|
93 |
+
|
94 |
+
|
95 |
+
|
96 |
+
<easynolo_bancasellapro_tokenization_newtoken translate="label">
|
97 |
+
<label>Generate a new token</label>
|
98 |
+
<reference name="root">
|
99 |
+
<action method="setTemplate"><template>page/1column.phtml</template></action>
|
100 |
+
</reference>
|
101 |
+
<reference name="head">
|
102 |
+
<block type="easynolo_bancasellapro/utility_text" name="gestpay.iframe.external"/>
|
103 |
+
<action method="addJs"><script>bancasellapro/newtoken.js</script></action>
|
104 |
+
<action method="addJs"><script>prototype/window.js</script></action>
|
105 |
+
<action method="addItem"><type>js_css</type><name>prototype/windows/themes/default.css</name></action>
|
106 |
+
<action method="addCss"><name>lib/prototype/windows/themes/magento.css</name></action>
|
107 |
+
</reference>
|
108 |
+
|
109 |
+
<reference name="content">
|
110 |
+
<block type="easynolo_bancasellapro/tokenization_newtoken" name="checkout.success" template="easynolo/bancasellapro/gestpay/newtoken.phtml"/>
|
111 |
+
</reference>
|
112 |
+
|
113 |
+
</easynolo_bancasellapro_tokenization_newtoken>
|
114 |
+
|
115 |
+
</layout>
|
app/design/frontend/base/default/template/easynolo/bancasellapro/checkout/onepage.phtml
ADDED
@@ -0,0 +1,43 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @category EasyNolo
|
4 |
+
* @package EasyNolo_BancaSellaPro
|
5 |
+
* @author Easy Nolo <ecommerce@sella.it>
|
6 |
+
*/
|
7 |
+
?>
|
8 |
+
|
9 |
+
<div class="page-title">
|
10 |
+
<h1><?php echo $this->__('Checkout') ?></h1>
|
11 |
+
</div>
|
12 |
+
<script type="text/javascript" src="<?php echo $this->getJsUrl('varien/accordion.js') ?>"></script>
|
13 |
+
<script type="text/javascript" src="<?php echo $this->getSkinUrl('js/opcheckout.js') ?>"></script>
|
14 |
+
<script type="text/javascript" src="<?php echo $this->getJsUrl('bancasellapro/gestpayform.js') ?>"></script>
|
15 |
+
<ol class="opc" id="checkoutSteps">
|
16 |
+
<?php $i=0; foreach($this->getSteps() as $_stepId => $_stepInfo): ?>
|
17 |
+
<?php if (!$this->getChild($_stepId) || !$this->getChild($_stepId)->isShow()): continue; endif; $i++ ?>
|
18 |
+
<li id="opc-<?php echo $_stepId ?>" class="section<?php echo !empty($_stepInfo['allow'])?' allow':'' ?><?php echo !empty($_stepInfo['complete'])?' saved':'' ?>">
|
19 |
+
<div class="step-title">
|
20 |
+
<span class="number"><?php echo $i ?></span>
|
21 |
+
<h2><?php echo $_stepInfo['label'] ?></h2>
|
22 |
+
<a href="#"><?php echo $this->__('Edit') ?></a>
|
23 |
+
</div>
|
24 |
+
<div id="checkout-step-<?php echo $_stepId ?>" class="step a-item" style="display:none;">
|
25 |
+
<?php echo $this->getChildHtml($_stepId) ?>
|
26 |
+
</div>
|
27 |
+
</li>
|
28 |
+
<?php endforeach ?>
|
29 |
+
</ol>
|
30 |
+
<script type="text/javascript">
|
31 |
+
//<![CDATA[
|
32 |
+
var accordion = new Accordion('checkoutSteps', '.step-title', true);
|
33 |
+
<?php if($this->getActiveStep()): ?>
|
34 |
+
accordion.openSection('opc-<?php echo $this->getActiveStep() ?>');
|
35 |
+
<?php endif ?>
|
36 |
+
var checkout = new Checkout(accordion,{
|
37 |
+
progress: '<?php echo $this->getUrl('checkout/onepage/progress') ?>',
|
38 |
+
review: '<?php echo $this->getUrl('checkout/onepage/review') ?>',
|
39 |
+
saveMethod: '<?php echo $this->getUrl('checkout/onepage/saveMethod') ?>',
|
40 |
+
failure: '<?php echo $this->getUrl('checkout/cart') ?>'}
|
41 |
+
);
|
42 |
+
//]]>
|
43 |
+
</script>
|
app/design/frontend/base/default/template/easynolo/bancasellapro/checkout/onepage1-6.phtml
ADDED
@@ -0,0 +1,43 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @category EasyNolo
|
4 |
+
* @package EasyNolo_BancaSellaPro
|
5 |
+
* @author Easy Nolo <ecommerce@sella.it>
|
6 |
+
*/
|
7 |
+
?>
|
8 |
+
<div class="page-title">
|
9 |
+
<h1><?php echo $this->__('Checkout') ?></h1>
|
10 |
+
</div>
|
11 |
+
<script type="text/javascript" src="<?php echo $this->getJsUrl('varien/accordion.js') ?>"></script>
|
12 |
+
<script type="text/javascript" src="<?php echo $this->getSkinUrl('js/opcheckout.js') ?>"></script>
|
13 |
+
<script type="text/javascript">countryRegions = <?php echo $this->helper('directory')->getRegionJson() ?></script>
|
14 |
+
<script type="text/javascript" src="<?php echo $this->getJsUrl('bancasellapro/gestpayform.js') ?>"></script>
|
15 |
+
<ol class="opc" id="checkoutSteps">
|
16 |
+
<?php $i=0; foreach($this->getSteps() as $_stepId => $_stepInfo): ?>
|
17 |
+
<?php if (!$this->getChild($_stepId) || !$this->getChild($_stepId)->isShow()): continue; endif; $i++ ?>
|
18 |
+
<li id="opc-<?php echo $_stepId ?>" class="section<?php echo !empty($_stepInfo['allow'])?' allow':'' ?><?php echo !empty($_stepInfo['complete'])?' saved':'' ?>">
|
19 |
+
<div class="step-title">
|
20 |
+
<span class="number"><?php echo $i ?></span>
|
21 |
+
<h2><?php echo $_stepInfo['label'] ?></h2>
|
22 |
+
<a href="#"><?php echo $this->__('Edit') ?></a>
|
23 |
+
</div>
|
24 |
+
<div id="checkout-step-<?php echo $_stepId ?>" class="step a-item" style="display:none;">
|
25 |
+
<?php echo $this->getChildHtml($_stepId) ?>
|
26 |
+
</div>
|
27 |
+
</li>
|
28 |
+
<?php endforeach ?>
|
29 |
+
</ol>
|
30 |
+
<script type="text/javascript">
|
31 |
+
//<![CDATA[
|
32 |
+
var accordion = new Accordion('checkoutSteps', '.step-title', true);
|
33 |
+
<?php if($this->getActiveStep()): ?>
|
34 |
+
accordion.openSection('opc-<?php echo $this->getActiveStep() ?>');
|
35 |
+
<?php endif ?>
|
36 |
+
var checkout = new Checkout(accordion,{
|
37 |
+
progress: '<?php echo $this->getUrl('checkout/onepage/progress') ?>',
|
38 |
+
review: '<?php echo $this->getUrl('checkout/onepage/review') ?>',
|
39 |
+
saveMethod: '<?php echo $this->getUrl('checkout/onepage/saveMethod') ?>',
|
40 |
+
failure: '<?php echo $this->getUrl('checkout/cart') ?>'}
|
41 |
+
);
|
42 |
+
//]]>
|
43 |
+
</script>
|
app/design/frontend/base/default/template/easynolo/bancasellapro/gestpay/confirm3d.phtml
ADDED
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<h1><?php echo Mage::helper('easynolo_bancasellapro')->__('You will be redirected to the payment system website in a few seconds.') ?></h1>
|
2 |
+
<div>
|
3 |
+
<p><?php echo Mage::helper('easynolo_bancasellapro')->__('You are redirecting to issuing bank for 3d authentification') ?></p>
|
4 |
+
</div>
|
5 |
+
<script type="text/javascript">
|
6 |
+
//<![CDATA[
|
7 |
+
|
8 |
+
var pares = '<?php echo $this->getPARes() ?>',
|
9 |
+
cartUrl = '<?php echo $this->getCartUrl() ?>',
|
10 |
+
bs = parent.BancaSellaForm;
|
11 |
+
|
12 |
+
if (typeof bs == 'undefined') {
|
13 |
+
parent.location.href = cartUrl;
|
14 |
+
} else {
|
15 |
+
bs.sendPares(pares);
|
16 |
+
}
|
17 |
+
//]]>
|
18 |
+
</script>
|
app/design/frontend/base/default/template/easynolo/bancasellapro/gestpay/form.phtml
ADDED
@@ -0,0 +1,129 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @category EasyNolo
|
4 |
+
* @package EasyNolo_BancaSellaPro
|
5 |
+
* @author Easy Nolo <ecommerce@sella.it>
|
6 |
+
*/
|
7 |
+
?>
|
8 |
+
|
9 |
+
<?php /* @var $this EasyNolo_BancaSellaPro_Block_Form */?>
|
10 |
+
<?php /* @var $method EasyNolo_BancaSellaPro_Model_Gestpay */?>
|
11 |
+
<?php $method = $this->getMethod() ?>
|
12 |
+
<?php $_code=$this->getMethodCode() ?>
|
13 |
+
<?php $merchantId = $method->getMerchantId() ?>
|
14 |
+
|
15 |
+
<?php
|
16 |
+
try{
|
17 |
+
/** @var EasyNolo_BancaSellaPro_Helper_Crypt $helper */
|
18 |
+
$encriptString = false;
|
19 |
+
//solo se il form è richimato in ajax recupero la stringa
|
20 |
+
if( $this->isAjaxRequest() && $this->isIframeEnable() ){
|
21 |
+
$helper =Mage::helper('easynolo_bancasellapro/crypt');
|
22 |
+
$encriptString = $helper->getEncryptStringBeforeOrder($method);
|
23 |
+
}
|
24 |
+
?>
|
25 |
+
|
26 |
+
<fieldset class="form-list">
|
27 |
+
<?php $_code=$this->getMethodCode() ?>
|
28 |
+
<ul class="form-list" id="payment_iframe_<?php echo $_code ?>" style="display:none;">
|
29 |
+
<li>
|
30 |
+
<label for="<?php echo $_code ?>_cc_number" class="required"><em>*</em><?php echo $this->__('Credit Card Number') ?></label>
|
31 |
+
<div class="input-box">
|
32 |
+
<input type="text" id="hid_<?php echo $_code ?>_cc_number" name="bancasella_iframe[cc_number]" title="<?php echo $this->__('Credit Card Number') ?>" class="input-text required-entry validate-number validate-cc-number" value="" autocomplete="off" />
|
33 |
+
</div>
|
34 |
+
</li>
|
35 |
+
<li>
|
36 |
+
<label for="hid_<?php echo $_code ?>_cc_exp_mm" class="required"><em>*</em><?php echo $this->__('Expiration Date') ?></label>
|
37 |
+
<div class="input-box">
|
38 |
+
<div class="v-fix">
|
39 |
+
<select id="hid_<?php echo $_code ?>_cc_exp_mm" name="bancasella_iframe[cc_exp_mm]" class="month required-entry">
|
40 |
+
<?php foreach ($this->getCcMonths() as $k=>$v): ?>
|
41 |
+
<option value="<?php echo $k?$k:'' ?>"><?php echo $v ?></option>
|
42 |
+
<?php endforeach ?>
|
43 |
+
</select>
|
44 |
+
</div>
|
45 |
+
<div class="v-fix">
|
46 |
+
<select id="hid_<?php echo $_code ?>_cc_exp_yy" name="bancasella_iframe[cc_exp_yy]" class="year required-entry">
|
47 |
+
<?php foreach ($this->getCcYears() as $k=>$v): ?>
|
48 |
+
<option value="<?php echo $k?$k:'' ?>"><?php echo $v ?></option>
|
49 |
+
<?php endforeach ?>
|
50 |
+
</select>
|
51 |
+
</div>
|
52 |
+
</div>
|
53 |
+
</li>
|
54 |
+
<li>
|
55 |
+
<label for="<?php echo $_code ?>_cc_cvv" class="required"><em>*</em><?php echo $this->__('CVV2 / 4DBC') ?></label>
|
56 |
+
<div class="input-box">
|
57 |
+
<input type="text" id="hid_<?php echo $_code ?>_cc_cvv" name="bancasella_iframe[cc_cvv]" title="<?php echo $this->__('CVV2 / 4DBC') ?>" class="input-text required-entry validate-number" value="" autocomplete="off" />
|
58 |
+
</div>
|
59 |
+
</li>
|
60 |
+
<li>
|
61 |
+
<label for="<?php echo $_code ?>_cc_name" class="required"><em>*</em><?php echo $this->__('Name on Card') ?></label>
|
62 |
+
<div class="input-box">
|
63 |
+
<input type="text" id="hid_<?php echo $_code ?>_cc_name" name="bancasella_iframe[cc_name]" title="<?php echo $this->__('Name on Card') ?>" class="input-text required-entry" value="" autocomplete="off" />
|
64 |
+
</div>
|
65 |
+
</li>
|
66 |
+
<li>
|
67 |
+
<label for="<?php echo $_code ?>_cc_email" class="required"><em>*</em><?php echo $this->__('Email') ?></label>
|
68 |
+
<div class="input-box">
|
69 |
+
<input type="text" id="hid_<?php echo $_code ?>_cc_email" name="bancasella_iframe[cc_email]" title="<?php echo $this->__('Email') ?>" class="input-text required-entry validate-email" value="" autocomplete="off" />
|
70 |
+
</div>
|
71 |
+
</li>
|
72 |
+
|
73 |
+
</ul>
|
74 |
+
<ul id="payment_form_<?php echo $_code ?>" style="display: none;">
|
75 |
+
<li>
|
76 |
+
<?php echo $this->__($method->getConfigData ( 'description' )) ?>
|
77 |
+
</li>
|
78 |
+
</ul>
|
79 |
+
<?php if($encriptString): ?>
|
80 |
+
<script type="text/javascript">
|
81 |
+
//<![CDATA[
|
82 |
+
if ( typeof BancaSellaForm !== 'undefined'){
|
83 |
+
|
84 |
+
var GestPayConfig = {};
|
85 |
+
GestPayConfig.merchantId = '<?php echo $merchantId ?>';
|
86 |
+
GestPayConfig.stringEnctipt = '<?php echo $encriptString ?>';
|
87 |
+
GestPayConfig.formId = 'payment_iframe_<?php echo $_code ?>';
|
88 |
+
GestPayConfig.radioBancaSella= 'p_method_<?php echo $_code ?>';
|
89 |
+
GestPayConfig.cssSelectorInfo = '#payment_form_<?php echo $_code ?> li';
|
90 |
+
GestPayConfig.GestPayExternalClass = GestPay;
|
91 |
+
GestPayConfig.idStart = 'hid_<?php echo $_code ?>';
|
92 |
+
GestPayConfig.cssSelectorRadioPayment = '#checkout-payment-method-load input[type="radio"]';
|
93 |
+
GestPayConfig.confirmPage = '<?php echo $this->getPage3d(); ?>';
|
94 |
+
GestPayConfig.authPage = '<?php echo $this->getAuthPage(); ?>';
|
95 |
+
GestPayConfig.showHidePaymentDivId = 'opc-payment';
|
96 |
+
GestPayConfig.waitImage= '<?php echo $this->getSkinUrl('images/opc-ajax-loader.gif') ?>';
|
97 |
+
GestPayConfig.successRedirect = '<?php echo $this->getSuccessRedirect()?>';
|
98 |
+
GestPayConfig.isRecurringProfile= '<?php echo $this->isRecurringProfile()?>';
|
99 |
+
GestPayConfig.code= '<?php echo $_code ?>';
|
100 |
+
|
101 |
+
GestPayConfig.enableFormToIframe = typeof BrowserEnabled !== 'undefined'? BrowserEnabled : false;
|
102 |
+
|
103 |
+
BancaSellaForm.init(GestPayConfig);
|
104 |
+
}
|
105 |
+
//]]>
|
106 |
+
</script>
|
107 |
+
<?php endif; ?>
|
108 |
+
</fieldset>
|
109 |
+
<?php
|
110 |
+
}catch(Exception $e){
|
111 |
+
//se il modulo non è configurato correttamente potrebbe
|
112 |
+
$_helper= Mage::helper('easynolo_bancasellapro');
|
113 |
+
$_helper->log($e->getMessage());
|
114 |
+
|
115 |
+
if($this->isRecurringProfile()){
|
116 |
+
//quando il quote contiene un recurring profile e ci sta un eccezione allora va rimosso il form perché non puo essere completato il pagamento
|
117 |
+
?>
|
118 |
+
<script type="text/javascript">
|
119 |
+
//<![CDATA[
|
120 |
+
if ( typeof BancaSellaForm !== 'undefined' ){
|
121 |
+
BancaSellaForm.code= '<?php echo $_code ?>';
|
122 |
+
BancaSellaForm.removePaymentMethod();
|
123 |
+
}
|
124 |
+
//]]>
|
125 |
+
</script>
|
126 |
+
<?php
|
127 |
+
}
|
128 |
+
}
|
129 |
+
?>
|
app/design/frontend/base/default/template/easynolo/bancasellapro/gestpay/form_onepagecheckout.phtml
ADDED
@@ -0,0 +1,116 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @category EasyNolo
|
4 |
+
* @package EasyNolo_BancaSellaPro
|
5 |
+
* @author Easy Nolo <ecommerce@sella.it>
|
6 |
+
*/
|
7 |
+
?>
|
8 |
+
|
9 |
+
<?php /* @var $this EasyNolo_BancaSellaPro_Block_Form */?>
|
10 |
+
<?php /* @var $method EasyNolo_BancaSellaPro_Model_Gestpay */?>
|
11 |
+
<?php $method = $this->getMethod() ?>
|
12 |
+
<?php $_code=$this->getMethodCode() ?>
|
13 |
+
<?php $merchantId = $method->getMerchantId() ?>
|
14 |
+
|
15 |
+
<?php
|
16 |
+
try{
|
17 |
+
/** @var EasyNolo_BancaSellaPro_Helper_Crypt $helper */
|
18 |
+
$encriptString = false;
|
19 |
+
|
20 |
+
if( $this->isIframeEnable() ){
|
21 |
+
$helper =Mage::helper('easynolo_bancasellapro/crypt');
|
22 |
+
$encriptString = $helper->getEncryptStringBeforeOrder($method);
|
23 |
+
}
|
24 |
+
?>
|
25 |
+
|
26 |
+
<fieldset class="form-list">
|
27 |
+
<?php $_code=$this->getMethodCode() ?>
|
28 |
+
<ul class="form-list" id="payment_iframe_<?php echo $_code ?>" style="display:none;">
|
29 |
+
<li>
|
30 |
+
<label for="<?php echo $_code ?>_cc_number" class="required"><em>*</em><?php echo $this->__('Credit Card Number') ?></label>
|
31 |
+
<div class="input-box">
|
32 |
+
<input type="text" id="hid_<?php echo $_code ?>_cc_number" name="bancasella_iframe[cc_number]" title="<?php echo $this->__('Credit Card Number') ?>" class="input-text required-entry validate-number validate-cc-number" value="" autocomplete="off" />
|
33 |
+
</div>
|
34 |
+
</li>
|
35 |
+
<li>
|
36 |
+
<label for="hid_<?php echo $_code ?>_cc_exp_mm" class="required"><em>*</em><?php echo $this->__('Expiration Date') ?></label>
|
37 |
+
<div class="input-box">
|
38 |
+
<div class="v-fix">
|
39 |
+
<select id="hid_<?php echo $_code ?>_cc_exp_mm" name="bancasella_iframe[cc_exp_mm]" class="month required-entry">
|
40 |
+
<?php foreach ($this->getCcMonths() as $k=>$v): ?>
|
41 |
+
<option value="<?php echo $k?$k:'' ?>"><?php echo $v ?></option>
|
42 |
+
<?php endforeach ?>
|
43 |
+
</select>
|
44 |
+
</div>
|
45 |
+
<div class="v-fix">
|
46 |
+
<select id="hid_<?php echo $_code ?>_cc_exp_yy" name="bancasella_iframe[cc_exp_yy]" class="year required-entry">
|
47 |
+
<?php foreach ($this->getCcYears() as $k=>$v): ?>
|
48 |
+
<option value="<?php echo $k?$k:'' ?>"><?php echo $v ?></option>
|
49 |
+
<?php endforeach ?>
|
50 |
+
</select>
|
51 |
+
</div>
|
52 |
+
</div>
|
53 |
+
</li>
|
54 |
+
<li>
|
55 |
+
<label for="<?php echo $_code ?>_cc_cvv" class="required"><em>*</em><?php echo $this->__('CVV2 / 4DBC') ?></label>
|
56 |
+
<div class="input-box">
|
57 |
+
<input type="text" id="hid_<?php echo $_code ?>_cc_cvv" name="bancasella_iframe[cc_cvv]" title="<?php echo $this->__('CVV2 / 4DBC') ?>" class="input-text required-entry validate-number" value="" autocomplete="off" />
|
58 |
+
</div>
|
59 |
+
</li>
|
60 |
+
<li>
|
61 |
+
<label for="<?php echo $_code ?>_cc_name" class="required"><em>*</em><?php echo $this->__('Name on Card') ?></label>
|
62 |
+
<div class="input-box">
|
63 |
+
<input type="text" id="hid_<?php echo $_code ?>_cc_name" name="bancasella_iframe[cc_name]" title="<?php echo $this->__('Name on Card') ?>" class="input-text required-entry" value="" autocomplete="off" />
|
64 |
+
</div>
|
65 |
+
</li>
|
66 |
+
<li>
|
67 |
+
<label for="<?php echo $_code ?>_cc_email" class="required"><em>*</em><?php echo $this->__('Email') ?></label>
|
68 |
+
<div class="input-box">
|
69 |
+
<input type="text" id="hid_<?php echo $_code ?>_cc_email" name="bancasella_iframe[cc_email]" title="<?php echo $this->__('Email') ?>" class="input-text required-entry validate-email" value="" autocomplete="off" />
|
70 |
+
</div>
|
71 |
+
</li>
|
72 |
+
|
73 |
+
</ul>
|
74 |
+
|
75 |
+
<ul id="payment_form_<?php echo $_code ?>" style="display: none;">
|
76 |
+
<li>
|
77 |
+
<?php echo $this->__($method->getConfigData ( 'description' )) ?>
|
78 |
+
</li>
|
79 |
+
</ul>
|
80 |
+
<?php if($encriptString): ?>
|
81 |
+
<script type="text/javascript">
|
82 |
+
//<![CDATA[
|
83 |
+
if ( typeof BancaSellaForm !== 'undefined'){
|
84 |
+
|
85 |
+
var GestPayConfig = {};
|
86 |
+
GestPayConfig.merchantId = '<?php echo $merchantId ?>';
|
87 |
+
GestPayConfig.stringEnctipt = '<?php echo $encriptString ?>';
|
88 |
+
GestPayConfig.formId = 'payment_iframe_<?php echo $_code ?>';
|
89 |
+
GestPayConfig.radioBancaSella= 'p_method_<?php echo $_code ?>';
|
90 |
+
GestPayConfig.cssSelectorInfo = '#payment_form_<?php echo $_code ?> li';
|
91 |
+
GestPayConfig.GestPayExternalClass = GestPay;
|
92 |
+
GestPayConfig.idStart = 'hid_<?php echo $_code ?>';
|
93 |
+
GestPayConfig.cssSelectorRadioPayment = '#checkout-payment-method-load input[type="radio"]';
|
94 |
+
GestPayConfig.confirmPage = '<?php echo $this->getPage3d(); ?>';
|
95 |
+
GestPayConfig.authPage = '<?php echo $this->getAuthPage(); ?>';
|
96 |
+
GestPayConfig.showHidePaymentDivId = 'opc-payment';
|
97 |
+
GestPayConfig.waitImage= '<?php echo $this->getSkinUrl('images/opc-ajax-loader.gif') ?>';
|
98 |
+
GestPayConfig.successRedirect = '<?php echo $this->getSuccessRedirect()?>';
|
99 |
+
GestPayConfig.isRecurringProfile= '<?php echo $this->isRecurringProfile()?>';
|
100 |
+
GestPayConfig.code= '<?php echo $_code ?>';
|
101 |
+
|
102 |
+
GestPayConfig.enableFormToIframe = typeof BrowserEnabled !== 'undefined'? BrowserEnabled : false;
|
103 |
+
|
104 |
+
BancaSellaForm.init(GestPayConfig);
|
105 |
+
}
|
106 |
+
//]]>
|
107 |
+
</script>
|
108 |
+
<?php endif; ?>
|
109 |
+
</fieldset>
|
110 |
+
<?php
|
111 |
+
}catch(Exception $e){
|
112 |
+
//se il modulo non è configurato correttamente potrebbe
|
113 |
+
$_helper= Mage::helper('easynolo_bancasellapro');
|
114 |
+
$_helper->log($e->getMessage());
|
115 |
+
}
|
116 |
+
?>
|
app/design/frontend/base/default/template/easynolo/bancasellapro/gestpay/newtoken.phtml
ADDED
@@ -0,0 +1,98 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
|
2 |
+
<?php /* @var $this EasyNolo_BancaSellaPro_Block_Tokenization_Newtoken*/?>
|
3 |
+
<?php /* @var $method EasyNolo_BancaSellaPro_Model_Gestpay */?>
|
4 |
+
<?php $method = $this->getMethod() ?>
|
5 |
+
<?php $_code=$this->getMethodCode() ?>
|
6 |
+
<?php $merchantId = $method->getMerchantId() ?>
|
7 |
+
|
8 |
+
<?php
|
9 |
+
|
10 |
+
/** @var EasyNolo_BancaSellaPro_Helper_Crypt $helper */
|
11 |
+
$encriptString = false;
|
12 |
+
//solo se il form è richimato in ajax recupero la stringa
|
13 |
+
if( $method->isIframeEnable() ){
|
14 |
+
$encriptString = $this->getEncryptString();
|
15 |
+
}
|
16 |
+
?>
|
17 |
+
<div class="fieldset" id="tokenization-form">
|
18 |
+
<h2 class="legend"><?php echo $this->__('Credit Card Data')?></h2>
|
19 |
+
<ul class="form-list">
|
20 |
+
<li>
|
21 |
+
<label for="<?php echo $_code ?>_cc_number" class="required"><em>*</em><?php echo $this->__('Credit Card Number') ?></label>
|
22 |
+
<div class="input-box">
|
23 |
+
<input type="text" id="<?php echo $_code ?>_cc_number" name="bancasella_iframe[cc_number]" title="<?php echo $this->__('Credit Card Number') ?>" class="input-text required-entry validate-number validate-cc-number" value="" autocomplete="off" />
|
24 |
+
</div>
|
25 |
+
</li>
|
26 |
+
<li>
|
27 |
+
<label for="<?php echo $_code ?>_cc_exp_mm" class="required"><em>*</em><?php echo $this->__('Expiration Date') ?></label>
|
28 |
+
<div class="input-box">
|
29 |
+
<div class="v-fix">
|
30 |
+
<select id="<?php echo $_code ?>_cc_exp_mm" name="bancasella_iframe[cc_exp_mm]" class="month required-entry">
|
31 |
+
<?php foreach ($this->getCcMonths() as $k=>$v): ?>
|
32 |
+
<option value="<?php echo $k?$k:'' ?>"><?php echo $v ?></option>
|
33 |
+
<?php endforeach ?>
|
34 |
+
</select>
|
35 |
+
</div>
|
36 |
+
<div class="v-fix">
|
37 |
+
<select id="<?php echo $_code ?>_cc_exp_yy" name="bancasella_iframe[cc_exp_yy]" class="year required-entry">
|
38 |
+
<?php foreach ($this->getCcYears() as $k=>$v): ?>
|
39 |
+
<option value="<?php echo $k?$k:'' ?>"><?php echo $v ?></option>
|
40 |
+
<?php endforeach ?>
|
41 |
+
</select>
|
42 |
+
</div>
|
43 |
+
</div>
|
44 |
+
</li>
|
45 |
+
<li>
|
46 |
+
<label for="<?php echo $_code ?>_cc_cvv" class="required"><em>*</em><?php echo $this->__('CVV2 / 4DBC') ?></label>
|
47 |
+
<div class="input-box">
|
48 |
+
<input type="text" id="<?php echo $_code ?>_cc_cvv" name="bancasella_iframe[cc_cvv]" title="<?php echo $this->__('CVV2 / 4DBC') ?>" class="input-text required-entry validate-number" value="" autocomplete="off" />
|
49 |
+
</div>
|
50 |
+
</li>
|
51 |
+
<li>
|
52 |
+
<label for="<?php echo $_code ?>_cc_name" class="required"><em>*</em><?php echo $this->__('Name on Card') ?></label>
|
53 |
+
<div class="input-box">
|
54 |
+
<input type="text" id="<?php echo $_code ?>_cc_name" name="bancasella_iframe[cc_name]" title="<?php echo $this->__('Name on Card') ?>" class="input-text required-entry" value="" autocomplete="off" />
|
55 |
+
</div>
|
56 |
+
</li>
|
57 |
+
<li>
|
58 |
+
<label for="<?php echo $_code ?>_cc_email" class="required"><em>*</em><?php echo $this->__('Email') ?></label>
|
59 |
+
<div class="input-box">
|
60 |
+
<input type="text" id="<?php echo $_code ?>_cc_email" name="bancasella_iframe[cc_email]" title="<?php echo $this->__('Email') ?>" class="input-text required-entry validate-email" value="" autocomplete="off" />
|
61 |
+
</div>
|
62 |
+
</li>
|
63 |
+
|
64 |
+
</ul>
|
65 |
+
</div>
|
66 |
+
|
67 |
+
<div class="buttons-set">
|
68 |
+
<p class="required"><?php echo $this->__('* Required Fields'); ?></p>
|
69 |
+
<button title="<?php echo $this->__('Send'); ?>" class="button" onclick="EasyNoloTokenization.sendPaymentIframe()"><span><span><?php echo $this->__('Send'); ?></span></span></button>
|
70 |
+
</div>
|
71 |
+
<?php if($encriptString): ?>
|
72 |
+
<script type="text/javascript">
|
73 |
+
//<![CDATA[
|
74 |
+
if ( typeof EasyNoloTokenization !== 'undefined'){
|
75 |
+
|
76 |
+
var GestPayConfig = {};
|
77 |
+
GestPayConfig.merchantId = '<?php echo $merchantId ?>';
|
78 |
+
GestPayConfig.stringEnctipt = '<?php echo $encriptString ?>';
|
79 |
+
GestPayConfig.formId = 'tokenization-form';
|
80 |
+
GestPayConfig.GestPayExternalClass = GestPay;
|
81 |
+
GestPayConfig.waitImage= '<?php echo $this->getSkinUrl('images/opc-ajax-loader.gif') ?>';
|
82 |
+
GestPayConfig.successRedirect = '<?php echo $this->getSuccessRedirect()?>';
|
83 |
+
GestPayConfig.disableProfileRedirect = '<?php echo $this->getDisableProfileRedirect()?>';
|
84 |
+
GestPayConfig.code= '<?php echo $_code ?>';
|
85 |
+
GestPayConfig.enableFormToIframe = typeof BrowserEnabled !== 'undefined'? BrowserEnabled : false;
|
86 |
+
|
87 |
+
EasyNoloTokenization.init(GestPayConfig);
|
88 |
+
}
|
89 |
+
//]]>
|
90 |
+
</script>
|
91 |
+
<?php endif; ?>
|
92 |
+
|
93 |
+
</div>
|
94 |
+
<script type="text/javascript">
|
95 |
+
//<![CDATA[
|
96 |
+
var dataForm = new VarienForm('tokenization-form', true);
|
97 |
+
//]]>
|
98 |
+
</script>
|
app/design/frontend/base/default/template/easynolo/bancasellapro/gestpay/redirect.phtml
ADDED
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @category EasyNolo
|
4 |
+
* @package EasyNolo_BancaSellaPro
|
5 |
+
* @author Easy Nolo <ecommerce@sella.it>
|
6 |
+
*/
|
7 |
+
?>
|
8 |
+
<div class="page-title">
|
9 |
+
<h1><img src="<?php echo $this->getSkinUrl('images/easynolo_bancasella/wait.gif') ?>" class="logo" alt="<?php echo $this->__('You are redirecting to Banca Sella for completion of payment') ?>" /><?php echo $this->__('You are redirecting to Banca Sella for completion of payment') ?></h1>
|
10 |
+
</div>
|
11 |
+
<?php if($this->getMessage()): ?>
|
12 |
+
<p><?php echo $this->getMessage() ?></p>
|
13 |
+
<?php endif; ?>
|
14 |
+
<?php echo $this->getRedirectOutput() ?>
|
15 |
+
<?php if(!$this->isHtmlFormRedirect()): ?>
|
16 |
+
<p><?php echo $this->__('Click <a href="%s">here</a> if you are not redirected within 10 seconds...', $this->getTargetURL()) ?></p>
|
17 |
+
<?php endif; ?>
|
app/design/frontend/base/default/template/easynolo/bancasellapro/page/redirect.phtml
ADDED
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Template for EasyNolo_BancaSellaPro_Block_Newroot
|
4 |
+
*/
|
5 |
+
?>
|
6 |
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
7 |
+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<?php echo $this->getLang() ?>" lang="<?php echo $this->getLang() ?>">
|
8 |
+
<head>
|
9 |
+
<?php echo $this->getChildHtml('head') ?>
|
10 |
+
</head>
|
11 |
+
<body class="page-print<?php echo $this->getBodyClass()?$this->getBodyClass():'' ?>">
|
12 |
+
<div>
|
13 |
+
<div class="print-head">
|
14 |
+
<img src="<?php echo $this->getPrintLogoUrl() ? $this->getPrintLogoUrl() : $this->getSkinUrl('images/logo_print.gif') ?>" class="logo" alt="" />
|
15 |
+
<?php if ($this->getPrintLogoText()):?>
|
16 |
+
<address><?php echo nl2br($this->htmlEscape($this->getPrintLogoText())) ?></address>
|
17 |
+
<?php endif;?>
|
18 |
+
</div>
|
19 |
+
<?php echo $this->getChildHtml('content') ?>
|
20 |
+
</div>
|
21 |
+
</body>
|
22 |
+
</html>
|
app/design/frontend/enterprise/default/layout/easynolo_bancasellapro.xml
ADDED
@@ -0,0 +1,71 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<layout>
|
3 |
+
|
4 |
+
<easynolo_bancasellapro_gestpay_redirect>
|
5 |
+
<label>Redirect...</label>
|
6 |
+
|
7 |
+
<block type="easynolo_bancasellapro/newroot" name="root" output="toHtml" template="easynolo/bancasellapro/page/redirect.phtml">
|
8 |
+
|
9 |
+
<block type="core/text_list" name="content" as="content" translate="label">
|
10 |
+
<label>Main Content Area</label>
|
11 |
+
<block type="easynolo_bancasellapro/redirect" name="bancasella_gestpay_redirect" template="easynolo/bancasellapro/gestpay/redirect.phtml"/>
|
12 |
+
</block>
|
13 |
+
|
14 |
+
</block>
|
15 |
+
|
16 |
+
</easynolo_bancasellapro_gestpay_redirect>
|
17 |
+
|
18 |
+
<easynolo_bancasellapro_gestpay_success translate="label">
|
19 |
+
<label>Checkout Success</label>
|
20 |
+
<reference name="root">
|
21 |
+
<action method="setTemplate"><template>page/2columns-right.phtml</template></action>
|
22 |
+
</reference>
|
23 |
+
<reference name="content">
|
24 |
+
<block type="checkout/onepage_success" name="checkout.success" template="checkout/success.phtml"/>
|
25 |
+
</reference>
|
26 |
+
</easynolo_bancasellapro_gestpay_success>
|
27 |
+
|
28 |
+
|
29 |
+
<easynolo_bancasellapro_gestpay_confirm3d>
|
30 |
+
<block type="easynolo_bancasellapro/newroot" name="root" output="toHtml" template="easynolo/bancasellapro/page/redirect.phtml">
|
31 |
+
<block type="core/text_list" name="content" as="content" translate="label">
|
32 |
+
<block type="easynolo_bancasellapro/confirm3d" name="bancasellagestpay_confirm"
|
33 |
+
template="easynolo/bancasellapro/gestpay/confirm3d.phtml" />
|
34 |
+
</block>
|
35 |
+
</block>
|
36 |
+
|
37 |
+
</easynolo_bancasellapro_gestpay_confirm3d>
|
38 |
+
|
39 |
+
<checkout_onepage_index>
|
40 |
+
<reference name="head">
|
41 |
+
|
42 |
+
<block type="easynolo_bancasellapro/utility_text" name="gestpay.iframe.external"/>
|
43 |
+
<action method="addJs"><script>prototype/window.js</script></action>
|
44 |
+
<action method="addItem"><type>js_css</type><name>prototype/windows/themes/default.css</name></action>
|
45 |
+
<action method="addCss"><name>lib/prototype/windows/themes/magento.css</name></action>
|
46 |
+
</reference>
|
47 |
+
<reference name="checkout.onepage">
|
48 |
+
<action method="setTemplate">
|
49 |
+
<template>easynolo/bancasellapro/checkout/onepage.phtml</template>
|
50 |
+
</action>
|
51 |
+
</reference>
|
52 |
+
</checkout_onepage_index>
|
53 |
+
|
54 |
+
|
55 |
+
<!--WARNING: this is a fix to magento 11.1. Comment before handle and enable this-->
|
56 |
+
<!-- <checkout_onepage_index>
|
57 |
+
<reference name="head">
|
58 |
+
|
59 |
+
<block type="easynolo_bancasellapro/utility_text" name="gestpay.iframe.external"/>
|
60 |
+
<action method="addJs"><script>prototype/window.js</script></action>
|
61 |
+
<action method="addItem"><type>js_css</type><name>prototype/windows/themes/default.css</name></action>
|
62 |
+
<action method="addItem"><type>js_css</type><name>prototype/windows/themes/magento.css</name></action>
|
63 |
+
</reference>
|
64 |
+
<reference name="checkout.onepage">
|
65 |
+
<action method="setTemplate">
|
66 |
+
<template>easynolo/bancasellapro/checkout/onepage.phtml</template>
|
67 |
+
</action>
|
68 |
+
</reference>
|
69 |
+
</checkout_onepage_index> -->
|
70 |
+
|
71 |
+
</layout>
|
app/design/frontend/enterprise/default/template/easynolo/bancasellapro/checkout/onepage.phtml
ADDED
@@ -0,0 +1,42 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<div class="opc-wrapper">
|
2 |
+
<div class="page-title">
|
3 |
+
<?php echo $this->getChildHtml('checkoutCallout') ?>
|
4 |
+
<h1><?php echo $this->__('Checkout') ?></h1>
|
5 |
+
</div>
|
6 |
+
<script type="text/javascript" src="<?php echo $this->getJsUrl('varien/accordion.js') ?>"></script>
|
7 |
+
<script type="text/javascript" src="<?php echo $this->getSkinUrl('js/opcheckout.js') ?>"></script>
|
8 |
+
<script type="text/javascript" src="<?php echo $this->getJsUrl('bancasellapro/gestpayform.js') ?>"></script>
|
9 |
+
<script type="text/javascript">countryRegions = <?php echo $this->helper('directory')->getRegionJson() ?></script>
|
10 |
+
<div class="opc-progress-container" id="col-right-opcheckout">
|
11 |
+
<?php echo $this->getChildHtml('checkoutProgress') ?>
|
12 |
+
</div>
|
13 |
+
<ol class="opc" id="checkoutSteps">
|
14 |
+
<?php $i=0; foreach($this->getSteps() as $_stepId => $_stepInfo): ?>
|
15 |
+
<?php if (!$this->getChild($_stepId) || !$this->getChild($_stepId)->isShow()): continue; endif; $i++ ?>
|
16 |
+
<li id="opc-<?php echo $_stepId ?>" class="section<?php echo !empty($_stepInfo['allow'])?' allow':'' ?><?php echo !empty($_stepInfo['complete'])?' saved':'' ?>">
|
17 |
+
<div class="step-title">
|
18 |
+
<span class="number"><?php echo $i ?></span>
|
19 |
+
<h2><?php echo $_stepInfo['label'] ?></h2>
|
20 |
+
<!--<a href="#"><?php echo $this->__('Edit') ?></a>-->
|
21 |
+
</div>
|
22 |
+
<div id="checkout-step-<?php echo $_stepId ?>" class="step a-item" style="display:none;">
|
23 |
+
<?php echo $this->getChildHtml($_stepId) ?>
|
24 |
+
</div>
|
25 |
+
</li>
|
26 |
+
<?php endforeach ?>
|
27 |
+
</ol>
|
28 |
+
<script type="text/javascript">
|
29 |
+
//<![CDATA[
|
30 |
+
var accordion = new Accordion('checkoutSteps', '.step-title', true);
|
31 |
+
<?php if($this->getActiveStep()): ?>
|
32 |
+
accordion.openSection('opc-<?php echo $this->getActiveStep() ?>');
|
33 |
+
<?php endif ?>
|
34 |
+
var checkout = new Checkout(accordion,{
|
35 |
+
progress: '<?php echo $this->getUrl('checkout/onepage/progress') ?>',
|
36 |
+
review: '<?php echo $this->getUrl('checkout/onepage/review') ?>',
|
37 |
+
saveMethod: '<?php echo $this->getUrl('checkout/onepage/saveMethod') ?>',
|
38 |
+
failure: '<?php echo $this->getUrl('checkout/cart') ?>'}
|
39 |
+
);
|
40 |
+
//]]>
|
41 |
+
</script>
|
42 |
+
</div>
|
app/etc/modules/EasyNolo_BancaSellaPro.xml
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<modules>
|
4 |
+
<EasyNolo_BancaSellaPro>
|
5 |
+
<active>true</active>
|
6 |
+
<codePool>community</codePool>
|
7 |
+
</EasyNolo_BancaSellaPro>
|
8 |
+
</modules>
|
9 |
+
</config>
|
app/etc/modules/EasyNolo_BancaSellaPro.xml.Onepage.txt
ADDED
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<modules>
|
4 |
+
<EasyNolo_BancaSellaPro>
|
5 |
+
<active>true</active>
|
6 |
+
<codePool>community</codePool>
|
7 |
+
<depends>
|
8 |
+
<!--WARNING: Only if you use IWD_Opc you have to enable the follow depends-->
|
9 |
+
<IWD_Opc />
|
10 |
+
</depends>
|
11 |
+
</EasyNolo_BancaSellaPro>
|
12 |
+
</modules>
|
13 |
+
</config>
|
app/locale/en_US/EasyNolo_BancaSellaPro.csv
ADDED
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
Attendi il completamento del pagamento, Wait for the completion of payment
|
2 |
+
Attendi..., Wait
|
3 |
+
Problema sulla verifica della carta,Problem on the card verification
|
4 |
+
Continua su bancasella, Continue on bancasella website
|
5 |
+
Conferma,Confirm
|
6 |
+
Correggi i campi evidenziati,Please correct the highlighted fields
|
7 |
+
3D secure,3D secure
|
app/locale/it_IT/EasyNolo_BancaSellaPro.csv
ADDED
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
Attendi il completamento del pagamento,Attendi il completamento del pagamento
|
2 |
+
Attendi...,Attendi...
|
3 |
+
Problema sulla verifica della carta,Problema sulla verifica della carta
|
4 |
+
Continua su bancasella,Continua su bancasella
|
5 |
+
Conferma,Conferma
|
6 |
+
Correggi i campi evidenziati,Correggi i campi evidenziati
|
7 |
+
3D secure,3D secure
|
js/bancasellapro/gestpayform.js
ADDED
@@ -0,0 +1,464 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
if (typeof BancaSellaForm == 'undefined') {
|
2 |
+
|
3 |
+
var BancaSellaForm = {
|
4 |
+
formId : false,
|
5 |
+
merchantId : false,
|
6 |
+
stringEnctipt : false,
|
7 |
+
radioBancaSella : false,
|
8 |
+
cssSelectorInfo : false,
|
9 |
+
GestPayExternalClass : false,
|
10 |
+
enable : false,
|
11 |
+
idStart : false,
|
12 |
+
cssSelectorRadioPayment : false,
|
13 |
+
redirectSuccessUrl : false,
|
14 |
+
redirectAfterIframe : false,
|
15 |
+
confirmPage : false,
|
16 |
+
authPage : false,
|
17 |
+
dialogCC : false,
|
18 |
+
lock: false,
|
19 |
+
modal3d : false,
|
20 |
+
successRedirect : false,
|
21 |
+
code:null,
|
22 |
+
enableFormToIframe:false,
|
23 |
+
isRecurringProfile:false,
|
24 |
+
|
25 |
+
init : function (config){
|
26 |
+
this.formId = config.formId;
|
27 |
+
this.merchantId = config.merchantId;
|
28 |
+
this.stringEnctipt = config.stringEnctipt;
|
29 |
+
this.radioBancaSella = config.radioBancaSella;
|
30 |
+
this.cssSelectorInfo = config.cssSelectorInfo;
|
31 |
+
this.idStart = config.idStart;
|
32 |
+
this.cssSelectorRadioPayment = config.cssSelectorRadioPayment;
|
33 |
+
this.showHidePaymentDivId = config.showHidePaymentDivId;
|
34 |
+
this.confirmPage = config.confirmPage;
|
35 |
+
this.authPage = config.authPage;
|
36 |
+
this.waitImage = config.waitImage;
|
37 |
+
this.GestPayExternalClass = config.GestPayExternalClass;
|
38 |
+
this.successRedirect = config.successRedirect;
|
39 |
+
this.enableFormToIframe= config.enableFormToIframe;
|
40 |
+
this.code= config.code;
|
41 |
+
this.isRecurringProfile= config.isRecurringProfile;
|
42 |
+
|
43 |
+
if(!this.enableFormToIframe && this.isRecurringProfile){
|
44 |
+
this.removePaymentMethod();
|
45 |
+
}else if (this.enableFormToIframe){
|
46 |
+
this.start();
|
47 |
+
// al click sulla form visibile e con input disabilitati, la funzione li riabilita
|
48 |
+
$(this.showHidePaymentDivId).down('.step-title').on('click', this.checkClickPayment.bind(this));
|
49 |
+
}
|
50 |
+
},
|
51 |
+
start : function(){
|
52 |
+
if(!this.lock){
|
53 |
+
|
54 |
+
this.showWait();
|
55 |
+
this.GestPayExternalClass.CreatePaymentPage( this.merchantId, this.stringEnctipt, this.paymentPageLoad);
|
56 |
+
|
57 |
+
$$(this.cssSelectorRadioPayment).each(
|
58 |
+
function(item){
|
59 |
+
Event.observe(item, 'click', BancaSellaForm.togglePaymentForm);
|
60 |
+
}
|
61 |
+
);
|
62 |
+
//aggiorniamo lo stato del form al caricamento del pagamento
|
63 |
+
payment.addAfterInitFunction('update-get-pay-form',BancaSellaForm.togglePaymentForm);
|
64 |
+
|
65 |
+
//aggiungiamo la validazione del form con i dati della carta nello step di pagamento
|
66 |
+
// e la rimozione del form per non far inviare i dati
|
67 |
+
payment.addBeforeValidateFunction('before-validate-gest-pay',function(){
|
68 |
+
if(!BancaSellaForm.lock){
|
69 |
+
if(BancaSellaForm.enable){
|
70 |
+
var validator = new Validation($(BancaSellaForm.formId ));
|
71 |
+
if (!validator.validate())
|
72 |
+
return false;
|
73 |
+
var form =$(BancaSellaForm.formId );
|
74 |
+
BancaSellaForm.realForm=form;
|
75 |
+
Form.getElements(form).each(function (input){
|
76 |
+
input.disabled=true;
|
77 |
+
});
|
78 |
+
}
|
79 |
+
}
|
80 |
+
//restituisco true per la validazione
|
81 |
+
return true;
|
82 |
+
});
|
83 |
+
|
84 |
+
}
|
85 |
+
},
|
86 |
+
|
87 |
+
checkClickPayment : function (){
|
88 |
+
if(BancaSellaForm.enable
|
89 |
+
&& $(BancaSellaForm.showHidePaymentDivId).hasClassName('allow')) {
|
90 |
+
Form.getElements($(BancaSellaForm.formId )).each(function (input){
|
91 |
+
if(input.hasAttribute('disabled') && input.readAttribute('disable') != false ){
|
92 |
+
BancaSellaForm.enableInputs();
|
93 |
+
return;
|
94 |
+
}
|
95 |
+
});
|
96 |
+
}
|
97 |
+
},
|
98 |
+
toggleStatusForm : function (isEnable){
|
99 |
+
if(isEnable){
|
100 |
+
this.lock = false;
|
101 |
+
this.enable = false;
|
102 |
+
this.togglePaymentForm();
|
103 |
+
//nascondo il messaggio del redirect dopo la conferma ordine
|
104 |
+
$$(this.cssSelectorInfo).first().hide();
|
105 |
+
}else{
|
106 |
+
this.disableForm();
|
107 |
+
//mostro il messaggio del redirect dopo la conferma ordine
|
108 |
+
$$(this.cssSelectorInfo).first().show();
|
109 |
+
this.lock = true;
|
110 |
+
}
|
111 |
+
},
|
112 |
+
toggleForm: function (){
|
113 |
+
if(!this.lock){
|
114 |
+
if(this.enable && this.formId){
|
115 |
+
this.disableForm();
|
116 |
+
}
|
117 |
+
else{
|
118 |
+
this.enableForm();
|
119 |
+
}
|
120 |
+
}
|
121 |
+
},
|
122 |
+
enableForm : function (){
|
123 |
+
if(!this.lock){
|
124 |
+
if(!this.enable ){
|
125 |
+
$(this.formId).show();
|
126 |
+
Form.enable( $(this.formId));
|
127 |
+
this.enable = true;
|
128 |
+
}
|
129 |
+
return true;
|
130 |
+
}
|
131 |
+
return false;
|
132 |
+
},
|
133 |
+
disableForm : function(){
|
134 |
+
if(!this.lock){
|
135 |
+
if(this.enable ){
|
136 |
+
$(this.formId).hide();
|
137 |
+
Form.disable( $(this.formId));
|
138 |
+
this.enable = false;
|
139 |
+
}
|
140 |
+
return true;
|
141 |
+
}
|
142 |
+
return false;
|
143 |
+
},
|
144 |
+
enableInputs : function (){
|
145 |
+
Form.getElements($(BancaSellaForm.formId )).each(function (input){
|
146 |
+
input.disabled=false;
|
147 |
+
});
|
148 |
+
},
|
149 |
+
debugInputForm : function (){
|
150 |
+
var obj ={
|
151 |
+
CC : $F($(this.idStart+'_cc_number')),
|
152 |
+
EXPMM : $F($(this.idStart+'_cc_exp_mm')),
|
153 |
+
EXPYY : $F($(this.idStart+'_cc_exp_yy')),
|
154 |
+
CVV2 : $F($(this.idStart+'_cc_cvv')),
|
155 |
+
Name: $F($(this.idStart+'_cc_name')),
|
156 |
+
Email: $F($(this.idStart+'_cc_email'))
|
157 |
+
};
|
158 |
+
console.log(obj);
|
159 |
+
},
|
160 |
+
|
161 |
+
togglePaymentForm : function (){
|
162 |
+
if($(BancaSellaForm.radioBancaSella).checked){
|
163 |
+
BancaSellaForm.enableForm();
|
164 |
+
}else{
|
165 |
+
BancaSellaForm.disableForm();
|
166 |
+
}
|
167 |
+
return false;
|
168 |
+
},
|
169 |
+
paymentPageLoad : function( Result ){
|
170 |
+
BancaSellaForm.hideWait();
|
171 |
+
if(Result.ErrorCode != 10){
|
172 |
+
BancaSellaForm.toggleStatusForm(false);
|
173 |
+
}else{
|
174 |
+
BancaSellaForm.toggleStatusForm(true);
|
175 |
+
}
|
176 |
+
},
|
177 |
+
sendPaymentIframe : function (){
|
178 |
+
BancaSellaForm.showWait();
|
179 |
+
BancaSellaForm.GestPayExternalClass.SendPayment ({
|
180 |
+
CC : BancaSellaForm.ccData.cc,
|
181 |
+
EXPMM : BancaSellaForm.ccData.expmm,
|
182 |
+
EXPYY : BancaSellaForm.ccData.expyy,
|
183 |
+
CVV2 : BancaSellaForm.ccData.cvv2,
|
184 |
+
Name: BancaSellaForm.ccData.name,
|
185 |
+
Email: BancaSellaForm.ccData.email
|
186 |
+
},
|
187 |
+
function ( Result ) {
|
188 |
+
BancaSellaForm.hideWait();
|
189 |
+
BancaSellaForm.analizeResponse.delay(0.8,Result);
|
190 |
+
}
|
191 |
+
);
|
192 |
+
return true;
|
193 |
+
},
|
194 |
+
analizeResponse : function(Result){
|
195 |
+
|
196 |
+
if (Result.ErrorCode != 0){
|
197 |
+
if (Result.ErrorCode == 8006){
|
198 |
+
//3D Transaction
|
199 |
+
var TransKey = Result.TransKey;
|
200 |
+
var VBVRisp = Result.VBVRisp;
|
201 |
+
BancaSellaForm.call3dSecure ( TransKey, VBVRisp );
|
202 |
+
}else{
|
203 |
+
|
204 |
+
var idErrorInput = '';
|
205 |
+
if(Result.ErrorCode == 1119 || Result.ErrorCode == 1120){
|
206 |
+
idErrorInput= BancaSellaForm.idStart+'_cc_number';
|
207 |
+
}else
|
208 |
+
if(Result.ErrorCode == 1124 || Result.ErrorCode == 1126){
|
209 |
+
idErrorInput= BancaSellaForm.idStart+'_cc_exp_mm'
|
210 |
+
} else
|
211 |
+
if(Result.ErrorCode == 1125){
|
212 |
+
idErrorInput= BancaSellaForm.idStart+'_cc_exp_yy'
|
213 |
+
}else
|
214 |
+
if(Result.ErrorCode == 1149){
|
215 |
+
idErrorInput= BancaSellaForm.idStart+'_cc_cvv'
|
216 |
+
}else
|
217 |
+
{
|
218 |
+
//altri errori, uno dei possibili 4707
|
219 |
+
Dialog.alert(Result.ErrorDescription,
|
220 |
+
{
|
221 |
+
className:'magento',
|
222 |
+
width:300,
|
223 |
+
height:90,
|
224 |
+
zIndex:1000,
|
225 |
+
okLabel: Translator.translate('Complete payment on Banca Sella website'),
|
226 |
+
buttonClass: "scalable",
|
227 |
+
id: "alertRedirect",
|
228 |
+
title: Translator.translate('Payment authorization error'),
|
229 |
+
onOk: BancaSellaForm.redirectPaymentPage
|
230 |
+
}
|
231 |
+
);
|
232 |
+
return false;
|
233 |
+
}
|
234 |
+
BancaSellaForm.showModalDialogCC(idErrorInput, Result.ErrorDescription);
|
235 |
+
return false;
|
236 |
+
}
|
237 |
+
}else{
|
238 |
+
//pagamento effettuato con successo oppure l'utente ha annullato il 3dsecure;
|
239 |
+
url = BancaSellaForm.successRedirect + '?a='+ BancaSellaForm.merchantId + '&b='+ Result.EncryptedString;
|
240 |
+
location.href = url;
|
241 |
+
return;
|
242 |
+
}
|
243 |
+
},
|
244 |
+
call3dSecure : function (TransKey, VBVRisp){
|
245 |
+
BancaSellaForm.transKey=TransKey;
|
246 |
+
var a = this.merchantId;
|
247 |
+
var b = VBVRisp;
|
248 |
+
var c= BancaSellaForm.confirmPage;
|
249 |
+
var definitiveUrl = BancaSellaForm.authPage+'?a='+a+'&b='+b+'&c='+c ;
|
250 |
+
BancaSellaForm.showModal(definitiveUrl);
|
251 |
+
},
|
252 |
+
redirectPaymentPage : function (){
|
253 |
+
setLocation(BancaSellaForm.successRedirect);
|
254 |
+
return;
|
255 |
+
},
|
256 |
+
showModal : function (url)
|
257 |
+
{
|
258 |
+
this.modal3d = new Window(
|
259 |
+
{
|
260 |
+
className:'magento',
|
261 |
+
id:'gestpay_window',
|
262 |
+
title:Translator.translate('3D secure'),
|
263 |
+
url:url,
|
264 |
+
width:400,
|
265 |
+
height:400,
|
266 |
+
zIndex:1000,
|
267 |
+
minimizable: false,
|
268 |
+
maximizable : false,
|
269 |
+
closable:false,
|
270 |
+
destroyOnClose:true,
|
271 |
+
recenterAuto:true
|
272 |
+
});
|
273 |
+
this.modal3d.setZIndex(1000);
|
274 |
+
this.modal3d.showCenter(true);
|
275 |
+
},
|
276 |
+
//chiamata dall'iframe e non in questa pagina
|
277 |
+
sendPares : function (pares){
|
278 |
+
this.modal3d.close();
|
279 |
+
BancaSellaForm.showWait.delay(0.8);
|
280 |
+
this.GestPayExternalClass.SendPayment ({
|
281 |
+
PARes : pares ,
|
282 |
+
TransKey : BancaSellaForm.transKey
|
283 |
+
},
|
284 |
+
function ( Result ) {
|
285 |
+
BancaSellaForm.hideWait();
|
286 |
+
BancaSellaForm.analizeResponse.delay(0.8,Result);
|
287 |
+
}
|
288 |
+
);
|
289 |
+
return false;
|
290 |
+
},
|
291 |
+
showModalDialogCC : function( id, message ){
|
292 |
+
var form = BancaSellaForm.realForm;
|
293 |
+
|
294 |
+
BancaSellaForm.populateForm(form,id,false);
|
295 |
+
|
296 |
+
BancaSellaForm.checkAndCloseDialogCC();
|
297 |
+
|
298 |
+
if (!BancaSellaForm.dialogCC){
|
299 |
+
|
300 |
+
BancaSellaForm.dialogCC = Dialog.alert('<div id="modal-form"><ul class="form-list">'+form.innerHTML+'</ul></div>',
|
301 |
+
{
|
302 |
+
className:'magento',
|
303 |
+
closeOnEsc:false,
|
304 |
+
width:300,
|
305 |
+
height:400,
|
306 |
+
zIndex:1000,
|
307 |
+
okLabel: Translator.translate('Send Credit Card Data'),
|
308 |
+
buttonClass: "scalable",
|
309 |
+
id: "dialogcc",
|
310 |
+
title: Translator.translate('Please correct the highlighted fields'),
|
311 |
+
onOk: function (){
|
312 |
+
var validator = new Validation($('modal-form'));
|
313 |
+
if (!validator.validate())
|
314 |
+
return false;
|
315 |
+
BancaSellaForm.saveDataCC($('modal-form'));
|
316 |
+
|
317 |
+
BancaSellaForm.sendPaymentIframe.delay(0.8);
|
318 |
+
return true;
|
319 |
+
}
|
320 |
+
}
|
321 |
+
);
|
322 |
+
}
|
323 |
+
alert(message);
|
324 |
+
// BancaSellaForm.openAlert(message);
|
325 |
+
},
|
326 |
+
openAlert : function (message){
|
327 |
+
Dialog.alert(message,
|
328 |
+
{ className:'magento', width:280, height:100, okLabel: "ok",
|
329 |
+
ok:function() { return true;}
|
330 |
+
}
|
331 |
+
);
|
332 |
+
},
|
333 |
+
showWait : function(){
|
334 |
+
Dialog.info('<img src="'+BancaSellaForm.waitImage+'" class="v-middle" />'+ Translator.translate('Please wait...'),
|
335 |
+
{ className:'magento',
|
336 |
+
width:150,
|
337 |
+
height:50,
|
338 |
+
zIndex:1000
|
339 |
+
}
|
340 |
+
);
|
341 |
+
},
|
342 |
+
hideWait: function(){
|
343 |
+
Dialog.closeInfo();
|
344 |
+
},
|
345 |
+
saveDataCC :function (form){
|
346 |
+
BancaSellaForm.ccData=[];
|
347 |
+
BancaSellaForm.ccData.cc = $F(form.getElementsBySelector('#'+BancaSellaForm.idStart+'_cc_number').first());
|
348 |
+
BancaSellaForm.ccData.expmm = $F(form.getElementsBySelector('#'+BancaSellaForm.idStart+'_cc_exp_mm').first());
|
349 |
+
BancaSellaForm.ccData.expyy = $F(form.getElementsBySelector('#'+BancaSellaForm.idStart+'_cc_exp_yy').first());
|
350 |
+
BancaSellaForm.ccData.cvv2 = $F(form.getElementsBySelector('#'+BancaSellaForm.idStart+'_cc_cvv').first());
|
351 |
+
BancaSellaForm.ccData.name = $F(form.getElementsBySelector('#'+BancaSellaForm.idStart+'_cc_name').first());
|
352 |
+
BancaSellaForm.ccData.email = $F(form.getElementsBySelector('#'+BancaSellaForm.idStart+'_cc_email').first());
|
353 |
+
return true;
|
354 |
+
},
|
355 |
+
populateForm:function(form,id,enable){
|
356 |
+
Form.getElements(form).each(function (input){
|
357 |
+
input.disabled=enable;
|
358 |
+
if(input.id == id){
|
359 |
+
input.addClassName('validation-failed');
|
360 |
+
}else {
|
361 |
+
input.removeClassName('validation-failed');
|
362 |
+
}
|
363 |
+
switch (input.id){
|
364 |
+
case BancaSellaForm.idStart+'_cc_number':
|
365 |
+
input.setAttribute('value',BancaSellaForm.ccData.cc);
|
366 |
+
break;
|
367 |
+
case BancaSellaForm.idStart+'_cc_exp_mm':
|
368 |
+
options = input.childElements();
|
369 |
+
len = options.length;
|
370 |
+
for (var i = 0; i < len; i++) {
|
371 |
+
if(options[i].value == BancaSellaForm.ccData.expmm){
|
372 |
+
options[i].setAttribute('selected',true);
|
373 |
+
}
|
374 |
+
}
|
375 |
+
break;
|
376 |
+
case BancaSellaForm.idStart+'_cc_exp_yy':
|
377 |
+
options = input.childElements();
|
378 |
+
len = options.length;
|
379 |
+
for (var i = 0; i < len; i++) {
|
380 |
+
if(options[i].value == BancaSellaForm.ccData.expyy){
|
381 |
+
options[i].setAttribute('selected',true);
|
382 |
+
}
|
383 |
+
}
|
384 |
+
break;
|
385 |
+
case BancaSellaForm.idStart+'_cc_cvv':
|
386 |
+
input.setAttribute('value',BancaSellaForm.ccData.cvv2);
|
387 |
+
break;
|
388 |
+
case BancaSellaForm.idStart+'_cc_name':
|
389 |
+
input.setAttribute('value',BancaSellaForm.ccData.name);
|
390 |
+
break;
|
391 |
+
case BancaSellaForm.idStart+'_cc_email':
|
392 |
+
input.setAttribute('value',BancaSellaForm.ccData.email);
|
393 |
+
break;
|
394 |
+
default :
|
395 |
+
console.log('non ho trovato '+ input.id);
|
396 |
+
}
|
397 |
+
});
|
398 |
+
},
|
399 |
+
checkAndCloseDialogCC : function(){
|
400 |
+
if(BancaSellaForm.dialogCC){
|
401 |
+
Windows.close('dialogcc');
|
402 |
+
BancaSellaForm.dialogCC=false;
|
403 |
+
}
|
404 |
+
},
|
405 |
+
removePaymentMethod : function(){
|
406 |
+
if(this.formId){
|
407 |
+
$(this.formId).hide();
|
408 |
+
}
|
409 |
+
var $paymentForm = $('p_method_' + this.code);
|
410 |
+
$paymentForm.setAttribute('disabled','disabled');
|
411 |
+
$paymentForm.up().up().hide();
|
412 |
+
}
|
413 |
+
};
|
414 |
+
}
|
415 |
+
|
416 |
+
if (typeof Review != 'undefined') {
|
417 |
+
Review.addMethods({
|
418 |
+
nextStep: function(transport){
|
419 |
+
if (transport && transport.responseText) {
|
420 |
+
response = eval('(' + transport.responseText + ')');
|
421 |
+
|
422 |
+
if (!response.success) {
|
423 |
+
var msg = response.error_messages;
|
424 |
+
if (typeof(msg)=='object') {
|
425 |
+
msg = msg.join("\n");
|
426 |
+
}
|
427 |
+
if (msg) {
|
428 |
+
alert(msg);
|
429 |
+
}
|
430 |
+
if (response.update_section) {
|
431 |
+
$('checkout-'+response.update_section.name+'-load').update(response.update_section.html);
|
432 |
+
}
|
433 |
+
if (response.goto_section) {
|
434 |
+
checkout.gotoSection(response.goto_section);
|
435 |
+
}
|
436 |
+
}else{
|
437 |
+
this.isSuccess = true;
|
438 |
+
BancaSellaForm.redirectSuccessUrl = this.successUrl;
|
439 |
+
if(!BancaSellaForm.lock && ($(BancaSellaForm.radioBancaSella).checked)){
|
440 |
+
|
441 |
+
if (response.success) {
|
442 |
+
BancaSellaForm.redirectAfterIframe = this.successUrl;
|
443 |
+
}
|
444 |
+
if (response.redirect) {
|
445 |
+
BancaSellaForm.redirectAfterIframe = response.redirect;
|
446 |
+
}
|
447 |
+
|
448 |
+
BancaSellaForm.saveDataCC(BancaSellaForm.realForm);
|
449 |
+
//inviamo i dati della carta
|
450 |
+
BancaSellaForm.sendPaymentIframe();
|
451 |
+
}else{
|
452 |
+
if (response.redirect) {
|
453 |
+
location.href = response.redirect;
|
454 |
+
return;
|
455 |
+
}
|
456 |
+
if (response.success) {
|
457 |
+
window.location=this.successUrl;
|
458 |
+
}
|
459 |
+
}
|
460 |
+
}
|
461 |
+
}
|
462 |
+
}
|
463 |
+
});
|
464 |
+
}
|
js/bancasellapro/gestpayform_onepagecheckout.js
ADDED
@@ -0,0 +1,592 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
if (typeof(BancaSellaForm) == 'undefined') {
|
2 |
+
|
3 |
+
var BancaSellaForm = {
|
4 |
+
formId : false,
|
5 |
+
merchantId : false,
|
6 |
+
stringEnctipt : false,
|
7 |
+
radioBancaSella : false,
|
8 |
+
cssSelectorInfo : false,
|
9 |
+
GestPayExternalClass : false,
|
10 |
+
enable : false,
|
11 |
+
idStart : false,
|
12 |
+
cssSelectorRadioPayment : false,
|
13 |
+
redirectSuccessUrl : false,
|
14 |
+
redirectAfterIframe : false,
|
15 |
+
confirmPage : false,
|
16 |
+
authPage : false,
|
17 |
+
dialogCC : false,
|
18 |
+
lock: false,
|
19 |
+
modal3d : false,
|
20 |
+
successRedirect : false,
|
21 |
+
initalized : false,
|
22 |
+
code:null,
|
23 |
+
enableFormToIframe:false,
|
24 |
+
isRecurringProfile:false,
|
25 |
+
|
26 |
+
init : function (config){
|
27 |
+
this.formId = config.formId;
|
28 |
+
this.merchantId = config.merchantId;
|
29 |
+
this.stringEnctipt = config.stringEnctipt;
|
30 |
+
this.radioBancaSella = config.radioBancaSella;
|
31 |
+
this.cssSelectorInfo = config.cssSelectorInfo;
|
32 |
+
this.idStart = config.idStart;
|
33 |
+
this.cssSelectorRadioPayment = config.cssSelectorRadioPayment;
|
34 |
+
this.showHidePaymentDivId = config.showHidePaymentDivId;
|
35 |
+
this.confirmPage = config.confirmPage;
|
36 |
+
this.authPage = config.authPage;
|
37 |
+
this.waitImage = config.waitImage;
|
38 |
+
this.GestPayExternalClass = config.GestPayExternalClass;
|
39 |
+
this.successRedirect = config.successRedirect;
|
40 |
+
|
41 |
+
this.enableFormToIframe= config.enableFormToIframe;
|
42 |
+
this.code= config.code;
|
43 |
+
this.isRecurringProfile= config.isRecurringProfile;
|
44 |
+
|
45 |
+
if(!this.enableFormToIframe && this.isRecurringProfile){
|
46 |
+
this.removePaymentMethod();
|
47 |
+
return;
|
48 |
+
}
|
49 |
+
|
50 |
+
document.observe("payment-method:switched", function(event) {
|
51 |
+
if(event.memo.method_code == "gestpaypro"){
|
52 |
+
if(!BancaSellaForm.initalized){
|
53 |
+
BancaSellaForm.start();
|
54 |
+
}
|
55 |
+
BancaSellaForm.toggleStatusForm(true);
|
56 |
+
}else{
|
57 |
+
BancaSellaForm.disableForm();
|
58 |
+
}
|
59 |
+
});
|
60 |
+
|
61 |
+
},
|
62 |
+
start : function(){
|
63 |
+
if(!this.lock){
|
64 |
+
this.showWait();
|
65 |
+
BancaSellaForm.initalized = true;
|
66 |
+
BancaSellaForm.createPagePaymentToOrder(false);
|
67 |
+
|
68 |
+
$$(this.cssSelectorRadioPayment).each(
|
69 |
+
function(item){
|
70 |
+
Event.observe(item, 'click', BancaSellaForm.togglePaymentForm);
|
71 |
+
}
|
72 |
+
);
|
73 |
+
//aggiorniamo lo stato del form al caricamento del pagamento
|
74 |
+
payment.addAfterInitFunction('update-get-pay-form',BancaSellaForm.togglePaymentForm);
|
75 |
+
|
76 |
+
//aggiungiamo i dati dell form ad una variabile interna per l'invio dei dati
|
77 |
+
payment.addBeforeValidateFunction('before-validate-gest-pay',function(){
|
78 |
+
if(!BancaSellaForm.lock){
|
79 |
+
if(BancaSellaForm.enable){
|
80 |
+
var form =$(BancaSellaForm.formId );
|
81 |
+
BancaSellaForm.realForm=form;
|
82 |
+
return;
|
83 |
+
}
|
84 |
+
}
|
85 |
+
BancaSellaForm.realForm = null;
|
86 |
+
});
|
87 |
+
}
|
88 |
+
},
|
89 |
+
toggleStatusForm : function (isEnable){
|
90 |
+
if(isEnable){
|
91 |
+
this.lock = false;
|
92 |
+
this.enable = false;
|
93 |
+
this.togglePaymentForm();
|
94 |
+
//nascondo il messaggio del redirect dopo la conferma ordine
|
95 |
+
$$(this.cssSelectorInfo).first().hide();
|
96 |
+
}else{
|
97 |
+
this.disableForm();
|
98 |
+
//mostro il messaggio del redirect dopo la conferma ordine
|
99 |
+
$$(this.cssSelectorInfo).first().show();
|
100 |
+
this.lock = true;
|
101 |
+
}
|
102 |
+
},
|
103 |
+
toggleForm: function (){
|
104 |
+
if(!this.lock){
|
105 |
+
if(this.enable && this.formId){
|
106 |
+
this.disableForm();
|
107 |
+
}
|
108 |
+
else{
|
109 |
+
this.enableForm();
|
110 |
+
}
|
111 |
+
}
|
112 |
+
},
|
113 |
+
enableForm : function (){
|
114 |
+
if(!this.lock){
|
115 |
+
// if(!this.enable ){
|
116 |
+
$(this.formId).show();
|
117 |
+
Form.enable( $(this.formId));
|
118 |
+
this.enable = true;
|
119 |
+
// }
|
120 |
+
return true;
|
121 |
+
}
|
122 |
+
return false;
|
123 |
+
},
|
124 |
+
disableForm : function(){
|
125 |
+
// if(!this.lock){
|
126 |
+
if(this.enable ){
|
127 |
+
$(this.formId).hide();
|
128 |
+
Form.disable( $(this.formId));
|
129 |
+
this.enable = false;
|
130 |
+
// }
|
131 |
+
return true;
|
132 |
+
}
|
133 |
+
return false;
|
134 |
+
},
|
135 |
+
togglePaymentForm : function (){
|
136 |
+
if($(BancaSellaForm.radioBancaSella).checked){
|
137 |
+
BancaSellaForm.enableForm();
|
138 |
+
}else{
|
139 |
+
BancaSellaForm.disableForm();
|
140 |
+
}
|
141 |
+
return false;
|
142 |
+
},
|
143 |
+
paymentPageLoad : function( Result ){
|
144 |
+
if(Result.ErrorCode != 10){
|
145 |
+
//l'iframe non è stato creato
|
146 |
+
if(!this.enableFormToIframe && this.isRecurringProfile){
|
147 |
+
//se il pagamento era per un profilo ricorrente allora rimuovo la form
|
148 |
+
BancaSellaForm.removePaymentMethod();
|
149 |
+
return;
|
150 |
+
}else{
|
151 |
+
BancaSellaForm.toggleStatusForm(false);
|
152 |
+
}
|
153 |
+
}else{
|
154 |
+
BancaSellaForm.toggleStatusForm(true);
|
155 |
+
}
|
156 |
+
BancaSellaForm.hideWait();
|
157 |
+
BancaSellaForm.unlockPlaceOrder();
|
158 |
+
},
|
159 |
+
paymentPageLoadToOrder : function( Result ){
|
160 |
+
if(Result.ErrorCode != 10){
|
161 |
+
if(!BancaSellaForm.enableFormToIframe && BancaSellaForm.isRecurringProfile){
|
162 |
+
//se il pagamento era per un profilo ricorrente allora rimuovo la form
|
163 |
+
BancaSellaForm.removePaymentMethod();
|
164 |
+
return;
|
165 |
+
}else{
|
166 |
+
BancaSellaForm.toggleStatusForm(false);
|
167 |
+
}
|
168 |
+
}else{
|
169 |
+
BancaSellaForm.toggleStatusForm(true);
|
170 |
+
IWD.OPC.saveOrder();
|
171 |
+
IWD.OPC.Plugin.dispatch('savePaymentAfter');
|
172 |
+
}
|
173 |
+
BancaSellaForm.hideWait();
|
174 |
+
},
|
175 |
+
paymentPageLoadToSaveOrder : function( Result ){
|
176 |
+
|
177 |
+
BancaSellaForm.paymentPageLoad(Result);
|
178 |
+
IWD.OPC.saveOrder();
|
179 |
+
|
180 |
+
},
|
181 |
+
sendPaymentIframe : function (){
|
182 |
+
BancaSellaForm.showWait();
|
183 |
+
BancaSellaForm.GestPayExternalClass.SendPayment ({
|
184 |
+
CC : BancaSellaForm.ccData.cc,
|
185 |
+
EXPMM : BancaSellaForm.ccData.expmm,
|
186 |
+
EXPYY : BancaSellaForm.ccData.expyy,
|
187 |
+
CVV2 : BancaSellaForm.ccData.cvv2,
|
188 |
+
Name: BancaSellaForm.ccData.name,
|
189 |
+
Email: BancaSellaForm.ccData.email
|
190 |
+
},
|
191 |
+
function ( Result ) {
|
192 |
+
BancaSellaForm.hideWait();
|
193 |
+
BancaSellaForm.analizeResponse.delay(0.8,Result);
|
194 |
+
}
|
195 |
+
);
|
196 |
+
return true;
|
197 |
+
},
|
198 |
+
analizeResponse : function(Result){
|
199 |
+
if (Result.ErrorCode != 0){
|
200 |
+
if (Result.ErrorCode == 8006){
|
201 |
+
//3D Transaction
|
202 |
+
var TransKey = Result.TransKey;
|
203 |
+
var VBVRisp = Result.VBVRisp;
|
204 |
+
BancaSellaForm.call3dSecure ( TransKey, VBVRisp );
|
205 |
+
}else{
|
206 |
+
|
207 |
+
var idErrorInput = '';
|
208 |
+
if(Result.ErrorCode == 1119 || Result.ErrorCode == 1120){
|
209 |
+
idErrorInput= BancaSellaForm.idStart+'_cc_number';
|
210 |
+
}else
|
211 |
+
if(Result.ErrorCode == 1124 || Result.ErrorCode == 1126){
|
212 |
+
idErrorInput= BancaSellaForm.idStart+'_cc_exp_mm'
|
213 |
+
} else
|
214 |
+
if(Result.ErrorCode == 1125){
|
215 |
+
idErrorInput= BancaSellaForm.idStart+'_cc_exp_yy'
|
216 |
+
}else
|
217 |
+
if(Result.ErrorCode == 1149){
|
218 |
+
idErrorInput= BancaSellaForm.idStart+'_cc_cvv'
|
219 |
+
}else
|
220 |
+
{
|
221 |
+
//altri errori, uno dei possibili 4707
|
222 |
+
Dialog.alert(Result.ErrorDescription,
|
223 |
+
{
|
224 |
+
className:'magento',
|
225 |
+
width:300,
|
226 |
+
height:90,
|
227 |
+
zIndex:1000,
|
228 |
+
okLabel: Translator.translate('Complete payment on Banca Sella website'),
|
229 |
+
buttonClass: "scalable",
|
230 |
+
id: "alertRedirect",
|
231 |
+
title: Translator.translate('Payment authorization error'),
|
232 |
+
onOk: BancaSellaForm.redirectPaymentPage
|
233 |
+
}
|
234 |
+
);
|
235 |
+
return false;
|
236 |
+
}
|
237 |
+
BancaSellaForm.showModalDialogCC(idErrorInput, Result.ErrorDescription);
|
238 |
+
return false;
|
239 |
+
}
|
240 |
+
}else{
|
241 |
+
//pagamento effettuato con successo oppure l'utente ha annullato il 3dsecure;
|
242 |
+
setLocation(BancaSellaForm.successRedirect + '?a='+ BancaSellaForm.merchantId + '&b='+ Result.EncryptedString);
|
243 |
+
return;
|
244 |
+
}
|
245 |
+
},
|
246 |
+
call3dSecure : function (TransKey, VBVRisp){
|
247 |
+
BancaSellaForm.transKey=TransKey;
|
248 |
+
var a = this.merchantId;
|
249 |
+
var b = VBVRisp;
|
250 |
+
var c= BancaSellaForm.confirmPage;
|
251 |
+
var definitiveUrl = BancaSellaForm.authPage+'?a='+a+'&b='+b+'&c='+c ;
|
252 |
+
BancaSellaForm.showModal(definitiveUrl);
|
253 |
+
},
|
254 |
+
redirectPaymentPage : function (){
|
255 |
+
if(BancaSellaForm.isRecurringProfile){
|
256 |
+
//il pagamento ricorrente non puo essere effettuato su bancasella
|
257 |
+
setLocation(BancaSellaForm.redirectAfterIframe);
|
258 |
+
}else{
|
259 |
+
setLocation(BancaSellaForm.successRedirect);
|
260 |
+
}
|
261 |
+
return;
|
262 |
+
},
|
263 |
+
showModal : function (url)
|
264 |
+
{
|
265 |
+
this.modal3d = new Window(
|
266 |
+
{
|
267 |
+
className:'magento',
|
268 |
+
id:'gestpay_window',
|
269 |
+
title:Translator.translate('3D secure'),
|
270 |
+
url:url,
|
271 |
+
width:400,
|
272 |
+
height:400,
|
273 |
+
zIndex:1000,
|
274 |
+
minimizable: false,
|
275 |
+
maximizable : false,
|
276 |
+
closable:false,
|
277 |
+
destroyOnClose:true,
|
278 |
+
recenterAuto:true
|
279 |
+
});
|
280 |
+
this.modal3d.setZIndex(1000);
|
281 |
+
this.modal3d.showCenter(true);
|
282 |
+
},
|
283 |
+
//chiamata dall'iframe e non in questa pagina
|
284 |
+
sendPares : function (pares){
|
285 |
+
this.modal3d.close();
|
286 |
+
BancaSellaForm.showWait.delay(0.8);
|
287 |
+
this.GestPayExternalClass.SendPayment ({
|
288 |
+
PARes : pares ,
|
289 |
+
TransKey : BancaSellaForm.transKey
|
290 |
+
},
|
291 |
+
function ( Result ) {
|
292 |
+
BancaSellaForm.hideWait();
|
293 |
+
BancaSellaForm.analizeResponse.delay(0.8,Result);
|
294 |
+
}
|
295 |
+
);
|
296 |
+
return false;
|
297 |
+
},
|
298 |
+
showModalDialogCC : function( id, message ){
|
299 |
+
var form = BancaSellaForm.realForm;
|
300 |
+
|
301 |
+
BancaSellaForm.populateForm(form,id,false);
|
302 |
+
|
303 |
+
BancaSellaForm.checkAndCloseDialogCC();
|
304 |
+
|
305 |
+
if (!BancaSellaForm.dialogCC){
|
306 |
+
|
307 |
+
BancaSellaForm.dialogCC = Dialog.alert('<div id="modal-form"><ul class="form-list">'+form.innerHTML+'</ul></div>',
|
308 |
+
{
|
309 |
+
className:'magento',
|
310 |
+
closeOnEsc:false,
|
311 |
+
width:300,
|
312 |
+
height:400,
|
313 |
+
zIndex:1000,
|
314 |
+
okLabel: Translator.translate('Send Credit Card Data'),
|
315 |
+
buttonClass: "scalable",
|
316 |
+
id: "dialogcc",
|
317 |
+
title: Translator.translate('Please correct the highlighted fields'),
|
318 |
+
onOk: function (){
|
319 |
+
var validator = new Validation($('modal-form'));
|
320 |
+
if (!validator.validate())
|
321 |
+
return false;
|
322 |
+
BancaSellaForm.saveDataCC($('modal-form'));
|
323 |
+
BancaSellaForm.sendPaymentIframe.delay(0.8);
|
324 |
+
return true;
|
325 |
+
}
|
326 |
+
}
|
327 |
+
);
|
328 |
+
}
|
329 |
+
alert(message);
|
330 |
+
},
|
331 |
+
showWait : function(){
|
332 |
+
IWD.OPC.Checkout.showLoader();
|
333 |
+
IWD.OPC.Checkout.lockPlaceOrder();
|
334 |
+
},
|
335 |
+
hideWait: function(){
|
336 |
+
IWD.OPC.Checkout.hideLoader();
|
337 |
+
IWD.OPC.Checkout.unlockPlaceOrder();
|
338 |
+
},
|
339 |
+
lockPlaceOrder: function(){
|
340 |
+
IWD.OPC.Checkout.lockPlaceOrder();
|
341 |
+
},
|
342 |
+
unlockPlaceOrder: function(){
|
343 |
+
IWD.OPC.Checkout.unlockPlaceOrder();
|
344 |
+
},
|
345 |
+
|
346 |
+
saveDataCC :function (form){
|
347 |
+
BancaSellaForm.ccData=[];
|
348 |
+
BancaSellaForm.ccData.cc = $F(form.getElementsBySelector('#'+BancaSellaForm.idStart+'_cc_number').first());
|
349 |
+
BancaSellaForm.ccData.expmm = $F(form.getElementsBySelector('#'+BancaSellaForm.idStart+'_cc_exp_mm').first());
|
350 |
+
BancaSellaForm.ccData.expyy = $F(form.getElementsBySelector('#'+BancaSellaForm.idStart+'_cc_exp_yy').first());
|
351 |
+
BancaSellaForm.ccData.cvv2 = $F(form.getElementsBySelector('#'+BancaSellaForm.idStart+'_cc_cvv').first());
|
352 |
+
BancaSellaForm.ccData.name = $F(form.getElementsBySelector('#'+BancaSellaForm.idStart+'_cc_name').first());
|
353 |
+
BancaSellaForm.ccData.email = $F(form.getElementsBySelector('#'+BancaSellaForm.idStart+'_cc_email').first());
|
354 |
+
return true;
|
355 |
+
},
|
356 |
+
populateForm:function(form,id,enable){
|
357 |
+
Form.getElements(form).each(function (input){
|
358 |
+
input.disabled=enable;
|
359 |
+
if(input.id == id){
|
360 |
+
input.addClassName('validation-failed');
|
361 |
+
}else {
|
362 |
+
input.removeClassName('validation-failed');
|
363 |
+
}
|
364 |
+
switch (input.id){
|
365 |
+
case BancaSellaForm.idStart+'_cc_number':
|
366 |
+
input.setAttribute('value',BancaSellaForm.ccData.cc);
|
367 |
+
break;
|
368 |
+
case BancaSellaForm.idStart+'_cc_exp_mm':
|
369 |
+
options = input.childElements();
|
370 |
+
len = options.length;
|
371 |
+
for (var i = 0; i < len; i++) {
|
372 |
+
if(options[i].value == BancaSellaForm.ccData.expmm){
|
373 |
+
options[i].setAttribute('selected',true);
|
374 |
+
}
|
375 |
+
}
|
376 |
+
break;
|
377 |
+
case BancaSellaForm.idStart+'_cc_exp_yy':
|
378 |
+
options = input.childElements();
|
379 |
+
len = options.length;
|
380 |
+
for (var i = 0; i < len; i++) {
|
381 |
+
if(options[i].value == BancaSellaForm.ccData.expyy){
|
382 |
+
options[i].setAttribute('selected',true);
|
383 |
+
}
|
384 |
+
}
|
385 |
+
break;
|
386 |
+
case BancaSellaForm.idStart+'_cc_cvv':
|
387 |
+
input.setAttribute('value',BancaSellaForm.ccData.cvv2);
|
388 |
+
break;
|
389 |
+
case BancaSellaForm.idStart+'_cc_name':
|
390 |
+
input.setAttribute('value',BancaSellaForm.ccData.name);
|
391 |
+
break;
|
392 |
+
case BancaSellaForm.idStart+'_cc_email':
|
393 |
+
input.setAttribute('value',BancaSellaForm.ccData.email);
|
394 |
+
break;
|
395 |
+
default :
|
396 |
+
console.log('non ho trovato '+ input.id);
|
397 |
+
}
|
398 |
+
});
|
399 |
+
},
|
400 |
+
checkAndCloseDialogCC : function(){
|
401 |
+
if(BancaSellaForm.dialogCC){
|
402 |
+
Windows.close('dialogcc');
|
403 |
+
BancaSellaForm.dialogCC=false;
|
404 |
+
}
|
405 |
+
},
|
406 |
+
removePaymentMethod : function(){
|
407 |
+
$(this.formId).hide();
|
408 |
+
var $paymentForm = $('p_method_' + this.code);
|
409 |
+
$paymentForm.setAttribute('disabled','disabled');
|
410 |
+
$paymentForm.up('dt').hide();
|
411 |
+
},
|
412 |
+
createPagePaymentToOrder: function (callSendOrder){
|
413 |
+
IWD.OPC.Checkout.showLoader();
|
414 |
+
IWD.OPC.Checkout.lockPlaceOrder();
|
415 |
+
if(callSendOrder){
|
416 |
+
BancaSellaForm.GestPayExternalClass.CreatePaymentPage( BancaSellaForm.merchantId, BancaSellaForm.stringEnctipt, BancaSellaForm.paymentPageLoadToOrder);
|
417 |
+
}
|
418 |
+
else{
|
419 |
+
BancaSellaForm.GestPayExternalClass.CreatePaymentPage( BancaSellaForm.merchantId, BancaSellaForm.stringEnctipt, BancaSellaForm.paymentPageLoad);
|
420 |
+
}
|
421 |
+
}
|
422 |
+
};
|
423 |
+
}
|
424 |
+
|
425 |
+
// define jquery
|
426 |
+
if(typeof($j_opc) == 'undefined' || $j_opc == undefined || !$j_opc){
|
427 |
+
$j_opc = false;
|
428 |
+
|
429 |
+
if(typeof($ji) != 'undefined' && $ji != undefined && $ji)
|
430 |
+
$j_opc = $ji; // from iwd_all 2.x
|
431 |
+
else{
|
432 |
+
if(typeof($j) != 'undefined' && $j != undefined && $j)
|
433 |
+
$j_opc = $j; // from default magento 1.9
|
434 |
+
else{
|
435 |
+
if(typeof(jQuery) != 'undefined' && jQuery != undefined && jQuery)
|
436 |
+
$j_opc = jQuery;
|
437 |
+
}
|
438 |
+
}
|
439 |
+
}
|
440 |
+
|
441 |
+
if(typeof IWD.OPC != 'undefined'){
|
442 |
+
|
443 |
+
IWD.OPC.prepareOrderResponse = function (response){
|
444 |
+
IWD.OPC.Checkout.xhr = null;
|
445 |
+
if (typeof(response.error) != "undefined" && response.error!=false){
|
446 |
+
IWD.OPC.Checkout.hideLoader();
|
447 |
+
IWD.OPC.Checkout.unlockPlaceOrder();
|
448 |
+
IWD.OPC.saveOrderStatus = false;
|
449 |
+
$j_opc('.opc-message-container').html(response.error);
|
450 |
+
$j_opc('.opc-message-wrapper').show();
|
451 |
+
IWD.OPC.Plugin.dispatch('error');
|
452 |
+
return;
|
453 |
+
}
|
454 |
+
|
455 |
+
if (typeof(response.error_messages) != "undefined" && response.error_messages!=false){
|
456 |
+
IWD.OPC.Checkout.hideLoader();
|
457 |
+
IWD.OPC.Checkout.unlockPlaceOrder();
|
458 |
+
|
459 |
+
IWD.OPC.saveOrderStatus = false;
|
460 |
+
$j_opc('.opc-message-container').html(response.error_messages);
|
461 |
+
$j_opc('.opc-message-wrapper').show();
|
462 |
+
IWD.OPC.Plugin.dispatch('error');
|
463 |
+
return;
|
464 |
+
}
|
465 |
+
|
466 |
+
if (typeof(response.update_section) != "undefined"){
|
467 |
+
IWD.OPC.Checkout.hideLoader();
|
468 |
+
IWD.OPC.Checkout.unlockPlaceOrder();
|
469 |
+
//create catch for default logic - for not spam errors to console
|
470 |
+
try{
|
471 |
+
$j_opc('#checkout-' + response.update_section.name + '-load').html(response.update_section.html);
|
472 |
+
}catch(e){
|
473 |
+
|
474 |
+
}
|
475 |
+
IWD.OPC.prepareExtendPaymentForm();
|
476 |
+
$j_opc('#payflow-advanced-iframe').show();
|
477 |
+
$j_opc('#payflow-link-iframe').show();
|
478 |
+
$j_opc('#hss-iframe').show();
|
479 |
+
}
|
480 |
+
|
481 |
+
if(!BancaSellaForm.lock && ($(BancaSellaForm.radioBancaSella).checked)){
|
482 |
+
IWD.OPC.prepareExtendPaymentForm();
|
483 |
+
$j_opc('.opc-col-right').find('h3').first().text(Translator.translate('Please wait...'));
|
484 |
+
$j_opc('#opc-review-block').html('<div><p>'+Translator.translate('You are waiting the completion of payment')+'</p></div>');
|
485 |
+
|
486 |
+
if (response.redirect) {
|
487 |
+
BancaSellaForm.redirectAfterIframe = response.redirect;
|
488 |
+
}
|
489 |
+
|
490 |
+
BancaSellaForm.saveDataCC(BancaSellaForm.realForm);
|
491 |
+
//inviamo i dati della carta
|
492 |
+
BancaSellaForm.sendPaymentIframe();
|
493 |
+
}else{
|
494 |
+
if (typeof(response.redirect) !="undefined"){
|
495 |
+
if (response.redirect!==false){
|
496 |
+
setLocation(response.redirect);
|
497 |
+
return;
|
498 |
+
}
|
499 |
+
}
|
500 |
+
}
|
501 |
+
IWD.OPC.Checkout.hideLoader();
|
502 |
+
IWD.OPC.Checkout.unlockPlaceOrder();
|
503 |
+
|
504 |
+
IWD.OPC.Plugin.dispatch('responseSaveOrder', response);
|
505 |
+
};
|
506 |
+
IWD.OPC.preparePaymentResponse = function(response){
|
507 |
+
|
508 |
+
IWD.OPC.Checkout.xhr = null;
|
509 |
+
|
510 |
+
IWD.OPC.agreements = $j_opc('#checkout-agreements').serializeArray();
|
511 |
+
|
512 |
+
IWD.OPC.getSubscribe();
|
513 |
+
|
514 |
+
if (typeof(response.review)!= "undefined"){
|
515 |
+
IWD.OPC.Decorator.updateGrandTotal(response);
|
516 |
+
|
517 |
+
$j_opc('#opc-review-block').html(response.review);
|
518 |
+
IWD.OPC.Checkout.removePrice();
|
519 |
+
|
520 |
+
// need to recheck subscribe and agreenet checkboxes
|
521 |
+
IWD.OPC.recheckItems();
|
522 |
+
}
|
523 |
+
|
524 |
+
IWD.OPC.Checkout.hideLoader();
|
525 |
+
IWD.OPC.Checkout.unlockPlaceOrder();
|
526 |
+
|
527 |
+
if (typeof(response.error) != "undefined"){
|
528 |
+
|
529 |
+
IWD.OPC.Plugin.dispatch('error');
|
530 |
+
|
531 |
+
$j_opc('.opc-message-container').html(response.error);
|
532 |
+
$j_opc('.opc-message-wrapper').show();
|
533 |
+
IWD.OPC.Checkout.hideLoader();
|
534 |
+
IWD.OPC.Checkout.unlockPlaceOrder();
|
535 |
+
IWD.OPC.saveOrderStatus = false;
|
536 |
+
|
537 |
+
return;
|
538 |
+
}
|
539 |
+
|
540 |
+
//SOME PAYMENT METHOD REDIRECT CUSTOMER TO PAYMENT GATEWAY
|
541 |
+
if (typeof(response.redirect) != "undefined" && IWD.OPC.saveOrderStatus===true){
|
542 |
+
IWD.OPC.Checkout.xhr = null;
|
543 |
+
IWD.OPC.Plugin.dispatch('redirectPayment', response.redirect);
|
544 |
+
if (IWD.OPC.Checkout.xhr==null){
|
545 |
+
setLocation(response.redirect);
|
546 |
+
}
|
547 |
+
else
|
548 |
+
{
|
549 |
+
IWD.OPC.Checkout.hideLoader();
|
550 |
+
IWD.OPC.Checkout.unlockPlaceOrder();
|
551 |
+
}
|
552 |
+
|
553 |
+
return;
|
554 |
+
}
|
555 |
+
|
556 |
+
if(typeof(response.encrypt_string) != "undefined" ){
|
557 |
+
|
558 |
+
if (typeof IWD.OPC.Checkout.showLoader != "undefined"){
|
559 |
+
IWD.OPC.Checkout.showLoader();
|
560 |
+
}
|
561 |
+
//aggiorno la stringa
|
562 |
+
BancaSellaForm.stringEnctipt = response.encrypt_string;
|
563 |
+
|
564 |
+
BancaSellaForm.createPagePaymentToOrder(IWD.OPC.saveOrderStatus===true);
|
565 |
+
|
566 |
+
}else if (IWD.OPC.saveOrderStatus===true){
|
567 |
+
IWD.OPC.saveOrder();
|
568 |
+
}else{
|
569 |
+
if (typeof IWD.OPC.Checkout.hideLoader != "undefined"){
|
570 |
+
IWD.OPC.Checkout.hideLoader();
|
571 |
+
}
|
572 |
+
IWD.OPC.Checkout.unlockPlaceOrder();
|
573 |
+
}
|
574 |
+
IWD.OPC.Plugin.dispatch('savePaymentAfter');
|
575 |
+
}
|
576 |
+
}
|
577 |
+
|
578 |
+
$j_opc.ajaxPrefilter(function( options ) {
|
579 |
+
if(decodeURIComponent(options.data).indexOf('payment[method]=gestpaypro') != -1 ){
|
580 |
+
//salvo i dati della carta nel oggetto
|
581 |
+
BancaSellaForm.saveDataCC(BancaSellaForm.realForm);
|
582 |
+
|
583 |
+
//rimuovo tutti i dati della carta dalla richiesta
|
584 |
+
var splitItems= options.data.split('&');
|
585 |
+
for(var i=0; i < splitItems.length; ++i){
|
586 |
+
if(decodeURIComponent(splitItems[i]).indexOf('bancasella_iframe') == 0 ){
|
587 |
+
splitItems.splice(i--,1);
|
588 |
+
}
|
589 |
+
}
|
590 |
+
options.data = splitItems.join('&');
|
591 |
+
}
|
592 |
+
});
|
js/bancasellapro/newtoken.js
ADDED
@@ -0,0 +1,115 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
if (typeof EasyNoloTokenization == 'undefined') {
|
2 |
+
|
3 |
+
var EasyNoloTokenization = {
|
4 |
+
|
5 |
+
init : function (config){
|
6 |
+
|
7 |
+
this.formId = config.formId;
|
8 |
+
this.merchantId = config.merchantId;
|
9 |
+
this.stringEnctipt = config.stringEnctipt;
|
10 |
+
this.waitImage = config.waitImage;
|
11 |
+
this.GestPayExternalClass = config.GestPayExternalClass;
|
12 |
+
this.successRedirect = config.successRedirect;
|
13 |
+
this.enableFormToIframe= config.enableFormToIframe;
|
14 |
+
this.code= config.code;
|
15 |
+
this.disableProfileRedirect = config.disableProfileRedirect;
|
16 |
+
|
17 |
+
if(!this.enableFormToIframe ){
|
18 |
+
this.suspendProfilePage();
|
19 |
+
}else {
|
20 |
+
this.start();
|
21 |
+
}
|
22 |
+
},
|
23 |
+
start : function(){
|
24 |
+
this.showWait();
|
25 |
+
this.GestPayExternalClass.CreatePaymentPage( this.merchantId, this.stringEnctipt, this.paymentPageLoad);
|
26 |
+
},
|
27 |
+
paymentPageLoad : function( Result ){
|
28 |
+
EasyNoloTokenization.hideWait();
|
29 |
+
if(Result.ErrorCode != 10){
|
30 |
+
EasyNoloTokenization.suspendProfilePage(Result.ErrorDescription);
|
31 |
+
}
|
32 |
+
},
|
33 |
+
showWait : function(){
|
34 |
+
Dialog.info('<img src="'+EasyNoloTokenization.waitImage+'" class="v-middle" />'+ Translator.translate('Please wait...'),
|
35 |
+
{ className:'magento',
|
36 |
+
width:150,
|
37 |
+
height:50,
|
38 |
+
zIndex:1000
|
39 |
+
}
|
40 |
+
);
|
41 |
+
},
|
42 |
+
getFormContent: function(name){
|
43 |
+
return $F(EasyNoloTokenization.code+name);
|
44 |
+
},
|
45 |
+
sendPaymentIframe : function (){
|
46 |
+
|
47 |
+
EasyNoloTokenization.showWait();
|
48 |
+
EasyNoloTokenization.GestPayExternalClass.SendPayment ({
|
49 |
+
CC : EasyNoloTokenization.getFormContent('_cc_number'),
|
50 |
+
EXPMM : EasyNoloTokenization.getFormContent('_cc_exp_mm'),
|
51 |
+
EXPYY : EasyNoloTokenization.getFormContent('_cc_exp_yy'),
|
52 |
+
CVV2 : EasyNoloTokenization.getFormContent('_cc_cvv'),
|
53 |
+
Name: EasyNoloTokenization.getFormContent('_cc_name'),
|
54 |
+
Email: EasyNoloTokenization.getFormContent('_cc_email')
|
55 |
+
},
|
56 |
+
function ( Result ) {
|
57 |
+
EasyNoloTokenization.hideWait();
|
58 |
+
EasyNoloTokenization.analizeResponse.delay(0.8,Result);
|
59 |
+
}
|
60 |
+
);
|
61 |
+
return true;
|
62 |
+
},
|
63 |
+
hideWait: function(){
|
64 |
+
Dialog.closeInfo();
|
65 |
+
},
|
66 |
+
|
67 |
+
analizeResponse : function(Result){
|
68 |
+
|
69 |
+
if (Result.ErrorCode != 0){
|
70 |
+
if (Result.ErrorCode == 8006){
|
71 |
+
//non gestiamo il 3d secure perché non è possibile effettuare pagamenti ricorrenti
|
72 |
+
EasyNoloTokenization.suspendProfilePage();
|
73 |
+
}else{
|
74 |
+
|
75 |
+
var idErrorInput = '';
|
76 |
+
if(Result.ErrorCode == 1119 || Result.ErrorCode == 1120){
|
77 |
+
idErrorInput= EasyNoloTokenization.code+'_cc_number';
|
78 |
+
}else
|
79 |
+
if(Result.ErrorCode == 1124 || Result.ErrorCode == 1126){
|
80 |
+
idErrorInput= EasyNoloTokenization.code+'_cc_exp_mm'
|
81 |
+
} else
|
82 |
+
if(Result.ErrorCode == 1125){
|
83 |
+
idErrorInput= EasyNoloTokenization.code+'_cc_exp_yy'
|
84 |
+
}else
|
85 |
+
if(Result.ErrorCode == 1149){
|
86 |
+
idErrorInput= EasyNoloTokenization.code+'_cc_cvv'
|
87 |
+
}else
|
88 |
+
{
|
89 |
+
EasyNoloTokenization.suspendProfilePage();
|
90 |
+
return false;
|
91 |
+
}
|
92 |
+
EasyNoloTokenization.showErrorMessageCC(idErrorInput, Result.ErrorDescription);
|
93 |
+
return false;
|
94 |
+
}
|
95 |
+
}else{
|
96 |
+
//pagamento effettuato con successo oppure l'utente ha annullato il 3dsecure;
|
97 |
+
url = EasyNoloTokenization.successRedirect + '?a='+ EasyNoloTokenization.merchantId + '&b='+ Result.EncryptedString;
|
98 |
+
location.href = url;
|
99 |
+
return;
|
100 |
+
}
|
101 |
+
},
|
102 |
+
|
103 |
+
showErrorMessageCC: function (idError, message){
|
104 |
+
EasyNoloTokenization.hideWait();
|
105 |
+
alert(message);
|
106 |
+
},
|
107 |
+
|
108 |
+
suspendProfilePage : function(description){
|
109 |
+
url = EasyNoloTokenization.disableProfileRedirect
|
110 |
+
location.href = url;
|
111 |
+
return;
|
112 |
+
}
|
113 |
+
|
114 |
+
}
|
115 |
+
}
|
package.xml
ADDED
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<package>
|
3 |
+
<name>EasyNolo_BancaSellaPro</name>
|
4 |
+
<version>1.4.0.0</version>
|
5 |
+
<stability>stable</stability>
|
6 |
+
<license>GNU General Public License (GPL)</license>
|
7 |
+
<channel>community</channel>
|
8 |
+
<extends/>
|
9 |
+
<summary>Plugin UFFICIALE per integrare Magento con il sistema di pagamento online Banca Sella</summary>
|
10 |
+
<description>Plugin UFFICIALE per integrare Magento con il sistema di pagamento online Banca Sella</description>
|
11 |
+
<notes>Plugin UFFICIALE per integrare Magento con il sistema di pagamento online Banca Sella.</notes>
|
12 |
+
<authors><author><name>EasyNolo Spa</name><user>easynolospa</user><email>ecommerce@sella.it</email></author></authors>
|
13 |
+
<date>2016-06-25</date>
|
14 |
+
<time>17:00:35</time>
|
15 |
+
<contents><target name="magecommunity"><dir name="EasyNolo"><dir name="BancaSellaPro"><dir name="Block"><file name="Confirm3d.php" hash="1748f46552f38387d9ef7a206ef64994"/><file name="Form.php" hash="6ffa41645293b4d66a8c0069a1bee68c"/><file name="Newroot.php" hash="37bd80f36e789a5337a3daff1d2cf7ff"/><file name="Redirect.php" hash="97ab12024835edc02493de228d57947c"/><dir name="Tokenization"><file name="Newtoken.php" hash="e73bfa0b89c2f2e5d1b3196914fedbb0"/></dir><dir name="Utility"><file name="Text.php" hash="8453faf49af4d416492f98aa65b9868d"/></dir></dir><file name="Exception.php" hash="9de691c89f0eb1c280ef92c31d2aa6a8"/><dir name="Helper"><file name="Baseclient.php" hash="20dc76a3a04cc054eaf5b8bb7a1005af"/><file name="Crypt.php" hash="d28e0850445f8ecd5744e5e2f7edd417"/><file name="Data.php" hash="be76c6ea71b0aeb653d2857e31526669"/><file name="Recurringprofile.php" hash="b1b972f4a7abe50c5b6e3e032d465617"/><file name="S2s.php" hash="e8a8dab8f4b99768e7b12ff6a9fe66d4"/></dir><dir name="Model"><file name="Gestpay.php" hash="dde99b1114c8fb82b50183b117626f0f"/><file name="Observer.php" hash="d35f9a5373b88c9db94a75586250755d"/><dir name="Resource"><dir name="Token"><file name="Collection.php" hash="e6b6104f94e9dcd2d28927090552ee61"/></dir><file name="Token.php" hash="3539976882da08550b612ae0316c7628"/></dir><dir name="Sales"><dir name="Recurring"><file name="Profile.php" hash="644520b275a0f535eb6b881d50a2e708"/></dir></dir><dir name="System"><dir name="Config"><dir name="Source"><file name="Currency.php" hash="098d64776e12ec7599ff9339e5c504b5"/><file name="Language.php" hash="92f4275a8911cf9e22fda7e22596fdd0"/><file name="PaymentAction.php" hash="c78defcf9655741b2c8423eee7f3fbeb"/></dir></dir></dir><file name="Token.php" hash="272442207ef26d9e2b0ac53272dfb107"/><dir name="Webservice"><file name="Abstract.php" hash="3edc6e1eca436b52b74b080071326d01"/><file name="Wscryptdecrypt.php" hash="5b982fbf80ca0ea4cec652bb55342f8d"/><file name="Wss2s.php" hash="2141061fa7bc360b34de21dc495fc03b"/></dir></dir><dir name="controllers"><file name="GestpayController.php" hash="d04ea1e625c9dc95b13fe9628aff7b37"/><file name="JsonController.php" hash="161a211f82dc838561250e071d6a0adb"/><file name="TokenizationController.php" hash="b1bfb614514d26710bf9227d5597b605"/></dir><dir name="etc"><file name="config.xml" hash="b8afdb4afba870ac6673367ceb94ae97"/><file name="jstranslator.xml" hash="920aae1d6d4503df794d8830b60e500e"/><file name="system.xml" hash="72d973b7fcf1d83135c8e27d01e97114"/></dir><dir name="sql"><dir name="easynolo_bancasellapro_setup"><file name="install-1.3.0.php" hash="aa542fc162f55557dbaf3f93165b6944"/><file name="upgrade-1.3.0-1.3.1.php" hash="43f9171d7beeaf6b350f76778bb2eb35"/></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="EasyNolo_BancaSellaPro.xml" hash="822546906a1d54b670c2610cab8761fb"/></dir></target><target name="mage"><dir name="app"><dir name="etc"><dir name="modules"><file name="EasyNolo_BancaSellaPro.xml.Onepage.txt" hash="08b9164dcc646e2629907b5e90b43fff"/></dir></dir></dir></target><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="easynolo_bancasellapro.xml" hash="9ef47cbd2c4af6176bea6c1de8a722db"/></dir><dir name="template"><dir name="easynolo"><dir name="bancasellapro"><dir name="checkout"><file name="onepage.phtml" hash="e374b0ca92ccb73c811807c2123fb0c1"/><file name="onepage1-6.phtml" hash="09caee142bab0224dd8c3aa495ad6bdb"/></dir><dir name="gestpay"><file name="confirm3d.phtml" hash="8b7a1172989831dd741cd24608d4dce6"/><file name="form.phtml" hash="6b8826ba976d73228a78cf4dc84e8fe0"/><file name="form_onepagecheckout.phtml" hash="1e0f91cecb259f839f138d4f53d0f52a"/><file name="newtoken.phtml" hash="ae142dd4c59a7e8e6a2a30a65ebfb6e6"/><file name="redirect.phtml" hash="16fc850ca5955abf0a13ad9e0feb5d47"/></dir><dir name="page"><file name="redirect.phtml" hash="b4355d7f50036ac9bbe065c797466edb"/></dir></dir></dir></dir></dir></dir><dir name="enterprise"><dir name="default"><dir name="layout"><file name="easynolo_bancasellapro.xml" hash="7bc6d917f3b38f9842d1a7d142e56db7"/></dir><dir name="template"><dir name="easynolo"><dir name="bancasellapro"><dir name="checkout"><file name="onepage.phtml" hash="c1f9e27e9a1c0779c46b515b84e6ffd8"/></dir></dir></dir></dir></dir></dir></dir></target><target name="mageweb"><dir name="js"><dir name="bancasellapro"><file name="gestpayform.js" hash="8f75369fcc80dcfc31ad1f18bce2e2fe"/><file name="gestpayform_onepagecheckout.js" hash="97db1734fba29bda71ce28ea759f2ea1"/><file name="newtoken.js" hash="857173a9ba1f338b43efcea124d95946"/></dir></dir></target><target name="mageskin"><dir name="frontend"><dir name="base"><dir name="default"><dir name="images"><dir name="easynolo_bancasella"><file name="wait.gif" hash="c717328261f92d92c1b1f550d222e0e4"/></dir></dir></dir></dir></dir></target><target name="magelocale"><dir name="en_US"><file name="EasyNolo_BancaSellaPro.csv" hash="3a67c88f9e1ddce1d5304e276a78e774"/></dir><dir name="it_IT"><file name="EasyNolo_BancaSellaPro.csv" hash="70be36e7a2ee8f97a195426d0b813160"/></dir></target></contents>
|
16 |
+
<compatible/>
|
17 |
+
<dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies>
|
18 |
+
</package>
|
skin/frontend/base/default/images/easynolo_bancasella/wait.gif
ADDED
Binary file
|