Allopass_Hipay - Version 1.2.2

Version Notes

Add paypal API

Download this release

Release Info

Developer Kassim_Profileo
Extension Allopass_Hipay
Version 1.2.2
Comparing to
See all releases


Code changes from version 1.0.6 to 1.2.2

Files changed (105) hide show
  1. app/code/community/Allopass/Hipay/Block/Adminhtml/Card/Edit.php +59 -0
  2. app/code/community/Allopass/Hipay/Block/Adminhtml/Card/Edit/Form.php +95 -0
  3. app/code/community/Allopass/Hipay/Block/Adminhtml/Customer/Edit/Tab/Card.php +155 -0
  4. app/code/community/Allopass/Hipay/Block/Adminhtml/PaymentProfile.php +14 -0
  5. app/code/community/Allopass/Hipay/Block/Adminhtml/PaymentProfile/Edit.php +35 -0
  6. app/code/community/Allopass/Hipay/Block/Adminhtml/PaymentProfile/Edit/Form.php +75 -0
  7. app/code/community/Allopass/Hipay/Block/Adminhtml/PaymentProfile/Grid.php +83 -0
  8. app/code/community/Allopass/Hipay/Block/Adminhtml/SplitPayment.php +14 -0
  9. app/code/community/Allopass/Hipay/Block/Adminhtml/SplitPayment/Edit.php +55 -0
  10. app/code/community/Allopass/Hipay/Block/Adminhtml/SplitPayment/Edit/Form.php +96 -0
  11. app/code/community/Allopass/Hipay/Block/Adminhtml/SplitPayment/Grid.php +103 -0
  12. app/code/community/Allopass/Hipay/Block/Adminhtml/System/Config/Form/Field/3dsRule.php +5 -0
  13. app/code/community/Allopass/Hipay/Block/Adminhtml/System/Config/Form/Field/Allowsplitpayment.php +42 -0
  14. app/code/community/Allopass/Hipay/Block/Adminhtml/System/Config/Form/Field/MultiselectSortable.php +46 -0
  15. app/code/community/Allopass/Hipay/Block/Card.php +59 -0
  16. app/code/community/Allopass/Hipay/Block/Card/Edit.php +44 -0
  17. app/code/community/Allopass/Hipay/Block/Form/Abstract.php +94 -3
  18. app/code/community/Allopass/Hipay/Block/Form/Cc.php +14 -0
  19. app/code/community/Allopass/Hipay/Block/Info/Cc.php +14 -0
  20. app/code/community/Allopass/Hipay/Block/Info/Hosted.php +50 -1
  21. app/code/community/Allopass/Hipay/Controller/Payment.php +79 -49
  22. app/code/community/Allopass/Hipay/Helper/Data.php +368 -11
  23. app/code/community/Allopass/Hipay/Model/Api/Request.php +1 -0
  24. app/code/community/Allopass/Hipay/Model/Card.php +20 -0
  25. app/code/community/Allopass/Hipay/Model/Config.php +8 -1
  26. app/code/community/Allopass/Hipay/Model/Method/Abstract.php +409 -83
  27. app/code/community/Allopass/Hipay/Model/Method/Cc.php +22 -5
  28. app/code/community/Allopass/Hipay/Model/Method/Dexia.php +3 -0
  29. app/code/community/Allopass/Hipay/Model/Method/Giropay.php +4 -1
  30. app/code/community/Allopass/Hipay/Model/Method/Hosted.php +11 -4
  31. app/code/community/Allopass/Hipay/Model/Method/Ideal.php +2 -0
  32. app/code/community/Allopass/Hipay/Model/Method/Ing.php +4 -1
  33. app/code/community/Allopass/Hipay/Model/Method/Kbc.php +2 -0
  34. app/code/community/Allopass/Hipay/Model/Method/PaypalApi.php +87 -0
  35. app/code/community/Allopass/Hipay/Model/Method/Przelewy24Api.php +10 -5
  36. app/code/community/Allopass/Hipay/Model/Method/Qiwi.php +3 -0
  37. app/code/community/Allopass/Hipay/Model/Method/Sisal.php +3 -0
  38. app/code/community/Allopass/Hipay/Model/Method/SisalApi.php +12 -5
  39. app/code/community/Allopass/Hipay/Model/Method/SofortApi.php +9 -5
  40. app/code/community/Allopass/Hipay/Model/Method/Webmoney.php +3 -0
  41. app/code/community/Allopass/Hipay/Model/Method/WebmoneyApi.php +12 -5
  42. app/code/community/Allopass/Hipay/Model/Method/Yandex.php +3 -0
  43. app/code/community/Allopass/Hipay/Model/Method/YandexApi.php +12 -5
  44. app/code/community/Allopass/Hipay/Model/Observer.php +133 -0
  45. app/code/community/Allopass/Hipay/Model/PaymentProfile.php +155 -0
  46. app/code/community/Allopass/Hipay/Model/Resource/Card.php +12 -0
  47. app/code/community/Allopass/Hipay/Model/Resource/Card/Collection.php +19 -0
  48. app/code/community/Allopass/Hipay/Model/Resource/PaymentProfile.php +12 -0
  49. app/code/community/Allopass/Hipay/Model/Resource/PaymentProfile/Collection.php +37 -0
  50. app/code/community/Allopass/Hipay/Model/Resource/SplitPayment.php +12 -0
  51. app/code/community/Allopass/Hipay/Model/Resource/SplitPayment/Collection.php +19 -0
  52. app/code/community/Allopass/Hipay/Model/Rule.php +7 -2
  53. app/code/community/Allopass/Hipay/Model/Rule/Condition/Address.php +6 -2
  54. app/code/community/Allopass/Hipay/Model/Rule/Condition/Customer.php +25 -11
  55. app/code/community/Allopass/Hipay/Model/Rule/Config.php +22 -3
  56. app/code/community/Allopass/Hipay/Model/Source/3ds.php +6 -2
  57. app/code/community/Allopass/Hipay/Model/Source/CcType.php +23 -1
  58. app/code/community/Allopass/Hipay/Model/Source/CcTypeHosted.php +21 -1
  59. app/code/community/Allopass/Hipay/Model/Source/PaymentProfile.php +48 -0
  60. app/code/community/Allopass/Hipay/Model/Source/Template.php +1 -12
  61. app/code/community/Allopass/Hipay/Model/SplitPayment.php +91 -0
  62. app/code/community/Allopass/Hipay/Model/System/Config/Backend/CcTypes.php +12 -0
  63. app/code/community/Allopass/Hipay/controllers/Adminhtml/CardController.php +150 -0
  64. app/code/community/Allopass/Hipay/controllers/Adminhtml/PaymentController.php +297 -0
  65. app/code/community/Allopass/Hipay/controllers/Adminhtml/PaymentProfileController.php +153 -0
  66. app/code/community/Allopass/Hipay/controllers/Adminhtml/RuleController.php +1 -0
  67. app/code/community/Allopass/Hipay/controllers/Adminhtml/SplitPaymentController.php +163 -0
  68. app/code/community/Allopass/Hipay/controllers/CardController.php +175 -0
  69. app/code/community/Allopass/Hipay/controllers/NotifyController.php +15 -6
  70. app/code/community/Allopass/Hipay/controllers/PaypalapiController.php +8 -0
  71. app/code/community/Allopass/Hipay/controllers/Sales/Order/CreateController.php +79 -0
  72. app/code/community/Allopass/Hipay/etc/config.xml +222 -72
  73. app/code/community/Allopass/Hipay/etc/system.xml +778 -221
  74. app/code/community/Allopass/Hipay/sql/allopass_hipay_setup/mysql4-install-0.1.0.php +14 -14
  75. app/code/community/Allopass/Hipay/sql/allopass_hipay_setup/mysql4-upgrade-1.0.6-1.0.7.php +43 -0
  76. app/code/community/Allopass/Hipay/sql/allopass_hipay_setup/mysql4-upgrade-1.0.7-1.0.8.php +18 -0
  77. app/code/community/Allopass/Hipay/sql/allopass_hipay_setup/mysql4-upgrade-1.0.8-1.0.9.php +32 -0
  78. app/code/community/Allopass/Hipay/sql/allopass_hipay_setup/mysql4-upgrade-1.0.9-1.1.0.php +69 -0
  79. app/design/adminhtml/default/default/layout/hipay.xml +38 -1
  80. app/design/{frontend → adminhtml}/default/default/template/hipay/form/cc.phtml +43 -19
  81. app/design/adminhtml/default/default/template/hipay/form/hosted.phtml +41 -0
  82. app/design/adminhtml/default/default/template/hipay/info/cc.phtml +19 -0
  83. app/design/adminhtml/default/default/template/hipay/info/hosted.phtml +19 -0
  84. app/design/frontend/base/default/layout/hipay.xml +41 -0
  85. app/design/frontend/base/default/template/hipay/card/account.phtml +56 -0
  86. app/design/frontend/base/default/template/hipay/card/form/edit.phtml +33 -0
  87. app/design/frontend/{default → base}/default/template/hipay/checkout/pending.phtml +0 -0
  88. app/design/frontend/base/default/template/hipay/form/cc.phtml +245 -0
  89. app/design/frontend/{default → base}/default/template/hipay/form/hosted.phtml +40 -12
  90. app/design/frontend/base/default/template/hipay/info/cc.phtml +19 -0
  91. app/design/frontend/base/default/template/hipay/info/hosted.phtml +19 -0
  92. app/design/frontend/default/default/layout/hipay.xml +0 -12
  93. app/locale/en_US/Allopass_Hipay.csv +35 -3
  94. app/locale/en_US/template/email/hipay_fraud_payment.html +64 -0
  95. app/locale/en_US/template/email/hipay_fraud_payment_accept.html +64 -0
  96. app/locale/en_US/template/email/hipay_fraud_payment_deny.html +64 -0
  97. app/locale/fr_FR/Allopass_Hipay.csv +38 -2
  98. app/locale/fr_FR/template/email/hipay_fraud_payment.html +66 -0
  99. app/locale/fr_FR/template/email/hipay_fraud_payment_accept.html +64 -0
  100. app/locale/fr_FR/template/email/hipay_fraud_payment_deny.html +64 -0
  101. app/locale/it_IT/Allopass_Hipay.csv +33 -0
  102. app/locale/it_IT/template/email/hipay_fraud_payment.html +64 -0
  103. app/locale/it_IT/template/email/hipay_fraud_payment_accept.html +64 -0
  104. app/locale/it_IT/template/email/hipay_fraud_payment_deny.html +64 -0
  105. package.xml +6 -6
app/code/community/Allopass/Hipay/Block/Adminhtml/Card/Edit.php ADDED
@@ -0,0 +1,59 @@
1
+ <?php
2
+ class Allopass_Hipay_Block_Adminhtml_Card_Edit extends Mage_Adminhtml_Block_Widget_Form_Container
3
+ {
4
+ /**
5
+ * Initialize cms page edit block
6
+ *
7
+ * @return void
8
+ */
9
+ public function __construct()
10
+ {
11
+
12
+ $this->_objectId = 'card_id';
13
+ $this->_blockGroup = 'hipay';
14
+ $this->_controller = 'adminhtml_card';
15
+ $this->_headerText = $this->__('Card Hipay');
16
+ parent::__construct();
17
+
18
+ $this->removeButton('delete');
19
+
20
+
21
+ $this->_addButton('saveandcontinue', array(
22
+ 'label' => Mage::helper('adminhtml')->__('Save and Continue Edit'),
23
+ 'onclick' => 'saveAndContinueEdit(\''.$this->getUrl('*/*/save', array('_current'=>true,'back'=>'edit')).'\')',
24
+ 'class' => 'save',
25
+ ), -100);
26
+
27
+
28
+ $this->_formScripts[] = "
29
+ function saveAndContinueEdit(){
30
+ editForm.submit($('edit_form').action+'back/edit/');
31
+ }
32
+
33
+ function run(url){
34
+ editForm.submit(url);
35
+ }
36
+ ";
37
+ }
38
+
39
+ /**
40
+ * Get URL for back (reset) button
41
+ *
42
+ * @return string
43
+ */
44
+ public function getBackUrl()
45
+ {
46
+ return $this->getUrl('adminhtml/customer/edit',array('id'=>$this->getCard()->getCustomerId()));
47
+ }
48
+
49
+ /**
50
+ * Retrieve card model object
51
+ *
52
+ * @return Allopass_Hipay_Model_Card
53
+ */
54
+ public function getCard()
55
+ {
56
+ return Mage::registry('current_card');
57
+ }
58
+
59
+ }
app/code/community/Allopass/Hipay/Block/Adminhtml/Card/Edit/Form.php ADDED
@@ -0,0 +1,95 @@
1
+ <?php
2
+
3
+ class Allopass_Hipay_Block_Adminhtml_Card_Edit_Form extends Mage_Adminhtml_Block_Widget_Form
4
+ {
5
+
6
+ protected function _prepareForm()
7
+ {
8
+
9
+ /* @var $card Allopass_Hipay_Model_Card */
10
+ $card = Mage::registry('current_card');
11
+
12
+
13
+ $form = new Varien_Data_Form(array('id'=>'edit_form','action' => $this->getUrl('*/card/save'), 'method' => 'post'));
14
+
15
+ $fieldset = $form->addFieldset('card_form', array('legend'=>Mage::helper('hipay')->__('Card Hipay')));
16
+
17
+ if ($card->getCardId()) {
18
+ $fieldset->addField('card_id', 'hidden', array(
19
+ 'name' => 'card_id',
20
+ ));
21
+ $fieldset->addField('customer_id', 'hidden', array(
22
+ 'name' => 'customer_id',
23
+ ));
24
+ }
25
+ $fieldset->addField('name', 'text', array(
26
+ 'label' => Mage::helper('hipay')->__('Card #'),
27
+ 'title' => Mage::helper('hipay')->__('Card #'),
28
+ 'class' => 'required-entry',
29
+ 'required' => true,
30
+ 'name' => 'name',
31
+ ));
32
+
33
+ $fieldset->addField('is_default', 'select', array(
34
+ 'label' => Mage::helper('hipay')->__('Is default'),
35
+ 'title' => Mage::helper('hipay')->__('Is default'),
36
+ 'name' => 'is_default',
37
+ 'values' => array(Mage::helper('sales')->__('No'),Mage::helper('adminhtml')->__('Yes'))
38
+ ));
39
+
40
+ $statues = array(Allopass_Hipay_Model_Card::STATUS_ENABLED =>$this->__('Enabled') ,Allopass_Hipay_Model_Card::STATUS_DISABLED=>$this->__('Disabled'));
41
+ $fieldset->addField('cc_status', 'select', array(
42
+ 'label' => Mage::helper('hipay')->__('Status'),
43
+ 'title' => Mage::helper('hipay')->__('Status'),
44
+ 'name' => 'cc_status',
45
+ 'values' => $statues
46
+ ));
47
+
48
+
49
+ $fieldset_info = $form->addFieldset('card_info', array('legend'=>Mage::helper('hipay')->__('Informations'))) ;
50
+
51
+ $fieldset_info->addField('cc_type', 'text', array(
52
+ 'label' => Mage::helper('payment')->__('Card type'),
53
+ 'title' => Mage::helper('payment')->__('Card type'),
54
+ 'name' => 'cc_type',
55
+ 'readonly' => true,
56
+ ));
57
+
58
+ $fieldset_info->addField('cc_number_enc', 'text', array(
59
+ 'label' => Mage::helper('payment')->__('Card number'),
60
+ 'title' => Mage::helper('payment')->__('Card number'),
61
+ 'name' => 'cc_number_enc',
62
+ 'readonly' => true,
63
+ ));
64
+
65
+ $fieldset_info->addField('cc_exp_month', 'text', array(
66
+ 'label' => Mage::helper('payment')->__('Card Exp. month'),
67
+ 'title' => Mage::helper('payment')->__('Card Exp. month'),
68
+ 'name' => 'cc_exp_month',
69
+ 'readonly' => true,
70
+ ));
71
+
72
+ $fieldset_info->addField('cc_exp_year', 'text', array(
73
+ 'label' => Mage::helper('payment')->__('Card Exp. year'),
74
+ 'title' => Mage::helper('payment')->__('Card Exp. year'),
75
+ 'name' => 'cc_exp_year',
76
+ 'readonly' => true,
77
+ ));
78
+
79
+
80
+ $fieldset_info->addField('cc_token', 'text', array(
81
+ 'label' => Mage::helper('hipay')->__('Card Token'),
82
+ 'title' => Mage::helper('hipay')->__('Card Token'),
83
+ 'readonly' => true,
84
+ 'name' => 'cc_token',
85
+ ));
86
+
87
+
88
+
89
+ $form->setUseContainer(true);
90
+ $form->setValues($card->getData());
91
+ $this->setForm($form);
92
+ return parent::_prepareForm();
93
+ }
94
+
95
+ }
app/code/community/Allopass/Hipay/Block/Adminhtml/Customer/Edit/Tab/Card.php ADDED
@@ -0,0 +1,155 @@
1
+ <?php
2
+
3
+ class Allopass_Hipay_Block_Adminhtml_Customer_Edit_Tab_Card extends
4
+ Mage_Adminhtml_Block_Widget_Grid implements
5
+ Mage_Adminhtml_Block_Widget_Tab_Interface {
6
+
7
+ /**
8
+ * Initialize Grid
9
+ *
10
+ */
11
+ public function __construct() {
12
+ parent::__construct();
13
+ $this->setId('hipay_card_grid');
14
+ $this->setDefaultSort('card_id', 'desc');
15
+ $this->setUseAjax(true);
16
+ }
17
+
18
+ /**
19
+ * Retrieve current customer object
20
+ *
21
+ * @return Mage_Customer_Model_Customer
22
+ */
23
+ protected function _getCustomer() {
24
+ return Mage::registry('current_customer');
25
+ }
26
+
27
+ /**
28
+ * Create customer cards collection
29
+ *
30
+ * @return Allopass_Hipay_Model_Resource_Card_Collection
31
+ */
32
+ protected function _createCollection() {
33
+ return Mage::getModel('hipay/card')->getCollection();
34
+ }
35
+
36
+ /**
37
+ * Prepare customer card collection
38
+ *
39
+ * @return Allopass_Hipay_Block_Adminhtml_Customer_Edit_Tab_Card
40
+ */
41
+ protected function _prepareCollection() {
42
+ $collection = $this->_createCollection()
43
+ ->addFieldToFilter('customer_id',
44
+ $this->_getCustomer()->getId());
45
+ $this->setCollection($collection);
46
+
47
+ return parent::_prepareCollection();
48
+ }
49
+
50
+ /**
51
+ * Prepare Grid columns
52
+ *
53
+ * @return Mage_Adminhtml_Block_Customer_Edit_Tab_Wishlist
54
+ */
55
+ protected function _prepareColumns() {
56
+ $this
57
+ ->addColumn('name',
58
+ array(
59
+ 'header' => Mage::helper('hipay')
60
+ ->__('Card Name'),
61
+ 'index' => 'name',));
62
+
63
+ $this
64
+ ->addColumn('cc_type',
65
+ array(
66
+ 'header' => Mage::helper('hipay')->__('Type'),
67
+ 'index' => 'cc_type',));
68
+
69
+ $this
70
+ ->addColumn('cc_exp_month',
71
+ array(
72
+ 'header' => Mage::helper('hipay')
73
+ ->__('Exp. Month'),
74
+ 'index' => 'cc_exp_month',
75
+ 'type' => 'number', 'width' => '30px'));
76
+
77
+ $this
78
+ ->addColumn('cc_exp_year',
79
+ array(
80
+ 'header' => Mage::helper('hipay')
81
+ ->__('Exp. Year'),
82
+ 'index' => 'cc_exp_year',
83
+ 'type' => 'number', 'width' => '30px'));
84
+
85
+ $this
86
+ ->addColumn('cc_token',
87
+ array(
88
+ 'header' => Mage::helper('hipay')
89
+ ->__('Alias oneclick'),
90
+ 'index' => 'cc_token',));
91
+
92
+ $this->addColumn('cc_status',
93
+ array(
94
+ 'header'=> Mage::helper('hipay')->__('Status'),
95
+ 'index' => 'cc_status',
96
+ 'type' => 'options',
97
+ 'options' => array(Allopass_Hipay_Model_Card::STATUS_ENABLED=>$this->__('Enabled'),Allopass_Hipay_Model_Card::STATUS_DISABLED=>$this->__('Disabled')),
98
+ ));
99
+
100
+ $this->addColumn('is_default',
101
+ array(
102
+ 'header'=> Mage::helper('hipay')->__('Is default'),
103
+ 'index' => 'is_default',
104
+ 'type' => 'options',
105
+ 'options' => array($this->__('No'),$this->__('Yes')),
106
+ ));
107
+
108
+
109
+
110
+ return parent::_prepareColumns();
111
+ }
112
+
113
+
114
+ public function getGridUrl() {
115
+ return $this
116
+ ->getUrl('hipay/adminhtml_card/cards',
117
+ array('_current' => true));
118
+ }
119
+
120
+ /**
121
+ * Row click url
122
+ *
123
+ * @return string
124
+ */
125
+ public function getRowUrl($row)
126
+ {
127
+ return $this->getUrl('adminhtml/card/edit', array('card_id' => $row->getId()));
128
+ }
129
+
130
+ public function getTabLabel() {
131
+ return Mage::helper('hipay')->__("Hipay's Cards");
132
+
133
+ }
134
+ public function getTabTitle() {
135
+ return Mage::helper('hipay')->__("Hipay's Cards");
136
+
137
+ }
138
+
139
+ public function canShowTab()
140
+ {
141
+ if (Mage::registry('current_customer')->getId()) {
142
+ return true;
143
+ }
144
+ return false;
145
+ }
146
+
147
+ public function isHidden()
148
+ {
149
+ if (Mage::registry('current_customer')->getId()) {
150
+ return false;
151
+ }
152
+ return true;
153
+ }
154
+
155
+ }
app/code/community/Allopass/Hipay/Block/Adminhtml/PaymentProfile.php ADDED
@@ -0,0 +1,14 @@
1
+ <?php
2
+ class Allopass_Hipay_Block_Adminhtml_PaymentProfile extends Mage_Adminhtml_Block_Widget_Grid_Container
3
+ {
4
+ public function __construct()
5
+ {
6
+
7
+ $this->_controller = 'adminhtml_paymentProfile';
8
+ $this->_blockGroup = 'hipay';
9
+ $this->_headerText = $this->__('Hipay Payment Profiles');
10
+ $this->_addButtonLabel = $this->__('Add payment profile');
11
+
12
+ parent::__construct();
13
+ }
14
+ }
app/code/community/Allopass/Hipay/Block/Adminhtml/PaymentProfile/Edit.php ADDED
@@ -0,0 +1,35 @@
1
+ <?php
2
+ class Allopass_Hipay_Block_Adminhtml_PaymentProfile_Edit extends Mage_Adminhtml_Block_Widget_Form_Container
3
+ {
4
+ /**
5
+ * Initialize cms page edit block
6
+ *
7
+ * @return void
8
+ */
9
+ public function __construct()
10
+ {
11
+
12
+ $this->_objectId = 'profile_id';
13
+ $this->_blockGroup = 'hipay';
14
+ $this->_controller = 'adminhtml_paymentProfile';
15
+ $this->_headerText = $this->__('Payment Profile');
16
+ parent::__construct();
17
+
18
+ $this->_addButton('saveandcontinue', array(
19
+ 'label' => Mage::helper('adminhtml')->__('Save and Continue Edit'),
20
+ 'onclick' => 'saveAndContinueEdit(\''.$this->getUrl('*/*/save', array('_current'=>true,'back'=>'edit')).'\')',
21
+ 'class' => 'save',
22
+ ), -100);
23
+
24
+ $this->_formScripts[] = "
25
+ function saveAndContinueEdit(){
26
+ editForm.submit($('edit_form').action+'back/edit/');
27
+ }
28
+ ";
29
+
30
+ }
31
+
32
+
33
+
34
+
35
+ }
app/code/community/Allopass/Hipay/Block/Adminhtml/PaymentProfile/Edit/Form.php ADDED
@@ -0,0 +1,75 @@
1
+ <?php
2
+
3
+ class Allopass_Hipay_Block_Adminhtml_PaymentProfile_Edit_Form extends Mage_Adminhtml_Block_Widget_Form
4
+ {
5
+
6
+ protected function _prepareForm()
7
+ {
8
+ /* @var $profile Allopass_Hipay_Model_PaymentProfile */
9
+ $profile = Mage::registry('payment_profile');
10
+
11
+ $form = new Varien_Data_Form(array('id'=>'edit_form','action' => $this->getUrl('*/paymentProfile/save'), 'method' => 'post'));
12
+
13
+ $fieldset = $form->addFieldset('paymentProfile_form', array('legend'=>Mage::helper('hipay')->__('Payment Profile')));
14
+
15
+ if ($profile->getProfileId()) {
16
+ $fieldset->addField('profile_id', 'hidden', array(
17
+ 'name' => 'profile_id',
18
+ ));
19
+ }
20
+ $fieldset->addField('name', 'text', array(
21
+ 'label' => Mage::helper('hipay')->__('Name'),
22
+ 'title' => Mage::helper('hipay')->__('Name'),
23
+ 'class' => 'required-entry',
24
+ 'required' => true,
25
+ 'name' => 'name',
26
+ ));
27
+
28
+ $fieldset->addField('period_unit', 'select', array(
29
+ 'label' => $profile->getFieldLabel('period_unit'),
30
+ 'title' => $profile->getFieldLabel('period_unit'),
31
+ 'class' => 'required-entry',
32
+ 'name' => 'period_unit',
33
+ 'values' => Mage::getSingleton('hipay/paymentProfile')->getAllPeriodUnits(),
34
+ 'note'=>$this->__('Unit for billing during the subscription period.')
35
+ )
36
+ );
37
+
38
+ $fieldset->addField('period_frequency', 'text', array(
39
+ 'label' => $profile->getFieldLabel('period_frequency'),
40
+ 'title' => $profile->getFieldLabel('period_frequency'),
41
+ 'class' => 'required-entry validate-number',
42
+ 'required' => true,
43
+ 'name' => 'period_frequency',
44
+ 'note'=>$this->__('Number of billing periods that make up one billing cycle.')
45
+ ));
46
+
47
+ $fieldset->addField('period_max_cycles', 'text', array(
48
+ 'label' => $profile->getFieldLabel('period_max_cycles'),
49
+ 'title' => $profile->getFieldLabel('period_max_cycles'),
50
+ 'class' => 'required-entry validate-number',
51
+ 'required' => true,
52
+ 'name' => 'period_max_cycles',
53
+ 'note'=>$this->__('The number of billing cycles for payment period.')
54
+ ));
55
+
56
+ /*$fieldset->addField('payment_type', 'select', array(
57
+ 'label' => $profile->getPaymentTypeLabel('payment_type'),
58
+ 'title' => $profile->getPaymentTypeLabel('payment_type'),
59
+ 'name' => 'payment_type',
60
+ 'values' => $profile->getAllPaymentTypes(),
61
+ )
62
+ );*/
63
+
64
+ $fieldset->addField('payment_type', "hidden", array(
65
+ 'name' => 'payment_type'
66
+ ));
67
+ $profile->setData('payment_type',"split_payment");
68
+
69
+ $form->setUseContainer(true);
70
+ $form->setValues($profile->getData());
71
+ $this->setForm($form);
72
+ return parent::_prepareForm();
73
+ }
74
+
75
+ }
app/code/community/Allopass/Hipay/Block/Adminhtml/PaymentProfile/Grid.php ADDED
@@ -0,0 +1,83 @@
1
+ <?php
2
+ class Allopass_Hipay_Block_Adminhtml_PaymentProfile_Grid extends Mage_Adminhtml_Block_Widget_Grid
3
+ {
4
+
5
+ protected function _prepareCollection()
6
+ {
7
+
8
+ $collection = Mage::getModel('hipay/paymentProfile')->getCollection();
9
+ $this->setCollection($collection);
10
+ parent::_prepareCollection();
11
+ return $this;
12
+ }
13
+
14
+
15
+ protected function _prepareColumns()
16
+ {
17
+ /* @var $profile Allopass_Hipay_Model_PaymentProfile */
18
+ $profile = Mage::getModel('hipay/paymentProfile');
19
+
20
+ $this->addColumn('profile_id',
21
+ array(
22
+ 'header'=> Mage::helper('hipay')->__('ID'),
23
+ 'width' => '50px',
24
+ 'type' => 'number',
25
+ 'index' => 'profile_id',
26
+ ));
27
+ $this->addColumn('name',
28
+ array(
29
+ 'header'=> Mage::helper('hipay')->__('Name'),
30
+ 'index' => 'name',
31
+ ));
32
+
33
+
34
+ $this->addColumn('period_unit',
35
+ array(
36
+ 'header'=> $profile->getFieldLabel('period_unit'),
37
+ 'width' => '60px',
38
+ 'index' => 'period_unit',
39
+ 'type' => 'options',
40
+ 'options' => Mage::getSingleton('hipay/paymentProfile')->getAllPeriodUnits(),
41
+ ));
42
+
43
+
44
+ $this->addColumn('period_frequency',
45
+ array(
46
+ 'header'=> $profile->getFieldLabel('period_frequency'),
47
+ 'width' => '10px',
48
+ 'type' => 'number',
49
+ 'index' => 'period_frequency',
50
+ ));
51
+
52
+ $this->addColumn('period_max_cycles',
53
+ array(
54
+ 'header'=> $profile->getFieldLabel('period_max_cycles'),
55
+ 'width' => '10px',
56
+ 'type' => 'number',
57
+ 'index' => 'period_max_cycles',
58
+ ));
59
+
60
+ $this->addColumn('payment_type',
61
+ array(
62
+ 'header'=> Mage::helper('hipay')->__('Payment type'),
63
+ 'width' => '60px',
64
+ 'index' => 'payment_type',
65
+ 'type' => 'options',
66
+ 'options' => Mage::getSingleton('hipay/paymentProfile')->getAllPaymentTypes(),
67
+ ));
68
+
69
+
70
+
71
+ return parent::_prepareColumns();
72
+ }
73
+
74
+ /**
75
+ * Row click url
76
+ *
77
+ * @return string
78
+ */
79
+ public function getRowUrl($row)
80
+ {
81
+ return $this->getUrl('*/*/edit', array('profile_id' => $row->getId()));
82
+ }
83
+ }
app/code/community/Allopass/Hipay/Block/Adminhtml/SplitPayment.php ADDED
@@ -0,0 +1,14 @@
1
+ <?php
2
+ class Allopass_Hipay_Block_Adminhtml_SplitPayment extends Mage_Adminhtml_Block_Widget_Grid_Container
3
+ {
4
+ public function __construct()
5
+ {
6
+ $this->_controller = 'adminhtml_splitPayment';
7
+ $this->_blockGroup = 'hipay';
8
+ $this->_headerText = $this->__('Hipay Split Payments');
9
+
10
+ parent::__construct();
11
+
12
+ $this->_removeButton('add');
13
+ }
14
+ }
app/code/community/Allopass/Hipay/Block/Adminhtml/SplitPayment/Edit.php ADDED
@@ -0,0 +1,55 @@
1
+ <?php
2
+ class Allopass_Hipay_Block_Adminhtml_SplitPayment_Edit extends Mage_Adminhtml_Block_Widget_Form_Container
3
+ {
4
+ /**
5
+ * Initialize cms page edit block
6
+ *
7
+ * @return void
8
+ */
9
+ public function __construct()
10
+ {
11
+
12
+ $this->_objectId = 'split_payment_id';
13
+ $this->_blockGroup = 'hipay';
14
+ $this->_controller = 'adminhtml_splitPayment';
15
+ $this->_headerText = $this->__('Split Payment');
16
+ parent::__construct();
17
+
18
+ $this->removeButton('delete');
19
+
20
+
21
+ $this->_addButton('saveandcontinue', array(
22
+ 'label' => Mage::helper('adminhtml')->__('Save and Continue Edit'),
23
+ 'onclick' => 'saveAndContinueEdit(\''.$this->getUrl('*/*/save', array('_current'=>true,'back'=>'edit')).'\')',
24
+ 'class' => 'save',
25
+ ), -100);
26
+
27
+ if($this->getSplitPayment()->canPay())
28
+ $this->_addButton('payNow', array(
29
+ 'label' => Mage::helper('adminhtml')->__('Pay now'),
30
+ 'onclick' => 'run(\''.$this->getUrl('*/*/payNow', array('_current'=>true,'back'=>'edit')).'\')',
31
+ 'class' => 'go',
32
+ ), -120);
33
+
34
+ $this->_formScripts[] = "
35
+ function saveAndContinueEdit(){
36
+ editForm.submit($('edit_form').action+'back/edit/');
37
+ }
38
+
39
+ function run(url){
40
+ editForm.submit(url);
41
+ }
42
+ ";
43
+ }
44
+
45
+ /**
46
+ * Retrieve SplitPayment model object
47
+ *
48
+ * @return Allopass_Hipay_Model_SplitPayment
49
+ */
50
+ public function getSplitPayment()
51
+ {
52
+ return Mage::registry('split_payment');
53
+ }
54
+
55
+ }
app/code/community/Allopass/Hipay/Block/Adminhtml/SplitPayment/Edit/Form.php ADDED
@@ -0,0 +1,96 @@
1
+ <?php
2
+
3
+ class Allopass_Hipay_Block_Adminhtml_SplitPayment_Edit_Form extends Mage_Adminhtml_Block_Widget_Form
4
+ {
5
+
6
+ protected function _prepareForm()
7
+ {
8
+ /* @var $profile Allopass_Hipay_Model_SplitPayment */
9
+ $splitPayment = Mage::registry('split_payment');
10
+
11
+ $form = new Varien_Data_Form(array('id'=>'edit_form','action' =>$this->getUrl('*/splitPayment/save'), 'method' => 'post'));
12
+
13
+ $fieldset = $form->addFieldset('splitPayment_form', array('legend'=>Mage::helper('hipay')->__('Split Payment')));
14
+
15
+ if ($splitPayment->getSplitPaymentId()) {
16
+ $fieldset->addField('split_payment_id', 'hidden', array(
17
+ 'name' => 'split_payment_id',
18
+ ));
19
+ }
20
+ $fieldset->addField('real_order_id', 'text', array(
21
+ 'label' => Mage::helper('sales')->__('Order #'),
22
+ 'title' => Mage::helper('sales')->__('Order #'),
23
+ 'class' => 'required-entry',
24
+ 'required' => true,
25
+ 'name' => 'real_order_id',
26
+ 'readonly' => true,
27
+ ));
28
+
29
+ $fieldset->addField('customer_id', 'text', array(
30
+ 'label' => Mage::helper('customer')->__('Customer ID'),
31
+ 'title' => Mage::helper('customer')->__('Customer ID'),
32
+ 'class' => 'required-entry',
33
+ 'required' => true,
34
+ 'name' => 'customer_id',
35
+ 'readonly' => true,
36
+ ));
37
+
38
+ $fieldset->addField('card_token', 'text', array(
39
+ 'label' => Mage::helper('hipay')->__('Card Token'),
40
+ 'title' => Mage::helper('hipay')->__('Card Token'),
41
+ 'class' => 'required-entry',
42
+ 'required' => true,
43
+ 'name' => 'card_token',
44
+ ));
45
+
46
+ $fieldset->addField('total_amount', 'text', array(
47
+ 'label' => Mage::helper('sales')->__('G.T. (Purchased)'),
48
+ 'title' => Mage::helper('sales')->__('G.T. (Purchased)'),
49
+ 'class' => 'required-entry validate-number',
50
+ 'required' => true,
51
+ 'name' => 'total_amount',
52
+ 'readonly' => true,
53
+ ));
54
+
55
+ $fieldset->addField('amount_to_pay', 'text', array(
56
+ 'label' => Mage::helper('hipay')->__('Amount to pay'),
57
+ 'title' => Mage::helper('hipay')->__('Amount to pay'),
58
+ 'class' => 'required-entry validate-number',
59
+ 'required' => true,
60
+ 'name' => 'amount_to_pay',
61
+ ));
62
+
63
+ $fieldset->addField('date_to_pay', 'date', array(
64
+ 'label' => Mage::helper('hipay')->__('Date to pay'),
65
+ 'title' => Mage::helper('hipay')->__('Date to pay'),
66
+ 'class' => 'required-entry',
67
+ 'required' => true,
68
+ 'name' => 'date_to_pay',
69
+ 'format' => Mage::app()->getLocale()->getDateFormat(Mage_Core_Model_Locale::FORMAT_TYPE_SHORT),
70
+ 'image' => $this->getSkinUrl('images/grid-cal.gif'),
71
+ ));
72
+
73
+ $fieldset->addField('attempts', 'text', array(
74
+ 'label' => Mage::helper('hipay')->__('Attempts'),
75
+ 'title' => Mage::helper('hipay')->__('Attempts'),
76
+ 'class' => 'required-entry validate-number',
77
+ 'required' => true,
78
+ 'name' => 'attempts',
79
+ 'readonly' => true,
80
+ ));
81
+
82
+ $fieldset->addField('status', 'select', array(
83
+ 'label' => Mage::helper('hipay')->__('Status'),
84
+ 'title' => Mage::helper('hipay')->__('Status'),
85
+ 'name' => 'status',
86
+ 'values' => Allopass_Hipay_Model_SplitPayment::getStatues(),
87
+ )
88
+ );
89
+
90
+ $form->setUseContainer(true);
91
+ $form->setValues($splitPayment->getData());
92
+ $this->setForm($form);
93
+ return parent::_prepareForm();
94
+ }
95
+
96
+ }
app/code/community/Allopass/Hipay/Block/Adminhtml/SplitPayment/Grid.php ADDED
@@ -0,0 +1,103 @@
1
+ <?php
2
+ class Allopass_Hipay_Block_Adminhtml_SplitPayment_Grid extends Mage_Adminhtml_Block_Widget_Grid
3
+ {
4
+ protected $_defaultSort = 'split_payment_id';
5
+
6
+ protected function _prepareCollection()
7
+ {
8
+
9
+ $collection = Mage::getModel('hipay/splitPayment')->getCollection();
10
+ $this->setCollection($collection);
11
+ parent::_prepareCollection();
12
+ return $this;
13
+ }
14
+
15
+
16
+ protected function _prepareColumns()
17
+ {
18
+
19
+
20
+ $this->addColumn('split_payment_id',
21
+ array(
22
+ 'header'=> Mage::helper('hipay')->__('ID'),
23
+ 'width' => '50px',
24
+ 'type' => 'number',
25
+ 'index' => 'split_payment_id',
26
+ ));
27
+ $this->addColumn('real_order_id',
28
+ array(
29
+ 'header'=> Mage::helper('sales')->__('Order #'),
30
+ 'type' => 'text',
31
+ 'width'=>'20px',
32
+ 'index' => 'real_order_id',
33
+ ));
34
+
35
+ $this->addColumn('customer_id',
36
+ array(
37
+ 'header'=> Mage::helper('customer')->__('Customer ID'),
38
+ 'type' => 'text',
39
+ 'width'=>'20px',
40
+ 'index' => 'customer_id',
41
+ ));
42
+
43
+ $this->addColumn('card_token',
44
+ array(
45
+ 'header'=> Mage::helper('hipay')->__('Card Token'),
46
+ 'type' => 'text',
47
+ 'width'=>'60px',
48
+ 'index' => 'card_token',
49
+ ));
50
+
51
+
52
+ $this->addColumn('total_amount',
53
+ array(
54
+ 'header'=> Mage::helper('sales')->__('G.T. (Purchased)'),
55
+ 'index' => 'total_amount',
56
+ 'type' => 'currency',
57
+ ));
58
+
59
+
60
+ $this->addColumn('amount_to_pay',
61
+ array(
62
+ 'header'=> Mage::helper('hipay')->__('Amount to pay'),
63
+ 'type' => 'currency',
64
+ 'index' => 'amount_to_pay',
65
+ ));
66
+
67
+ $this->addColumn('date_to_pay',
68
+ array(
69
+ 'header'=> Mage::helper('hipay')->__('Date to pay'),
70
+ 'type' => 'date',
71
+ 'index' => 'date_to_pay',
72
+ ));
73
+
74
+ $this->addColumn('attempts',
75
+ array(
76
+ 'header'=> Mage::helper('hipay')->__('Attempts'),
77
+ 'index' => 'attempts',
78
+ 'type' => 'number',
79
+ ));
80
+
81
+ $this->addColumn('status',
82
+ array(
83
+ 'header'=> Mage::helper('hipay')->__('Status'),
84
+ 'index' => 'status',
85
+ 'type' => 'options',
86
+ 'options' => Allopass_Hipay_Model_SplitPayment::getStatues(),
87
+ ));
88
+
89
+
90
+
91
+ return parent::_prepareColumns();
92
+ }
93
+
94
+ /**
95
+ * Row click url
96
+ *
97
+ * @return string
98
+ */
99
+ public function getRowUrl($row)
100
+ {
101
+ return $this->getUrl('*/*/edit', array('split_payment_id' => $row->getId()));
102
+ }
103
+ }
app/code/community/Allopass/Hipay/Block/Adminhtml/System/Config/Form/Field/3dsRule.php CHANGED
@@ -29,12 +29,17 @@ class Allopass_Hipay_Block_Adminhtml_System_Config_Form_Field_3dsRule extends M
29
*/
30
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
31
{
32
$partsId = explode("_", $element->getId());
33
$method_code = $partsId[1]. "_" . $partsId[2];
34
$rule = Mage::getModel('hipay/rule');
35
$rule->setMethodCode($method_code);
36
if($element->getValue())
37
$rule->load($element->getValue());
38
39
$element->setRule($rule);
40
29
*/
30
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
31
{
32
+
33
$partsId = explode("_", $element->getId());
34
$method_code = $partsId[1]. "_" . $partsId[2];
35
$rule = Mage::getModel('hipay/rule');
36
$rule->setMethodCode($method_code);
37
+
38
if($element->getValue())
39
$rule->load($element->getValue());
40
+
41
+ if($rule->getConfigPath() == "")
42
+ $rule->setConfigPath($element->getId());
43
44
$element->setRule($rule);
45
app/code/community/Allopass/Hipay/Block/Adminhtml/System/Config/Form/Field/Allowsplitpayment.php ADDED
@@ -0,0 +1,42 @@
1
+ <?php
2
+
3
+ class Allopass_Hipay_Block_Adminhtml_System_Config_Form_Field_Allowsplitpayment extends Mage_Adminhtml_Block_System_Config_Form_Field
4
+ {
5
+
6
+ /**
7
+ *
8
+ * @param Varien_Data_Form_Element_Abstract $element
9
+ * @return string
10
+ */
11
+ protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
12
+ {
13
+ $javaScript = "
14
+ <script type=\"text/javascript\">
15
+ Event.observe('{$element->getId()}', 'change', function(){
16
+ split_payment=$('{$element->getId()}').value;
17
+ $('{$this->_getSplitPaymentElementId($element)}').disabled = (!split_payment || split_payment!=1);
18
+ });
19
+ </script>";
20
+
21
+ $element->setData('after_element_html',$javaScript.$element->getAfterElementHtml());
22
+
23
+ $this->toggleDisabled($element);
24
+
25
+ return parent::_getElementHtml($element);
26
+ }
27
+
28
+ public function toggleDisabled($element)
29
+ {
30
+ if(!$element->getValue() || $element->getValue()!=1) {
31
+
32
+ $element->getForm()->getElement($this->_getSplitPaymentElementId($element))->setDisabled('disabled');
33
+ }
34
+ return parent::getHtml();
35
+ }
36
+
37
+ protected function _getSplitPaymentElementId($element)
38
+ {
39
+ return substr($element->getId(), 0, strrpos($element->getId(), 'allow_split_payment')) . 'split_payment_profile';
40
+ }
41
+
42
+ }
app/code/community/Allopass/Hipay/Block/Adminhtml/System/Config/Form/Field/MultiselectSortable.php ADDED
@@ -0,0 +1,46 @@
1
+ <?php
2
+ class Allopass_Hipay_Block_Adminhtml_System_Config_Form_Field_MultiselectSortable extends Mage_Adminhtml_Block_System_Config_Form_Field
3
+ {
4
+
5
+ /**
6
+ *
7
+ * @param Varien_Data_Form_Element_Abstract $element
8
+ * @return string
9
+ */
10
+ protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
11
+ {
12
+ $javaScript = "
13
+ <script type=\"text/javascript\">
14
+ var options = $(\"#row_".$element->getHtmlId()." ul.checkboxes li\");
15
+ options.each(function(e){
16
+ var input = e.select('input').first();
17
+ input.name = input.name + '[]';
18
+
19
+ var label = e.select('label').first();
20
+ label.setStyle({cursor:'move'});
21
+ label.writeAttribute('for',false);
22
+
23
+ });
24
+ /*$(\"#row_".$element->getHtmlId()." ul.checkboxes li input\").each(function(e,i)
25
+ {
26
+ e.name = e.name + '[]';
27
+ });
28
+
29
+ $(\"#row_".$element->getHtmlId()." ul.checkboxes li label\").each(function(e,i)
30
+ {
31
+ e.setStyle({cursor:'move'});
32
+ e.writeAttribute({for}:'');
33
+ });*/
34
+
35
+
36
+ //Sortable.create('".$element->getHtmlId()."',{elements:$('#".$element->getHtmlId()." option'),handles:$('#".$element->getHtmlId()." option')});
37
+ var container = $(\"#row_".$element->getHtmlId()." ul.checkboxes\").first();
38
+ Sortable.create(container);
39
+ </script>";
40
+ $element->setData('after_element_html',$javaScript.$element->getAfterElementHtml());
41
+
42
+ return parent::_getElementHtml($element);
43
+ }
44
+
45
+
46
+ }
app/code/community/Allopass/Hipay/Block/Card.php ADDED
@@ -0,0 +1,59 @@
1
+ <?php
2
+
3
+ class Allopass_Hipay_Block_Card extends Mage_Core_Block_Template
4
+ {
5
+
6
+ public function __construct()
7
+ {
8
+ parent::__construct();
9
+ $this->setTemplate('hipay/card/account.phtml');
10
+
11
+ $cards = Mage::getResourceModel('hipay/card_collection')
12
+ ->addFieldToSelect('*')
13
+ ->addFieldToFilter('customer_id', Mage::getSingleton('customer/session')->getCustomer()->getId())
14
+ ->addFieldToFilter('cc_status', Allopass_Hipay_Model_Card::STATUS_ENABLED)
15
+ ->setOrder('card_id', 'desc')
16
+ ;
17
+
18
+ $this->setCards($cards);
19
+
20
+ Mage::app()->getFrontController()->getAction()->getLayout()->getBlock('root')->setHeaderTitle(Mage::helper('hipay')->__("Hipay's Cards"));
21
+ }
22
+
23
+ protected function _prepareLayout()
24
+ {
25
+ parent::_prepareLayout();
26
+
27
+ $pager = $this->getLayout()->createBlock('page/html_pager', 'hipay.card.account.pager')
28
+ ->setCollection($this->getCards());
29
+ $this->setChild('pager', $pager);
30
+ $this->getCards()->load();
31
+ return $this;
32
+ }
33
+
34
+ public function getPagerHtml()
35
+ {
36
+ return $this->getChildHtml('pager');
37
+ }
38
+
39
+ public function getEditUrl($card)
40
+ {
41
+ return $this->getUrl('*/*/edit', array('card_id' => $card->getId()));
42
+ }
43
+
44
+ public function canDelete()
45
+ {
46
+ return true;
47
+ }
48
+
49
+
50
+ public function getDeleteUrl($card)
51
+ {
52
+ return $this->getUrl('*/*/delete', array('card_id' => $card->getId()));
53
+ }
54
+
55
+ public function getBackUrl()
56
+ {
57
+ return $this->getUrl('customer/account/');
58
+ }
59
+ }
app/code/community/Allopass/Hipay/Block/Card/Edit.php ADDED
@@ -0,0 +1,44 @@
1
+ <?php
2
+ class Allopass_Hipay_Block_Card_Edit extends Mage_Core_Block_Template
3
+ {
4
+ protected $_card;
5
+
6
+ protected function _prepareLayout()
7
+ {
8
+ parent::_prepareLayout();
9
+ $this->_card = Mage::registry('current_card');
10
+
11
+
12
+ if ($headBlock = $this->getLayout()->getBlock('head')) {
13
+ $headBlock->setTitle($this->getTitle());
14
+ }
15
+
16
+ if ($postedData = Mage::getSingleton('customer/session')->getCardFormData(true)) {
17
+ $this->_card->addData($postedData);
18
+ }
19
+
20
+ return $this;
21
+ }
22
+
23
+ public function getCard()
24
+ {
25
+ return $this->_card;
26
+ }
27
+
28
+
29
+ public function getBackUrl()
30
+ {
31
+ if ($this->getData('back_url')) {
32
+ return $this->getData('back_url');
33
+ }
34
+
35
+ return $this->getUrl('hipay/card');
36
+
37
+ }
38
+
39
+ public function getSaveUrl()
40
+ {
41
+ return Mage::getUrl('hipay/card/editPost', array('_secure'=>true, 'id'=>$this->getCard()->getId()));
42
+ }
43
+
44
+ }
app/code/community/Allopass/Hipay/Block/Form/Abstract.php CHANGED
@@ -1,6 +1,11 @@
1
<?php
2
abstract class Allopass_Hipay_Block_Form_Abstract extends Mage_Payment_Block_Form
3
{
4
5
/**
6
* Retrieve payment configuration object
@@ -11,14 +16,50 @@ abstract class Allopass_Hipay_Block_Form_Abstract extends Mage_Payment_Block_For
11
{
12
return Mage::getSingleton('hipay/config');
13
}
14
-
15
16
public function getCustomerHasAlias()
17
{
18
return $this->getCustomer()->getHipayAliasOneclick() != "";
19
20
}
21
22
public function getCustomer()
23
{
24
return Mage::getSingleton('customer/session')->getCustomer();
@@ -29,6 +70,11 @@ abstract class Allopass_Hipay_Block_Form_Abstract extends Mage_Payment_Block_For
29
return $this->helper('hipay')->checkIfCcExpDateIsValid((int)Mage::getSingleton('customer/session')->getCustomerId());
30
}
31
32
public function oneClickIsAllowed()
33
{
34
$checkoutMethod = Mage::getSingleton('checkout/session')->getQuote()->getCheckoutMethod();
@@ -40,15 +86,59 @@ abstract class Allopass_Hipay_Block_Form_Abstract extends Mage_Payment_Block_For
40
41
}
42
43
public function getQuote()
44
{
45
return Mage::getSingleton('checkout/session')->getQuote();
46
}
47
48
49
- public function allowUseOneClick()
50
{
51
- return $this->getMethod()->getConfigData('allow_use_oneclick');
52
}
53
54
public function getIframeConfig()
@@ -56,6 +146,7 @@ abstract class Allopass_Hipay_Block_Form_Abstract extends Mage_Payment_Block_For
56
$iframe['iframe_width'] = $this->getMethod()->getConfigData('iframe_width');
57
$iframe['iframe_height'] = $this->getMethod()->getConfigData('iframe_height');
58
$iframe['iframe_style'] = $this->getMethod()->getConfigData('iframe_style');
59
return $iframe;
60
}
61
1
<?php
2
abstract class Allopass_Hipay_Block_Form_Abstract extends Mage_Payment_Block_Form
3
{
4
+ /**
5
+ *
6
+ * @var Allopass_Hipay_Model_Resource_Card_Collection
7
+ */
8
+ protected $_cards = null;
9
10
/**
11
* Retrieve payment configuration object
16
{
17
return Mage::getSingleton('hipay/config');
18
}
19
20
+ public function getCards()
21
+ {
22
+ if(is_null($this->_cards))
23
+ {
24
+ $today = new Zend_Date(Mage::app()->getLocale()->storeTimeStamp());
25
+
26
+ $currentYear = (int)$today->getYear()->toString("YY");
27
+ $currentMonth = (int)$today->getMonth()->toString("MM");
28
+
29
+ $this->_cards = Mage::getResourceModel('hipay/card_collection')
30
+ ->addFieldToSelect('*')
31
+ ->addFieldToFilter('customer_id', $this->getCustomer()->getId())
32
+ ->addFieldToFilter('cc_status', Allopass_Hipay_Model_Card::STATUS_ENABLED)
33
+ ->addFieldToFilter('cc_exp_year', array("gteq"=>$currentYear))
34
+ ->setOrder('card_id', 'desc')
35
+ ->setOrder('is_default', 'desc');
36
+
37
+ foreach ($this->_cards as $card)
38
+ {
39
+ if($card->ccExpYear == $currentYear && $currentMonth < $card->ccExpMonth)
40
+ $this->_cards->removeItemByKey($card->getId());
41
+ }
42
+ }
43
+
44
+ return $this->_cards;
45
+ }
46
+
47
+ /**
48
+ * @deprecated since v1.0.9
49
+ * @return boolean
50
+ */
51
public function getCustomerHasAlias()
52
{
53
return $this->getCustomer()->getHipayAliasOneclick() != "";
54
55
}
56
57
+ public function getCustomerHasCard()
58
+ {
59
+ return $this->getCards()->count() > 0;
60
+
61
+ }
62
+
63
public function getCustomer()
64
{
65
return Mage::getSingleton('customer/session')->getCustomer();
70
return $this->helper('hipay')->checkIfCcExpDateIsValid((int)Mage::getSingleton('customer/session')->getCustomerId());
71
}
72
73
+ /**
74
+ * If checkout method is GUEST oneclick is not allowed
75
+ * Or We check method configuration
76
+ * @return boolean
77
+ */
78
public function oneClickIsAllowed()
79
{
80
$checkoutMethod = Mage::getSingleton('checkout/session')->getQuote()->getCheckoutMethod();
86
87
}
88
89
+ /**
90
+ * @return Mage_Sales_Model_Quote
91
+ *
92
+ * */
93
public function getQuote()
94
{
95
return Mage::getSingleton('checkout/session')->getQuote();
96
}
97
98
+ public function allowSplitPayment()
99
+ {
100
+
101
+ $checkoutMethod = $this->getQuote()->getCheckoutMethod();
102
+ $minAmount = $this->getMethod()->getConfigData('min_order_total_split_payment');
103
+
104
+ if($checkoutMethod == Mage_Checkout_Model_Type_Onepage::METHOD_GUEST ||
105
+ !$this->getMethod()->getConfigData('allow_split_payment') ||
106
+ ($this->getMethod()->getConfigData('allow_split_payment') && !empty($minAmount) && $minAmount >= $this->getQuote()->getBaseGrandTotal() ))
107
+ return false;
108
+
109
+ return true;
110
+ }
111
+
112
+ public function getSplitPaymentProfiles()
113
+ {
114
+ $profileIds = explode(",", $this->getMethod()->getConfigData('split_payment_profile'));
115
+ $profiles = Mage::getModel('hipay/paymentProfile')->getCollection()->addIdsToFilter($profileIds);
116
+ return $profiles;
117
+
118
+ }
119
+
120
121
+ protected function allowUseOneClick()
122
{
123
+ switch ((int)$this->getMethod()->getConfigData('allow_use_oneclick')) {
124
+ case 0:
125
+ return false;
126
+
127
+ case 1:
128
+ /* @var $rule Allopass_Hipay_Model_Rule */
129
+
130
+ $rule = Mage::getModel('hipay/rule')->load($this->getMethod()->getConfigData('filter_oneclick'));
131
+ if($rule->getId())
132
+ {
133
+ /*$objToValidate = new Varien_Object();
134
+ $objToValidate->setQuoteId($this->getQuote()->getId());
135
+ $objToValidate->setQuote($this->getQuote());
136
+ $objToValidate->setCreatedAt($this->getQuote()->getCreatedAt());*/
137
+ return (int)$rule->validate($this->getQuote());
138
+ }
139
+ return true;
140
+
141
+ }
142
}
143
144
public function getIframeConfig()
146
$iframe['iframe_width'] = $this->getMethod()->getConfigData('iframe_width');
147
$iframe['iframe_height'] = $this->getMethod()->getConfigData('iframe_height');
148
$iframe['iframe_style'] = $this->getMethod()->getConfigData('iframe_style');
149
+ $iframe['iframe_wrapper_style'] = $this->getMethod()->getConfigData('iframe_style');
150
return $iframe;
151
}
152
app/code/community/Allopass/Hipay/Block/Form/Cc.php CHANGED
@@ -20,11 +20,25 @@ class Allopass_Hipay_Block_Form_Cc extends Allopass_Hipay_Block_Form_Abstract
20
$availableTypes = $method->getConfigData('cctypes');
21
if ($availableTypes) {
22
$availableTypes = explode(',', $availableTypes);
23
foreach ($types as $code=>$name) {
24
if (!in_array($code, $availableTypes)) {
25
unset($types[$code]);
26
}
27
}
28
}
29
}
30
return $types;
20
$availableTypes = $method->getConfigData('cctypes');
21
if ($availableTypes) {
22
$availableTypes = explode(',', $availableTypes);
23
+
24
+
25
+
26
foreach ($types as $code=>$name) {
27
if (!in_array($code, $availableTypes)) {
28
unset($types[$code]);
29
}
30
+
31
+ }
32
+ $ordered = array();
33
+ foreach($availableTypes as $key) {
34
+ if(array_key_exists($key,$types)) {
35
+ $ordered[$key] = $types[$key];
36
+ unset($types[$key]);
37
+ }
38
}
39
+ return $ordered;
40
+
41
+ //todo order $types
42
}
43
}
44
return $types;
app/code/community/Allopass/Hipay/Block/Info/Cc.php CHANGED
@@ -5,6 +5,13 @@
5
*/
6
class Allopass_Hipay_Block_Info_Cc extends Mage_Payment_Block_Info
7
{
8
/**
9
* Retrieve credit card type name
10
*
@@ -76,6 +83,13 @@ class Allopass_Hipay_Block_Info_Cc extends Mage_Payment_Block_Info
76
if ($this->getInfo()->getCcLast4()) {
77
$data[Mage::helper('payment')->__('Credit Card Number')] = sprintf('xxxx-%s', $this->getInfo()->getCcLast4());
78
}
79
if (!$this->getIsSecureMode()) {
80
if ($ccSsIssue = $this->getInfo()->getCcSsIssue()) {
81
$data[Mage::helper('payment')->__('Switch/Solo/Maestro Issue Number')] = $ccSsIssue;
5
*/
6
class Allopass_Hipay_Block_Info_Cc extends Mage_Payment_Block_Info
7
{
8
+
9
+ protected function _construct()
10
+ {
11
+ parent::_construct();
12
+ $this->setTemplate('hipay/info/cc.phtml');
13
+ }
14
+
15
/**
16
* Retrieve credit card type name
17
*
83
if ($this->getInfo()->getCcLast4()) {
84
$data[Mage::helper('payment')->__('Credit Card Number')] = sprintf('xxxx-%s', $this->getInfo()->getCcLast4());
85
}
86
+
87
+ if($this->getInfo()->getAdditionalInformation('fraud_type') && $this->getInfo()->getAdditionalInformation('fraud_score'))
88
+ {
89
+ $data[Mage::helper('hipay')->__('Fraud result')] = ucfirst($this->getInfo()->getAdditionalInformation('fraud_type'));
90
+ $data[Mage::helper('hipay')->__('Fraud scoring')] = $this->getInfo()->getAdditionalInformation('fraud_score');
91
+ }
92
+
93
if (!$this->getIsSecureMode()) {
94
if ($ccSsIssue = $this->getInfo()->getCcSsIssue()) {
95
$data[Mage::helper('payment')->__('Switch/Solo/Maestro Issue Number')] = $ccSsIssue;
app/code/community/Allopass/Hipay/Block/Info/Hosted.php CHANGED
@@ -5,5 +5,54 @@
5
*/
6
class Allopass_Hipay_Block_Info_Hosted extends Mage_Payment_Block_Info
7
{
8
-
9
}
5
*/
6
class Allopass_Hipay_Block_Info_Hosted extends Mage_Payment_Block_Info
7
{
8
+
9
+ protected function _construct()
10
+ {
11
+ parent::_construct();
12
+ $this->setTemplate('hipay/info/cc.phtml');
13
+ }
14
+
15
+ /**
16
+ * Retrieve credit card type name
17
+ *
18
+ * @return string
19
+ */
20
+ public function getCcTypeName()
21
+ {
22
+ $types = Mage::getSingleton('payment/config')->getCcTypes();
23
+ $ccType = $this->getInfo()->getCcType();
24
+ if (isset($types[$ccType])) {
25
+ return $types[$ccType];
26
+ }
27
+ return (empty($ccType)) ? Mage::helper('payment')->__('N/A') : $ccType;
28
+ }
29
+
30
+ /**
31
+ * Prepare credit card related payment info
32
+ *
33
+ * @param Varien_Object|array $transport
34
+ * @return Varien_Object
35
+ */
36
+ protected function _prepareSpecificInformation($transport = null)
37
+ {
38
+ if (null !== $this->_paymentSpecificInformation) {
39
+ return $this->_paymentSpecificInformation;
40
+ }
41
+ $transport = parent::_prepareSpecificInformation($transport);
42
+ $data = array();
43
+ if ($ccType = $this->getCcTypeName()) {
44
+ $data[Mage::helper('payment')->__('Credit Card Type')] = $ccType;
45
+ }
46
+ if ($this->getInfo()->getCcLast4()) {
47
+ $data[Mage::helper('payment')->__('Credit Card Number')] = sprintf('xxxx-%s', $this->getInfo()->getCcLast4());
48
+ }
49
+
50
+ if($this->getInfo()->getAdditionalInformation('fraud_type') && $this->getInfo()->getAdditionalInformation('fraud_score'))
51
+ {
52
+ $data[Mage::helper('hipay')->__('Fraud result')] = ucfirst($this->getInfo()->getAdditionalInformation('fraud_type'));
53
+ $data[Mage::helper('hipay')->__('Fraud scoring')] = $this->getInfo()->getAdditionalInformation('fraud_score');
54
+ }
55
+
56
+ return $transport->setData(array_merge($data, $transport->getData()));
57
+ }
58
}
app/code/community/Allopass/Hipay/Controller/Payment.php CHANGED
@@ -13,22 +13,9 @@ class Allopass_Hipay_Controller_Payment extends Mage_Core_Controller_Front_Actio
13
*/
14
public function preDispatch() {
15
parent::preDispatch();
16
-
17
- if (!$this->_validateSignature()) {
18
- $this->getResponse()->setBody("NOK. Wrong Signature!");
19
- $this->setFlag('', 'no-dispatch', true);
20
- }
21
- }
22
-
23
-
24
- protected function _validateSignature()
25
- {
26
- return true;
27
- /* @var $_helper Allopass_Hipay_Helper_Data */
28
- $_helper = Mage::helper('hipay');
29
- $signature = $this->getRequest()->getParam('hash');
30
- return $_helper->checkSignature($signature);
31
}
32
33
/**
34
*
@@ -43,6 +30,7 @@ class Allopass_Hipay_Controller_Payment extends Mage_Core_Controller_Front_Actio
43
{
44
$order = $this->getOrder();
45
$payment = $order->getPayment();
46
$methodInstance = $this->_getMethodInstance();
47
48
try
@@ -92,6 +80,15 @@ class Allopass_Hipay_Controller_Payment extends Mage_Core_Controller_Front_Actio
92
$profile->save();
93
}
94
}
95
}
96
/*else
97
{
@@ -113,6 +110,11 @@ class Allopass_Hipay_Controller_Payment extends Mage_Core_Controller_Front_Actio
113
114
public function declineAction()
115
{
116
$this->processResponse();
117
$this->_redirect('checkout/onepage/failure');
118
return $this;
@@ -121,6 +123,12 @@ class Allopass_Hipay_Controller_Payment extends Mage_Core_Controller_Front_Actio
121
122
public function exceptionAction()
123
{
124
$this->_redirect('checkout/onepage/failure');
125
return $this;
126
}
@@ -182,45 +190,12 @@ class Allopass_Hipay_Controller_Payment extends Mage_Core_Controller_Front_Actio
182
$this->_order->getPayment()->setAdditionalInformation('token',isset($additionalInfo['token']) ? $additionalInfo['token'] : "");
183
$this->_order->getPayment()->setAdditionalInformation('create_oneclick',isset($additionalInfo['create_oneclick']) ? $additionalInfo['create_oneclick'] : 1);
184
$this->_order->getPayment()->setAdditionalInformation('use_oneclick',isset($additionalInfo['use_oneclick']) ? $additionalInfo['use_oneclick'] : 0);
185
}
186
187
188
189
return $this->_order; //because only one nominal item in cart is authorized and Hipay not manage many profiles
190
-
191
- //$amount = $this->getAmountFromProfile($profile);
192
-
193
- /*$productItemInfo = new Varien_Object;
194
- $type = "Regular";
195
- if ($type == 'Trial') {
196
- $productItemInfo->setPaymentType(Mage_Sales_Model_Recurring_Profile::PAYMENT_TYPE_TRIAL);
197
- } elseif ($type == 'Regular') {
198
- $productItemInfo->setPaymentType(Mage_Sales_Model_Recurring_Profile::PAYMENT_TYPE_REGULAR);
199
- }
200
-
201
-
202
- if($this->isInitialProfileOrder($profile))// because is not additonned in prodile obj
203
- $productItemInfo->setPrice($profile->getBillingAmount() + $profile->getInitAmount());
204
-
205
- $this->_order = $profile->createOrder($productItemInfo);
206
-
207
- $additionalInfo = $profile->getAdditionalInfo();
208
-
209
- $this->_order->getPayment()->setCcType($additionalInfo['ccType']);
210
- $this->_order->getPayment()->setCcExpMonth($additionalInfo['ccExpMonth']);
211
- $this->_order->getPayment()->setCcExpYear($additionalInfo['ccExpYear']);
212
- $this->_order->getPayment()->setAdditionalInformation('token',$additionalInfo['token']);
213
- $this->_order->getPayment()->setAdditionalInformation('create_oneclick',$additionalInfo['create_oneclick']);
214
- $this->_order->getPayment()->setAdditionalInformation('use_oneclick',$additionalInfo['use_oneclick']);
215
-
216
- $orderId = 'create-recurring';
217
- $orderId .= "-".$profileId;
218
- //$this->_order->setIncrementId($orderId);
219
- $this->_order->save();
220
- $profile->addOrderRelation($this->_order->getId());
221
- $profile->save();*/
222
- return $this->_order; //because only one nominal item in cart is authorized and Hipay not manage many profiles
223
- //break;
224
}
225
226
@@ -232,7 +207,9 @@ class Allopass_Hipay_Controller_Payment extends Mage_Core_Controller_Front_Actio
232
233
}
234
else
235
$this->_order = Mage::getModel('sales/order')->load($this->getCheckout()->getLastOrderId());
236
}
237
238
return $this->_order;
@@ -269,4 +246,57 @@ class Allopass_Hipay_Controller_Payment extends Mage_Core_Controller_Front_Actio
269
{
270
return Mage::getSingleton('checkout/session');
271
}
272
}
13
*/
14
public function preDispatch() {
15
parent::preDispatch();
16
+
17
}
18
+
19
20
/**
21
*
30
{
31
$order = $this->getOrder();
32
$payment = $order->getPayment();
33
+
34
$methodInstance = $this->_getMethodInstance();
35
36
try
80
$profile->save();
81
}
82
}
83
+
84
+
85
+ $session = Mage::getSingleton('checkout/session');
86
+ if (!$session->getLastSuccessQuoteId()) {
87
+
88
+ $session->setLastSuccessQuoteId($this->getOrder()->getIncrementId());
89
+ $session->setLastQuoteId($this->getOrder()->getId());
90
+ }
91
+
92
}
93
/*else
94
{
110
111
public function declineAction()
112
{
113
+ $lastOrderId = $this->getOrder()->getIncrementId();
114
+
115
+ Mage::getSingleton('checkout/session')->setLastQuoteId($lastOrderId);
116
+ Mage::getSingleton('checkout/session')->setLastOrderId($lastOrderId);
117
+
118
$this->processResponse();
119
$this->_redirect('checkout/onepage/failure');
120
return $this;
123
124
public function exceptionAction()
125
{
126
+
127
+ $lastOrderId = $this->getOrder()->getIncrementId();
128
+
129
+ Mage::getSingleton('checkout/session')->setLastQuoteId($lastOrderId);
130
+ Mage::getSingleton('checkout/session')->setLastOrderId($lastOrderId);
131
+
132
$this->_redirect('checkout/onepage/failure');
133
return $this;
134
}
190
$this->_order->getPayment()->setAdditionalInformation('token',isset($additionalInfo['token']) ? $additionalInfo['token'] : "");
191
$this->_order->getPayment()->setAdditionalInformation('create_oneclick',isset($additionalInfo['create_oneclick']) ? $additionalInfo['create_oneclick'] : 1);
192
$this->_order->getPayment()->setAdditionalInformation('use_oneclick',isset($additionalInfo['use_oneclick']) ? $additionalInfo['use_oneclick'] : 0);
193
+ $this->_order->getPayment()->setAdditionalInformation('selected_oneclick_card',isset($additionalInfo['selected_oneclick_card']) ? $additionalInfo['selected_oneclick_card'] : 0);
194
}
195
196
197
198
return $this->_order; //because only one nominal item in cart is authorized and Hipay not manage many profiles
199
}
200
201
207
208
}
209
else
210
+ {
211
$this->_order = Mage::getModel('sales/order')->load($this->getCheckout()->getLastOrderId());
212
+ }
213
}
214
215
return $this->_order;
246
{
247
return Mage::getSingleton('checkout/session');
248
}
249
+
250
+
251
+ public function updateDebitAmountAction()
252
+ {
253
+ /* @var $_helper Allopass_Hipay_Helper_Data */
254
+ $_helper = Mage::helper('hipay');
255
+ $response = array();
256
+ $response['error'] = true;
257
+ $response['success'] = false;
258
+
259
+ $payment_profile_id = $this->getRequest()->getParam('payment_profile_id',false);
260
+ $amount = $this->getCheckout()->getQuote()->getGrandTotal();
261
+
262
+ $response['message'] = Mage::helper('hipay')->__('You will be debit of amount %s only after submit order.',Mage::app()->getStore()->getBaseCurrency()->format($amount, array(), true));
263
+
264
+ if($payment_profile_id)
265
+ {
266
+ try {
267
+
268
+ $splitPayment = $_helper->splitPayment((int)$payment_profile_id, $amount);
269
+ $response['success'] = true;
270
+ $response['error'] = false;
271
+ $response['splitPayment'] = $splitPayment;
272
+ $response['grandTotal'] = $amount;
273
+ $firstAmount = $splitPayment[0]['amountToPay'];
274
+ array_shift($splitPayment);
275
+ $otherPayments = "<p><span>" . Mage::helper('hipay')->__("Your next payments:") . '</span><table class="data-table" id="split-payment-cc-table">';
276
+ foreach ($splitPayment as $value)
277
+ {
278
+ $otherPayments .= '<tr>';
279
+ $amount = Mage::app()->getStore()->getBaseCurrency()->format($value['amountToPay'], array(), true);
280
+ $dateToPay = new Zend_Date($value['dateToPay']);
281
+ $otherPayments .= '<td>' . $dateToPay->toString(Zend_Date::DATE_LONG) . "</td><td> " . $amount . '</td>' ;
282
+ $otherPayments .= '</tr>';
283
+ }
284
+ $otherPayments .= '<table></p>';
285
+
286
+ $response['labelSplitPayment'] = "<p><span>" . Mage::helper('hipay')->__('You will be debit of amount %s only after submit order.',Mage::app()->getStore()->getBaseCurrency()->format($firstAmount, array(), true)) . '</span></p>';
287
+ $response['labelSplitPayment'] .= $otherPayments;
288
+
289
+ } catch (Exception $e) {
290
+
291
+ $response['message'] = $e->getMessage();
292
+
293
+ }
294
+
295
+
296
+ }
297
+
298
+
299
+ $this->getResponse()->setBody(Mage::helper('core')->jsonEncode($response));
300
+
301
+ }
302
}
app/code/community/Allopass/Hipay/Helper/Data.php CHANGED
@@ -2,6 +2,150 @@
2
class Allopass_Hipay_Helper_Data extends Mage_Core_Helper_Abstract
3
{
4
5
public function getHipayMethods()
6
{
7
$methods = array();
@@ -9,7 +153,8 @@ class Allopass_Hipay_Helper_Data extends Mage_Core_Helper_Abstract
9
foreach (Mage::getStoreConfig('payment') as $code => $data) {
10
if(strpos($code, 'hipay') !== false)
11
{
12
- $methods[$code] = $data['model'];
13
}
14
}
15
@@ -17,9 +162,27 @@ class Allopass_Hipay_Helper_Data extends Mage_Core_Helper_Abstract
17
18
}
19
20
- public function checkSignature($signature,$fromNotification = false)
21
{
22
- $passphrase = Mage::getStoreConfig('hipay/hipay_api/secret_passphrase');
23
if(empty($passphrase) || empty($signature))
24
return true;
25
@@ -59,7 +222,10 @@ class Allopass_Hipay_Helper_Data extends Mage_Core_Helper_Abstract
59
if(!empty($expDate) && !empty($alias))
60
{
61
list($expMonth,$expYear) = explode("-", $expDate);
62
- $today = new Zend_Date(Mage::app()->getLocale()->storeTimeStamp());
63
64
$currentYear = (int)$today->getYear()->toString("YY");
65
$currentMonth = (int)$today->getMonth()->toString("MM");
@@ -70,13 +236,29 @@ class Allopass_Hipay_Helper_Data extends Mage_Core_Helper_Abstract
70
if($currentYear == (int)$expYear && $currentMonth > (int)$expMonth)
71
return false;
72
73
- return true;
74
75
}
76
77
return false;
78
}
79
80
/**
81
*
82
* @param Mage_Customer_Model_Customer $customer
@@ -112,6 +294,62 @@ class Allopass_Hipay_Helper_Data extends Mage_Core_Helper_Abstract
112
return $this;
113
}
114
115
public function reAddToCart($incrementId) {
116
117
$cart = Mage::getSingleton('checkout/cart');
@@ -188,21 +426,22 @@ class Allopass_Hipay_Helper_Data extends Mage_Core_Helper_Abstract
188
}
189
190
$card = $this->__('Credit Card: xxxx-%s', $payment->getCcLast4());
191
192
- $pattern = '%s - %s. %s %s.';
193
- $texts = array($operation,$result,$card, $amount);
194
195
if (!is_null($lastTransactionId)) {
196
- $pattern .= ' %s.';
197
$texts[] = $this->__('Hipay Transaction ID %s', $lastTransactionId);
198
}
199
200
if ($additionalMessage) {
201
- $pattern .= ' %s.';
202
$texts[] = $additionalMessage;
203
}
204
- $pattern .= ' %s';
205
- $texts[] = $exception;
206
207
return call_user_func_array(array($this, '__'), array_merge(array($pattern), $texts));
208
}
@@ -217,4 +456,122 @@ class Allopass_Hipay_Helper_Data extends Mage_Core_Helper_Abstract
217
{
218
return $payment->getOrder()->getBaseCurrency()->formatTxt($amount);
219
}
220
}
2
class Allopass_Hipay_Helper_Data extends Mage_Core_Helper_Abstract
3
{
4
5
+ /**
6
+ *
7
+ * @param Allopass_Hipay_Model_PaymentProfile|int $profile
8
+ * @param float $amount
9
+ */
10
+ public function splitPayment($profile,$amount)
11
+ {
12
+ $paymentsSplit = array();
13
+
14
+ if(is_int($profile))
15
+ $profile = Mage::getModel('hipay/paymentProfile')->load($profile);
16
+
17
+ if($profile)
18
+ {
19
+ $maxCycles = (int)$profile->getPeriodMaxCycles();
20
+
21
+ $periodFrequency = (int)$profile->getPeriodFrequency();
22
+ $periodUnit = $profile->getPeriodUnit();
23
+
24
+ $todayDate = new Zend_Date();
25
+
26
+ if($maxCycles < 1)
27
+ Mage::throwException("Period max cycles is equals zero or negative for Payment Profile ID: ".$profile->getId());
28
+
29
+
30
+ $part = (int)($amount / $maxCycles);
31
+ $reste = $amount%$maxCycles;
32
+ $fmod = fmod($amount, $maxCycles);
33
+ //Mage::log("PART = ".$part." RESTE = ".$reste,null,'hipay_split_debug.log');
34
+
35
+ for ($i=-1;$i<($maxCycles-1);$i++)
36
+ {
37
+ $todayClone = clone $todayDate;
38
+ switch ($periodUnit)
39
+ {
40
+ case Allopass_Hipay_Model_PaymentProfile::PERIOD_UNIT_MONTH:
41
+ {
42
+ $dateToPay = $todayClone->addMonth($periodFrequency+$i)->getDate()->toString('yyyy-MM-dd');
43
+ break;
44
+ }
45
+ case Allopass_Hipay_Model_PaymentProfile::PERIOD_UNIT_DAY:
46
+ {
47
+ $dateToPay = $todayClone->addDay($periodFrequency+$i)->getDate()->toString('yyyy-MM-dd');
48
+
49
+ break;
50
+ }
51
+ case Allopass_Hipay_Model_PaymentProfile::PERIOD_UNIT_SEMI_MONTH://TODO test this case !!!
52
+ {
53
+ $dateToPay = $todayClone->addDay(15 + $periodFrequency+$i)->getDate()->toString('yyyy-MM-dd');
54
+ break;
55
+ }
56
+ case Allopass_Hipay_Model_PaymentProfile::PERIOD_UNIT_WEEK:
57
+ {
58
+ $dateToPay = $todayClone->addWeek($periodFrequency+$i)->getDate()->toString('yyyy-MM-dd');
59
+ break;
60
+ }
61
+ case Allopass_Hipay_Model_PaymentProfile::PERIOD_UNIT_YEAR:
62
+ {
63
+ $dateToPay = $todayClone->addYear($periodFrequency+$i)->getDate()->toString('yyyy-MM-dd');
64
+ break;
65
+ }
66
+ }
67
+
68
+ $amountToPay = $i==($maxCycles-1) ? ($part + $fmod) : $part;
69
+ $paymentsSplit[] = array('dateToPay'=>$dateToPay,'amountToPay'=>$amountToPay);
70
+ }
71
+
72
+ return $paymentsSplit;
73
+
74
+ }
75
+
76
+ Mage::throwException("Payment Profile not found");
77
+
78
+ }
79
+
80
+ /**
81
+ *
82
+ * @param Mage_Sales_Model_Order $order
83
+ * @param Allopass_Hipay_Model_PaymentProfile|int $profile $profile
84
+ */
85
+ public function insertSplitPayment($order,$profile,$customerId,$cardToken)
86
+ {
87
+
88
+
89
+
90
+ if(is_int($profile))
91
+ $profile = Mage::getModel('hipay/paymentProfile')->load($profile);
92
+
93
+ if(!$this->splitPaymentsExists($order->getId()))
94
+ {
95
+
96
+ $paymentsSplit = $this->splitPayment($profile, $order->getBaseGrandTotal());
97
+
98
+
99
+ //remove first element because is already paid
100
+ array_shift($paymentsSplit);
101
+
102
+
103
+ //remove last element because the first split is already paid
104
+ //array_pop($paymentsSplit);
105
+
106
+ foreach ($paymentsSplit as $split)
107
+ {
108
+ $splitPayment = Mage::getModel('hipay/splitPayment');
109
+ $data = array('order_id'=>$order->getId(),
110
+ 'real_order_id'=>(int)$order->getRealOrderId(),
111
+ 'customer_id'=>$customerId,
112
+ 'card_token'=>$cardToken,
113
+ 'total_amount'=>$order->getBaseGrandTotal(),
114
+ 'amount_to_pay'=>$split['amountToPay'],
115
+ 'date_to_pay'=>$split['dateToPay'],
116
+ 'method_code'=>$order->getPayment()->getMethod(),
117
+ 'status'=>Allopass_Hipay_Model_SplitPayment::SPLIT_PAYMENT_STATUS_PENDING,
118
+ );
119
+
120
+ $splitPayment->setData($data);
121
+
122
+
123
+ try {
124
+ $splitPayment->save();
125
+ } catch (Exception $e) {
126
+
127
+ Mage::throwException("Error on save split payments!");
128
+ }
129
+ }
130
+
131
+ }
132
+ }
133
+
134
+
135
+ /**
136
+ *
137
+ * @param int $orderId
138
+ * @return boolean
139
+ */
140
+ public function splitPaymentsExists($orderId)
141
+ {
142
+ $collection = Mage::getModel('hipay/splitPayment')->getCollection()->addFieldToFilter('order_id',$orderId);
143
+ if($collection->count())
144
+ return true;
145
+
146
+ return false;
147
+ }
148
+
149
public function getHipayMethods()
150
{
151
$methods = array();
153
foreach (Mage::getStoreConfig('payment') as $code => $data) {
154
if(strpos($code, 'hipay') !== false)
155
{
156
+ if (isset($data['model']))
157
+ $methods[$code] = $data['model'];
158
}
159
}
160
162
163
}
164
165
+ public function checkSignature($signature,$fromNotification = false,$response = null)
166
{
167
+ $passphrase =$this->getConfig()->getSecretPassphrase();
168
+ if(!is_null($response))
169
+ {
170
+ $orderArr = $response->getOrder();
171
+
172
+ /* @var $order Mage_Sales_Model_Order */
173
+ $order = Mage::getModel('sales/order')->loadByIncrementId($orderArr['id']);
174
+
175
+ if($order->getId())
176
+ {
177
+ $method = $order->getPayment()->getMethodInstance();
178
+ if($method->getConfigData('is_test_mode'))
179
+ {
180
+ $passphrase = $this->getConfig()->getSecretPassphraseTest();
181
+ }
182
+ }
183
+ }
184
+
185
+
186
if(empty($passphrase) || empty($signature))
187
return true;
188
222
if(!empty($expDate) && !empty($alias))
223
{
224
list($expMonth,$expYear) = explode("-", $expDate);
225
+
226
+ return $this->checkIfCcIsExpired($expMonth, $expYear);
227
+
228
+ /*$today = new Zend_Date(Mage::app()->getLocale()->storeTimeStamp());
229
230
$currentYear = (int)$today->getYear()->toString("YY");
231
$currentMonth = (int)$today->getMonth()->toString("MM");
236
if($currentYear == (int)$expYear && $currentMonth > (int)$expMonth)
237
return false;
238
239
+ return true;*/
240
241
}
242
243
return false;
244
}
245
246
+ public function checkIfCcIsExpired($expMonth,$expYear)
247
+ {
248
+ $today = new Zend_Date(Mage::app()->getLocale()->storeTimeStamp());
249
+
250
+ $currentYear = (int)$today->getYear()->toString("YY");
251
+ $currentMonth = (int)$today->getMonth()->toString("MM");
252
+
253
+ if($currentYear > (int)$expYear)
254
+ return false;
255
+
256
+ if($currentYear == (int)$expYear && $currentMonth > (int)$expMonth)
257
+ return false;
258
+
259
+ return true;
260
+ }
261
+
262
/**
263
*
264
* @param Mage_Customer_Model_Customer $customer
294
return $this;
295
}
296
297
+ protected function _cardTokenExist($ccToken,$customer_id=0)
298
+